Guest User

Untitled

a guest
May 4th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Can someone explain where Applicative instances arise in this code?
  2. isAlphaNum :: Char -> Bool
  3. isAlphaNum = (||) <$> isAlpha <*> isNum
  4.  
  5. s :: (r -> a -> b) -> (r -> a) -> r -> b
  6. s f g x = f x (g x)
  7.  
  8. newtype Reader r a = Reader (r -> a)
  9.  
  10. f <*> x = c -> (f c) (x c)
  11.  
  12. isAlphaNum c = (isAlpha c) || (isNum c)
  13.  
  14. import Data.Char
  15. import Control.Applicative
  16.  
  17. isAlphaNum = liftA2 (||) isAlpha isNumber
  18.  
  19. import Data.Char
  20. import Control.Monad
  21.  
  22. isAlphaNum = liftM2 (||) isAlpha isNumber
  23.  
  24. import Data.Function
  25.  
  26. orFst = (||) `on` fst
  27.  
  28. -- orFst (True,3) (False, 7)
  29. --> True
Advertisement
Add Comment
Please, Sign In to add comment