-
Notifications
You must be signed in to change notification settings - Fork 72
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
First class polymorphism + refined types? #2
Comments
Hi! In theory, I don't see a problem, as the type inference/(ML) type-checking phase, which transforms the AST into a typed expression tree, and the refined type-checking (which makes sure that contracts are satisfied) are strictly separated. The problem, however, is that in the current implementation of the refined type system, functions as parameters are not implemented, and functions as return types are not fully implemented (hence, a lot of first-class polymorphism wouldn't pass the refined type checker because it would raise NotImplemented errors). I don't think it would be particularly hard to implement that, and it's completely orthogonal to first-class polymorphism, I'll probably implement it sometime soon. But yes, I completely agree, a perfect type system would definitely support both refined types and first-class polymorphism (and hopefully other things as well, like a good record system). |
Nice. I will continue playing with these two then and compare my version with yours if you decide to do it. I agree, records and variants would be in indeed. Out of curiosity, is there any other specific features or properties your perfect type system would have? To me, a mix of ocaml/F# + type classes of haskell + easy to use dependent types sounds pretty perfect yea. |
Uh, that's a hard question... I'm still conflicted about it, as I haven't discovered yet how to even make some of the "perfect" parts of the "perfect" type system, let alone combine them. Some ideas:
|
Something like the indexed monad is really interesting here. Logic is type checked. https://gist.github.com/gelisam/9845116
Something like functionally reactive?
I was surprised F# didn't have something like list fusion in haskell. A typical functional pattern like folding creates new objects instead of modifying them, lifetime and usage isn't tracked. https://www.haskell.org/ghc/docs/7.0.1/html/users_guide/rewrite-rules.html
Yea subtyping seems unavoidable.
I've had a problem for which type classes would've been nice not too long at work. It's just basically attaching interfaces but after a type definition. F# doesn't allow that, which forces you to write a bunch of boilerplate to contain types supported by the language (int, bool, string, etc).
pls no |
Hi, I noticed this part of the discussion here:
I just wanted to share that long-term plans for Elm involve type-classy functionality which will likely be done with the already available (extensible) records and implicit arguments. I think one of the first mentions of this plan is here, and there are more references to records+Agda style implicit arguments on the mailing list. |
Hi Jeff! Thanks for the pointer. I have a similar plan; combine combine records and implicit arguments to make type-classes. This is an interesting paper that I read on that topic: http://homepages.inf.ed.ac.uk/wadler/papers/implicits/implicits.pdf. I'm not sure it would work when combined with records or extensible records, but I think it's worth trying. |
Daan Leijen has an excellent paper that introduces an effect-based type system called LambdaK. The effect system is row-polymorphic, so multiple effects can be attributed to a single expression. There's an example implementation in Haskell for his language Koka. |
And I just saw your comment about Koka. Sorry! |
Sorry, had stumbled on this thread by accident, I see there’s no recent activity here, but maybe you also would be interested in what was done about them in Ceylon. I haven’t read papers about its type system, but for example, they play nice there with contra/covariant type parameters. They also help there in encoding nonemptiness of streams and sequences and in typing tuples treated as heterogeneous lists (if I represent it correctly) and for representing types of argument lists containing optionals. |
First of all, I would like to say thank you for your great project on type systems. I've been interested in the concept for a while without never really touching or implementing them and your project really helps me to better understand them.
I've always thought that a perfect type system would be something along two of your sub-projects, first class polymorphism + refined types. I've been playing around with those two a little bit with the hope of merging them but I wanted to ask you first if it made sense since you seem to be well versed on the subject. Is there anything that would prevent them both from co-existing within the same type system?
The text was updated successfully, but these errors were encountered: