[GHC] #14921: Type inference breaks on constraint-kinded parameter used by a Rank-2 callback
GHC
ghc-devs at haskell.org
Sun Sep 16 16:22:26 UTC 2018
#14921: Type inference breaks on constraint-kinded parameter used by a Rank-2
callback
-------------------------------------+-------------------------------------
Reporter: glittershark | Owner: (none)
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.2
Resolution: invalid | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC rejects | Unknown/Multiple
valid program | Test Case:
Blocked By: | Blocking:
Related Tickets: #10651, #15649 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by infinity0):
As mentioned on the other tickets `Proxy` is an alternative workaround to
`TypeApplications` + `AllowAmbiguousTypes`, the latter being quite a
strong relaxation that one often doesn't want to enable in library code.
{{{#!haskell
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Scratch where
import Data.Proxy
import Prelude
data Foo
= FooA Int
| FooB String
useFoo :: forall cls a . (cls Int, cls String) => Proxy cls -> (forall k .
cls k => k -> a) -> Foo -> a
useFoo _ f (FooA a) = f a
useFoo _ f (FooB b) = f b
x = useFoo (Proxy :: Proxy Show) show (FooA 1)
}}}
compiles without errors.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14921#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list