Created
March 18, 2011 04:14
-
-
Save dagit/875609 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 Prelude hiding (log) | |
import Control.Monad ( (<$>) ) | |
import Control.Monad.Trans ( liftIO, when, baz, Bar(..) ) -- some made up names | |
{- | Our very important FOO compilation option -} | |
#ifdef FOO | |
foo = 1 | |
#endif | |
{- {- Nested comments aren't quite right -} nope... -} | |
-- Sample Hello, World program | |
main :: IO () | |
main = do | |
(x:xs) <- getArgs | |
let y = tail xs | |
putStrLn "hello, world!" | |
return () | |
a :: Char | |
a = 'a' | |
fibs :: [Integer] | |
fibs = 0 : 1 : zipWith (+) fibs (tail fibs) | |
foo :: Num a => a -> a | |
foo 1 = 4 | |
foo n = n+1 | |
-- | baz combines map and Maybe. | |
baz :: (a -> Maybe b) -> [a] -> [Maybe b] | |
baz _ [] = [Nothing] | |
baz f (x:xs) = f x : baz f xs | |
integers = [1,2,3,4,5 ..] | |
pi :: Maybe Double | |
pi = Just 3.14159 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment