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

Lifted sequence coercions #1

Closed
treeowl opened this issue Sep 12, 2015 · 7 comments
Closed

Lifted sequence coercions #1

treeowl opened this issue Sep 12, 2015 · 7 comments

Comments

@treeowl
Copy link

treeowl commented Sep 12, 2015

Currently, you use data Any a where Any :: a b c -> Any a. This has a potential efficiency problem because of the extra constructor. I'm also not sure if it's entirely safe. As best I can tell, the officially sanctioned way to do this sort of thing is with the somewhat magical GHC.Prim.Any :: *, which is designed as a "safe" intermediary for unsafeCoerce. To use it, you'd just make a Seq Any or similar, and unsafeCoerce both on the way in and on the way out. GHC seems to promise not to play games with this type.

newtype FakeSequence a b c = FakeSequence (Seq Any)
@atzeus
Copy link
Owner

atzeus commented Sep 13, 2015

Where do I use Any? Cheers!

@atzeus
Copy link
Owner

atzeus commented Sep 13, 2015

O wait in LiftSequence :)

@atzeus
Copy link
Owner

atzeus commented Sep 13, 2015

Yep this is definitely an improvement! I'll change it. Thanks!

@treeowl
Copy link
Author

treeowl commented Sep 13, 2015

I guess you'll want a kind annotation there. Probably something like

newtype FakeSequence (a :: k -> k -> *) (b::k) (c::k) = FakeSequence (Seq Any)

@treeowl
Copy link
Author

treeowl commented Mar 7, 2016

Any progress on this? Should I open a pull request?

@atzeus
Copy link
Owner

atzeus commented Mar 8, 2016

Fixed by #2ab000be1ddc49a2ec36afaaa58485df56aef654

@atzeus atzeus closed this as completed Mar 8, 2016
@treeowl
Copy link
Author

treeowl commented Mar 22, 2016

I just looked at this again, and was surprised to see unsafeCoerce# rather than the "safer" unsafeCoerce. Why is that primitive needed here?

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

No branches or pull requests

2 participants