[Haskell-beginners] point-free + IO Monad
Tony Morris
tmorris at tmorris.net
Sun Mar 31 11:59:25 CEST 2013
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" <ovidiudeac at gmail.com> wrote:
> That's good enough. Thanks!
>
>
> On Sun, Mar 31, 2013 at 11:08 AM, Franco <franco00 at 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 at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at 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.htm>
More information about the Beginners
mailing list