Skip to content

Instantly share code, notes, and snippets.

@MiyamonY
Created March 1, 2015 12:11
Show Gist options
  • Save MiyamonY/07e3cc0ebfc93c4f6e92 to your computer and use it in GitHub Desktop.
Save MiyamonY/07e3cc0ebfc93c4f6e92 to your computer and use it in GitHub Desktop.
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