Commit Graph

1659 Commits

Author SHA1 Message Date
Neil Brown
8cc602100d Added code to replace the unknown types with their deduced values after type unification 2008-05-18 11:34:26 +00:00
Neil Brown
ec5baf4e97 Stopped the Rain parser using any as a placeholder, and switched to using the unknown types 2008-05-18 11:34:05 +00:00
Neil Brown
760c8a9a1e Added marking up of types in foreach replicators for type unification 2008-05-18 11:13:48 +00:00
Neil Brown
0c443255e6 Changed the expression types to use type unification, and removed the old test
The new behaviour is to check that both sides of a dyadic operator have the same type.  This means that multiplying time by a scalar is no longer possible, but it also means (due to the lack of checks after unification) that multiplying two lists is possible, or concatenating two integers.  This needs to be fixed by adding another pass.
2008-05-18 10:30:25 +00:00
Neil Brown
6758cd7da3 Changed the list concatenation operator to be ++ in Rain 2008-05-18 10:30:17 +00:00
Neil Brown
46aa0383be Removed some unused functions from RainTypes 2008-05-18 09:52:50 +00:00
Neil Brown
4586cdd43a Added an export list to RainTypes, and removed some tests for old passes 2008-05-18 09:49:11 +00:00
Neil Brown
f79cba0616 Changed the parameter type checking to use type unification 2008-05-18 09:43:12 +00:00
Neil Brown
7bbfab34a0 Added simple instances of the Typed class for actuals and formals 2008-05-18 09:42:51 +00:00
Neil Brown
ecb4758b64 Corrected a slight bug in the type tests 2008-05-18 09:34:04 +00:00
Neil Brown
fb090a3618 Hacked the ShowCode module quickly to display a lot more Rain code (stealing from the occam stuff, and twiddling it slightly) 2008-05-17 22:21:18 +00:00
Neil Brown
90986ea97b Added a backend that prints out the AST as source (rather than dumping the raw AST) 2008-05-17 22:20:38 +00:00
Neil Brown
e53fda754e Fixed the Rain passes so the the alphabet test case now works (at least) 2008-05-17 20:51:42 +00:00
Neil Brown
1e5268dea5 Fixed the types that are definitely known (declarations, etc) so that they are available during type unification 2008-05-17 19:48:48 +00:00
Neil Brown
bf07c441ae Changed the communication type checking to be part of the type unification framework 2008-05-17 19:47:47 +00:00
Neil Brown
1115364d47 Changed TypeExp to stop using Data.Generics (which was getting awkward)
Instead of storing the Constr, which was messy, we now store a String (to allow comparison of constructor types during unification) and a function to reform the type at the end of the type checking.
2008-05-17 19:44:45 +00:00
Neil Brown
abbca5f235 Added tests for channel communications (and type unification) 2008-05-17 19:43:44 +00:00
Neil Brown
ddb9ba2fd3 Corrected a bug in unifyArgs where errors that occur while processing arguments were being ignored 2008-05-17 19:42:49 +00:00
Neil Brown
e72e537c47 Added a missing line in the Makefile for UnifyType 2008-05-17 16:55:04 +00:00
Neil Brown
ab0301a342 Made the Rain parser actually record an unknown (to-be-inferred) type for numeric literals 2008-05-17 14:24:45 +00:00
Neil Brown
cd0c8d2901 Added assignments to the new type unification system for Rain 2008-05-17 14:23:31 +00:00
Neil Brown
1e6ae6bff9 Improved the error messages when the type unification fails 2008-05-17 14:23:00 +00:00
Neil Brown
f10cb7d525 Moved the TypeExp type out to its own module, UnifyType 2008-05-17 14:21:57 +00:00
Neil Brown
0aeebfeeb8 Added more tests for the Rain type system, this time assignment 2008-05-17 14:19:50 +00:00
Neil Brown
3249381995 Added a Rain test file for the type checker 2008-05-17 13:17:12 +00:00
Neil Brown
7d65db43c0 Changed TestHarness to support Rain test files as well as occam 2008-05-17 13:13:52 +00:00
Neil Brown
63a28d0044 Changed the conditionals type-checking to use type unification rather than the old system 2008-05-17 12:53:05 +00:00
Neil Brown
f8b7e8f8cb Added unifying-related items to CompState, and changed all the uses of ST to IO in the TypeUnification module
As part of this patch I also had to provide a Data instance for TypeExp (to allow CompState to still be an instance of Data).  Using IORefs is easier than STRef RealWorld, and puts everything in terms of IO (which is already in PassM) rather than ST (which would require more lifting).
2008-05-17 12:50:52 +00:00
Neil Brown
e6162877af Changed the AST to fix the different unknown/inferred types
The Infer type (used by the occam frontend) is now separated from the "Unknown" types used in type unification that I'm experimenting with in Rain.
2008-05-17 12:47:31 +00:00
Neil Brown
e72e95625a Added a checkDepthM2 function to the Traversal module 2008-05-17 12:44:55 +00:00
Neil Brown
875cf4b40a Provided slightly better error messages from the type unification module 2008-05-14 12:18:58 +00:00
Neil Brown
e843ce5022 Added a mapMapWithKeyM function to Utils, and cleaned up some of the whitespace 2008-05-14 12:18:27 +00:00
Neil Brown
e3bf321f33 Made the key type in the type unification generic (as long as it provides Ord and Show) 2008-05-14 12:06:11 +00:00
Neil Brown
e09fb2b9ec Added support for numeric literals in the type inference algorithm 2008-05-14 12:01:32 +00:00
Neil Brown
962c1477b9 Added a special type for marking the type of numeric literals to be inferred later 2008-05-14 11:59:33 +00:00
Neil Brown
ed9c92878a Added a helper function to RainTypesTest to make the unification tests shorter 2008-05-14 10:09:42 +00:00
Neil Brown
9f1d65f4a0 Added more tests for type unification, fixed some bugs and added cleaner error handling 2008-05-14 09:52:16 +00:00
Neil Brown
e3fa3df623 Added a module for doing type unification, and some very basic tests for it 2008-05-13 23:25:42 +00:00
Neil Brown
3ca4ee1a5e Added a new helper function to Utils for transforming Map values monadically 2008-05-13 23:24:43 +00:00
Neil Brown
89c25e3f6c Added a type-class for retrieving the (AST) type of things
This patch hides all the old typeOfExpression, typeOfName, typeOfVariable, etc, and unifies them into a single type-class with an "astTypeOf" function.  The type-class is currently named Typed, but that can easily be changed (it's only explicitly referred to in the Types module).  The patch is essentially the type-class with a giant find-and-replace on the other modules.
2008-05-17 11:41:52 +00:00
Neil Brown
3daf82d318 Merged Alternative and AlternativeCond into a single Alternative item that always has a pre-condition 2008-04-03 14:52:37 +00:00
Adam Sampson
04da66531f Fix nesting.occ so it has a valid TLP signature. 2008-05-15 12:23:44 +00:00
Adam Sampson
0106e6bbb7 Fix the page size in the Tock logo.
This makes it render properly in things other than Inkscape; previously the
logo was drawn outside the page area.
2008-05-14 23:22:50 +00:00
Adam Sampson
7a7e3e2b24 Make GenNavAST generate instances of a "Polyplate" class.
This provides transformM, which we can build applyX (etc.) on top of:
it takes a set of functions, and applies them wherever they could
match in a data structure, without automatically recursing. This is
done using a four(!)-argument typeclass, drawing inspiration from
Biplate.

The resulting 25,000-line set of instances takes a little while to
compile...
2008-05-10 16:27:46 +00:00
Adam Sampson
058a3488d9 Generate instances of a Navigable class.
This isn't immediately useful, but I plan to build on it.
2008-05-09 15:46:18 +00:00
Adam Sampson
710be039cb Have the pregen programs figure out the types using generics.
Previously they had a list of the types they needed to generate
instances for.  This patch adds some helper code that can be used to
list all the AST.* types in the AST automatically. The result is that we
should be able to add new types to the AST without needing to change the
generator code.

This also means that GenOrdAST is now generating *all* the instances of
Ord for the AST; previously the trivial ones were derived by the
compiler.
2008-05-09 14:02:13 +00:00
Adam Sampson
9f172865ff Move DataBox into Utils.
AnyDataItem is effectively the same, so we could reuse DataBox for that
too in the future.
2008-05-09 09:50:42 +00:00
Adam Sampson
9c77aed7b3 Move Gen* into their own directory. 2008-05-09 09:36:45 +00:00
Adam Sampson
8babfb2911 Remove profiling options added by mistake. 2008-05-09 09:36:29 +00:00
Adam Sampson
06296276a4 Use unlines in GenOrdAST too. 2008-05-08 20:45:48 +00:00