daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ----------------------------- 1.9 ---------------------------------
  3.  
  4. f2p :: (a -> (b,c)) -> (a -> b, a -> c)
  5. f2p f  = (fst . f, snd . f)
  6.  
  7. testF :: Double -> (Integer, String)
  8. testF d = (round d, show d)
  9.  
  10. p2f :: (a -> b, a -> c) -> (a -> (b,c))
  11. p2f (f,g) = (\x -> (f x, g x))      
  12.  
  13.  
  14. ---------------------------- 1.10 --------------------------------
  15.  
  16. s2p :: (Either b c -> a) -> (b -> a, c -> a)
  17. s2p f = (f . Left, f . Right)
  18.  
  19.  
  20. p2s :: (b -> a, c -> a) -> (Either b c -> a)
  21. p2s (f,g) = (\x -> either f g x)
  22.  
  23. --------------------------- 1.11 ---------------------------------
  24.  
  25. -- a : Card A
  26. -- b : Card B
  27. -- c : Card C
  28.  
  29.  
  30. -- Either a b   : A + B
  31. -- (a,b)        : A * B
  32. -- a -> b       :  
  33.  
  34. --------------------------- 1.12 ---------------------------------
  35.  
  36. isoR :: (Bool -> t) -> (t,t)
  37. isoR f = (f False, f True)
  38.  
  39. isoL :: (t,t) -> (Bool -> t)
  40. isoL (x,y) = (\b -> if b then y else x)
  41.  
  42. --------------------------- 1.13 --------------------------------
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