Skip to content

Instantly share code, notes, and snippets.

@mandubian
Last active March 21, 2017 21:38
Show Gist options
  • Save mandubian/83d28f126ddf684eca633e809ba87fdd to your computer and use it in GitHub Desktop.
Save mandubian/83d28f126ddf684eca633e809ba87fdd to your computer and use it in GitHub Desktop.
why this compile error?
mapAccumL : Traversable t => (a -> b -> (c, a)) -> a -> t b -> (t c, a)
mapAccumL f a1 tb = runState (traverse stateFlip tb) a1
where
-- if I comment next line, it compiles OK
-- else it fails with :
--
-- test.idr:91:37:When checking right hand side of test.mapAccumL, stateFlip with expected type
-- StateT a Identity c
-- When checking an application of f:
-- Type mismatch between
-- b1 (Type of b1)
-- and
-- b (Expected type)
stateFlip : b -> StateT a Identity c
stateFlip b1 = ST (\x => pure(f x b1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment