34 lines
964 B
Diff
34 lines
964 B
Diff
commit 1a2f65b97199bd69ef8f0cebcb8f58de5b26af1c
|
|
Author: Shea Levy <shea@shealevy.com>
|
|
Date: Mon Jan 12 08:57:34 2015 -0500
|
|
|
|
Prepare for AMP
|
|
|
|
See https://www.haskell.org/haskellwiki/Functor-Applicative-Monad_Proposal
|
|
|
|
diff --git a/lib/Options/Tokenize.hs b/lib/Options/Tokenize.hs
|
|
index 2ead1ff..91998b6 100644
|
|
--- a/lib/Options/Tokenize.hs
|
|
+++ b/lib/Options/Tokenize.hs
|
|
@@ -11,6 +11,7 @@ module Options.Tokenize
|
|
, tokenize
|
|
) where
|
|
|
|
+import Control.Applicative (Applicative(..))
|
|
import Control.Monad.Error hiding (throwError)
|
|
import qualified Control.Monad.Error
|
|
import Control.Monad.State
|
|
@@ -53,6 +54,13 @@ data TokState = TokState
|
|
|
|
newtype Tok a = Tok { unTok :: ErrorT String (StateT TokState Identity) a }
|
|
|
|
+instance Functor Tok where
|
|
+ fmap = liftM
|
|
+
|
|
+instance Applicative Tok where
|
|
+ pure = return
|
|
+ (<*>) = ap
|
|
+
|
|
instance Monad Tok where
|
|
return = Tok . return
|
|
m >>= f = Tok (unTok m >>= unTok . f)
|