Proposal: GHC.Generics marked UNSAFE for SafeHaskell

adam vogt vogt.adam
Mon Oct 7 19:28:47 UTC 2013


On Mon, Oct 7, 2013 at 1:33 PM, Ryan Newton <rrnewton at gmail.com> wrote:
> Again, my use-case (closed/safe Eq & Ord instances) is a few steps removed
> from this Generics business and I don't feel strongly about how it gets
> done.  But having *SOME* way of doing it will be a massive boon to my lab's
> particular effort at maximizing the abilities of guaranteed-Safe
> deterministic parallelism in Haskell.  Further, I think anyone else who
> tries to do something in SafeHaskell that depends on guaranteeing a
> closed/controlled set of instances (SafeEq, SafeOrd but also others) based
> on GHC.Generics will *also* find this change useful.

Hi,

In containers we have Data instances "This instance preserves data
abstraction at the cost of inefficiency". Generic is a more modern way
to address the same problem. This Generic instance for Set is just a
more convenient way to use Set.toList/Set.fromList
<http://lpaste.net/94028>, which are -XSafe functions right?

For your problem I suggest using template-haskell to write your
"SafeEq" "SafeOrd" instances. It will let you access unexported
constructors too, which means people using LVish can maintain their
abstractions for everybody except LVish. My understanding is that the
proposed changes to ghc/Generic would mean that all data used with
LVish would have to expose it's implementation to everybody through
the derived Generic instance.

Regards,
Adam




More information about the Libraries mailing list