Weird syntax error in State's Applicative instance
paul-snively opened this issue · 3 comments
paul-snively commented
instance Applicative (State s) where
pure ::
a
-> State s a
pure a = State (\s -> (a, s))
(<*>) ::
State s (a -> b)
-> State s a
-> State s b
State f <*> State a =
State (\s -> let (g, t) = f s
(z, u) = a t
in (g z, u))
This is copied straight out of State.hs
, but haskell-ide-engine
complains of a syntax error on the (
of Iz, u)
. So does ghci when I try to load it (unsurprisingly).
tonymorris commented
What's the error?
vaibhavsagar commented
It looks like the last two lines of the code sample need to be indented by one further space, but State.hs
looks fine to me:
instance Applicative (State s) where
pure ::
a
-> State s a
pure a = State (\s -> (a, s))
(<*>) ::
State s (a -> b)
-> State s a
-> State s b
State f <*> State a =
State (\s -> let (g, t) = f s
(z, u) = a t
in (g z, u))
paul-snively commented
I went back to significant whitespace but can't reproduce the issue now, so I'm closing this. Thanks, guys!