[GHC] #11439: Request for comments: Allow duplicate type signatures

GHC ghc-devs at haskell.org
Wed Feb 24 22:54:29 UTC 2016


#11439: Request for comments: Allow duplicate type signatures
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
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 Iceland_jack):

 Similar for type families:

 {{{#!hs
 type family
   Sing (res :: k -> Type) | res -> k where
   -- Sing :: Nat -> Type
   Sing = SingNat
   -- Sing :: Nat -> Type
   Sing = SingBool
 }}}

 Annotations work fine here `Sing = (SingNat :: Nat -> Type)`, ... but its
 utility is clearer in this
 [https://gist.github.com/AndrasKovacs/c7d385aa117929503feb gist] where we
 could annotate `(@@)` instances in different ways without modifying the
 definitions:

 {{{#!hs
 data Con1 :: (a -> b) -> (a ~> b)
 data Con2 :: (a -> b -> c) -> (a ~> b ~> c)
 data Con3 :: (a -> b -> c -> d) -> (a ~> b ~> c ~> d)

 type family (@@) (f :: a ~> b) (x :: a) :: b

 -- (@@) :: (a ~> b)             -> (a -> b)
 type instance Con1 c @@ a = c a
 -- (@@) :: (a ~> b ~> c)        -> a -> (b ~> c)
 -- (@@) :: (a ~> (b ~> c))      -> (a -> (b ~> c))
 -- (@@) :: (a ~> b ~> c)        -> (a -> b ~> c)
 type instance Con2 c @@ a = Con1 (c a)
 -- (@@) :: (a ~> b ~> c ~> d)   -> a -> (b ~> c ~> d)
 -- (@@) :: (a ~> (b ~> c ~> d)) -> (a -> (b ~> c ~> d))
 -- (@@) :: (a ~> b ~> c ~> d)   -> (a -> b ~> c ~> d)
 type instance Con3 c @@ a = Con2 (c a)
 }}}

 I think this will only become more useful as GHC's type system evolves

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


More information about the ghc-tickets mailing list