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: Multiple versions (Mark Bestley)
2. Re: More direct binding of IO result (Daniel Fischer)
3. Re: Printing the entries of a Data.Map m (Daniel Fischer)
4. Re: More direct binding of IO result (aditya siram)
5. Re: More direct binding of IO result (Michael Snoyman)
6. Re: More direct binding of IO result (aditya siram)
----------------------------------------------------------------------
Message: 1
Date: Sun, 15 May 2011 11:11:25 +0100
From: news{@bestley.co.uk (Mark Bestley)
Subject: Re: [Haskell-beginners] Multiple versions
To: [email protected]
Message-ID: <1k1b2wg.104j61y15pip34N%news{@bestley.co.uk>
Tom Murphy <[email protected]> wrote:
> My god! Another ghci!
>
> Thanks for helping me find that.
>
> Re-running the Haskell Platform installer ends with an "Installation
> Failed," and I know enough to not start swapping out binaries in
> /opt/local/bin, so is there a best-practices way to fix this?
>
If the other is in /opt/local/bin then this is probably from Macports
and so you need to remove it.
I had this issue and had to unintsll haskell and its varias ports
so
port uninstall x
where x was haskell-platform, hs-platform-cabal ,
hs-platform-haskell-src and anyother hs*
If you dion't use macports for anything then see
<http://guide.macports.org/#installing.macports.uninstalling>
--
Mark
------------------------------
Message: 2
Date: Sun, 15 May 2011 12:37:56 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] More direct binding of IO result
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="utf-8"
On Sunday 15 May 2011 08:29:10, Michael Snoyman wrote:
> On Sun, May 15, 2011 at 9:27 AM, Christopher Howard <
>
> [email protected]> wrote:
> > I understand that one can bind the unwrapped results of IO functions
> > to variables, and pass them to functions, like so:
> >
> > main = do filecontents <- readFile "data.txt"
> >
> > putStrLn filecontents
> >
> > But does the syntax allow you to cut out the middle man, so to speak,
> > and bind the results directly to the parameter? Like
> >
> > -- Tried this and it didn't work.
> > main = do putStrLn (<- readFile "data.txt")
> >
> > do-notation is just syntactic sugar for the ">>" and ">>=" operators.
> > Your
>
> example gets translated internally to:
>
> readFile "data.txt" >>= \filecontents -> putStrLn filecontents
>
> To get rid of that extra "filecontents", you could instead write:
>
> readFile "data.txt" >>= putStrLn
Or, if you prefer to read your data-flow right-to-left:
putStrLn =<< readFile "data.txt"
------------------------------
Message: 3
Date: Sun, 15 May 2011 12:52:13 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] Printing the entries of a Data.Map m
To: [email protected]
Cc: Manfred Lotz <[email protected]>
Message-ID: <[email protected]>
Content-Type: Text/Plain; charset="iso-8859-1"
On Sunday 15 May 2011 09:32:32, Manfred Lotz wrote:
> Hi all,
> I have a map with some two thousand entries. Now I want to print that
> map.
>
>
> I could do:
> print m
>
>
> but I like to use my own print function:
> mapM_ myprint (Map.toList m)
>
>
> I may be wrong but having to use Map.toList looks pretty inefficient.
It's pretty efficient. I'm not sure that the compiler can completely fuse
away the intermediate list, but such allocations are cheap.
The list is consumed as it's generated, the consumed cells are collected in
the next gc - the space and time overhead should be negligible.
>
> Question: I'd like to know if there is a more efficient way to do it?
------------------------------
Message: 4
Date: Sun, 15 May 2011 06:56:13 -0500
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] More direct binding of IO result
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
You can also try the applicative way:
(<$>) :: (a -> b) -> f a -> f b
import Control.Applicative
-- Think of the <$> as a monadic version of $
main = putStrLn <$> readFile "contents.txt"
Or if you want to chain the functions and not worry about the "contents.txt"
argument:
import Control.Monad
main= (readFile >=> putStrLn) "contents.txt"
-deech
On Sun, May 15, 2011 at 1:27 AM, Christopher Howard <
[email protected]> wrote:
> I understand that one can bind the unwrapped results of IO functions to
> variables, and pass them to functions, like so:
>
> main = do filecontents <- readFile "data.txt"
> putStrLn filecontents
>
> But does the syntax allow you to cut out the middle man, so to speak,
> and bind the results directly to the parameter? Like
>
> -- Tried this and it didn't work.
> main = do putStrLn (<- readFile "data.txt")
>
> --
> frigidcode.com
> theologia.indicium.us
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110515/9ca2adc8/attachment-0001.htm>
------------------------------
Message: 5
Date: Sun, 15 May 2011 14:58:55 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] More direct binding of IO result
To: aditya siram <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
On Sun, May 15, 2011 at 2:56 PM, aditya siram <[email protected]>wrote:
> You can also try the applicative way:
> (<$>) :: (a -> b) -> f a -> f b
>
> import Control.Applicative
> -- Think of the <$> as a monadic version of $
> main = putStrLn <$> readFile "contents.txt"
>
> Actually, <$> is just a synonym for fmap, so this will have the same
problems as the fmap approach.
Michael
> Or if you want to chain the functions and not worry about the
> "contents.txt" argument:
>
> import Control.Monad
> main= (readFile >=> putStrLn) "contents.txt"
>
> -deech
>
> On Sun, May 15, 2011 at 1:27 AM, Christopher Howard <
> [email protected]> wrote:
>
>> I understand that one can bind the unwrapped results of IO functions to
>> variables, and pass them to functions, like so:
>>
>> main = do filecontents <- readFile "data.txt"
>> putStrLn filecontents
>>
>> But does the syntax allow you to cut out the middle man, so to speak,
>> and bind the results directly to the parameter? Like
>>
>> -- Tried this and it didn't work.
>> main = do putStrLn (<- readFile "data.txt")
>>
>> --
>> frigidcode.com
>> theologia.indicium.us
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110515/d0919738/attachment-0001.htm>
------------------------------
Message: 6
Date: Sun, 15 May 2011 07:00:48 -0500
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] More direct binding of IO result
To: Michael Snoyman <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Crap! You're right, should've tried it out. Sorry Christopher! The second
approach does work though.
-deech
On Sun, May 15, 2011 at 6:58 AM, Michael Snoyman <[email protected]>wrote:
>
>
> On Sun, May 15, 2011 at 2:56 PM, aditya siram <[email protected]>wrote:
>
>> You can also try the applicative way:
>> (<$>) :: (a -> b) -> f a -> f b
>>
>> import Control.Applicative
>> -- Think of the <$> as a monadic version of $
>> main = putStrLn <$> readFile "contents.txt"
>>
>> Actually, <$> is just a synonym for fmap, so this will have the same
> problems as the fmap approach.
>
> Michael
>
>
>> Or if you want to chain the functions and not worry about the
>> "contents.txt" argument:
>>
>> import Control.Monad
>> main= (readFile >=> putStrLn) "contents.txt"
>>
>> -deech
>>
>> On Sun, May 15, 2011 at 1:27 AM, Christopher Howard <
>> [email protected]> wrote:
>>
>>> I understand that one can bind the unwrapped results of IO functions to
>>> variables, and pass them to functions, like so:
>>>
>>> main = do filecontents <- readFile "data.txt"
>>> putStrLn filecontents
>>>
>>> But does the syntax allow you to cut out the middle man, so to speak,
>>> and bind the results directly to the parameter? Like
>>>
>>> -- Tried this and it didn't work.
>>> main = do putStrLn (<- readFile "data.txt")
>>>
>>> --
>>> frigidcode.com
>>> theologia.indicium.us
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110515/a5d6d6fa/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 35, Issue 30
*****************************************