Skip to content

Instantly share code, notes, and snippets.

@dagit
Created March 18, 2011 04:14
Show Gist options
  • Save dagit/875609 to your computer and use it in GitHub Desktop.
Save dagit/875609 to your computer and use it in GitHub Desktop.
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