+instance Functor Step where
+ fmap f (Step s) = Step \st.let (x, st`)=s st in (fmap f x, st`)
+instance Applicative Step where
+ pure s = Step \st.(pure s, st)
+ (<*>) x1 x2 = ap x1 x2
+instance Monad Step where
+ bind (Step s) f = Step \st.case s st of
+ (Just x, st`) = let (Step s`) = f x in s` st`
+ (_, st`) = (Nothing, st`)
+
+instance arith Step where
+ lit x = pure x
+ (+.) x1 x2 = (+) <$> x1 <*> x2
+ (*.) x1 x2 = (*) <$> x1 <*> x2
+instance store Step where
+ read = Step \st.(Just st, st)
+ write (Step x) = Step \st.case x st of
+ (Just v`, _) = (Just v`, v`)
+ (_, st) = (Nothing, st)
+instance truth Step where
+ (XOR) x1 x2 = (\x.(\y.x && not y || not x && y)) <$> x1 <*> x2
+ -. x1 = (not) <$> x1
+instance =.= Step where
+ (=.=) x1 x2 = (==) <$> x1 <*> x2
+instance except Step where
+ throw = Step \st.(Nothing, st)
+ try (Step x1) (Step x2) = Step \st.case x1 st of
+ (Just v`, st`) = (Just v`, st)
+ (Nothing, st`) = x2 st`
+
+eval (Step f) = f 0
+
+seven :: e Int | aexpr e