Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Getting started with repa on MacOS (Konrad Hinsen)
2. State Monad - Not in scope: data constructor `State'
(Hugo Ferreira)
3. Re: State Monad - Not in scope: data constructor `State'
(Brent Yorgey)
----------------------------------------------------------------------
Message: 1
Date: Sat, 29 Oct 2011 12:12:55 +0200
From: Konrad Hinsen <[email protected]>
Subject: Re: [Haskell-beginners] Getting started with repa on MacOS
To: Andres L?h <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=iso-8859-1
On 28 Oct, 2011, at 19:38 , Andres L?h wrote:
> (1) The latest version of repa doesn't work with ghc-7.0.3 or
> ghc-7.0.4. These provide base-4.3, and base is hardwired in GHC and
> cannot be upgraded. The easiest way for you to get around this is to
> explicitly say "cabal install repa-2.1.1.5".
That works fine indeed. Thanks!
Konrad.
------------------------------
Message: 2
Date: Sat, 29 Oct 2011 20:48:28 +0100
From: Hugo Ferreira <[email protected]>
Subject: [Haskell-beginners] State Monad - Not in scope: data
constructor `State'
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Hello,
I am trying to use some State Monad code
in order to learn about this. However in
GHCi I cannot use the "State" constructor.
import qualified Control.Monad.State
>:{
| let fromStoAandS c | c `mod` 5 == 0 = ("foo",c+1)
| | otherwise = ("bar",c+1)
| :}
> :t fromStoAandS
>fromStoAandS :: Integral t => t -> ([Char], t)
>:{
| let stateIntString = State fromStoAandS
>Prelude Control.Monad.State| :}
>
><interactive>:1:22: Not in scope: data constructor `State'
I have found a message stating that this is not possible
because their is "no State data constructor", it is only "defined
to be a type alias". The author of the message then says we should use:
http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-State-Lazy.html#v:state
instead. Still lost however.
So, how do I create the "Sate" above?
TIA,
Hugo F.
------------------------------
Message: 3
Date: Sat, 29 Oct 2011 16:09:52 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] State Monad - Not in scope: data
constructor `State'
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sat, Oct 29, 2011 at 08:48:28PM +0100, Hugo Ferreira wrote:
> Hello,
>
> I am trying to use some State Monad code
> in order to learn about this. However in
> GHCi I cannot use the "State" constructor.
>
> import qualified Control.Monad.State
>
> >:{
> | let fromStoAandS c | c `mod` 5 == 0 = ("foo",c+1)
> | | otherwise = ("bar",c+1)
> | :}
> > :t fromStoAandS
> >fromStoAandS :: Integral t => t -> ([Char], t)
>
> >:{
> | let stateIntString = State fromStoAandS
> >Prelude Control.Monad.State| :}
> >
> ><interactive>:1:22: Not in scope: data constructor `State'
>
> I have found a message stating that this is not possible
> because their is "no State data constructor", it is only "defined
> to be a type alias".
That is correct. State used to be defined directly; now it is just an
alias for StateT s Identity. You don't really have to worry about
what this means, but the point is that there is no longer a real State
constructor.
The author of the message then says we should use:
>
> http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-State-Lazy.html#v:state
>
> instead. Still lost however.
> So, how do I create the "Sate" above?
You simply replace 'State' by 'state', a function provided to act like
the old State constructor. So you write
let stateIntString = state fromStoAandS
-Brent
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 40, Issue 47
*****************************************