summaryrefslogtreecommitdiff
path: root/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/cpranal/should_compile/Cpr001_imp.hs')
-rw-r--r--testsuite/tests/cpranal/should_compile/Cpr001_imp.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs b/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs
index 5b2586127b..22352ead05 100644
--- a/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs
+++ b/testsuite/tests/cpranal/should_compile/Cpr001_imp.hs
@@ -2,6 +2,9 @@
module Cpr001_imp where
+import Control.Applicative (Applicative(..))
+import Control.Monad (liftM, ap)
+
data MS = MS { instr :: String
, pc :: Int
, mem :: String
@@ -18,6 +21,13 @@ newtype StateTrans s a = ST ( s -> (s, Maybe a))
-- as it is and Nothing is returned as value
-- else execution continues
+instance Functor (StateTrans s) where
+ fmap = liftM
+
+instance Applicative (StateTrans s) where
+ pure = return
+ (<*>) = ap
+
instance Monad (StateTrans s) where
(ST p) >>= k
= ST (\s0 -> let