Created
March 1, 2015 12:11
-
-
Save MiyamonY/07e3cc0ebfc93c4f6e92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Applicative | |
-- class (Functor f) => Applicative f where | |
-- pure :: a -> f a | |
-- (<*>) :: f (a -> b) -> f a -> f b | |
-- instance Appilcative Maybe where | |
-- pure = Just | |
-- Nothing <*> _ = Nothing | |
-- (Just f) <*> something = fmap f something | |
myAction :: IO String | |
myAction = (++) <$> getLine <*> getLine | |
main :: IO () | |
main = do | |
a <- (++) <$> getLine <*> getLine | |
putStrLn $ "The two lines concatenated turn out to be : " ++ a | |
sequenceA :: (Applicative f) => [f a] -> f [a] | |
-- sequenceA [] = pure [] | |
-- sequenceA (x:xs) = (:) <$> x <*> sequenceA xs | |
sequenceA = foldr (liftA2 (:)) (pure []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment