Guest User

Untitled

a guest
Dec 11th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. let a = Just (5+) -- Instead of mapping + to Just 5
  2. let b = (3+) <$> a -- I imported Control.Applicative even though most of these modules are deprecated
  3. let c = Just (3+) <*> a -- I expect this to be equivalent to b and :t b, :t c shows that they are the 'same'
  4. a <*> Just 1 -- returns 6 as I expected
  5.  
  6. b <*> Just 1 -- and get 9 as in (3+) $ (5+) 1 or ((3+) . (5+)) 1
  7.  
  8. b :: (Num (a -> a), Num a) => Maybe (a -> a)
  9.  
  10. let Just val = b <*> Just 1
  11. :t val -- returns ((Num (t -> t), Num t) => t which tells me that val is an instance of Num but then again I am just a beginner so what do I know?
  12.  
  13. let b = (3+) <$> Just (5+)
  14.  
  15. Just (3 + (5+))
  16.  
  17. b :: (Num (a -> a), Num a) => Maybe (a -> a)
  18.  
  19. let b = ((3+).) <$> Just (5+)
Add Comment
Please, Sign In to add comment