Proposal: GHC.Generics marked UNSAFE for SafeHaskell
Mon Oct 7 15:11:39 UTC 2013
On Mon, Oct 7, 2013 at 10:22 AM, Edward Kmett <ekmett at gmail.com> wrote:
> Am I correct in understanding your issue arises from manually rolled
> instances of Generic, not from Generic itself?
> Wouldn't then perhaps the better fix be to resurrect the old rule for
> derived Typeable instances and apply it to Generic and Generic1 instead?
The new rule would be that if you hand-implemented Generic or Generic1 in
> your module it isn't Safe.
Ah... so you're proposing adding an extra rule to the GHC compiler itself?
Isn't it simpler to do it just with a library-level fix? I.e. my proposal
is that GHC.Generics is marked as Unsafe. And then if you really want you
can mark your module as TrustWorthy even with manual instances. (And then,
yes, we'd need a GHC.Generics.Safe to pull the Generic symbol itself from
when we just want to derive it.)
That would make it so that derived Generic, Generic1 would be considered
> Safe, and you wouldn't break literally every user of the library who care
> about Safe Haskell.
Isn't that also accomplished just by "import GHC.Generic.Safe (Generic)"?
And the handful of hypothetical people that are using this right now can
make that one-line fix. I will *personally* make that fix for all those
people if they would come forward and share the link to their code ;-).
As it stands the things are damn-near impossible to get right instantiating
> them by hand anyways, so I expect this would affect only 1 or 2 users
> rather than all of them!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs