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. Type constructor (mike h)
2. Re: Type constructor (David McBride)
3. Re: Type constructor (mike h)
----------------------------------------------------------------------
Message: 1
Date: Wed, 8 Nov 2017 19:21:14 +0000
From: mike h <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: [Haskell-beginners] Type constructor
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Hi,
I’m modelling fractions with a view to looking at continued fractions and I
have this recursive structure.
type Numerator = Integer
data Fraction = Numbr Integer | F Numerator Fraction
in ghci I do
λ-> :t F 1 (Numbr 2)
F 1 (Numbr 2) :: Fraction
which is fine. But what surprised me is that it also works without using Numbr
e.g.
λ-> :t F 1 2
F 1 2 :: Fraction
why is this?
Thanks
Mike
------------------------------
Message: 2
Date: Wed, 8 Nov 2017 14:31:50 -0500
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Type constructor
Message-ID:
<can+tr40f8kychakpvimzrkjb0+kaupyw0rcsmdbqyeairu+...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
The only thing I can think of is that you wrote a Num instance for
Fraction. That allows it to represent a fraction as a literal 2 because
you can create a fraction from an integer via fromInteger.
On Wed, Nov 8, 2017 at 2:21 PM, mike h <[email protected]> wrote:
> Hi,
>
> I’m modelling fractions with a view to looking at continued fractions and
> I have this recursive structure.
>
> type Numerator = Integer
> data Fraction = Numbr Integer | F Numerator Fraction
>
>
> in ghci I do
>
> λ-> :t F 1 (Numbr 2)
> F 1 (Numbr 2) :: Fraction
>
> which is fine. But what surprised me is that it also works without using
> Numbr e.g.
>
> λ-> :t F 1 2
> F 1 2 :: Fraction
>
> why is this?
>
> Thanks
>
> Mike
> _______________________________________________
> 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/20171108/5d843e16/attachment-0001.html>
------------------------------
Message: 3
Date: Wed, 8 Nov 2017 20:26:41 +0000
From: mike h <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Type constructor
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Duh!
Give that man a ceeeegar!
Thanks
:)
> On 8 Nov 2017, at 19:31, David McBride <[email protected]> wrote:
>
> The only thing I can think of is that you wrote a Num instance for Fraction.
> That allows it to represent a fraction as a literal 2 because you can create
> a fraction from an integer via fromInteger.
>
> On Wed, Nov 8, 2017 at 2:21 PM, mike h <[email protected]
> <mailto:[email protected]>> wrote:
> Hi,
>
> I’m modelling fractions with a view to looking at continued fractions and I
> have this recursive structure.
>
> type Numerator = Integer
> data Fraction = Numbr Integer | F Numerator Fraction
>
>
> in ghci I do
>
> λ-> :t F 1 (Numbr 2)
> F 1 (Numbr 2) :: Fraction
>
> which is fine. But what surprised me is that it also works without using
> Numbr e.g.
>
> λ-> :t F 1 2
> F 1 2 :: Fraction
>
> why is this?
>
> Thanks
>
> Mike
> _______________________________________________
> Beginners mailing list
> [email protected] <mailto:[email protected]>
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> <http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners>
>
> _______________________________________________
> 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/20171108/23d431a7/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 113, Issue 6
*****************************************