[GHC] #12369: data families shouldn't be required to have return kind *, data instances should
GHC
ghc-devs at haskell.org
Thu Oct 20 09:36:34 UTC 2016
#12369: data families shouldn't be required to have return kind *, data instances
should
-------------------------------------+-------------------------------------
Reporter: ekmett | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 8.2.1
Component: Compiler (Type | Version: 8.0.1
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Iceland_jack):
[http://cs.brynmawr.edu/~rae/papers/2016/thesis/eisenberg-thesis-draft.pdf
Eisenberg]:
> A ''data family'' defines a family of datatypes. An example shows best
how this works:
>
> {{{#!hs
> data family Array a -- compact storage of elements of type a
> data instance Array Bool = MkArrayBool ByteArray
> data instance Array Int = MkArrayInt (Vector Int)
> }}}
>
> With such a definition, we can have a different runtime representation
for `Array Bool` than we do for `Array Int`, something not possible with
more traditional parameterized types.
The part about **runtime representation** made me wonder if you could
define
{{{#!hs
-- × × × FAILS × × ×
data family Array a :: TYPE rep
}}}
I dunno about the instances, maybe using
[https://ghc.haskell.org/trac/ghc/wiki/UnliftedDataTypes#Proposal3:Allownewtypesoverunliftedtypes
Proposal 3: Allow newtypes over unlifted types]
{{{#!hs
newtype instance Array Int# :: TYPE PtrRepUnlifted where
MkInt# :: ByteArray# -> Array Int#
newtype instance Array (##) :: TYPE IntRep where
MkInt# :: Int# -> Array (##)
}}}
I don't really understand representation polymorphism, may suffer from
same problem as #11471.
----
{{{#!hs
-- WORKS FINE
data family Array (a :: TYPE rep) :: Type
-- × × × FAILS × × ×
--
-- Unexpected type ‘Int#’
data Array Int#
-- Should this fail?
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12369#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list