Send Beginners mailing list submissions to
        beginners@haskell.org

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
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  point-free + IO Monad (Ovidiu D)
   2. Re:  point-free + IO Monad (Franco)
   3. Re:  point-free + IO Monad (Ovidiu D)
   4. Re:  point-free + IO Monad (Tony Morris)


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

Message: 1
Date: Sun, 31 Mar 2013 09:55:24 +0300
From: Ovidiu D <ovidiud...@gmail.com>
Subject: [Haskell-beginners] point-free + IO Monad
To: beginners@haskell.org
Message-ID:
        <cakvse7t0+tv_f1dkpnbto1w3i_v83-r5yi-icrgp6+j2jpo...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I have the following code:

f1 :: String -> String

f2 :: IO String -> IO ()
f2 a = do
   b <- a
   putStr $ f1 b

How can I write the function f2 in a point-free style?

I have tried this:
f2 = return.f1 >>=  putStr

...but it doesn't work.


Thanks!



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

Message: 2
Date: Sun, 31 Mar 2013 08:08:30 +0000 (UTC)
From: Franco <franc...@gmx.com>
Subject: Re: [Haskell-beginners] point-free + IO Monad
To: beginners@haskell.org
Message-ID: <loom.20130331t100051-...@post.gmane.org>
Content-Type: text/plain; charset=us-ascii

Ovidiu D <ovidiudeac <at> gmail.com> writes:

> 
> I have the following code:
> 
> f1 :: String -> String
> 
> f2 :: IO String -> IO ()
> f2 a = do
>    b <- a
>    putStr $ f1 b
> 
> How can I write the function f2 in a point-free style?
> 

maybe 

f2 = (=<<) (putStrLn . f1)

I still prefer the non point-free but clearer

f2 = a >>= (putStrLn . f1)





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

Message: 3
Date: Sun, 31 Mar 2013 12:27:49 +0300
From: Ovidiu D <ovidiud...@gmail.com>
Subject: Re: [Haskell-beginners] point-free + IO Monad
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <cakvse7v1f9asc0ev+5uabocq_kwev9kccyxgnersouvajz+...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

That's good enough. Thanks!


On Sun, Mar 31, 2013 at 11:08 AM, Franco <franc...@gmx.com> wrote:

> Ovidiu D <ovidiudeac <at> gmail.com> writes:
>
> >
> > I have the following code:
> >
> > f1 :: String -> String
> >
> > f2 :: IO String -> IO ()
> > f2 a = do
> >    b <- a
> >    putStr $ f1 b
> >
> > How can I write the function f2 in a point-free style?
> >
>
> maybe
>
> f2 = (=<<) (putStrLn . f1)
>
> I still prefer the non point-free but clearer
>
> f2 = a >>= (putStrLn . f1)
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130331/04de00ec/attachment-0001.htm>

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

Message: 4
Date: Sun, 31 Mar 2013 19:59:25 +1000
From: Tony Morris <tmor...@tmorris.net>
Subject: Re: [Haskell-beginners] point-free + IO Monad
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Message-ID:
        <cajf6usiwlxh1c-mej-z+g+9qk5acxlpf8twudxow20j5y_o...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

You can drop the parens if you like.

f2 a = putStrLn . f1 =<< a -- my preference

f2 a = a >>= putStrLn . f1
 On 31/03/2013 7:29 PM, "Ovidiu D" <ovidiud...@gmail.com> wrote:

> That's good enough. Thanks!
>
>
> On Sun, Mar 31, 2013 at 11:08 AM, Franco <franc...@gmx.com> wrote:
>
>> Ovidiu D <ovidiudeac <at> gmail.com> writes:
>>
>> >
>> > I have the following code:
>> >
>> > f1 :: String -> String
>> >
>> > f2 :: IO String -> IO ()
>> > f2 a = do
>> >    b <- a
>> >    putStr $ f1 b
>> >
>> > How can I write the function f2 in a point-free style?
>> >
>>
>> maybe
>>
>> f2 = (=<<) (putStrLn . f1)
>>
>> I still prefer the non point-free but clearer
>>
>> f2 = a >>= (putStrLn . f1)
>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> Beginners@haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20130331/a15237f4/attachment-0001.htm>

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

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 57, Issue 43
*****************************************

Reply via email to