Skip to content

Instance declaration of type constructor type classes for newtypes leads to ghc error message

Consider the following Curry program.

newtype S a = S { runS :: Int -> (a, Int) }

instance Monad S where
  return x = S $ \s -> (x, s)

  m >>= f = S $ \s -> let (x, s') = runS m s
                      in runS (f x) s'

test :: S ()
test = return ()

Compiling this module and executing test with kics2 results in the following ghc error message

.curry/kics2/Curry_Newtype.hs:38:63: error:
    • The type synonym ‘C_S’ should have 1 argument, but has been given none
    • In the type signature:
        d_OP_uscore_inst_hash_Prelude_dot_Monad_hash_Newtype_dot_S :: Cover
                                                                      -> ConstStore
                                                                         -> Curry_Prelude.OP_uscore_Dict_hash_Monad C_S
   |
38 | d_OP_uscore_inst_hash_Prelude_dot_Monad_hash_Newtype_dot_S :: Cover
   |                                                               ^^^^^...

.curry/kics2/Curry_Newtype.hs:47:64: error:
    • The type synonym ‘C_S’ should have 1 argument, but has been given none
    • In the type signature:
        nd_OP_uscore_inst_hash_Prelude_dot_Monad_hash_Newtype_dot_S :: IDSupply
                                                                       -> Cover
                                                                          -> ConstStore
                                                                             -> Curry_Prelude.OP_uscore_Dict_hash_Monad C_S
   |
47 | nd_OP_uscore_inst_hash_Prelude_dot_Monad_hash_Newtype_dot_S :: IDSupply -> Cover
   |                                                                ^^^^^^^^^^^^^^^^^...                                                            ^^^^^^^^^^^^^^^^^^^...