Skip to content

Instantly share code, notes, and snippets.

@gergoerdi
Created April 6, 2013 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gergoerdi/5324462 to your computer and use it in GitHub Desktop.
Save gergoerdi/5324462 to your computer and use it in GitHub Desktop.
Trying to observe a difference between `pure id <*> x` and `x`
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