Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org 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 <mike_k_hough...@yahoo.co.uk> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: [Haskell-beginners] Type constructor Message-ID: <f8964fef-3927-4f50-8fc0-15167f5b6...@yahoo.co.uk> 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 <toa...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> 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 <mike_k_hough...@yahoo.co.uk> 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 > Beginners@haskell.org > 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 <mike_k_hough...@yahoo.co.uk> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Type constructor Message-ID: <96e5750b-f32c-46a1-8d5f-2c9ef0eb4...@yahoo.co.uk> Content-Type: text/plain; charset="utf-8" Duh! Give that man a ceeeegar! Thanks :) > On 8 Nov 2017, at 19:31, David McBride <toa...@gmail.com> 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 <mike_k_hough...@yahoo.co.uk > <mailto:mike_k_hough...@yahoo.co.uk>> 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 > Beginners@haskell.org <mailto:Beginners@haskell.org> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > <http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners> > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > 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 Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 113, Issue 6 *****************************************