[Haskell-cafe] Irritating Referential Transparency behavior?
martin
martin.drautzburg at web.de
Sun Aug 10 18:20:50 UTC 2014
Hello all,
I came across something strange:
This code compiles:
------------------------------------------------------------
data LProcess a = LP {lstep :: Writer [String] (Event a -> ([Event a], LProcess a))}
------------------------------------------------------------
exProcess2 :: ProcState -> Location -> LProcess EvtData
exProcess2 pState loc = LP {lstep = xxx}
where
xxx = myStep pState
myStep _ = return $ \(E t l _) -> ([E (t+1) l Wakeup], (proc' pState))
proc' state = exProcess2 (trc state) loc
but when I replace xxx by myStep pState as in
exProcess2 pState loc = LP {lstep = myStep pState}
where
xxx = myStep pState
myStep _ = return $ \(E t l _) -> ([E (t+1) l Wakeup], (proc' pState))
proc' state = exProcess2 (trc state) loc
I get
No instance for (Monad m0) arising from a use of `myStep'
The type variable `m0' is ambiguous
Possible fix: add a type signature that fixes these type variable(s)
It compiles again when I remove the xxx = line. Why is that so?
More information about the Haskell-Cafe
mailing list