On Tuesday 03 July 2007 09:51, Arie Peterson wrote:
No, there is a 'State s' monad provided (for arbitrary state type 's'),
which implements the 'get' and 'put' methods. In other words, 'State s' is
an instance of the 'MonadState s' class. This terminology can be really
confusing at first.
Alexis Hazell wrote:
| This may be a stupid question, but i don't understand how (indeed, if) one
| can
| maintain multiple states using the State monad, since 'get' etc. don't
| seem
| to require that one specify which particular copy of a State monad one
| wishes
| to 'get' from, 'put' to etc.?
On Thu, Jul 05, 2007 at 12:58:06AM +1000, Alexis Hazell wrote:
On Tuesday 03 July 2007 09:51, Arie Peterson wrote:
No, there is a 'State s' monad provided (for arbitrary state type 's'),
which implements the 'get' and 'put' methods. In other words, 'State s' is
an instance of the
As a programming exercise I'm trying to use the State monad to create a simple
parser. It's for a very simple assembly language for a simple virtual machine.
The state is a string of instructions. I want to be able to call something
like getNextInstruction to pull out the next instruction
Gregory Propf wrote:
As a programming exercise I'm trying to use the State monad to create a
simple parser. It's for a very simple assembly language for a simple
virtual machine. The state is a string of instructions. I want to be
able to call something like getNextInstruction to pull out
vim: set ft=lhaskell:
On Mon, Jul 02, 2007 at 02:25:57PM -0700, Gregory Propf wrote:
| As a programming exercise I'm trying to use the State monad to create
| a simple parser. It's for a very simple assembly language for a
| simple virtual machine. The state is a string of instructions. I
|
of the examples
seem to just use functions that manipulate a state but do not create a new
datatype.
- Original Message
From: Arie Peterson [EMAIL PROTECTED]
To: haskell-cafe@haskell.org
Sent: Monday, July 2, 2007 2:46:14 PM
Subject: Re: [Haskell-cafe] Very simple parser
Did you look
Graham Hutton has some great tutorials on parsing. Check out the Are
parsers monodic? thread (not exact name) for a good reference.
There's also a good tutorial at http://www.cs.nott.ac.uk/~gmh/book.html In
Section Slides, click on 8 Functional parsers, but you may just want to
start from 1.
Gregory Propf wrote:
| [...] For example, am I to assume that I need to
| create my own instance of State and then define get and put for it?
No, there is a 'State s' monad provided (for arbitrary state type 's'),
which implements the 'get' and 'put' methods. In other words, 'State s' is
an
Message
From: Arie Peterson [EMAIL PROTECTED]
To: haskell-cafe@haskell.org
Sent: Monday, July 2, 2007 4:51:59 PM
Subject: Re: [Haskell-cafe] Very simple parser
To get you going, start with the example from the documentation, modified
slightly:
tick :: State Int String
tick = do
n - get
On 7/2/07, Gregory Propf [EMAIL PROTECTED] wrote:
This was a bit baffling too. It appears that there's an implied argument to
runTick. This also works and makes it more explicit. I suppose the compiler
just works out that the only place to put the 'n' is after tick.
runTick :: Int -
Chevalier [EMAIL PROTECTED]
To: Gregory Propf [EMAIL PROTECTED]
Cc: haskell-cafe@haskell.org
Sent: Monday, July 2, 2007 5:37:41 PM
Subject: Re: [Haskell-cafe] Very simple parser
On 7/2/07, Gregory Propf [EMAIL PROTECTED] wrote:
This was a bit baffling too. It appears that there's an implied
12 matches
Mail list logo