| 47 | | With the new `-XPolyKinds` functionality we can make the support for generic programming better typed. The basic idea is to define the universe codes (`M1`, `:+:`, etc.) as constructors of a datatype. Promotion then lifts these constructors to types, which we can use as before, only that now we have them all classified under a new kind: |
| 48 | | |
| 49 | | {{{ |
| 50 | | {-# LANGUAGE TypeOperators #-} |
| 51 | | {-# LANGUAGE GADTs #-} |
| 52 | | {-# LANGUAGE TypeFamilies #-} |
| 53 | | {-# LANGUAGE ScopedTypeVariables #-} |
| 54 | | {-# LANGUAGE FlexibleContexts #-} |
| 55 | | {-# LANGUAGE FlexibleInstances #-} |
| 56 | | {-# LANGUAGE PolyKinds #-} |
| 57 | | {-# LANGUAGE DefaultSignatures #-} |
| 58 | | {-# LANGUAGE NoImplicitPrelude #-} |
| 59 | | |
| 60 | | module GHC.NewGenerics where |
| 61 | | |
| 62 | | import Prelude hiding (Functor(..), Show(..)) -- we'll redefine them |
| 63 | | import qualified Prelude as P (Show(..)) |
| 64 | | }}} |
| | 47 | With the new `-XPolyKinds` functionality we can make the support for generic programming better typed. The basic idea is to define the universe codes (`M1`, `:+:`, etc.) as constructors of a datatype. Promotion then lifts these constructors to types, which we can use as before, only that now we have them all classified under a new kind. The overhaul of the main module is explained below; for easier comparison with the current approach, names are kept the same whenever possible. |