
Hi, I've imported the State monad module and used in the 'pop' function that will pop the head out of the list but am getting error in GHCi. ----- import Control.Monad.State let pop = State $ \(x:xs) -> (x,xs) <interactive>:73:11: Not in scope: data constructor ‘State’ Perhaps you meant ‘StateT’ (imported from Control.Monad.State) ----- Please can anyone point out what the issue is here? Thanks, Shishir

On Fri, May 8, 2015 at 2:25 PM, Shishir Srivastava < shishir.srivastava@gmail.com> wrote:
I've imported the State monad module and used in the 'pop' function that will pop the head out of the list but am getting error in GHCi.
You are probably working from outdated documentation of some kind. The original standalone monads like State from mtl1 were replaced several years ago with type aliases (in this case `type State s a = StateT s Identity a`) in mtl2, which means State is no longer a constructor. The `state` function can be used as a quick replacement for the old `State` constructor for any purpose other than pattern matching. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (2)
-
Brandon Allbery
-
Shishir Srivastava