Created
May 31, 2011 21:27
-
-
Save yairchu/1001318 to your computer and use it in GitHub Desktop.
GHC performance mysteries
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.Monad (MonadPlus(mzero)) | |
import Control.Monad.ListT (ListT) | |
import Data.Copointed | |
import Data.List.Class | |
import Prelude hiding (enumFromTo) | |
-- This is exactly the same as Data.List.Class.enumFromTo | |
pastedEnumFromTo :: (List l, Enum a) => a -> a -> l a | |
pastedEnumFromTo from to | |
| fromEnum from > fromEnum to = mzero | |
| otherwise = cons from (pastedEnumFromTo (succ from) to) | |
nums :: [Int] | |
--nums :: ListT ((->) ()) Int | |
nums = enumFromTo 0 10000000 | |
--nums = pastedEnumFromTo 0 10000000 | |
main = print $ div (copoint (foldlL (+) 0 nums)) (copoint (lengthL nums)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment