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:  stream of monadic calculations (Patrick Redmond)
   2. Re:  stream of monadic calculations (Brent Yorgey)
   3.  ACID-state - how does it evaluate data (Konrad Szyc)


----------------------------------------------------------------------

Message: 1
Date: Wed, 3 Oct 2012 19:21:45 -0400
From: Patrick Redmond <[email protected]>
Subject: Re: [Haskell-beginners] stream of monadic calculations
Cc: [email protected]
Message-ID:
        <CAHUea4Ejrzra0isLBC=1Zsw=oks6z+mw937nq0ybevdqojs...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8

Wouldn't the applicative style be applicable here? I just read the
chapter in LYAH on it, and I feel like it could be used somehow..?


On Tue, Oct 2, 2012 at 3:14 PM, Nick Vanderweit
<[email protected]> wrote:
> Let's look at the analogous case:
>
> let a'  = f a
>       a'' = g a'
>      a''' = h a''
>   in <something to do with a'''>
>
> Here, the way we would shorten "apply f, then apply g, then apply h" is using
> the function composition operator, (.), whose type signature is:
>
> (.) :: (b -> c) -> (a -> b) -> a -> c
>
> So instead of the above, we could say:
> let a''' = h . g . f $ a
>
> Similarly, you have some functions:
> f :: a -> m b
> g :: b -> m c
>
> for some monad m. And what you'd like to do is, in some sense, to compose
> these, to get:
>
> g . f :: a -> m c
>
> But you can't exactly do that with the Prelude composition operator; the types
> are wrong. Fortunately, smart people have already thought about how to
> generally compose function-like things. The way you do this in a 
> monad-specific
> way is to use the (<=<) operator from Control.Monad, whose signature is:
>
> (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
>
> And so that's really what you want: h <=< g <=< f $ a.
>
> More generally, this whole idea of composing things that are similar to
> functions is encapsulated by the notion of a category, and this can be viewed
> as a specific case of using the composition operator from Control.Category. In
> this case, the function-like things (called "arrows" or "morphisms") being
> composed are the so-called Kleisli arrows, which are really the functions
> you're manipulating here, f :: a -> m b.
>
>
>
> Nick
>
>
> On Tuesday, October 02, 2012 10:12:44 AM Christopher Howard wrote:
>> Say I've got a stream of monadic calculations, like so:
>>
>> code:
>> --------
>> do a' <- f a
>>    a'' <- g a'
>>    a''' <- h a''
>>    return a'''
>> --------
>>
>> There is a cleaner way to do that, yes? (Without using all the tick marks?)
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners



------------------------------

Message: 2
Date: Thu, 4 Oct 2012 02:32:35 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] stream of monadic calculations
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii

No, Applicative does not apply (haha).  

  do a' <- f a
     a'' <- g a'
     a''' <- h a''
     return a'''

What's going on here is that the result of each computation is used to
determine the next computation to run.  For example, the result of (f
a) is a', and the next computation is (g a') -- i.e. we use the
function g to compute an action based on a'.  This is precisely the
thing that Applicative *cannot* do, which Monad can (have the
structure of the computation depend on intermediate results).

-Brent

On Wed, Oct 03, 2012 at 07:21:45PM -0400, Patrick Redmond wrote:
> Wouldn't the applicative style be applicable here? I just read the
> chapter in LYAH on it, and I feel like it could be used somehow..?
> 
> 
> On Tue, Oct 2, 2012 at 3:14 PM, Nick Vanderweit
> <[email protected]> wrote:
> > Let's look at the analogous case:
> >
> > let a'  = f a
> >       a'' = g a'
> >      a''' = h a''
> >   in <something to do with a'''>
> >
> > Here, the way we would shorten "apply f, then apply g, then apply h" is 
> > using
> > the function composition operator, (.), whose type signature is:
> >
> > (.) :: (b -> c) -> (a -> b) -> a -> c
> >
> > So instead of the above, we could say:
> > let a''' = h . g . f $ a
> >
> > Similarly, you have some functions:
> > f :: a -> m b
> > g :: b -> m c
> >
> > for some monad m. And what you'd like to do is, in some sense, to compose
> > these, to get:
> >
> > g . f :: a -> m c
> >
> > But you can't exactly do that with the Prelude composition operator; the 
> > types
> > are wrong. Fortunately, smart people have already thought about how to
> > generally compose function-like things. The way you do this in a 
> > monad-specific
> > way is to use the (<=<) operator from Control.Monad, whose signature is:
> >
> > (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
> >
> > And so that's really what you want: h <=< g <=< f $ a.
> >
> > More generally, this whole idea of composing things that are similar to
> > functions is encapsulated by the notion of a category, and this can be 
> > viewed
> > as a specific case of using the composition operator from Control.Category. 
> > In
> > this case, the function-like things (called "arrows" or "morphisms") being
> > composed are the so-called Kleisli arrows, which are really the functions
> > you're manipulating here, f :: a -> m b.
> >
> >
> >
> > Nick
> >
> >
> > On Tuesday, October 02, 2012 10:12:44 AM Christopher Howard wrote:
> >> Say I've got a stream of monadic calculations, like so:
> >>
> >> code:
> >> --------
> >> do a' <- f a
> >>    a'' <- g a'
> >>    a''' <- h a''
> >>    return a'''
> >> --------
> >>
> >> There is a cleaner way to do that, yes? (Without using all the tick marks?)
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> 
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners



------------------------------

Message: 3
Date: Thu, 4 Oct 2012 10:06:03 +0200
From: Konrad Szyc <[email protected]>
Subject: [Haskell-beginners] ACID-state - how does it evaluate data
To: [email protected]
Message-ID:
        <cahwhtdo54pgaguyc2b7c5jo4b5y39rwb7feqe3kropmbfhj...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Dear Haskell-Beginners

I have a problem understanding how ACID-state stores its data. To be
more specific, I would like to know how does it deal with lazy
evaluation. I suppose it tries to "strictly" evaluate functions before
serializing, but then how does it handle infinitely-recursive
structures?

Regards,
kombat



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 52, Issue 5
****************************************

Reply via email to