mirror of
https://github.com/ilyakooo0/optparse-applicative.git
synced 2024-11-22 22:18:13 +03:00
Add instances for ParserResult
This commit is contained in:
parent
b9667c2735
commit
80618c2a6f
@ -256,6 +256,23 @@ data ParserResult a
|
||||
| CompletionInvoked CompletionResult
|
||||
deriving Show
|
||||
|
||||
instance Functor ParserResult where
|
||||
fmap f (Success a) = Success (f a)
|
||||
fmap _ (Failure f) = Failure f
|
||||
fmap _ (CompletionInvoked c) = CompletionInvoked c
|
||||
|
||||
instance Applicative ParserResult where
|
||||
pure = Success
|
||||
Success f <*> r = fmap f r
|
||||
Failure f <*> _ = Failure f
|
||||
CompletionInvoked c <*> _ = CompletionInvoked c
|
||||
|
||||
instance Monad ParserResult where
|
||||
return = pure
|
||||
Success x >>= f = f x
|
||||
Failure f >>= _ = Failure f
|
||||
CompletionInvoked c >>= _ = CompletionInvoked c
|
||||
|
||||
type Args = [String]
|
||||
|
||||
data ArgPolicy
|
||||
|
Loading…
Reference in New Issue
Block a user