Skip to content

Instantly share code, notes, and snippets.

@mbrcknl
Created August 6, 2013 02:46
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 mbrcknl/6161604 to your computer and use it in GitHub Desktop.
Save mbrcknl/6161604 to your computer and use it in GitHub Desktop.
import Data.Set.Monad as SM
import Debug.Trace as DT
(<+>) = liftM . plus
plus x y = DT.trace "." (x + y)
l = SM.fromList [0,1]
-- Intuitively expect 28 additions, but we actually get 60!
test = Set Int
test = do
a <- l
b <- a <+> l -- expect 4 additions, result [0..2]
c <- b <+> l -- expect 6 additions, result [0..3], actually get 8 additions
d <- c <+> l -- expect 8 additions, result [0..4], actually get 16 additions
d <+> l -- expect 10 additions, result [0..5], actually get 32 additions
@runarorama
Copy link

Hit that with Codensity and see if it improves. Oh, no, I see now. It will actually improve but not in this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment