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: Query regarding an unusually behaving code
(Theodore Lief Gannon)
2. Re: Query regarding an unusually behaving code
(Theodore Lief Gannon)
3. Re: which Applicative instance? (Graham Gill)
----------------------------------------------------------------------
Message: 1
Date: Sat, 14 Nov 2015 23:42:53 -0500
From: Theodore Lief Gannon <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Query regarding an unusually behaving
code
Message-ID:
<cajopsudkprs-9y1rlao_3nx83wvfsuxca1+a2v8cye-xwv5...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
GHCi doesn't quite support everything you could put in a source file. To do
what you want here, you need to use Haskell's alternative block syntax:
:{
let { digs 0 = [0]
; digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
}
:}
...yep, curly braces and semicolons just like C-family. :) It's intended
for machine-generated code, but works for this too. And in fact you
actually don't need multi-line, this is legal:
let { digs 0 = [0]; digs x = (digs (x `div` 10)) ++ [(x `rem` 10)] }
On Sat, Nov 14, 2015 at 9:35 PM, <[email protected]> wrote:
> In ghci you want to make a multi-line expression:
>
> :{
> let digs 0 =[0]
> digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
> :}
>
> (Note we don't put "let" on the second line)
>
> tom
>
>
> > El 13 nov 2015, a las 01:47, akash g <[email protected]> escribi?:
> >
> > let digs 0 =[0]
> > let digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151114/a21d9dfc/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 14 Nov 2015 23:45:26 -0500
From: Theodore Lief Gannon <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Query regarding an unusually behaving
code
Message-ID:
<CAJoPsuB14OcQsWZe1QsGWdv1ZQyacJv1R3gUd2dSZJ=9cxs...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Gah, got here late and missed that this was a response, not the problem
description. That's twice now I've put my foot in it. Stupid mailinglists,
with no edit buttons...
Well at least in both cases I've added SOMETHING useful. :)
On Sat, Nov 14, 2015 at 11:42 PM, Theodore Lief Gannon <[email protected]>
wrote:
> GHCi doesn't quite support everything you could put in a source file. To
> do what you want here, you need to use Haskell's alternative block syntax:
>
> :{
> let { digs 0 = [0]
> ; digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
> }
> :}
>
> ...yep, curly braces and semicolons just like C-family. :) It's intended
> for machine-generated code, but works for this too. And in fact you
> actually don't need multi-line, this is legal:
>
> let { digs 0 = [0]; digs x = (digs (x `div` 10)) ++ [(x `rem` 10)] }
>
>
> On Sat, Nov 14, 2015 at 9:35 PM, <[email protected]> wrote:
>
>> In ghci you want to make a multi-line expression:
>>
>> :{
>> let digs 0 =[0]
>> digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
>> :}
>>
>> (Note we don't put "let" on the second line)
>>
>> tom
>>
>>
>> > El 13 nov 2015, a las 01:47, akash g <[email protected]> escribi?:
>> >
>> > let digs 0 =[0]
>> > let digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151114/d2ebd876/attachment-0001.html>
------------------------------
Message: 3
Date: Sun, 15 Nov 2015 00:35:17 -0500
From: Graham Gill <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] which Applicative instance?
Message-ID: <[email protected]>
Content-Type: text/plain; charset="windows-1252"; Format="flowed"
On 11/14/2015 9:58 PM, Kim-Ee Yeoh wrote:
[...]
> Yes it is. The default instance is IO. It's a common gotcha, see
>
> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-evaluation.html#actions-at-prompt
>
> <https://downloads.haskell.org/%7Eghc/latest/docs/html/users_guide/interactive-evaluation.html#actions-at-prompt>
>
> and the example of how "return True" defaults to IO Bool.
Thanks Kim-Ee, that makes it clear.
> Might I compliment you on this:
>
> sequenceA' :: Applicative f => [f a] -> f [a]
> sequenceA' = foldr (\fa fla -> (:) <$> fa <*> fla) (pure [])
>
> There are strong arguments that this is the best way of writing sequenceA.
>
> -- Kim-Ee
Thanks, but it just seemed the most straightforward thing to do at my
present level of understanding.
Are there substantially different ways to define sequenceA? I'm
interested to read the arguments if you can give a pointer to a post
somewhere.
Graham
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151115/28f74461/attachment-0001.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 27
*****************************************