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: lambda notation vs function-argument notation in GHCi
(Ozgur Akgun)
2. Re: lambda notation vs function-argument notation in GHCi
(Morel Pisum)
3. how monomorphism restriction effects eta reduction (Song Zhang)
4. Re: problem with type (miro)
----------------------------------------------------------------------
Message: 1
Date: Sun, 17 Jun 2012 11:28:26 +0100
From: Ozgur Akgun <[email protected]>
Subject: Re: [Haskell-beginners] lambda notation vs function-argument
notation in GHCi
To: Morel Pisum <[email protected]>
Cc: [email protected]
Message-ID:
<CALzazPB6uvufwkU4192-=dLOZDBRfpV62tjs3dhbh-SXecO=q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
http://www.haskell.org/haskellwiki/Monomorphism_restriction
On 17 June 2012 08:13, Morel Pisum <[email protected]> wrote:
> Let's define a function in GHCi:
>
> > Prelude> let f s n = and (map (==s) n)
> > Prelude> :t f
> > f :: Eq a => a -> [a] -> Bool
>
> This is fine. But when I define this function using lambda notation, I
> get this
>
> > Prelude> let f = \s n -> and (map (==s) n)
> > Prelude> :t f
> > f :: () -> [()] -> Bool
>
> which is really weird.
>
> Why does this happen?
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
--
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120617/ec5d2b65/attachment-0001.htm>
------------------------------
Message: 2
Date: Sun, 17 Jun 2012 12:37:22 +0200
From: Morel Pisum <[email protected]>
Subject: Re: [Haskell-beginners] lambda notation vs function-argument
notation in GHCi
To: Ozgur Akgun <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
Aaaaah, of course! I didn't think I will ever stumble upon this?
Thank you!
> http://www.haskell.org/haskellwiki/Monomorphism_restriction
>
> On 17 June 2012 08:13, Morel Pisum <[email protected]> wrote:
>
>> Let's define a function in GHCi:
>>
>>> Prelude> let f s n = and (map (==s) n)
>>> Prelude> :t f
>>> f :: Eq a => a -> [a] -> Bool
>> This is fine. But when I define this function using lambda notation, I
>> get this
>>
>>> Prelude> let f = \s n -> and (map (==s) n)
>>> Prelude> :t f
>>> f :: () -> [()] -> Bool
>> which is really weird.
>>
>> Why does this happen?
------------------------------
Message: 3
Date: Mon, 18 Jun 2012 00:22:40 +0800
From: Song Zhang <[email protected]>
Subject: [Haskell-beginners] how monomorphism restriction effects eta
reduction
To: [email protected]
Message-ID:
<cacgmeonsqaagoaaztaij7fhkhcrvpykttw8k5fsjfa8k9m5...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I think monomorphism restriction is for shared evaluation.like following
function
f xs = let len = genericLength xs in (len, len) from haskell wiki
under monomorphism the type is Num t => [b] -> (t, t), if it no
monomorphism restriction the type will be (Num t, Num t1) => [b] -> (t, t1)
which lead to twice evaluation of len. However I didn't see how the
restriction effects eta reduction, when define function like f = show, g =
(==) or f = \x -> show x, g = \x -> \y -> (x==y). anyone can explain it to
me? Thanks a lot.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20120618/d507517c/attachment-0001.htm>
------------------------------
Message: 4
Date: Sun, 17 Jun 2012 20:53:35 +0200
From: miro <[email protected]>
Subject: Re: [Haskell-beginners] problem with type
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
Thank you!
Miro
On 6/17/12 9:08 AM, Morel Pisum wrote:
> What you want is probably
>
> checkNode :: String -> [String] -> Bool
> checkNode s nodes = and (map (==s) nodes)
>
> which returns True iff all nodes equal s.
>
>
>> Am a bit stuck here,... please, what is wrong with this?
>>
>> checkNode :: String -> [String] -> Bool
>> checkNode s nodes =
>> [s == node | node<- nodes ]
>>
>>
>> src/me.hs:3:4:
>> Couldn't match expected type `Bool' with actual type `[t0]'
>> [1 of 1] Compiling Main ( src/me.hs, interpreted )
>> In the expression: [s == node | node<- nodes]
>> Failed, modules loaded: none.
>> In an equation for `checkNode':
>> checkNode s nodes = [s == node | node<- nodes]
>>
>> thanks,
>> Miro
>
> _______________________________________________
> 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/20120617/5fce0234/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 48, Issue 23
*****************************************