concrete functor and monad transformers
#69Alternative instance for ContT
instance (Monoid r, Applicative m) => Alternative (ContT r m) where empty = ContT $ const (pure mempty) (ContT f) <|> (ContT g) = ContT $ \c -> liftA2 (<>) (f c) (g c)
Some ways this can be useful:
ContTto implement a backtracking search.
Maybe (First Result))for some
Result :: *.
a <|> bthen means "try
You have a function
inferType :: Expr a -> (a -> Type) -> Typewhere
Expr arepresents an AST containing free variables in
(a -> Type)is an environment which maps free variables to their type.
Typehas a monoid instance where
memptyis the type of bottom and
(<>)is unification; you form a
Cont Type aby way of
cont (inferType e). Then
(<>)from working in the empty environment to working in arbitrary ones.