Created
April 6, 2013 02:33
-
-
Save gergoerdi/5324462 to your computer and use it in GitHub Desktop.
Trying to observe a difference between `pure id <*> x` and `x`
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.Applicative.Free | |
import Control.Applicative | |
import Control.Monad.Identity | |
import Data.Monoid | |
count :: (Functor eff) => Free eff a -> Int | |
count = getSum . runIdentity . analyze (const $ Identity $ Sum 1) | |
test :: (Functor eff) => Free eff a -> (Int, Int) | |
test x = (count $ pure id <*> x, count x) | |
test' :: (Int, Int) | |
test' = test (effect undefined :: Free Identity ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment