emilyhorsman / elm-type-inference Goto Github PK
View Code? Open in Web Editor NEWA parser (using megaparsec) and type inference engine for Elm source code
License: BSD 3-Clause "New" or "Revised" License
A parser (using megaparsec) and type inference engine for Elm source code
License: BSD 3-Clause "New" or "Revised" License
i.e., (True)
is really just the boolean literal True
Right now function application is fairly naive: FunctionApplication String [Expression]
.
We want to allow things like this:
f a = a + 1
f 1 + 2 -- Yields 4
But we don't want to allow things like this:
f if True then a else b
However this is fine:
f (if True then a else b)
Essentially, function application is an operator that does not bind as tightly something like an arithmetic binary operator.
https://guide.elm-lang.org/types/reading_types.html#constrained-type-variables
Then do:
I think we can basically turn a top-level ProgramBody
into a big LetBinding
expression and just throw that into infer :: … -> Expression -> …
.
This should pass:
let
x : Int
x = 4
in
x
This should fail:
let
x : Int
x = 4
in
x
From elm repl
:
> '\a'
-- PARSE ERROR ------------------------------------------------------------- elm
Backslashes always start escaped characters, but I do not recognize this one:
4| '\a'
^
Maybe there is some typo?
Hint: Valid escape characters include:
\n
\r
\t
\"
\'
\\
\u{03BB}
The last one lets encode ANY character by its Unicode code point, so use that
for anything outside the ordinary six.
>
e.g.,
import Html exposing (..)
type alias State a =
{ a | count: Int }
type alias MoreState =
State { test: Int }
increment : State a -> State a
increment s = { s | count = s.count + 1 }
state : MoreState
state =
{ count = 0
, test = 1
}
|> increment
|> increment
main = text (String.fromInt state.count)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.