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

Explain why to use :> instead of Cons #170

Closed
tomjaguarpaw opened this issue Aug 19, 2016 · 5 comments
Closed

Explain why to use :> instead of Cons #170

tomjaguarpaw opened this issue Aug 19, 2016 · 5 comments
Milestone

Comments

@tomjaguarpaw
Copy link

There is a warning to use :> instead of Cons. Could you also explain in the warning the reason for it?

@ggreif
Copy link
Contributor

ggreif commented Aug 19, 2016

I guess (:>) is an abstract interface, Cons the concrete one. Possibly later the concrete interface won't be exposed to the module users.

As an aside, I have a little project underway to do run-length-encoded Vectors for simulation, which would not have Cons any more.

@tomjaguarpaw
Copy link
Author

If that's the case it would be helpful to have "Cons will be deprecated in future" in the docs.

@christiaanb
Copy link
Member

I'll update the documentation.

What @ggreif said is correct, :> is the abstract interface, while Cons is the concrete one.

The reason is a bit silly/sad: While the clash compiler happily supports the constructor aspect of GADTs, it (currently) does not support the pattern matching aspect (see the end of chapter 4 of my thesis if you want to know why). So I added the pattern synonym (:>), which is based on head and tail for the pattern-matching side, which are supported by the compiler.

Hopefully, if/when clash supports GADT patterns, the (:>) will become the concrete interface.

@martijnbastiaan
Copy link
Member

GADT support has recently landed in Clash (#465). We can now use Cons :). We should remove the warning and remove the pattern synonyms currently present.

@christiaanb
Copy link
Member

The warning has been removed. We keep the pattern synonym for the reasons described in: #966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants