Proposal: GHC.Generics marked UNSAFE for SafeHaskell

Dag Odenhall dag.odenhall
Tue Oct 8 09:04:53 UTC 2013


On Tue, Oct 8, 2013 at 9:48 AM, Jos? Pedro Magalh?es <dreixel at gmail.com>
wrote:


> On Mon, Oct 7, 2013 at 10:32 AM, Dag Odenhall <dag.odenhall at gmail.com>wrote:
>
>> Here?s a thought: doesn?t Generic already have an unused phantom type
>> that's only there ?just in case we need to add something in the future??
>>
> No, it doesn't.
>
Ah, I had misunderstood, then. :-)

Just a thought: what if we had a type family
>
> type family Derives (t :: k1) (c :: k2) :: Bool
>
> which would automatically be instantiated by GHC appropriately? E.g., if
> the user had the following code:
>
> data MyData = MyData deriving (Eq, Generic)
> deriving instance Show MyData
> instance Ord MyData
>
> GHC would automatically instantiate:
>
> type instance Derives MyData Eq      = True
> type instance Derives MyData Generic = True
> type instance Derives MyData Show    = True
> type instance Derives MyData Ord     = False
>
> Would this be something Ryan could use for detecting safe instances for
> LVish?
>
Yeah that looks like a much better plan to me. A slight issue with this is
GHC's error messages for this are kinda bad (couldn't match 'False with
'True with little or no context) but that's probably fixable?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20131008/05faf4b5/attachment.html>




More information about the Libraries mailing list