Parsing
Types and operations for monadic parsing.
Combinators are in the Parsing.Combinators
module.
Primitive parsers for String
input streams are in the Parsing.String
module.
#Parser
#runParser
runParser :: forall s a. s -> Parser s a -> Either ParseError a
Run a parser on an input stream s
and produce either an error or the
result a
of the parser.
#ParserT
newtype ParserT :: Type -> (Type -> Type) -> Type -> Type
newtype ParserT s m a
The Parser s
monad with a monad transformer parameter m
.
Constructors
ParserT (forall r. Fn5 (ParseState s) ((Unit -> r) -> r) (m (Unit -> r) -> r) (Fn2 (ParseState s) ParseError r) (Fn2 (ParseState s) a r) r)
Instances
Lazy (ParserT s m a)
(Semigroup a) => Semigroup (ParserT s m a)
(Monoid a) => Monoid (ParserT s m a)
Functor (ParserT s m)
Apply (ParserT s m)
Applicative (ParserT s m)
Bind (ParserT s m)
Monad (ParserT s m)
MonadRec (ParserT s m)
(MonadState t m) => MonadState t (ParserT s m)
(MonadAsk r m) => MonadAsk r (ParserT s m)
(MonadReader r m) => MonadReader r (ParserT s m)
MonadThrow ParseError (ParserT s m)
MonadError ParseError (ParserT s m)
Alt (ParserT s m)
Plus (ParserT s m)
Alternative (ParserT s m)
MonadPlus (ParserT s m)
MonadTrans (ParserT s)
#runParserT
runParserT :: forall m s a. MonadRec m => s -> ParserT s m a -> m (Either ParseError a)
runParser
with a monad transfomer parameter m
.
#runParserT'
runParserT' :: forall m s a. MonadRec m => ParseState s -> ParserT s m a -> m (Tuple (Either ParseError a) (ParseState s))
Run a parser and produce either an error or the result of the parser along with the internal state of the parser when it finishes.
#ParseError
data ParseError
A parsing error, consisting of an error message and the position in the input stream at which the error occurred.
Constructors
Instances
#parseErrorMessage
parseErrorMessage :: ParseError -> String
Get the Message
from a ParseError
#parseErrorPosition
parseErrorPosition :: ParseError -> Position
Get the Position
from a ParseError
.
#Position
newtype Position
Position
represents the position of the parser in the input stream.
index
is the position offset since the start of the input. Starts at 0.line
is the current line in the input. Starts at 1.column
is the column of the next character in the current line that will be parsed. Starts at 1.
Constructors
Instances
#initialPos
initialPos :: Position
The Position
before any input has been parsed.
{ index: 0, line: 1, column: 1 }
#consume
#failWithPosition
failWithPosition :: forall m s a. String -> Position -> ParserT s m a
Fail with a message and a position.
#region
region :: forall m s a. (ParseError -> ParseError) -> ParserT s m a -> ParserT s m a
Contextualize parsing failures inside a region. If a parsing failure
occurs, then the ParseError
will be transformed by each containing
region
as the parser backs out the call stack.
For example, here’s a helper function inContext
which uses region
to
add some string context to the error messages.
let
inContext :: forall s m a. (String -> String) -> ParserT s m a -> ParserT s m a
inContext context = region \(ParseError message pos) ->
ParseError (context message) pos
input = "Tokyo thirty-nine million"
lmap (parseErrorHuman input 30) $ runParser input do
inContext ("Megacity list: " <> _) do
cityname <- inContext ("city name: " <> _) (takeWhile isLetter)
skipSpaces
population <- inContext ("population: " <> _) intDecimal
pure $ Tuple cityname population
Megacity list: population: Expected Int at position index:6 (line:1, column:7)
▼
Tokyo thirty-nine million
#liftMaybe
liftMaybe :: forall s m a. Monad m => (Unit -> String) -> Maybe a -> ParserT s m a
Lift a Maybe a
computation into a ParserT
, with a note for
the ParseError
message in case of Nothing
.
Consumes no parsing input, does not change the parser state at all.
If the Maybe
computation is Nothing
, then this will fail
in the
ParserT
monad with the given error message String
at the current input
Position
.
This is a “validation” function, for when we want to produce some data from the parsing input or fail at the current parsing position if that’s impossible.
For example, parse an integer
BoundedEnum
code and validate it by turning it
into a MyEnum
. Use tryRethrow
to position the parse error at the
beginning of the integer in the input String
if the toEnum
fails.
runParser "3" do
myenum :: MyEnum <- tryRethrow do
x <- intDecimal
liftMaybe (\_ -> "Bad MyEnum " <> show x) $ toEnum x
#liftEither
liftEither :: forall s m a. Monad m => Either String a -> ParserT s m a
Lift an Either String a
computation into a ParserT
.
Consumes no parsing input, does not change the parser state at all.
If the Either
computation is Left String
, then this will fail
in the
ParserT
monad at the current input Position
.
This is a “validation” function, for when we want to produce some data from the parsing input or fail at the current parsing position if that’s impossible.
#liftExceptT
liftExceptT :: forall s m a. Monad m => ExceptT String m a -> ParserT s m a
Lift an ExceptT String m a
computation into a ParserT
.
Consumes no parsing input, does not change the parser state at all.
If the ExceptT
computation is Left String
, then this will fail
in the
ParserT
monad at the current input Position
.
This is a “validation” function, for when we want to produce some data from the parsing input or fail at the current parsing position if that’s impossible.
#ParseState
data ParseState s
The internal state of the ParserT s m
monad.
Contains the remaining input and current position and the consumed flag.
The consumed flag is used to implement the rule for alt
that
- If the left parser fails without consuming any input, then backtrack and try the right parser.
- If the left parser fails and consumes input, then fail immediately.
Constructors
#stateParserT
stateParserT :: forall s m a. (ParseState s -> Tuple a (ParseState s)) -> ParserT s m a
Query and modify the ParserT
internal state.
Like the state
member of MonadState
.
#getParserT
getParserT :: forall s m. ParserT s m (ParseState s)
Query the ParserT
internal state.
Like the get
member of MonadState
.
#hoistParserT
hoistParserT :: forall s m n a. (m ~> n) -> ParserT s m a -> ParserT s n a
#mapParserT
mapParserT :: forall b n s a m. MonadRec m => Functor n => (m (Tuple (Either ParseError a) (ParseState s)) -> n (Tuple (Either ParseError b) (ParseState s))) -> ParserT s m a -> ParserT s n b
Change the underlying monad action m
and result data type a
in
a ParserT s m
monad action.
Modules
- Aeson
- Affjax
- Affjax.RequestBody
- Affjax.RequestHeader
- Affjax.ResponseFormat
- Affjax.ResponseHeader
- Affjax.StatusCode
- Ansi.Codes
- Ansi.Output
- Cardano.AsCbor
- Cardano.Collateral.FakeOutput
- Cardano.Collateral.Select
- Cardano.Collateral.UtxoMinAda
- Cardano.FromData
- Cardano.FromMetadata
- Cardano.MessageSigning
- Cardano.Plutus.ApplyArgs
- Cardano.Plutus.DataSchema
- Cardano.Plutus.DataSchema.Indexed
- Cardano.Plutus.DataSchema.Nat
- Cardano.Plutus.DataSchema.RowList
- Cardano.Plutus.Types.Address
- Cardano.Plutus.Types.Credential
- Cardano.Plutus.Types.CurrencySymbol
- Cardano.Plutus.Types.Map
- Cardano.Plutus.Types.MintingPolicyHash
- Cardano.Plutus.Types.OutputDatum
- Cardano.Plutus.Types.PaymentPubKeyHash
- Cardano.Plutus.Types.PubKeyHash
- Cardano.Plutus.Types.StakePubKeyHash
- Cardano.Plutus.Types.StakingCredential
- Cardano.Plutus.Types.TokenName
- Cardano.Plutus.Types.TransactionOutput
- Cardano.Plutus.Types.TransactionOutputWithRefScript
- Cardano.Plutus.Types.TransactionUnspentOutput
- Cardano.Plutus.Types.UtxoMap
- Cardano.Plutus.Types.Validator
- Cardano.Plutus.Types.ValidatorHash
- Cardano.Plutus.Types.Value
- Cardano.Serialization.Lib
- Cardano.Serialization.Lib.Internal
- Cardano.ToData
- Cardano.ToMetadata
- Cardano.Transaction.Builder
- Cardano.Transaction.Edit
- Cardano.Types
- Cardano.Types.Address
- Cardano.Types.Anchor
- Cardano.Types.AnchorDataHash
- Cardano.Types.Asset
- Cardano.Types.AssetClass
- Cardano.Types.AssetName
- Cardano.Types.AuxiliaryData
- Cardano.Types.AuxiliaryDataHash
- Cardano.Types.Base58String
- Cardano.Types.BaseAddress
- Cardano.Types.Bech32String
- Cardano.Types.BigInt
- Cardano.Types.BigNum
- Cardano.Types.BootstrapWitness
- Cardano.Types.ByronAddress
- Cardano.Types.CborBytes
- Cardano.Types.Certificate
- Cardano.Types.Coin
- Cardano.Types.Committee
- Cardano.Types.Constitution
- Cardano.Types.CostModel
- Cardano.Types.Credential
- Cardano.Types.DRep
- Cardano.Types.DRepVotingThresholds
- Cardano.Types.DataHash
- Cardano.Types.Ed25519KeyHash
- Cardano.Types.Ed25519Signature
- Cardano.Types.EnterpriseAddress
- Cardano.Types.Epoch
- Cardano.Types.ExUnitPrices
- Cardano.Types.ExUnits
- Cardano.Types.GeneralTransactionMetadata
- Cardano.Types.GenesisHash
- Cardano.Types.GovernanceAction
- Cardano.Types.GovernanceActionId
- Cardano.Types.HardForkInitiationAction
- Cardano.Types.Int
- Cardano.Types.Internal.Helpers
- Cardano.Types.Ipv4
- Cardano.Types.Ipv6
- Cardano.Types.Language
- Cardano.Types.Mint
- Cardano.Types.MultiAsset
- Cardano.Types.NativeScript
- Cardano.Types.NetworkId
- Cardano.Types.NewConstitutionAction
- Cardano.Types.NoConfidenceAction
- Cardano.Types.OutputDatum
- Cardano.Types.ParameterChangeAction
- Cardano.Types.PaymentCredential
- Cardano.Types.PaymentPubKeyHash
- Cardano.Types.PlutusData
- Cardano.Types.PlutusScript
- Cardano.Types.PointerAddress
- Cardano.Types.PoolMetadata
- Cardano.Types.PoolMetadataHash
- Cardano.Types.PoolParams
- Cardano.Types.PoolPubKeyHash
- Cardano.Types.PoolVotingThresholds
- Cardano.Types.PrivateKey
- Cardano.Types.ProtocolParamUpdate
- Cardano.Types.ProtocolVersion
- Cardano.Types.PublicKey
- Cardano.Types.RawBytes
- Cardano.Types.Redeemer
- Cardano.Types.RedeemerDatum
- Cardano.Types.RedeemerTag
- Cardano.Types.Relay
- Cardano.Types.RewardAddress
- Cardano.Types.ScriptDataHash
- Cardano.Types.ScriptHash
- Cardano.Types.ScriptRef
- Cardano.Types.Slot
- Cardano.Types.StakeCredential
- Cardano.Types.StakePubKeyHash
- Cardano.Types.Transaction
- Cardano.Types.TransactionBody
- Cardano.Types.TransactionHash
- Cardano.Types.TransactionInput
- Cardano.Types.TransactionMetadatum
- Cardano.Types.TransactionOutput
- Cardano.Types.TransactionUnspentOutput
- Cardano.Types.TransactionWitnessSet
- Cardano.Types.TreasuryWithdrawalsAction
- Cardano.Types.URL
- Cardano.Types.UnitInterval
- Cardano.Types.UpdateCommitteeAction
- Cardano.Types.UtxoMap
- Cardano.Types.VRFKeyHash
- Cardano.Types.Value
- Cardano.Types.Vkey
- Cardano.Types.Vkeywitness
- Cardano.Types.Vote
- Cardano.Types.Voter
- Cardano.Types.VotingProcedure
- Cardano.Types.VotingProcedures
- Cardano.Types.VotingProposal
- Cardano.Wallet.Cip30
- Cardano.Wallet.Cip30.TypeSafe
- Cardano.Wallet.Cip30Mock
- Cardano.Wallet.Cip95
- Cardano.Wallet.Cip95.TypeSafe
- Cardano.Wallet.HD
- Cardano.Wallet.Key
- Contract.Address
- Contract.AuxiliaryData
- Contract.Backend.Ogmios
- Contract.Backend.Ogmios.Mempool
- Contract.BalanceTxConstraints
- Contract.CborBytes
- Contract.Chain
- Contract.ClientError
- Contract.Config
- Contract.Credential
- Contract.Crypto.Secp256k1
- Contract.Crypto.Secp256k1.ECDSA
- Contract.Crypto.Secp256k1.Schnorr
- Contract.Crypto.Secp256k1.Utils
- Contract.Hashing
- Contract.JsSdk
- Contract.Keys
- Contract.Log
- Contract.Metadata
- Contract.Monad
- Contract.Numeric.BigNum
- Contract.Numeric.Convert
- Contract.Numeric.Rational
- Contract.Plutarch.Types
- Contract.PlutusData
- Contract.Prelude
- Contract.Prim.ByteArray
- Contract.ProtocolParameters
- Contract.ScriptLookups
- Contract.Scripts
- Contract.Staking
- Contract.Sync
- Contract.Test
- Contract.Test.Assert
- Contract.Test.Blockfrost
- Contract.Test.Cip30Mock
- Contract.Test.E2E
- Contract.Test.Mote
- Contract.Test.Mote.ConsoleReporter
- Contract.Test.Testnet
- Contract.Test.Utils
- Contract.TextEnvelope
- Contract.Time
- Contract.Transaction
- Contract.TxConstraints
- Contract.UnbalancedTx
- Contract.Utxos
- Contract.Value
- Contract.Wallet
- Contract.Wallet.Key
- Contract.Wallet.KeyFile
- Control.Algebra.Properties
- Control.Alt
- Control.Alternative
- Control.Applicative
- Control.Apply
- Control.Biapplicative
- Control.Biapply
- Control.Bind
- Control.Category
- Control.Comonad
- Control.Comonad.Cofree
- Control.Comonad.Cofree.Class
- Control.Comonad.Cofree.Trans
- Control.Comonad.Env
- Control.Comonad.Env.Class
- Control.Comonad.Env.Trans
- Control.Comonad.Store
- Control.Comonad.Store.Class
- Control.Comonad.Store.Trans
- Control.Comonad.Traced
- Control.Comonad.Traced.Class
- Control.Comonad.Traced.Trans
- Control.Comonad.Trans.Class
- Control.Extend
- Control.Lazy
- Control.Monad
- Control.Monad.Cont
- Control.Monad.Cont.Class
- Control.Monad.Cont.Trans
- Control.Monad.Error.Class
- Control.Monad.Except
- Control.Monad.Except.Checked
- Control.Monad.Except.Trans
- Control.Monad.Fork.Class
- Control.Monad.Free
- Control.Monad.Free.Class
- Control.Monad.Free.Trans
- Control.Monad.Gen
- Control.Monad.Gen.Class
- Control.Monad.Gen.Common
- Control.Monad.Identity.Trans
- Control.Monad.List.Trans
- Control.Monad.Logger.Class
- Control.Monad.Logger.Trans
- Control.Monad.Maybe.Trans
- Control.Monad.Morph
- Control.Monad.RWS
- Control.Monad.RWS.Trans
- Control.Monad.Reader
- Control.Monad.Reader.Class
- Control.Monad.Reader.Trans
- Control.Monad.Rec.Class
- Control.Monad.ST
- Control.Monad.ST.Class
- Control.Monad.ST.Global
- Control.Monad.ST.Internal
- Control.Monad.ST.Ref
- Control.Monad.ST.Uncurried
- Control.Monad.State
- Control.Monad.State.Class
- Control.Monad.State.Trans
- Control.Monad.Trampoline
- Control.Monad.Trans.Class
- Control.Monad.Writer
- Control.Monad.Writer.Class
- Control.Monad.Writer.Trans
- Control.MonadPlus
- Control.Parallel
- Control.Parallel.Class
- Control.Plus
- Control.Promise
- Control.Safely
- Control.Semigroupoid
- Ctl.Examples.AdditionalUtxos
- Ctl.Examples.AlwaysMints
- Ctl.Examples.AlwaysSucceeds
- Ctl.Examples.AwaitTxConfirmedWithTimeout
- Ctl.Examples.BalanceTxConstraints
- Ctl.Examples.ByUrl
- Ctl.Examples.ChangeGeneration
- Ctl.Examples.Cip30
- Ctl.Examples.ContractTestUtils
- Ctl.Examples.Datums
- Ctl.Examples.DropTokens
- Ctl.Examples.ECDSA
- Ctl.Examples.ExUnits
- Ctl.Examples.Gov.DelegateVoteAbstain
- Ctl.Examples.Gov.Internal.Common
- Ctl.Examples.Gov.ManageDrep
- Ctl.Examples.Gov.ManageDrepScript
- Ctl.Examples.Gov.SubmitVote
- Ctl.Examples.Gov.SubmitVoteScript
- Ctl.Examples.Helpers
- Ctl.Examples.IncludeDatum
- Ctl.Examples.KeyWallet.Cip30
- Ctl.Examples.KeyWallet.DelegateVoteAbstain
- Ctl.Examples.KeyWallet.Internal.Cip30Contract
- Ctl.Examples.KeyWallet.Internal.Cip30HtmlForm
- Ctl.Examples.KeyWallet.Internal.Contract
- Ctl.Examples.KeyWallet.Internal.HtmlForm
- Ctl.Examples.KeyWallet.Internal.Pkh2PkhContract
- Ctl.Examples.KeyWallet.Internal.Pkh2PkhHtmlForm
- Ctl.Examples.KeyWallet.ManageDrep
- Ctl.Examples.KeyWallet.MintsAndSendsToken
- Ctl.Examples.KeyWallet.Pkh2Pkh
- Ctl.Examples.KeyWallet.SignMultiple
- Ctl.Examples.KeyWallet.SubmitVote
- Ctl.Examples.Lose7Ada
- Ctl.Examples.ManyAssets
- Ctl.Examples.MintsMultipleTokens
- Ctl.Examples.MultipleRedeemers
- Ctl.Examples.NativeScriptMints
- Ctl.Examples.OneShotMinting
- Ctl.Examples.PaysWithDatum
- Ctl.Examples.Pkh2Pkh
- Ctl.Examples.PlutusV2.AlwaysSucceeds
- Ctl.Examples.PlutusV2.InlineDatum
- Ctl.Examples.PlutusV2.OneShotMinting
- Ctl.Examples.PlutusV2.ReferenceInputsAndScripts
- Ctl.Examples.PlutusV2.Scripts.AlwaysMints
- Ctl.Examples.PlutusV2.Scripts.AlwaysSucceeds
- Ctl.Examples.PlutusV3.Scripts.AlwaysMints
- Ctl.Examples.Schnorr
- Ctl.Examples.SendsToken
- Ctl.Examples.SignData
- Ctl.Examples.SignMultiple
- Ctl.Examples.TxChaining
- Ctl.Examples.Utxos
- Ctl.Examples.Wallet
- Ctl.Internal.Affjax
- Ctl.Internal.BalanceTx
- Ctl.Internal.BalanceTx.CoinSelection
- Ctl.Internal.BalanceTx.Collateral
- Ctl.Internal.BalanceTx.Collateral.Select
- Ctl.Internal.BalanceTx.Constraints
- Ctl.Internal.BalanceTx.Error
- Ctl.Internal.BalanceTx.ExUnitsAndMinFee
- Ctl.Internal.BalanceTx.FakeOutput
- Ctl.Internal.BalanceTx.Sync
- Ctl.Internal.BalanceTx.Types
- Ctl.Internal.BalanceTx.UtxoMinAda
- Ctl.Internal.Cardano.TextEnvelope
- Ctl.Internal.CardanoCli
- Ctl.Internal.CoinSelection.UtxoIndex
- Ctl.Internal.Contract
- Ctl.Internal.Contract.AwaitTxConfirmed
- Ctl.Internal.Contract.Hooks
- Ctl.Internal.Contract.LogParams
- Ctl.Internal.Contract.MinFee
- Ctl.Internal.Contract.Monad
- Ctl.Internal.Contract.QueryBackend
- Ctl.Internal.Contract.QueryHandle
- Ctl.Internal.Contract.QueryHandle.Error
- Ctl.Internal.Contract.QueryHandle.Type
- Ctl.Internal.Contract.Sign
- Ctl.Internal.Contract.WaitUntilSlot
- Ctl.Internal.Contract.Wallet
- Ctl.Internal.Error
- Ctl.Internal.FfiHelpers
- Ctl.Internal.Helpers
- Ctl.Internal.Helpers.Formatter
- Ctl.Internal.IsData
- Ctl.Internal.JsWebSocket
- Ctl.Internal.Logging
- Ctl.Internal.Metadata.MetadataType
- Ctl.Internal.MinFee
- Ctl.Internal.NativeScripts
- Ctl.Internal.Partition
- Ctl.Internal.ProcessConstraints
- Ctl.Internal.ProcessConstraints.Error
- Ctl.Internal.ProcessConstraints.State
- Ctl.Internal.QueryM
- Ctl.Internal.QueryM.CurrentEpoch
- Ctl.Internal.QueryM.Dispatcher
- Ctl.Internal.QueryM.EraSummaries
- Ctl.Internal.QueryM.JsonRpc2
- Ctl.Internal.QueryM.Kupo
- Ctl.Internal.QueryM.Ogmios
- Ctl.Internal.QueryM.Pools
- Ctl.Internal.QueryM.UniqueId
- Ctl.Internal.ServerConfig
- Ctl.Internal.Service.Blockfrost
- Ctl.Internal.Service.Error
- Ctl.Internal.Service.Helpers
- Ctl.Internal.Spawn
- Ctl.Internal.Test.ConsoleReporter
- Ctl.Internal.Test.ContractTest
- Ctl.Internal.Test.E2E.Browser
- Ctl.Internal.Test.E2E.Feedback
- Ctl.Internal.Test.E2E.Feedback.Browser
- Ctl.Internal.Test.E2E.Feedback.Hooks
- Ctl.Internal.Test.E2E.Feedback.Node
- Ctl.Internal.Test.E2E.Options
- Ctl.Internal.Test.E2E.Route
- Ctl.Internal.Test.E2E.Runner
- Ctl.Internal.Test.E2E.Types
- Ctl.Internal.Test.E2E.Wallets
- Ctl.Internal.Test.KeyDir
- Ctl.Internal.Test.UtxoDistribution
- Ctl.Internal.Testnet.Contract
- Ctl.Internal.Testnet.DistributeFunds
- Ctl.Internal.Testnet.Server
- Ctl.Internal.Testnet.Types
- Ctl.Internal.Testnet.Utils
- Ctl.Internal.Transaction
- Ctl.Internal.TxOutput
- Ctl.Internal.Types.Cbor
- Ctl.Internal.Types.Chain
- Ctl.Internal.Types.DelegationsAndRewards
- Ctl.Internal.Types.EraSummaries
- Ctl.Internal.Types.Interval
- Ctl.Internal.Types.MetadataLabel
- Ctl.Internal.Types.ProtocolParameters
- Ctl.Internal.Types.Rational
- Ctl.Internal.Types.ScriptLookups
- Ctl.Internal.Types.StakeValidatorHash
- Ctl.Internal.Types.SystemStart
- Ctl.Internal.Types.TxConstraints
- Ctl.Internal.Types.UsedTxOuts
- Ctl.Internal.Types.Val
- Ctl.Internal.Wallet
- Ctl.Internal.Wallet.Cip30
- Ctl.Internal.Wallet.Cip30Mock
- Ctl.Internal.Wallet.KeyFile
- Ctl.Internal.Wallet.Spec
- Data.Align
- Data.Argonaut
- Data.Argonaut.Core
- Data.Argonaut.Decode
- Data.Argonaut.Decode.Class
- Data.Argonaut.Decode.Combinators
- Data.Argonaut.Decode.Decoders
- Data.Argonaut.Decode.Error
- Data.Argonaut.Decode.Parser
- Data.Argonaut.Encode
- Data.Argonaut.Encode.Class
- Data.Argonaut.Encode.Combinators
- Data.Argonaut.Encode.Encoders
- Data.Argonaut.Gen
- Data.Argonaut.JCursor
- Data.Argonaut.JCursor.Gen
- Data.Argonaut.Parser
- Data.Argonaut.Prisms
- Data.Argonaut.Traversals
- Data.Array
- Data.Array.NonEmpty
- Data.Array.NonEmpty.Internal
- Data.Array.Partial
- Data.Array.ST
- Data.Array.ST.Iterator
- Data.Array.ST.Partial
- Data.ArrayBuffer.Types
- Data.Bifoldable
- Data.Bifunctor
- Data.Bifunctor.Join
- Data.BigNumber
- Data.Bitraversable
- Data.Boolean
- Data.BooleanAlgebra
- Data.Bounded
- Data.Bounded.Generic
- Data.ByteArray
- Data.CatList
- Data.CatQueue
- Data.Char
- Data.Char.Gen
- Data.Char.Utils
- Data.CodePoint.Unicode
- Data.CodePoint.Unicode.Internal
- Data.CodePoint.Unicode.Internal.Casing
- Data.CommutativeRing
- Data.Comparison
- Data.Const
- Data.Coyoneda
- Data.Date
- Data.Date.Component
- Data.Date.Component.Gen
- Data.Date.Gen
- Data.DateTime
- Data.DateTime.Gen
- Data.DateTime.Instant
- Data.Decidable
- Data.Decide
- Data.Distributive
- Data.Divide
- Data.Divisible
- Data.DivisionRing
- Data.Either
- Data.Either.Inject
- Data.Either.Nested
- Data.Enum
- Data.Enum.Gen
- Data.Enum.Generic
- Data.Eq
- Data.Eq.Generic
- Data.Equivalence
- Data.EuclideanRing
- Data.Exists
- Data.Field
- Data.Foldable
- Data.FoldableWithIndex
- Data.FormURLEncoded
- Data.Formatter.DateTime
- Data.Formatter.Internal
- Data.Formatter.Interval
- Data.Formatter.Number
- Data.Formatter.Parser.Interval
- Data.Formatter.Parser.Number
- Data.Formatter.Parser.Utils
- Data.Function
- Data.Function.Memoize
- Data.Function.Uncurried
- Data.Functor
- Data.Functor.App
- Data.Functor.Clown
- Data.Functor.Compose
- Data.Functor.Contravariant
- Data.Functor.Coproduct
- Data.Functor.Coproduct.Inject
- Data.Functor.Coproduct.Nested
- Data.Functor.Costar
- Data.Functor.Flip
- Data.Functor.Invariant
- Data.Functor.Joker
- Data.Functor.Mu
- Data.Functor.Nu
- Data.Functor.Product
- Data.Functor.Product.Nested
- Data.Functor.Product2
- Data.Functor.Variant
- Data.FunctorWithIndex
- Data.Generic.Rep
- Data.HTTP.Method
- Data.HeytingAlgebra
- Data.HeytingAlgebra.Generic
- Data.Identity
- Data.Int
- Data.Int.Bits
- Data.Interval
- Data.Interval.Duration
- Data.Interval.Duration.Iso
- Data.JSDate
- Data.Lattice
- Data.Lattice.Verify
- Data.Lazy
- Data.Lens
- Data.Lens.AffineTraversal
- Data.Lens.At
- Data.Lens.Common
- Data.Lens.Fold
- Data.Lens.Fold.Partial
- Data.Lens.Getter
- Data.Lens.Grate
- Data.Lens.Index
- Data.Lens.Indexed
- Data.Lens.Internal.Bazaar
- Data.Lens.Internal.Exchange
- Data.Lens.Internal.Focusing
- Data.Lens.Internal.Forget
- Data.Lens.Internal.Grating
- Data.Lens.Internal.Indexed
- Data.Lens.Internal.Market
- Data.Lens.Internal.Re
- Data.Lens.Internal.Shop
- Data.Lens.Internal.Stall
- Data.Lens.Internal.Tagged
- Data.Lens.Internal.Wander
- Data.Lens.Internal.Zipping
- Data.Lens.Iso
- Data.Lens.Iso.Newtype
- Data.Lens.Lens
- Data.Lens.Lens.Product
- Data.Lens.Lens.Tuple
- Data.Lens.Lens.Unit
- Data.Lens.Lens.Void
- Data.Lens.Prism
- Data.Lens.Prism.Coproduct
- Data.Lens.Prism.Either
- Data.Lens.Prism.Maybe
- Data.Lens.Record
- Data.Lens.Setter
- Data.Lens.Traversal
- Data.Lens.Types
- Data.Lens.Zoom
- Data.List
- Data.List.Internal
- Data.List.Lazy
- Data.List.Lazy.NonEmpty
- Data.List.Lazy.Types
- Data.List.NonEmpty
- Data.List.Partial
- Data.List.Types
- Data.List.ZipList
- Data.Log.Filter
- Data.Log.Formatter.JSON
- Data.Log.Formatter.Pretty
- Data.Log.Level
- Data.Log.Message
- Data.Log.Tag
- Data.Map
- Data.Map.Gen
- Data.Map.Internal
- Data.Maybe
- Data.Maybe.First
- Data.Maybe.Last
- Data.MediaType
- Data.MediaType.Common
- Data.Monoid
- Data.Monoid.Additive
- Data.Monoid.Alternate
- Data.Monoid.Conj
- Data.Monoid.Disj
- Data.Monoid.Dual
- Data.Monoid.Endo
- Data.Monoid.Generic
- Data.Monoid.Multiplicative
- Data.NaturalTransformation
- Data.Newtype
- Data.NonEmpty
- Data.Nullable
- Data.Number
- Data.Number.Approximate
- Data.Number.Format
- Data.Op
- Data.Options
- Data.Ord
- Data.Ord.Down
- Data.Ord.Generic
- Data.Ord.Max
- Data.Ord.Min
- Data.Ordering
- Data.Posix
- Data.Posix.Signal
- Data.Predicate
- Data.Profunctor
- Data.Profunctor.Choice
- Data.Profunctor.Closed
- Data.Profunctor.Cochoice
- Data.Profunctor.Costrong
- Data.Profunctor.Join
- Data.Profunctor.Split
- Data.Profunctor.Star
- Data.Profunctor.Strong
- Data.Ratio
- Data.Rational
- Data.Reflectable
- Data.Ring
- Data.Ring.Generic
- Data.Semigroup
- Data.Semigroup.First
- Data.Semigroup.Foldable
- Data.Semigroup.Generic
- Data.Semigroup.Last
- Data.Semigroup.Traversable
- Data.Semiring
- Data.Semiring.Generic
- Data.Set
- Data.Set.NonEmpty
- Data.Show
- Data.Show.Generic
- Data.String
- Data.String.CaseInsensitive
- Data.String.CodePoints
- Data.String.CodeUnits
- Data.String.Common
- Data.String.Gen
- Data.String.NonEmpty
- Data.String.NonEmpty.CaseInsensitive
- Data.String.NonEmpty.CodePoints
- Data.String.NonEmpty.CodeUnits
- Data.String.NonEmpty.Internal
- Data.String.Pattern
- Data.String.Regex
- Data.String.Regex.Flags
- Data.String.Regex.Unsafe
- Data.String.Unicode
- Data.String.Unsafe
- Data.String.Utils
- Data.Symbol
- Data.TacitString
- Data.TextDecoder
- Data.TextEncoder
- Data.These
- Data.These.Gen
- Data.Time
- Data.Time.Component
- Data.Time.Component.Gen
- Data.Time.Duration
- Data.Time.Duration.Gen
- Data.Time.Gen
- Data.Traversable
- Data.Traversable.Accum
- Data.Traversable.Accum.Internal
- Data.TraversableWithIndex
- Data.Tuple
- Data.Tuple.Nested
- Data.Typelevel.Bool
- Data.Typelevel.Num
- Data.Typelevel.Num.Aliases
- Data.Typelevel.Num.Ops
- Data.Typelevel.Num.Reps
- Data.Typelevel.Num.Sets
- Data.Typelevel.Undefined
- Data.UInt
- Data.UInt.Gen
- Data.Unfoldable
- Data.Unfoldable1
- Data.Unit
- Data.Variant
- Data.Variant.Internal
- Data.Void
- Data.Yoneda
- Debug
- Effect
- Effect.AVar
- Effect.Aff
- Effect.Aff.AVar
- Effect.Aff.Class
- Effect.Aff.Compat
- Effect.Aff.Retry
- Effect.Class
- Effect.Class.Console
- Effect.Console
- Effect.Exception
- Effect.Exception.Unsafe
- Effect.Now
- Effect.Random
- Effect.Ref
- Effect.Uncurried
- Effect.Unsafe
- ExitCodes
- Foreign
- Foreign.Index
- Foreign.Keys
- Foreign.Object
- Foreign.Object.Gen
- Foreign.Object.ST
- Foreign.Object.ST.Unsafe
- Foreign.Object.Unsafe
- Heterogeneous.Folding
- Heterogeneous.Mapping
- Internal.CardanoCli.QueryHandle
- JS.BigInt
- JSURI
- Literals
- Literals.Boolean
- Literals.Int
- Literals.Literal
- Literals.Null
- Literals.Number
- Literals.String
- Literals.Undefined
- Mote
- Mote.Description
- Mote.Entry
- Mote.Monad
- Mote.Plan
- Mote.TestPlanM
- Noble.Secp256k1.ECDSA
- Noble.Secp256k1.Schnorr
- Noble.Secp256k1.Utils
- Node.Buffer
- Node.Buffer.Class
- Node.Buffer.Immutable
- Node.Buffer.Internal
- Node.Buffer.ST
- Node.Buffer.Types
- Node.ChildProcess
- Node.Crypto
- Node.Crypto.Cipher
- Node.Crypto.Decipher
- Node.Crypto.Hash
- Node.Crypto.Hmac
- Node.Encoding
- Node.FS
- Node.FS.Aff
- Node.FS.Async
- Node.FS.Perms
- Node.FS.Stats
- Node.FS.Stream
- Node.FS.Sync
- Node.HTTP
- Node.HTTP.Client
- Node.HTTP.Secure
- Node.Net
- Node.Net.Server
- Node.Net.Socket
- Node.Path
- Node.Platform
- Node.Process
- Node.ReadLine
- Node.Stream
- Node.Stream.Aff
- Node.Stream.Aff.Internal
- Node.URL
- Options.Applicative
- Options.Applicative.BashCompletion
- Options.Applicative.Builder
- Options.Applicative.Builder.Completer
- Options.Applicative.Builder.Internal
- Options.Applicative.Common
- Options.Applicative.Extra
- Options.Applicative.Help
- Options.Applicative.Help.Chunk
- Options.Applicative.Help.Core
- Options.Applicative.Help.Levenshtein
- Options.Applicative.Help.Pretty
- Options.Applicative.Help.Types
- Options.Applicative.Internal
- Options.Applicative.Internal.Utils
- Options.Applicative.Types
- PSCI.Support
- Parsing
- Parsing.Combinators
- Parsing.Combinators.Array
- Parsing.Expr
- Parsing.Indent
- Parsing.Language
- Parsing.String
- Parsing.String.Basic
- Parsing.String.Replace
- Parsing.Token
- Partial
- Partial.Unsafe
- Pipes
- Pipes.Core
- Pipes.Internal
- Pipes.ListT
- Pipes.Prelude
- Prelude
- Prim
- Prim.Boolean
- Prim.Coerce
- Prim.Int
- Prim.Ordering
- Prim.Row
- Prim.RowList
- Prim.Symbol
- Prim.TypeError
- Random.LCG
- Record
- Record.Builder
- Record.Unsafe
- Record.Unsafe.Union
- Safe.Coerce
- Scaffold
- Scaffold.Main
- Scaffold.Test.Blockfrost
- Scaffold.Test.E2E
- Scaffold.Test.E2E.Serve
- Test.Assert
- Test.Ctl.ApplyArgs
- Test.Ctl.BalanceTx.ChangeGeneration
- Test.Ctl.BalanceTx.Collateral
- Test.Ctl.BalanceTx.Time
- Test.Ctl.Blockfrost
- Test.Ctl.Blockfrost.Aeson.Suite
- Test.Ctl.Blockfrost.Contract
- Test.Ctl.Blockfrost.GenerateFixtures.ChainTip
- Test.Ctl.Blockfrost.GenerateFixtures.EraSummaries
- Test.Ctl.Blockfrost.GenerateFixtures.Helpers
- Test.Ctl.Blockfrost.GenerateFixtures.NativeScript
- Test.Ctl.Blockfrost.GenerateFixtures.ProtocolParameters
- Test.Ctl.Blockfrost.GenerateFixtures.ScriptInfo
- Test.Ctl.Blockfrost.GenerateFixtures.SystemStart
- Test.Ctl.CoinSelection
- Test.Ctl.CoinSelection.Arbitrary
- Test.Ctl.CoinSelection.RoundRobin
- Test.Ctl.CoinSelection.SelectionState
- Test.Ctl.CoinSelection.UtxoIndex
- Test.Ctl.CslGc
- Test.Ctl.Data
- Test.Ctl.Data.Interval
- Test.Ctl.E2E
- Test.Ctl.E2E.Route
- Test.Ctl.Fixtures
- Test.Ctl.Fixtures.CostModels
- Test.Ctl.Hashing
- Test.Ctl.Integration
- Test.Ctl.Internal.Hashing
- Test.Ctl.Internal.Plutus.Credential
- Test.Ctl.Internal.Plutus.Time
- Test.Ctl.Logging
- Test.Ctl.Main
- Test.Ctl.NativeScript
- Test.Ctl.Ogmios.Aeson
- Test.Ctl.Ogmios.EvaluateTx
- Test.Ctl.Ogmios.GenerateFixtures
- Test.Ctl.Partition
- Test.Ctl.PrivateKey
- Test.Ctl.ProtocolParameters
- Test.Ctl.QueryM.AffInterface
- Test.Ctl.Serialization
- Test.Ctl.Serialization.Hash
- Test.Ctl.Testnet
- Test.Ctl.Testnet.Common
- Test.Ctl.Testnet.Contract
- Test.Ctl.Testnet.Contract.Assert
- Test.Ctl.Testnet.Contract.Mnemonics
- Test.Ctl.Testnet.Contract.OgmiosMempool
- Test.Ctl.Testnet.DistributeFunds
- Test.Ctl.Testnet.ExUnits
- Test.Ctl.Testnet.Gov
- Test.Ctl.Testnet.Logging
- Test.Ctl.Testnet.SameWallets
- Test.Ctl.Testnet.Staking
- Test.Ctl.Testnet.Utils
- Test.Ctl.Testnet.UtxoDistribution
- Test.Ctl.Types.Interval
- Test.Ctl.Types.Ipv6
- Test.Ctl.Types.TokenName
- Test.Ctl.Types.Transaction
- Test.Ctl.Unit
- Test.Ctl.UsedTxOuts
- Test.Ctl.Utils
- Test.Ctl.Utils.DrainWallets
- Test.Ctl.Wallet.Bip32
- Test.QuickCheck
- Test.QuickCheck.Arbitrary
- Test.QuickCheck.Combinators
- Test.QuickCheck.Gen
- Test.QuickCheck.Laws
- Test.QuickCheck.Laws.Control
- Test.QuickCheck.Laws.Control.Align
- Test.QuickCheck.Laws.Control.Alignable
- Test.QuickCheck.Laws.Control.Alt
- Test.QuickCheck.Laws.Control.Alternative
- Test.QuickCheck.Laws.Control.Applicative
- Test.QuickCheck.Laws.Control.Apply
- Test.QuickCheck.Laws.Control.Bind
- Test.QuickCheck.Laws.Control.Category
- Test.QuickCheck.Laws.Control.Comonad
- Test.QuickCheck.Laws.Control.Crosswalk
- Test.QuickCheck.Laws.Control.Extend
- Test.QuickCheck.Laws.Control.Monad
- Test.QuickCheck.Laws.Control.MonadPlus
- Test.QuickCheck.Laws.Control.Plus
- Test.QuickCheck.Laws.Control.Semigroupoid
- Test.QuickCheck.Laws.Data
- Test.QuickCheck.Laws.Data.BooleanAlgebra
- Test.QuickCheck.Laws.Data.Bounded
- Test.QuickCheck.Laws.Data.BoundedEnum
- Test.QuickCheck.Laws.Data.CommutativeRing
- Test.QuickCheck.Laws.Data.DivisionRing
- Test.QuickCheck.Laws.Data.Enum
- Test.QuickCheck.Laws.Data.Eq
- Test.QuickCheck.Laws.Data.EuclideanRing
- Test.QuickCheck.Laws.Data.Field
- Test.QuickCheck.Laws.Data.Foldable
- Test.QuickCheck.Laws.Data.Functor
- Test.QuickCheck.Laws.Data.FunctorWithIndex
- Test.QuickCheck.Laws.Data.HeytingAlgebra
- Test.QuickCheck.Laws.Data.Monoid
- Test.QuickCheck.Laws.Data.Ord
- Test.QuickCheck.Laws.Data.Ring
- Test.QuickCheck.Laws.Data.Semigroup
- Test.QuickCheck.Laws.Data.Semiring
- Test.Scaffold.Main
- Test.Spec
- Test.Spec.Assertions
- Test.Spec.Assertions.String
- Test.Spec.Console
- Test.Spec.QuickCheck
- Test.Spec.Reporter
- Test.Spec.Reporter.Base
- Test.Spec.Reporter.Console
- Test.Spec.Reporter.ConsoleReporter
- Test.Spec.Reporter.Dot
- Test.Spec.Reporter.Spec
- Test.Spec.Reporter.Tap
- Test.Spec.Reporter.TeamCity
- Test.Spec.Result
- Test.Spec.Runner
- Test.Spec.Runner.Event
- Test.Spec.Speed
- Test.Spec.Style
- Test.Spec.Summary
- Test.Spec.Tree
- Text.PrettyPrint.Leijen
- Toppokki
- Type.Data.Boolean
- Type.Data.Ordering
- Type.Data.Symbol
- Type.Equality
- Type.Function
- Type.Prelude
- Type.Proxy
- Type.Row
- Type.Row.Homogeneous
- Type.RowList
- Unsafe.Coerce
- Untagged.Castable
- Untagged.TypeCheck
- Untagged.Union
- Web.DOM
- Web.DOM.CharacterData
- Web.DOM.ChildNode
- Web.DOM.Comment
- Web.DOM.DOMTokenList
- Web.DOM.Document
- Web.DOM.DocumentFragment
- Web.DOM.DocumentType
- Web.DOM.Element
- Web.DOM.HTMLCollection
- Web.DOM.Internal.Types
- Web.DOM.MutationObserver
- Web.DOM.MutationRecord
- Web.DOM.Node
- Web.DOM.NodeList
- Web.DOM.NodeType
- Web.DOM.NonDocumentTypeChildNode
- Web.DOM.NonElementParentNode
- Web.DOM.ParentNode
- Web.DOM.ProcessingInstruction
- Web.DOM.ShadowRoot
- Web.DOM.Text
- Web.Event.CustomEvent
- Web.Event.Event
- Web.Event.EventPhase
- Web.Event.EventTarget
- Web.Event.Internal.Types
- Web.File.Blob
- Web.File.File
- Web.File.FileList
- Web.File.FileReader
- Web.File.FileReader.ReadyState
- Web.File.Url
- Web.HTML
- Web.HTML.Common
- Web.HTML.Event.BeforeUnloadEvent
- Web.HTML.Event.BeforeUnloadEvent.EventTypes
- Web.HTML.Event.DataTransfer
- Web.HTML.Event.DataTransfer.DataTransferItem
- Web.HTML.Event.DragEvent
- Web.HTML.Event.DragEvent.EventTypes
- Web.HTML.Event.ErrorEvent
- Web.HTML.Event.EventTypes
- Web.HTML.Event.HashChangeEvent
- Web.HTML.Event.HashChangeEvent.EventTypes
- Web.HTML.Event.PageTransitionEvent
- Web.HTML.Event.PageTransitionEvent.EventTypes
- Web.HTML.Event.PopStateEvent
- Web.HTML.Event.PopStateEvent.EventTypes
- Web.HTML.Event.TrackEvent
- Web.HTML.Event.TrackEvent.EventTypes
- Web.HTML.HTMLAnchorElement
- Web.HTML.HTMLAreaElement
- Web.HTML.HTMLAudioElement
- Web.HTML.HTMLBRElement
- Web.HTML.HTMLBaseElement
- Web.HTML.HTMLBodyElement
- Web.HTML.HTMLButtonElement
- Web.HTML.HTMLCanvasElement
- Web.HTML.HTMLDListElement
- Web.HTML.HTMLDataElement
- Web.HTML.HTMLDataListElement
- Web.HTML.HTMLDivElement
- Web.HTML.HTMLDocument
- Web.HTML.HTMLDocument.ReadyState
- Web.HTML.HTMLDocument.VisibilityState
- Web.HTML.HTMLElement
- Web.HTML.HTMLEmbedElement
- Web.HTML.HTMLFieldSetElement
- Web.HTML.HTMLFormElement
- Web.HTML.HTMLHRElement
- Web.HTML.HTMLHeadElement
- Web.HTML.HTMLHeadingElement
- Web.HTML.HTMLHtmlElement
- Web.HTML.HTMLHyperlinkElementUtils
- Web.HTML.HTMLIFrameElement
- Web.HTML.HTMLImageElement
- Web.HTML.HTMLImageElement.CORSMode
- Web.HTML.HTMLImageElement.DecodingHint
- Web.HTML.HTMLImageElement.Laziness
- Web.HTML.HTMLInputElement
- Web.HTML.HTMLKeygenElement
- Web.HTML.HTMLLIElement
- Web.HTML.HTMLLabelElement
- Web.HTML.HTMLLegendElement
- Web.HTML.HTMLLinkElement
- Web.HTML.HTMLMapElement
- Web.HTML.HTMLMediaElement
- Web.HTML.HTMLMediaElement.CanPlayType
- Web.HTML.HTMLMediaElement.NetworkState
- Web.HTML.HTMLMediaElement.ReadyState
- Web.HTML.HTMLMetaElement
- Web.HTML.HTMLMeterElement
- Web.HTML.HTMLModElement
- Web.HTML.HTMLOListElement
- Web.HTML.HTMLObjectElement
- Web.HTML.HTMLOptGroupElement
- Web.HTML.HTMLOptionElement
- Web.HTML.HTMLOutputElement
- Web.HTML.HTMLParagraphElement
- Web.HTML.HTMLParamElement
- Web.HTML.HTMLPreElement
- Web.HTML.HTMLProgressElement
- Web.HTML.HTMLQuoteElement
- Web.HTML.HTMLScriptElement
- Web.HTML.HTMLSelectElement
- Web.HTML.HTMLSourceElement
- Web.HTML.HTMLSpanElement
- Web.HTML.HTMLStyleElement
- Web.HTML.HTMLTableCaptionElement
- Web.HTML.HTMLTableCellElement
- Web.HTML.HTMLTableColElement
- Web.HTML.HTMLTableDataCellElement
- Web.HTML.HTMLTableElement
- Web.HTML.HTMLTableHeaderCellElement
- Web.HTML.HTMLTableRowElement
- Web.HTML.HTMLTableSectionElement
- Web.HTML.HTMLTemplateElement
- Web.HTML.HTMLTextAreaElement
- Web.HTML.HTMLTimeElement
- Web.HTML.HTMLTitleElement
- Web.HTML.HTMLTrackElement
- Web.HTML.HTMLTrackElement.ReadyState
- Web.HTML.HTMLUListElement
- Web.HTML.HTMLVideoElement
- Web.HTML.History
- Web.HTML.Location
- Web.HTML.Navigator
- Web.HTML.SelectionMode
- Web.HTML.ValidityState
- Web.HTML.Window
- Web.Internal.FFI
- Web.Storage.Event.StorageEvent
- Web.Storage.Storage
- Web.XHR.EventTypes
- Web.XHR.FormData
- Web.XHR.ProgressEvent
- Web.XHR.ReadyState
- Web.XHR.ResponseType
- Web.XHR.XMLHttpRequest
- Web.XHR.XMLHttpRequestUpload
The alternative
Alt
instance provides thealt
combinator<|>
.The expression
p_left <|> p_right
will first try thep_left
parser and if that fails and consumes no input then it will try thep_right
parser.While we are parsing down the
p_left
branch we may reach a point where we know this is the correct branch, but we cannot parse further. At that point we want to fail the entire parse instead of trying thep_right
branch.For example, consider this
fileParser
which can parse either an HTML file that begins with<html>
or a shell script file that begins with#!
.If we read a file from disk and run this
fileParser
on it and thestring "<html>"
parser succeeds, then we know that the first branch is the correct branch, so we want to commit to the first branch. Even if theparseTheRestOfTheHtml
parser fails we don’t want to try the second branch.To control the point at which we commit to the
p_left
branch use thetry
combinator and thelookAhead
combinator and theconsume
function.The
alt
combinator works this way because it gives us good localized error messages while also allowing an efficient implementation. See Parsec: Direct Style Monadic Parser Combinators For The Real World section 2.3 Backtracking.