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. literate programming (Francisco Gutierrez)
----------------------------------------------------------------------
Message: 1
Date: Mon, 16 Apr 2012 13:45:46 -0700 (PDT)
From: Francisco Gutierrez <[email protected]>
Subject: [Haskell-beginners] literate programming
To: "[email protected]" <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Dear friends:
I am an ULTRA-ULTRA Haskell?beginner, just started literally yesterday.
?
I am just toying around with Cordelia Hall and John O'Donnell excellent book on
dicrete mathematics with Haskell. Well, they have a program, stdm,
to accompany the book. It happens that it is in literate style. In theory, this
should be very easy to work with, but after saving it with lhs extension, I try
to load it, without success. Could somebody out there help me with this?
Best regards,
Francisco Guti?rrez
From: "[email protected]" <[email protected]>
To: [email protected]
Sent: Monday, April 16, 2012 2:45 PM
Subject: Beginners Digest, Vol 46, Issue 23
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:? splitAt implementation (using foldr) and infinite lists
? ? ? (Lorenzo Bolla)
? 2. Re:? splitAt implementation (using foldr) and infinite lists
? ? ? (Ozgur Akgun)
? 3. Re:? Design of Webmachine in Haskell (Petar Radosevic)
? 4. Re:? Design of Webmachine in Haskell (Michael Snoyman)
? 5. Re:? splitAt implementation (using foldr) and infinite lists
? ? ? (Dmitriy Matrosov)
? 6.? Training tasks (Nikita Beloglazov)
? 7.? Cross-platform .hs files on Linux and Windows (Vinay Sajip)
? 8. Re:? Cross-platform .hs files on Linux and??? Windows (Lorenzo Bolla)
----------------------------------------------------------------------
Message: 1
Date: Mon, 16 Apr 2012 15:21:55 +0100
From: Lorenzo Bolla <[email protected]>
Subject: Re: [Haskell-beginners] splitAt implementation (using foldr)
??? and infinite lists
Cc: [email protected]
Message-ID: <20120416142155.GC30186@dell>
Content-Type: text/plain; charset=us-ascii
On Mon, Apr 16, 2012 at 12:52:02PM +0400, Dmitriy Matrosov wrote:
> Hi all.
>
> If i implement take using foldr
>
> take'? ? ? :: Int -> [a] -> [a]
> take' n? ? =? foldr (\x z -> if fst x <= n then snd x : z else []) []
>? ? ? ? ? ? ? ? . zip [1..]
>
> it'll work fine with infinite lists. But if i implement splitAt similarly
>
> splitAt'? ? :: Int -> [a] -> ([a], [a])
> splitAt' n? = foldr (\x (z1, z2) -> if fst x <= n then? (snd x : z1, z2)
>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? else? ? ? ? ? ? ? ([], snd x : z2))
>? ? ? ? ? ? ? ? ? ? ([], [])
>? ? ? ? ? ? ? ? ? ? . zip [1..]
>
> and call it like this
>
> *Main> fst $ splitAt' 4 [1..]
> ^CInterrupted.
Try something like this:
splitAt' n? = foldr (\x zs? -> if fst x <= n then? (snd x : fst zs, snd zs)
else? ? ? ? ? ? ? ([], snd x : snd zs)) ([], []) . zip [1..]
I'm no Haskell expert, but I suspect that when pattern-matching z2, it
tries to evaluate it and it hangs...
My version does not hang...
hth,
L.
--
Lorenzo Bolla
http://lbolla.info
------------------------------
Message: 2
Date: Mon, 16 Apr 2012 15:55:20 +0100
From: Ozgur Akgun <[email protected]>
Subject: Re: [Haskell-beginners] splitAt implementation (using foldr)
??? and infinite lists
To: Lorenzo Bolla <[email protected]>
Cc: [email protected]
Message-ID:
??? <calzazpas7x+jxd5nu4+e+hiyceqhbmwj7qj+bec0uczips6...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
You can also use lazy pattern matching.
http://en.wikibooks.org/wiki/Haskell/Laziness#Lazy_pattern_matching
On 16 April 2012 15:21, Lorenzo Bolla <[email protected]> wrote:
> > splitAt'? ? :: Int -> [a] -> ([a], [a])
> > splitAt' n? = foldr (\x ~(z1, z2) -> if fst x <= n then? (snd x : z1,
> z2)
> >? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? else? ? ? ? ? ? ? ([], snd x : z2))
> >? ? ? ? ? ? ? ? ? ? ([], [])
> >? ? ? ? ? ? ? ? ? ? . zip [1..]
>
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120416/528b7ede/attachment-0001.htm>
------------------------------
Message: 3
Date: Mon, 16 Apr 2012 17:05:23 +0200
From: Petar Radosevic <[email protected]>
Subject: Re: [Haskell-beginners] Design of Webmachine in Haskell
To: Michael Snoyman <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain
Hi Michael,
Michael Snoyman <[email protected]> writes:
> When I was at QCon, I heard a talk from Steve Vinoski on Webmachine,
> and I was surprised to hear how close webmachine was to Haskell
> already, The concept is basically sticking a state monad on top of
> WAI. My guess is you would want to use a record type for a Resource,
> not a typeclass, to make it easier to swap out behaviors. But
> honestly, I haven't given this any thought since I saw the
> presentation 6 months ago.
Thanks for your insight, I didn't even consider using record types for a
resource. Will also read up upon state monads. I believe that Webmachine
passes a dictionary to every function in the HTTP graph[1]. Do you see
the state monad having this purpose?
[1]: https://bitbucket.org/justin/webmachine/wiki/BigHTTPGraph
--
Petar Radosevic | @wunki
------------------------------
Message: 4
Date: Mon, 16 Apr 2012 18:36:11 +0300
From: Michael Snoyman <[email protected]>
Subject: Re: [Haskell-beginners] Design of Webmachine in Haskell
To: Petar Radosevic <[email protected]>
Cc: [email protected]
Message-ID:
??? <caka2jgluq1+zmsuwk-fmypafhg1rvpauxlud_2fsq8yzonq...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Apr 16, 2012 at 6:05 PM, Petar Radosevic <[email protected]> wrote:
> Hi Michael,
>
> Michael Snoyman <[email protected]> writes:
>
>> When I was at QCon, I heard a talk from Steve Vinoski on Webmachine,
>> and I was surprised to hear how close webmachine was to Haskell
>> already, The concept is basically sticking a state monad on top of
>> WAI. My guess is you would want to use a record type for a Resource,
>> not a typeclass, to make it easier to swap out behaviors. But
>> honestly, I haven't given this any thought since I saw the
>> presentation 6 months ago.
>
> Thanks for your insight, I didn't even consider using record types for a
> resource. Will also read up upon state monads. I believe that Webmachine
> passes a dictionary to every function in the HTTP graph[1]. Do you see
> the state monad having this purpose?
>
> [1]: https://bitbucket.org/justin/webmachine/wiki/BigHTTPGraph
> --
> Petar Radosevic | @wunki
IIRC, each function is passed a dictionary and returns a new
dictionary. That's the very essence of a state monad, which is why it
could be such a perfect fit here. Of course, I may *not* be
remembering correctly.
Michael
------------------------------
Message: 5
Date: Mon, 16 Apr 2012 20:12:54 +0400
From: Dmitriy Matrosov <[email protected]>
Subject: Re: [Haskell-beginners] splitAt implementation (using foldr)
??? and infinite lists
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"; Format="flowed"
On 04/16/12 18:21, Lorenzo Bolla wrote:
> Try something like this:
> splitAt' n? = foldr (\x zs? ->? if fst x<= n then? (snd x : fst zs, snd zs)
> else? ? ? ? ? ? ? ([], snd x : snd zs)) ([], []) . zip [1..]
>
> I'm no Haskell expert, but I suspect that when pattern-matching z2, it
> tries to evaluate it and it hangs...
>
> My version does not hang...
>
> hth,
> L.
>
Thanks, Lorenzo! It works now.
On 04/16/12 18:55, Ozgur Akgun wrote:
> You can also use lazy pattern matching.
>
> http://en.wikibooks.org/wiki/Haskell/Laziness#Lazy_pattern_matching
>
> On 16 April 2012 15:21, Lorenzo Bolla <[email protected]
> <mailto:[email protected]>> wrote:
>
>? ? > splitAt'? ? :: Int -> [a] -> ([a], [a])
>? ? > splitAt' n? = foldr (\x ~(z1, z2) -> if fst x <= n then? (snd x
>? ? : z1, z2)
>? ? >? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? else? ? ? ? ? ? ? ([], snd
>? ? x : z2))
>? ? >? ? ? ? ? ? ? ? ? ? ([], [])
>? ? >? ? ? ? ? ? ? ? ? ? . zip [1..]
>
>
> Ozgur
Thanks, Ozgur!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120416/ac7270c5/attachment-0001.htm>
------------------------------
Message: 6
Date: Mon, 16 Apr 2012 19:46:04 +0300
From: Nikita Beloglazov <[email protected]>
Subject: [Haskell-beginners] Training tasks
To: [email protected]
Message-ID:
??? <cajdg_ptsc07n5vuwrjacknnhvf34j5gqj9vka6xxuhh0rm5...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi.
I'm building website where people can try and "taste" new languages by
solving small or mediums size tasks. Tasks are language specific and should
show best features of the language. Website is not meant to teach new
language but to give idea what is this language good for.
Now I want to add Haskell. I need about 7-10 tasks for now. First three of
four tasks are introductory, they should show/check basics of haskell. E.g.
given n, return sum of squares of first n even numbers. Other tasks are
more complicated and show advantages of functional programming in general
or some specific haskell features.
I don't have any experience with haskell and I need you help. Could you
help me with ideas for tasks?
Thank you,
Nikita Beloglazov
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120416/17509069/attachment-0001.htm>
------------------------------
Message: 7
Date: Mon, 16 Apr 2012 18:23:57 +0000 (UTC)
From: Vinay Sajip <[email protected]>
Subject: [Haskell-beginners] Cross-platform .hs files on Linux and
??? Windows
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
I've been given a set of .hs files which contain the shebang line
#!/usr/bin/env runhaskell
and I would like them to work on Windows, but none of the Windows binaries seem
to be able to process them without a
<script.hs>:1:1: parse error on input `#!'
These files came from a Linux machine, where they run without trouble. Is there
any way I can get the Windows executables to run these files? I asked on IRC and
it was suggested that I change the files to literate Haskell, but I'd rather
have some way of having cross-platform operation which does not involve making
changes to the scripts themselves. Is there something that can be done e.g. by
using particular command line options or configuration settings?
Thanks & regards,
Vinay Sajip
------------------------------
Message: 8
Date: Mon, 16 Apr 2012 20:49:02 +0100
From: Lorenzo Bolla <[email protected]>
Subject: Re: [Haskell-beginners] Cross-platform .hs files on Linux and
??? Windows
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
Check this out:
http://stackoverflow.com/questions/6818031/use-shebang-hashbang-in-windows-command-prompt
hth,
L.
On Mon, Apr 16, 2012 at 06:23:57PM +0000, Vinay Sajip wrote:
> I've been given a set of .hs files which contain the shebang line
>
> #!/usr/bin/env runhaskell
>
> and I would like them to work on Windows, but none of the Windows binaries
> seem
> to be able to process them without a
>
> <script.hs>:1:1: parse error on input `#!'
>
> These files came from a Linux machine, where they run without trouble. Is
> there
> any way I can get the Windows executables to run these files? I asked on IRC
> and
> it was suggested that I change the files to literate Haskell, but I'd rather
> have some way of having cross-platform operation which does not involve making
> changes to the scripts themselves. Is there something that can be done e.g. by
> using particular command line options or configuration settings?
>
> Thanks & regards,
>
> Vinay Sajip
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
--
Lorenzo Bolla
http://lbolla.info
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120416/ec2325bf/attachment.pgp>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 46, Issue 23
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120416/17a667cb/attachment.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 46, Issue 24
*****************************************