Commit graph

1049 commits

Author SHA1 Message Date
Evan Czaplicki
a3a7b3ef62 Refactor type environment
Migrate some functions to Environment.hs, add built-in types like _List
and _Tuple2.
2013-07-17 19:29:27 +02:00
Evan Czaplicki
90c5c7d21c Add terse way to do type application 2013-07-17 19:26:42 +02:00
Evan Czaplicki
334d39c644 Manual dead code elimination ;) 2013-07-17 19:25:17 +02:00
Evan Czaplicki
1d1083600f Fix naming bug for List type 2013-07-17 19:24:56 +02:00
Evan Czaplicki
e852ae25e3 Add field to MetadataModule for datatypes 2013-07-17 19:24:40 +02:00
Evan Czaplicki
fceb46dd4e Try to support polymorphic pattern matching
Expands each pattern into basic PVars to attempt to recover polymorphis
through the same mechanism. Need to test further.
2013-07-16 21:46:06 +02:00
Evan Czaplicki
3bb618bcde Provide the type *and definition* for data constructurs during type checking 2013-07-16 21:44:41 +02:00
Evan Czaplicki
82983a6f24 Update more modules to use the MetadataModule data structure 2013-07-16 21:43:56 +02:00
Evan Czaplicki
8145e600fc Create MetadataModule for more refined information about modules
Used in most places to break a module into more orthogonal components.
Some of this data needs to be serialized into the interface files.
2013-07-16 21:42:37 +02:00
Evan Czaplicki
621a9c2d2e Add a way to flatten lets that have become nested 2013-07-16 21:40:11 +02:00
Evan Czaplicki
0cfae2e43b More specific imports 2013-07-16 21:38:43 +02:00
Evan Czaplicki
640f98e7d5 Rename functions and modules 2013-07-16 21:38:20 +02:00
Evan Czaplicki
1ffaad1f5c Create an isOp function for strings. 2013-07-16 21:37:48 +02:00
Evan Czaplicki
91be5a0c03 Rename the parser. 2013-07-16 16:02:04 +02:00
Evan Czaplicki
025b7a1ea4 Update changelog with latest parser improvements. 2013-07-16 14:58:02 +02:00
Evan Czaplicki
ce357b3d0d Switch to reporting errors with [Doc] for prettier layout. 2013-07-16 14:52:50 +02:00
Evan Czaplicki
1c9da4bf9c Force whitespace between number and operator in infix declarations. 2013-07-16 14:50:35 +02:00
Evan Czaplicki
8590c6bd18 Add parsing for infix declarations. No support for actually using this
information though.
2013-07-16 14:39:58 +02:00
Evan Czaplicki
72bd5cb8eb Clean out this file, getting rid of dead code and adding some types. 2013-07-16 14:39:26 +02:00
Evan Czaplicki
a5bc960067 Minor cosmetic changes 2013-07-16 00:40:11 +02:00
Evan Czaplicki
67ef1ec77b Create the Type.Inference module which handles type inference from
start to finish. Give it a Module and it returns a dictionary mapping
top-level values to types.
2013-07-16 00:38:31 +02:00
Evan Czaplicki
18adffc06d Turn unary negation back on. 2013-07-16 00:36:34 +02:00
Evan Czaplicki
90d50dbb13 Turn off unary negation parsing for now. It has weird behavior when
paired with function calls:

  (- sqrt 9)   -- parse error
  (-sqrt 9)    -- type error, cannot negate function
  -(sqrt 9)    -- this works
  - (sqrt 9)   -- parse error
  - sqrt 9     -- parse error
2013-07-15 12:22:04 +02:00
Evan Czaplicki
2b9886336f Fix parsing of unary negation when it is the first thing in parentheses. 2013-07-15 11:53:53 +02:00
Evan Czaplicki
93a948cd67 Add back in checks for duplicate and out-of-order definitions. 2013-07-15 01:06:00 +02:00
Evan Czaplicki
1fcb01f743 Finish switching over to '_Tuple' format for tuples. 2013-07-15 01:05:14 +02:00
Evan Czaplicki
0070a844d0 Switch the internal data constructor name for tuples. Before tuple
constructors could be shadowed by user defined ADT's such as "Tuple0",
"Tuple2", etc. Now it uses "_Tuple0" to make it impossible to overlap
with user defined ASTs.
2013-07-14 19:52:50 +02:00
Evan Czaplicki
e7b949df9b Begin adding testing framework to .cabal file. 2013-07-14 19:51:52 +02:00
Evan Czaplicki
003ebfd309 Add new syntax to the changelog 2013-07-14 19:41:09 +02:00
Evan Czaplicki
343dcf2250 Add support for unary negation with the '-' symbol. Makes the use of
'-' whitespace sensitive, as in the unary negation proposal in
elm-discuss.

f -1  == f (0-1)
x - 1 == (x-1)
x-1   == (x-1)
2013-07-14 17:55:38 +02:00
Evan Czaplicki
08ff939174 Be more flexible with the position of the closing bracket of a record type. 2013-07-14 14:55:29 +02:00
Evan Czaplicki
fe7357a0b5 Export boundVars function, which is currently reeded to generate JS. 2013-07-14 01:41:52 +02:00
Evan Czaplicki
87d2f8d57d Get declarations parsing properly. The definition parser needs to be
the last option.
2013-07-14 01:41:03 +02:00
Evan Czaplicki
2b9853ce9b Get variable reordering working for Declarations. 2013-07-13 13:44:40 +02:00
Evan Czaplicki
fe23c0e66d fix pretty printer for chars 2013-07-13 01:05:48 +02:00
Evan Czaplicki
7f433922ed Create module to sort let-blocks into "strongly connected components".
This does two things:

  * makes it possible to automatically generalize functions without
    bothering the programmer about managing dependencies.

  * sorts values such that they'll be defined in the appropriate order
    when they are mapped down to JavaScript.
2013-07-12 22:24:12 +02:00
Evan Czaplicki
433b533f4d Update tests to be actual programs, not just expressions. Content
stays the same.
2013-07-12 16:32:53 +02:00
Evan Czaplicki
a6bfa5f261 Add some basic test files for the type checker. 2013-07-12 16:32:02 +02:00
Evan Czaplicki
4d7562f317 Begin generating constraints for whole programs. Need to perform
dependency sort within let-expressions for things to work properly though.
2013-07-12 16:21:07 +02:00
Evan Czaplicki
4208b5c9de Remove some debugging stuff and generally clean up the code.
There was one potential error in which a debug needed to be a liftIO,
the computation it performed was not optional.
2013-07-12 11:05:03 +02:00
Evan Czaplicki
b0387821b4 Fix error in generalization in which some variables would escape their
rank. Problem was that young variables were not all being marked as
young.

This resolved a soundness issue described in the post on
"How OCaml type checker works".
2013-07-12 11:00:35 +02:00
Evan Czaplicki
dabada1d98 Make constraint pretty printing prettier. 2013-07-11 23:30:18 +02:00
Evan Czaplicki
cb914d91ff Get all of the Haskell files compiling with the new type checker.
Does not actually work, undefined is used in some places as a
stopgap measure.
2013-07-11 12:48:37 +02:00
Evan Czaplicki
abaa76943e Add Max's server changes to the changelog. 2013-07-11 12:17:49 +02:00
Evan Czaplicki
ca77056fc9 Improve quality of error messages. 2013-07-11 00:31:56 +02:00
Evan Czaplicki
d3bd238663 Add dependency on ansi-terminal for colorful results. 2013-07-10 14:33:54 +02:00
Evan Czaplicki
b5887f41c9 Get type inference working in the basic case. Begin working on
printing errors in a prettier way.
2013-07-10 14:31:57 +02:00
Evan Czaplicki
f87e316847 Make pretty printing properly parenthesize higher order functions.
Not the best implementation, but it is simple and works well.
2013-07-09 21:59:58 +02:00
Evan Czaplicki
497d478d26 Get the solver working on basic programs. It outputs pretty types for the
variables in the program. Need to test further and start doing some benchmarking.
2013-07-09 21:52:05 +02:00
Evan Czaplicki
ca62ee64a9 Create type pools, have an organized model of state to flow through
the State Transformer during constraint solving and variable unification.
2013-07-09 10:25:50 +02:00