Comments (4)
Thanks for reporting this! To set expectations:
- Issues are reviewed in batches, so it can take some time to get a response.
- Ask questions in a community forum. You will get an answer quicker that way!
- If you experience something similar, open a new issue. We like duplicates.
Finally, please be patient with the core team. They are trying their best with limited resources.
from compiler.
If you need a quick fix, try adding a type annotation to the module-level declaration. Issue seems similar to #1839
from compiler.
Re
The reason I even found this is that the error messages reported by both GHC and OCaml are quite poor.
What's the OCaml error message? This OCaml translation compiles and runs on at least OCaml 4.13.1 and 5.0.0:
let f x =
let _g : (('a -> unit) -> unit) = fun h -> h x
in x
https://try.ocamlpro.com/#code/let'f'x'=!let'_g':'(($,a'-$.'unit)'-$.'unit)'='fun'h'-$.'h'x!in'x
from compiler.
This is quite subtle, but the OCaml type you wrote is not actually equivalent to the one in Elm.
'a
variables are not implicitly quantified type variables like in Elm or Haskell. They are actually just stand-ins for unification variables, which are closer to _a
with PartialTypeSignatures in Haskell.
In other words, the following will compile and define a function f : Int -> int
let f : 'a -> 'a = fun x -> x + 1
To get the fully polymorphic behavior like in Elm or Haskell, one needs to use an explicit quantifier
let f x =
let g : 'a. ('a -> unit) -> unit =
fun h -> h x
in x
This generates the "fantastic" error message
Error: This definition has type ('a -> unit) -> unit which is less general than
'a0. ('a0 -> unit) -> unit
from compiler.
Related Issues (20)
- Package opvasger/comparable has been deleted & can no longer be installed HOT 1
- elm-live dies hard when it cant find output files. HOT 8
- What's the state of the Elm repo? HOT 9
- Simplify type system HOT 3
- Clarify type syntax HOT 3
- Docker build fails with rejected dependency HOT 1
- record extended with additional field not accepted as extensible record with record with same fields HOT 1
- Send Bytes through ports HOT 1
- Issue with extensible records and unit type HOT 1
- Permission Denied Error Due to Unset `ELM_HOME` Environment Variable in `Stuff` Module HOT 4
- Error message should be more informative when integer literal is being used as both integer and float HOT 3
- terminal/src/Develop/StaticFiles.hs:91:3: error: Exception when trying to run compile-time code: reactor: changeWorkingDirectory: does not exist HOT 3
- elm publish under zsh not printing error message HOT 1
- Inaccurate information in installation instructions HOT 1
- Let binding cyclic value detection is stronger than top level HOT 1
- Bug?: Confusing behaviour when combining `--optimize` with `--output=/dev/null` HOT 1
- Suboptimal error for mising function arguments HOT 1
- Bad function signature leads to 'EXPECTING DEFINITION' HOT 1
- Pattern parser not hinting at missing comma HOT 1
- - and + behave inconsistently HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compiler.