$ ghc a.hs
$ time ./a
./a 1.51s user 1.67s system 77% cpu 4.082 total
$ ghc b.hs
$ time ./b
./b 1.58s user 1.68s system 78% cpu 4.126 total
Created
February 11, 2014 07:50
-
-
Save pasberth/8930735 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
| {-# LANGUAGE NoImplicitPrelude #-} | |
| {-# LANGUAGE RankNTypes #-} | |
| import Prelude hiding (Maybe(..)) | |
| import Control.Monad | |
| type Maybe a | |
| = forall b. | |
| (a -> b) -- Just | |
| -> b -- Nothing | |
| -> b | |
| just :: a -> Maybe a | |
| just x y _ = y x | |
| nothing :: forall a. Maybe a | |
| nothing _ x = x | |
| dat :: Maybe Int | |
| dat = just 42 | |
| main :: IO () | |
| main = do | |
| forM_ [0..1000000] $ const $ do | |
| dat print (return ()) |
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
| {-# LANGUAGE NoImplicitPrelude #-} | |
| import Prelude hiding (Maybe(..)) | |
| import Control.Monad | |
| data Maybe a | |
| = Just a | |
| | Nothing | |
| dat :: Maybe Int | |
| dat = Just 42 | |
| main :: IO () | |
| main = do | |
| forM_ [0..1000000] $ const $ do | |
| case dat of | |
| Just x -> print x | |
| Nothing -> return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment