[Haskell-cafe] |> vs. $ (was: request for code review)

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Mar 8 03:16:38 EST 2006

Hello Shannon,

Tuesday, March 7, 2006, 10:52:01 PM, you wrote:

SjB> The function itself is a ParseContextTransformation.  It takes a
SjB> context, transforms it, and returns it.  Most of the pipelines in the
SjB> whole application are ParseContextTransformations, and the |> (or $ or
SjB> .) are ways of tying them together.  My questions concerning Monads
SjB> are in this example are:

SjB> 1. Monads apply a strategy to computation.  For instance, the list
SjB> monad applies the strategy, "Try it with each of my members."  What
SjB> part of my code is the strategy?

SjB> 2. Monads are containers that wrap a value.  For instance, the Maybe

1&2 is only possible variations, but they don't covers everything. in
GENERAL, monad is the way to write code as high-order functions that
then will be used in some special way. this allows to hide part of
computation details in the rules of this internal processing

what you need here, imho, is a state monad. your context will become a
state and monad should contain operations to read/write this state. to
be exact, you should use State monad here, which already contains
appropriate operations

in the State monad, each action has type:

type State a  =  StateType -> (a, StateType)

i.e. each action is higher order function which transforms state
(having type StateType) and in addition can return value of type 'a'

are you read http://www.nomaware.com/monads/monad_tutorial.zip ?

it's comprehensive tutorial about monads

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list