[Haskell-cafe] Confused about missing data constructor

Antoine Latter aslatter at gmail.com
Wed Nov 24 13:08:17 EST 2010


I meant that 'pop' and 'push' should have been written with 'modify', 'get',
and 'set' instead of the raw constructor, not as a drop-in replacement.

I can show you examples later if this isn't clear, unless I'm not
understanding your code above.

Antoine
On Nov 24, 2010 10:46 AM, "Adam Miezianko" <adam at theorylounge.org> wrote:
> On Wed, 24 Nov 2010 06:17:47 -0800, Antoine Latter <aslatter at gmail.com>
> wrote:
>
>> On Tue, Nov 23, 2010 at 6:58 PM, Adam Miezianko <adam at theorylounge.org>
>> wrote:
>>> I'm working through Learn You a Haskell for Great Good [1] and getting
>>> a compiler error while playing around with some of the code. I have
>>> this:
>>>
>>> pop :: State Stack Int
>>>
>>> But when I try to load it into ghci I get the following errors:
>>>
>>> /home/admi/.pe/state.hs:6:6: Not in scope: data constructor `State'
>>>
>>> Now, I'm not exactly sure how to read the documentation for
>>> Control.Monad.State [2] but it seems that newtype State s a = State
>>> {...} defines a constructor, or am I wrong on that point too? So,
>>> what am I missing here? In case it matters, I am using mtl-2.0.1.0
>>> and ghci 6.12.3.
>>>
>>> [1] http://learnyouahaskell.com/for-a-few-monads-more
>>> [2]
>>> http://cvs.haskell.org/Hugs/pages/libraries/mtl/Control-Monad-State.html
>>>
>>
>> It looks like your documentation doesn't match the library you're using.
>>
>> The documentation for mtl-2.x is here:
>> http://hackage.haskell.org/package/mtl
>
> Thanks!
>
> My documentation didn't have any version identification, so discovering
> that there was a breaking interface change is no surprise now. Next time
> hoogle doesn't return me what I want I'll first suspect it's been removed
> before questioning the accuracy of the search results.
>
> On a somewhat related note, I also found the link you provide, but I found

> hackage.haskell.org to be intermittently timing out for me this last week.
>
>> However you might be better served using the 'modify' function.
>
> Looking at the type signature of modify, I'm unsure how to use it. It
> does not look like I can just drop it in as a replacement for State
> (StateT, state). Could someone provide an example? The tutorials seem to
> mostly use the State constructor that's now gone.
>
> --
> Adam Miezianko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20101124/3ac89828/attachment.html


More information about the Haskell-Cafe mailing list