Skip to content

Instantly share code, notes, and snippets.

@swgillespie
Last active October 20, 2015 04:00
Show Gist options
  • Save swgillespie/4f925ee12edc09e2fd19 to your computer and use it in GitHub Desktop.
Save swgillespie/4f925ee12edc09e2fd19 to your computer and use it in GitHub Desktop.
occurs check
Prelude> let x = x x
<interactive>:2:9:
Occurs check: cannot construct the infinite type: t1 ~ t -> t1
Relevant bindings include x :: t -> t1 (bound at <interactive>:2:5)
In the expression: x x
In an equation for ‘x’: x = x x
# let rec x = x x;;
Error: This expression has type 'a -> 'b
but an expression was expected of type 'a
The type variable 'a occurs inside 'a -> 'b
> let rec x = x x;;
let rec x = x x;;
------------^^^
/Users/sean/Library/Developer/Xcode/DerivedData/lldb-ahryjcvbkbsloweweleakmzjotns/Build/Products/DebugClang/stdin(1,13): error FS0001: Type mismatch. Expecting a
'a -> 'b
but given a
'b
The resulting type would be infinite when unifying ''a' and ''b -> 'a'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment