You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a great project, it's really helping me learn Reason
I came across this error:
wat.re:1428-4311 │
12 │ type c 'a = option(tuple 'a);13 │
14 │ let optSwap:c'a => c 'a = Option.map swap
Error:The type of this expression,'_a c -> '_a c,
contains type variables that cannot be generalized
when I was doing something similar to this:
let module Option = {let map = fun f =>
fun
| None => None
| Some x => Some(f x);};type pair 'a = | Pair of 'a'a;let swap =
fun
| Pair x y => Pair y x;type c 'a = option(pair 'a);let optSwap:c'a => c 'a = Option.map swap
I understand why ref None needs more type information, but why does Option.map swap? I feel like the language should let me do this:
wat.re:1728-3114 │ let optSwap:c'a => c 'a = Option.map swap;15 │
16 │ let _ = optSwap(Some(Pair12));17 │ let _ = optSwap(Some(Pair'a''b'));Error:The types don't match.This is:charWanted: int
In any case, this probably deserves a better error, right?
The text was updated successfully, but these errors were encountered:
Hi!
This is a great project, it's really helping me learn Reason
I came across this error:
when I was doing something similar to this:
This page shows a very simple repro case:
https://ocaml.org/learn/tutorials/common_error_messages.html#Thetypeofthisexpressioncontainstypevariablesthatcannotbegeneralized
I understand why
ref None
needs more type information, but why doesOption.map swap
? I feel like the language should let me do this:In any case, this probably deserves a better error, right?
The text was updated successfully, but these errors were encountered: