Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsafe implementation of vacuous/vacuousM #3

Merged
merged 1 commit into from Dec 2, 2012

Conversation

ehird
Copy link
Collaborator

@ehird ehird commented Dec 2, 2012

Unfortunately, you can use GADTs to derive unsafeCoerce from this implementation; see http://lpaste.net/78660.

Perhaps the faster version should be exported as unsafeVacuous, possibly from another module (e.g. Data.Void.Unsafe)?

@ehird
Copy link
Collaborator Author

ehird commented Dec 2, 2012

Come to think of it, you might be able to do this without GADTs too, e.g. by using Leibniz equality.

Unfortunately, you can use these to derive unsafeCoerce:

    import Data.Void

    data Iso a b = Iso { to :: a -> b, from :: b -> a }

    instance Functor (Iso a) where
        fmap = undefined

    lie :: Iso Void a
    lie = vacuous (Iso id id)

    evil :: a -> b
    evil = to lie . from lie
@ehird
Copy link
Collaborator Author

ehird commented Dec 2, 2012

I was right; here's a Haskell 98 version of the trick. I've updated the commit message accordingly.

ekmett added a commit that referenced this pull request Dec 2, 2012
Remove unsafe implementation of vacuous/vacuousM
@ekmett ekmett merged commit 2a4d635 into ekmett:master Dec 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants