pietervdvn / Lang

Yet another programming language
1 stars 1 forks source link

Test supertype and bind #74

Closed pietervdvn closed 9 years ago

pietervdvn commented 9 years ago

Please test supertype and bind.

How?

cd SemanticAnalysis
ghci Languate/MaintenanceAccess/TestSuperType.hs

Now, type supers "List a" to see all the supertypes of List a", being {Collection a, Monoid, Mappable} (and more)

Type bind "List Nat" "List a" to see the binding calculated or a error message if binding failed.

Consult the list of types, especially the supertypetable

What is binding?

plusOne : Nat -> Nat
map : (a -> b) -> (functor:Functor) a -> functor b

When the type of map plusOne gets calculated, the type of plusOne gets "plugged" into (a -> b). We can deduce from this that a should be bound to Nat and that b should be bound to Nat.

The expected result from bnd "Nat -> Nat" "a -> b" should thus be { a --> Nat, b --> Nat}.

We can then further substitute this binding in the rest of the type expression:

:t map plusOne = (functor:Functor) Nat -> functor Nat

How to report?

Experiment at will!

If you get a faulty result, please report here. If you modify the source code (workspace/Data/src), please commit and push if it is usefull code; if these are toys and only for testing, make a new branch.

TODO