[GHC] #13179: Levity-polymorphic data types

GHC ghc-devs at haskell.org
Tue Jan 24 05:28:06 UTC 2017


#13179: Levity-polymorphic data types
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Core Libraries    |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #12708            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

@@ -7,2 +7,1 @@
-
- -- Sum Array# Array# :: Type -> Type
+ -- Product Array# Array# :: Type -> Type

New description:

 I don't know if this belongs as a part of [https://github.com/ghc-
 proposals/ghc-proposals/pull/30 levity-polymorphic type classes] (#12708)
 but many data types can be made levity-polymorphic, some have just been
 added to base:

 {{{#!hs
 -- Product Array# Array# :: Type -> Type
 data Product :: forall rep. (k -> TYPE rep) -> (k -> TYPE rep) -> (k ->
 Type) where
   Pair :: f a -> g a -> (Product f g) a

 -- Sum Array# Array# :: Type -> Type
 data Sum :: forall rep. (k -> TYPE rep) -> (k -> TYPE rep) -> (k -> Type)
 where
   InL :: f a -> (Sum f g) a
   InR :: g a -> (Sum f g) a

 -- Compose Array# [] :: Type -> Type
 data Compose :: forall rep. (b -> TYPE rep) -> (a -> b) -> (a -> Type)
 where
   Compose :: f (g a) -> (Compose f g) a
 }}}

 Can you think of other examples?

--

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


More information about the ghc-tickets mailing list