daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data FreeT (f :: (k -> *) -> k -> *) (g :: (k -> *)) (a :: k)
  2.   = Done' (g a)
  3.   | More' (f (FreeT f g) a)
  4.  
  5. class FFunctor t where
  6.   ffmap :: (forall x. f x -> g x) -> t f a -> t g a
  7.  
  8. class FFunctor t => FMonad t where
  9.   freturn :: f a -> t f a
  10.   fbind :: (forall x. f x -> t g x) -> t f a -> t g a
  11.  
  12. instance FFunctor t => FFunctor (FreeT t) where
  13.   ffmap f (Done' a) = Done' (f a)
  14.   ffmap f (More' a) = More' (ffmap (ffmap f) a)
  15.  
  16. instance FFunctor t => FMonad (FreeT t) where
  17.   freturn = Done'
  18.   fbind f (Done' a) = f a
  19.   fbind f (More' a) = More' (ffmap (fbind f) a)
  20.  
  21. foldFreeT
  22.   :: (FFunctor f, FMonad t)
  23.   => (forall x y. f y x -> t y x)
  24.   -> FreeT f g a -> t g a
  25. foldFreeT f (Done' a) = freturn a
  26. foldFreeT f (More' a) = fbind (foldFreeT f) (f a)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top