0
foreign import subscribeEventedOnPrime
  "function subscribeEventedOnPrime(n){  \
  \ return function(fn){                 \
  \    return function(obj){             \
  \       return function(){             \
  \         obj.addEventListener(n, fn); \
  \         return obj;                  \
  \       };                             \
  \     };                               \
  \  };                                  \
  \}" :: forall d a o eff. 
         String -> 
         (d -> a) -> 
         o -> 
         Eff (customEvent :: CustomEvent | eff) o

subscribeEventedOn n f o = subscribeEventedOnPrime n (\e -> do
    trace "wtf" -- if this line is removed, everything seems to work
    f $ newEvent e."type" e."detail"
  ) o

Whether a do block has one line vs more than one line, seems to effect whether or not that code actually gets called. What am I missing?

Fresheyeball
  • 29,567
  • 20
  • 102
  • 164

1 Answers1

1

I think it's because by intoducing the trace you're making d -> a into something like

forall e. d -> Eff (trace :: Trace | e) Unit

which means it's not going to be evaluated unless you use unsafeInterleaveEff or something similar to actually run it.

I'm not 100% sure, but maybe the compiler shouldn't let you use the do without the trace at all, I'll have to investigate a bit.

gb.
  • 4,629
  • 1
  • 20
  • 19
  • hey, is there any way I can get one on one support for this? I've been struggling with this one unit test for days now, and the problem seems to be syntax. – Fresheyeball Jul 26 '14 at 15:45