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

built-in typeclasses don't get replaced by the actual type like normal type variables #1013

Closed
Apanatshka opened this issue Aug 7, 2015 · 2 comments
Labels
Milestone

Comments

@Apanatshka
Copy link
Contributor

Another issue to be aggregated in #1008?

Observe:

$ elm-repl
> f1 = (<)
<function> : comparable -> comparable -> Bool
> f2 = (<) 1
<function> : comparable -> Bool
> f2 "a"
As I infer the type of values flowing through your program, I see a conflict
between these two types:

    comparable

    String

Expected behaviour: f2 : number -> Bool (or perhaps Int, I don't know exactly what the compiler does there).

Original data comes from this StackOverflow question.

@evancz
Copy link
Member

evancz commented Aug 7, 2015

Thanks for describing this. Seems separate from #1008, looks like a bug instead. It is closer to #880 which seems to stem from the same code.

I suspect the root issue arises from this function or from this section. If someone could take a look, it may not be too crazy to find the root issue here.

@evancz evancz added the bug label Aug 19, 2015
@evancz evancz added this to the Type Inference milestone Aug 19, 2015
evancz pushed a commit that referenced this issue Oct 19, 2015
- Get rid of pretty printing for Type.Type
- Stop modeling records with overlapping fields in Type.Type
- Explicit exports for Type.Environment
- Make type Mismatch notes an ADT not a String
- Track expected/actual through the unification process

Errors still print out weird. Next task is to clean that up!

This also appears to resolve issues #1013, #917, #821, #656, and #654.
We should do further testing before closing them all though!
@evancz
Copy link
Member

evancz commented Oct 23, 2015

Alright, this is resolved on the type-fixes branch which I am currently merging into master. So it'll be out with 0.16 and I'll try to do an alpha soon. Here's what I'm seeing now:

$ elm-repl
---- elm repl 0.16.0 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> (<)
<function> : comparable -> comparable -> Bool
> isNegative n = n < 0
<function> : number -> Bool
> isPositive = (<) 0
<function> : number -> Bool
> 

@evancz evancz closed this as completed Oct 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants