[Haskell-beginners] why does the superclass not work?

Alexander Chen alexander at chenjia.nl
Wed Apr 29 19:34:35 UTC 2020


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.html>


More information about the Beginners mailing list