Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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: let , equations, and monads (PATRICK BROWNE)
2. Re: Partition a list recursively (Alexandre Delano?)
3. Re: let , equations, and monads (Chadda? Fouch?)
4. Re: Getting Started
(Sumit Sahrawat, Maths & Computing, IIT (BHU))
----------------------------------------------------------------------
Message: 1
Date: Tue, 3 Nov 2015 12:24:46 +0000
From: PATRICK BROWNE <[email protected]>
To: Chadda? Fouch? <[email protected]>
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] let , equations, and monads
Message-ID:
<cagflrke0efozalotwjhkv-b66vx4flm04tzbcdzvdmrsyck...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Chadda?,
Thank you very much for your response to my question. It confirms my
intuition, but I was not sure.
Is it true in general that let expressions (e.g. eligibleLet) are always
semantically equivalent to their equational counterparts (e.g.
eligibleEquational)? Would it be fair to say that "let" is syntactic sugar
for an equational equivalent? Or is there more to it?
With respect to the ordering of the operations is generally true that a
monadic version is semantically equivalent to a set of "let expressions"
in a nested if-then-else?
Thanks,
Pat
On 3 November 2015 at 06:56, Chadda? Fouch? <[email protected]>
wrote:
> Hello,
>
> Le mer. 28 oct. 2015 ? 15:59, PATRICK BROWNE <[email protected]> a
> ?crit :
>
>> {- From Learn Haskell Fast and Hard : 4.3.1. Maybe is a monad
>>
>> http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/#maybe-monad
>>
>> Concerning the code below I have the following questions:
>> 1) Are eligibleLet and eligibleEquational operationally equivalent (i.e.
>> perform the same operations) and/or semantically equivalent(i.e.
>> Church-Rosser)?
>>
>
> A priori, they're only semantically equivalent since in eligibleEquational
> intermediary computation are repeated whereas in eligibleLet they're only
> effectued once.
>
>
>> 2) Apart from the return type of Maybe instead of Bool how does
>> eligibleMonad differ from eligibleLet?
>>
>
> eligibleMonad is nice and readable while eligibleLet is a tiresome mess to
> write and maintain...
> Basically in eligibleMonad the logic that checks whether an operation is
> possible is rolled into the monadic operations themselves whereas in
> eligibleLet you have to check every operation validity yourself (so you can
> forget one or do it incorrectly).
>
> Note that with more familiarity with monads, you would probably rewrite
> eligibleMonad to avoid naming the intermediary account (and thus avoid any
> confusion between versions) :
>
> eligibleMonad account = depositM 100 account
> >>= withdrawM 200
> >>= depositM 100
> >>= withdrawM 300
> >>= depositM 1000
> >> Just True
>
> This would make it very easy to add or remove operations.
>
>
> --
> Jeda?
>
--
This email originated from DIT. If you received this email in error, please
delete it from your system. Please note that if you are not the named
addressee, disclosing, copying, distributing or taking any action based on
the contents of this email or attachments is prohibited. www.dit.ie
Is ? ITB?C a th?inig an r?omhphost seo. M? fuair t? an r?omhphost seo tr?
earr?id, scrios de do ch?ras ? le do thoil. Tabhair ar aird, mura t? an
seola? ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon ch?ipe?il, aon
d?ileadh n? ar aon ghn?omh a dh?anfar bunaithe ar an ?bhar at? sa
r?omhphost n? sna hiat?in seo. www.dit.ie
T? ITB?C ag aistri? go Gr?inseach Ghorm?in ? DIT is on the move to
Grangegorman <http://www.dit.ie/grangegorman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151103/8a523e1a/attachment-0001.html>
------------------------------
Message: 2
Date: Tue, 3 Nov 2015 14:29:07 +0100
From: Alexandre Delano? <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Partition a list recursively
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
2015/11/03 12:46, Francesco Ariis:
> On Tue, Nov 03, 2015 at 11:12:31AM +0100, Alexandre Delano? wrote:
> > Hello,
> > I am looking for such function:
> >
> > function :: Ord a => [a] -> [a] -> [[a]]
> > function [1,3,6] [0..6] == [[0,1],[2,3],[4,5,6]]
> >
> > Question: does it exist already ?
>
> ``Data.List.Split`` (from package ``split``) may have what you are
> looking for.
Thanks. I had a look on it but I did not find what I need (maybe I am
wrong). In fact, "span" was exactly the tool indeed (see below).
> >
> > Let:
> >
> > partIt :: Ord a => a -> [a] -> [[a]]
> > partIt m xs = [takeWhile (<= m) xs, dropWhile (<= m) xs]
> > example:
> > partIt 1 [0..5] == [[0,1],[2,3,4,5]]
> >
> > Question: How to define recursively partIt
> > 1) with a list as parameter ?
> > 2) recursively on the second part of the list ?
>
> With pattern matching:
>
> partIt :: Ord a => a -> [a] -> [[a]]
> partIt [] xs = xs
> partIt (m:ms) xs = let (a, b) = span (<= m) xs in (a : partIt ms b)
Thanks! Yes, exactly. With some minor corrections:
partIt :: Ord a => [a] -> [a] -> [[a]]
partIt [] xs = [xs]
partIt (m:ms) xs = let (a, b) = span (<= m) xs in (a : partIt ms b)
> ?> partIt [1,3,6] [0..6]
> [[0,1],[2,3],[4,5,6],[]] -- expected: splits on 6 too
ok
>
> Learn You a Haskell has nice section on pattern matching.
> Did this answer the question?
Yes, now it is time to practice and I discover (each time) how pattern
matching is powerful.
Thanks again,
--
Alexandre Delano?
------------------------------
Message: 3
Date: Tue, 03 Nov 2015 15:59:25 +0000
From: Chadda? Fouch? <[email protected]>
To: [email protected]
Cc: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] let , equations, and monads
Message-ID:
<CANfjZRZJ8eUD2hSCogKth+xujj=srlr7hurhgir-u-gre9a...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Le mar. 3 nov. 2015 ? 13:24, PATRICK BROWNE <[email protected]> a
?crit :
> Chadda?,
> Thank you very much for your response to my question. It confirms my
> intuition, but I was not sure.
>
> Is it true in general that let expressions (e.g. eligibleLet) are always
> semantically equivalent to their equational counterparts (e.g.
> eligibleEquational)?
>
Yes, in Haskell that is true because it is pure/referentially transparent
(absent case of misuse of the "escape hatch"es like unsafePerformIO). That
is one of the big advantage : that you're always able to reason
equationally. (note that this remains true with monads, they're not impure,
they're just a notation that can describe impure computations)
> Would it be fair to say that "let" is syntactic sugar for an equational
> equivalent? Or is there more to it?
>
"let x = stuff in expr" is syntactic sugar for "(\x -> expr) stuff"
basically. Though there's a few syntactical conveniences that complicate
the translation.
> With respect to the ordering of the operations is generally true that a
> monadic version is semantically equivalent to a set of "let expressions"
> in a nested if-then-else?
>
Well with the Maybe monad like here yes, though that's more of a nested
case-of. With IO this is more complicated, especially if you use forkIO
(concurrency).
>
> Thanks,
>
You're welcome !
--
Chadda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151103/2cc8ef17/attachment-0001.html>
------------------------------
Message: 4
Date: Tue, 3 Nov 2015 22:20:21 +0530
From: "Sumit Sahrawat, Maths & Computing, IIT (BHU)"
<[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Getting Started
Message-ID:
<cajbew8m1rmcu5-krhxkvpvu2unbycap6wlnt-2u5++mwh-f...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I remember hearing that Cabal has a lot of labeled easy-to-fix bugs:
https://github.com/haskell/cabal/issues?q=is%3Aopen+is%3Aissue+label%3Aeasy
On 2 November 2015 at 13:41, Magnus Therning <[email protected]> wrote:
> On Mon, Nov 02, 2015 at 01:33:18PM +0530, Abhishek Kumar wrote:
> > Thanks Magnus Therning
> >
> > I came across following libraries
> > http://hackage.haskell.org/package/graphs graphs and
> > http://hackage.haskell.org/package/bytestring-trie and few others.
>
> Oh, there are so many more on there :)
>
> > I am not sure whether these libraries are under active development and
> > I can find some beginner level bugs there to start with.Can someone
> > please suggest me some libraries having open beginner issues.
>
> That sort of thing you're only likely to find on the individual
> libraries' home pages. So you have to start following links from
> Hackage to their homes. I suspect only larger projects might maintain a
> list of beginner-friendly bugs. I do believe the compiler itself, ghc,
> tries to mark some bugs as easy-to-fix.
>
> /M
>
> --
> Magnus Therning OpenPGP: 0xAB4DFBA4
> email: [email protected] jabber: [email protected]
> twitter: magthe http://therning.org/magnus
>
> The cheapest, fastest and most reliable components of a computer system
> are those that aren't there.
> -- Gordon Bell
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151103/88907b5a/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 89, Issue 4
****************************************