Changes between Version 19 and Version 20 of NewtypeWrappers


Ignore:
Timestamp:
Nov 19, 2013 5:22:22 PM (5 months ago)
Author:
nomeata
Comment:

Link to note in source code

Legend:

Unmodified
Added
Removed
Modified
  • NewtypeWrappers

    v19 v20  
    6262== The implementation == 
    6363 
    64 Core already had provided all the necessary feature; the question was just how to offer it on the Haskell level. The implementation comes in form of a `coerce :: Coercible a b -> a -> b` and a type class `Coercible` that relates two types if they have the same representation, i.e. can be related by a coercion of role Representational (see [wiki:Roles]). See the haddock documentation for `coercible` for user-level documentation and Note [Coercible Instances] for information on the implementation. 
     64Core already had provided all the necessary feature; the question was just how to offer it on the Haskell level. The implementation comes in form of a `coerce :: Coercible a b -> a -> b` and a type class `Coercible` that relates two types if they have the same representation, i.e. can be related by a coercion of role Representational (see [wiki:Roles]). See the haddock documentation for `coercible` for user-level documentation and [https://ghc.haskell.org/trac/ghc/browser/ghc/compiler/typecheck/TcInteract.lhs#L2013 Note [Coercible Instances]] for information on the implementation. 
    6565 
    6666The implementation fulfills the first goal, the second partly (`C N -> C T` is allowed even without `C`'s data constructors in scope; if `C` should be abstract the role of its argument needs to be `Nominal`). Due to the ad-hoc nature of the `Coercible` instances, the second and third goal are not achieve. No work towards the fifths goal has been done.