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. why does the superclass not work? (Alexander Chen) 2. Re: why does the superclass not work? (Mihai Maruseac) ---------------------------------------------------------------------- Message: 1 Date: Wed, 29 Apr 2020 21:34:35 +0200 (CEST) From: Alexander Chen <alexan...@chenjia.nl> To: beginners@haskell.org Subject: [Haskell-beginners] why does the superclass not work? Message-ID: <120272377.203134.1588188875...@ichabod.co-bxl> Content-Type: text/plain; charset="utf-8" Hi, superclass.hs myX = 1 :: Int sigmund :: Int -> Int sigmund x = myX prelude> :l superclass.hs [1 of 1] Compiling Main Ok, one module loaded. ================================================================================== superclass.hs myX = 1 :: Int sigmund :: Num -> Num sigmund x = myX prelude> :l superclass.hs typed_checked.hs:3:13: error: • Expecting one more argument to ‘Num’ Expected a type, but ‘Num’ has kind ‘* -> Constraint’ • In the type signature: sigmund :: Num -> Num | 3 | sigmund :: Num -> Num | ^^^ typed_checked.hs:3:20: error: • Expecting one more argument to ‘Num’ Expected a type, but ‘Num’ has kind ‘* -> Constraint’ • In the type signature: sigmund :: Num -> Num =================================================================================== I would think since Num is a superclass of Int defining the type in the superclass would be OK, also in the error message it refers to (see black) what does that refer to? thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.haskell.org/pipermail/beginners/attachments/20200429/19d48b81/attachment-0001.html> ------------------------------ Message: 2 Date: Wed, 29 Apr 2020 13:11:54 -0700 From: Mihai Maruseac <mihai.marus...@gmail.com> To: Alexander Chen <alexan...@chenjia.nl>, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] why does the superclass not work? Message-ID: <CAOMsUMLRRqR6LEFQAwMcisB-tfJs2HJGs6=+pg2wy6h7xtg...@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" Hi. Num is not a superclass of Int. Int is a type whereas Num is a type of a type. The fix would be sigmund :: Num a => a -> a ... This signature means "sigmund has type a to a where a is constrained to be a type variable of type Num" (so Num is the type of the type variable a) On Wed, Apr 29, 2020 at 12:41 PM Alexander Chen <alexan...@chenjia.nl> wrote: > > Hi, > > superclass.hs > > myX = 1 :: Int > > sigmund :: Int -> Int > sigmund x = myX > > > prelude> :l superclass.hs > [1 of 1] Compiling Main > Ok, one module loaded. > > ================================================================================== > > superclass.hs > > myX = 1 :: Int > > sigmund :: Num -> Num > sigmund x = myX > > prelude> :l superclass.hs > typed_checked.hs:3:13: error: > • Expecting one more argument to ‘Num’ > Expected a type, but ‘Num’ has kind ‘* -> Constraint’ > • In the type signature: sigmund :: Num -> Num > | > 3 | sigmund :: Num -> Num | ^^^ > > typed_checked.hs:3:20: error: > • Expecting one more argument to ‘Num’ > Expected a type, but ‘Num’ has kind ‘* -> Constraint’ > • In the type signature: sigmund :: Num -> Num > > > =================================================================================== > > I would think since Num is a superclass of Int defining the type in the > superclass would be OK, also in the error message it refers to (see black) > what does that refer to? > > thanks! > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -- Mihai Maruseac (MM) "If you can't solve a problem, then there's an easier problem you can solve: find it." -- George Polya ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 142, Issue 8 *****************************************