[GHC] #12679: Permit abstract data types in signatures that don't have kind *

GHC ghc-devs at haskell.org
Mon Oct 10 06:41:41 UTC 2016


#12679: Permit abstract data types in signatures that don't have kind *
-------------------------------------+-------------------------------------
        Reporter:  ezyang            |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  low               |            Milestone:
       Component:  Compiler (Type    |              Version:  8.1
  checker)                           |
      Resolution:                    |             Keywords:  backpack
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by ezyang:

@@ -22,0 +22,3 @@
+ The point is to make the *constraint* for Map parametrizable, so that
+ HashMap can levy a different constraint (Hashable) than Map (Ord).
+

New description:

 Here is a fascinating program that I would like to write, but cannot with
 Backpack today:

 {{{
 unit p where
     signature Key where
         import GHC.Exts (Constraint)
         data Key k :: Constraint
         instance Key Bool
     signature Map where
         import Key
         data Map k a
         empty :: Map k a
         insert :: Key k => k -> a -> Map k a -> Map k a
         lookup :: Key k => k -> Map k a -> Maybe a
     module M where
         import Map
         import Key
         x = insert True "foo" empty
 }}}

 The point is to make the *constraint* for Map parametrizable, so that
 HashMap can levy a different constraint (Hashable) than Map (Ord).

 `data Key k :: Constraint` is implementable, because we can implement
 abstract data types using type synonyms in Backpack, and synonyms can have
 more kinds than just `*`. However, GHC chokes on this declaration, because
 it thinks that data types always have to have kind `*`.

--

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


More information about the ghc-tickets mailing list