[GHC] #9819: Create typesafe method of obtaining dictionary types from class definitions, and constraint objects from dictionary types

GHC ghc-devs at haskell.org
Fri Nov 21 12:50:59 UTC 2014


#9819: Create typesafe method of obtaining dictionary types from class
definitions, and constraint objects from dictionary types
-------------------------------------+-------------------------------------
              Reporter:              |            Owner:
  spacekitteh                        |           Status:  new
                  Type:  feature     |        Milestone:
  request                            |          Version:
              Priority:  normal      |         Keywords:
             Component:  Compiler    |     Architecture:  Unknown/Multiple
            Resolution:              |       Difficulty:  Moderate (less
      Operating System:              |  than a day)
  Unknown/Multiple                   |       Blocked By:
       Type of failure:              |  Related Tickets:
  None/Unknown                       |
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 I'm sorry, but I don't understand your request. The dictionary for
 `IntLike` would look something like this:

 {{{
 data IntLikeDict a = MkIntLikeDict { fromInt :: Int -> a
                                    ; toInt :: a -> Int   }
 }}}

 There isn't an actual number stored anywhere. And, in fact, my example has
 made things more complicated than they really are. The dictionary type
 within GHC '''is''' `IntLike` -- there's no separate dictionary type.

 Is `Dict` what you're looking for?

 {{{
 data Dict c where
   Dict :: c => Dict c
 }}}

 That's definable today with !ConstraintKinds.

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


More information about the ghc-tickets mailing list