[GHC] #14180: Strange/bad error message binding unboxed type variable

GHC ghc-devs at haskell.org
Tue Aug 21 15:19:59 UTC 2018


#14180: Strange/bad error message binding unboxed type variable
-------------------------------------+-------------------------------------
        Reporter:  dfeuer            |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.2.3
       Component:  Compiler (Type    |              Version:  8.3
  checker)                           |
      Resolution:                    |             Keywords:  TypeInType
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 It's here in `tc_fun_type`
 {{{
 tc_fun_type :: TcTyMode -> LHsType GhcRn -> LHsType GhcRn -> TcKind
             -> TcM TcType
 tc_fun_type mode ty1 ty2 exp_kind = case mode_level mode of
   TypeLevel ->
     do { arg_k <- newOpenTypeKind
        ; res_k <- newOpenTypeKind
        ; ty1' <- tc_lhs_type mode ty1 arg_k
        ; ty2' <- tc_lhs_type mode ty2 res_k
        ; checkExpectedKind (HsFunTy noExt ty1 ty2) (mkFunTy ty1' ty2')
                            liftedTypeKind exp_kind }
   KindLevel ->  -- no representation polymorphism in kinds. yet.
     do { ty1' <- tc_lhs_type mode ty1 liftedTypeKind
        ; ty2' <- tc_lhs_type mode ty2 liftedTypeKind
        ; checkExpectedKind (HsFunTy noExt ty1 ty2) (mkFunTy ty1' ty2')
                            liftedTypeKind exp_kind }
 }}}
 In a kind signature, `(mode_level mode)` is `KindLevel`, so we insist that
 the arguments of `(->)` are of kind `Type`.

 A type synonym doesn't know what level it is at, so it escapes this check.
 You are right that this gives silly results.

 Now that types and kind are the same, perhaps we shouldn't have this
 `TypeLevel`/`KindLevel` distinction.  But I don't know what the
 raminfications would be, esp for error messages.

 Or we could simplfy `tc_fun_type` to not check the distinction.

 But do you really want unboxed types in kinds??

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14180#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list