
#8739: ($) returning kind # no longer type checks -------------------------------------+------------------------------------ Reporter: NeilMitchell | Owner: Type: bug | Status: infoneeded Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: 7.8.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): It's absolutely right that the second argument to `($)` must not have an unboxed kind. Because the code for `($)` must move that argument around (pass to the function), so it must know its width, pointerhood ect. But actually it would be ok for the ''result'' of the call `(f $ x)` to be unboxed, because the code for `($)` doesn't mess with the result; it just tail-calls `f`. It's a bit like the call `(error "foo")` which is allowed to have an unboxed type. So `error` has a rather magical type {{{ error :: forall (a:OpenKind). String -> a }}} where the funny quantifier `a:OpenKind` allows `a` to be instantiated to `Int#` as well as to `Int`. So we could regard `($)` as having the type {{{ ($) :: forall (a:*) (r:OpenKind). (a->r) -> a -> r }}} reflecting the fact that the result kind can range over unboxed types. Unless I'm being stupid here, the fix is simple in `TcExpr`, lines 329-ish: * Remove `b_ty <- newPolyFlexiTyVarTy` * Remove the `unifyType op_res_ty b_ty` * Replace the other reference to `b_ty` with `op_res_ty` Would someone like to try? Of course this deserves an elaboration of `Note [Typing rule for ($)]`, and a reference to this ticket. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8739#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler