Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module State where
  2.  
  3. type State   s a = s -> (a, s)
  4. type CoState s a = (a, s) -> s
  5.  
  6. hyloState :: State s a -> (CoState b a) -> s ->  b  
  7. hyloState f c = go                                                      
  8.    where                                                                        
  9.      go = c . fmap go . f
  10. -- (\(x,q') -> c (x,go q')) . f
  11.  
  12. --
  13.  
  14. type SafeState   s a = s -> (a, Maybe s)
  15. type CoSafeState s a = (a, Maybe s) -> s
  16.  
  17. hyloSafeState :: SafeState s a -> (CoSafeState b a) -> s ->  b
  18. hyloSafeState f c = go
  19.  where
  20.      go = c . fmap (fmap go) . f
  21.  
  22. --
  23.  
  24. type StateSafe   s a = s -> Maybe (a, s)
  25. type CoStateSafe s a = Maybe (a, s) -> s
  26.  
  27. hyloStateSafe :: StateSafe s a -> (CoStateSafe b a) -> s -> b
  28. hyloStateSafe f c = go
  29.  where
  30.   go = c . fmap (fmap go) . f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement