Skip to content

Commit 626a09c

Browse files
committed
A tiny working compilation!
1 parent d087814 commit 626a09c

14 files changed

+1115
-98
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Thumbs.db
1818
# Test files
1919
/test.purs
2020
*.purs.bak
21+
/output

src/codegen/js.rs

Lines changed: 527 additions & 45 deletions
Large diffs are not rendered by default.

src/typechecker/check.rs

Lines changed: 367 additions & 33 deletions
Large diffs are not rendered by default.

src/typechecker/infer.rs

Lines changed: 144 additions & 15 deletions
Large diffs are not rendered by default.

tests/codegen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ codegen_test_multi!(codegen_operator_module_reexport, "OperatorModuleReexport",
237237
codegen_test_multi!(codegen_superclass_dict, "SuperclassDict", "TestSuperclass.purs", ["MyFunctor.purs", "MyApply.purs", "TestSuperclass.purs"]);
238238
codegen_test!(codegen_call_site_dict_passing, "CallSiteDictPassing");
239239
codegen_test_multi!(codegen_superclass_dict_deep, "SuperclassDictDeep", "TestDeep.purs", ["MyFunctor.purs", "MyApply.purs", "MyAlternative.purs", "MyPrelude.purs", "TestDeep.purs"]);
240+
codegen_test_multi!(codegen_method_constraints, "MethodConstraints", "MyEq1.purs", ["MyEq.purs", "MyEq1.purs", "TestMethodConstraints.purs"]);
240241

241242
// ===== Node.js execution tests =====
242243
// These tests verify that the generated JS actually runs correctly by executing
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module MyEq where
2+
3+
class MyEq a where
4+
myEq :: a -> a -> Boolean
5+
6+
instance myEqInt :: MyEq Int where
7+
myEq x y = true
8+
9+
instance myEqArray :: MyEq a => MyEq (Array a) where
10+
myEq xs ys = true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module MyEq1 where
2+
3+
import MyEq (class MyEq, myEq)
4+
5+
class MyEq1 f where
6+
myEq1 :: forall a. MyEq a => f a -> f a -> Boolean
7+
8+
instance myEq1Array :: MyEq1 Array where
9+
myEq1 = myEq
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module TestMethodConstraints where
2+
3+
import MyEq (class MyEq)
4+
import MyEq1 (class MyEq1, myEq1)
5+
6+
-- Use eq1 in a constrained function to verify dict passing works
7+
testEq1 :: forall a. MyEq a => Array a -> Array a -> Boolean
8+
testEq1 xs ys = myEq1 xs ys

tests/snapshots/codegen__codegen_CallSiteDictPassing.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ var wrapper = function(dictMyShow) {
1414
};
1515
};
1616

17+
var myShow = function(dict) {
18+
return dict.myShow;
19+
};
20+
1721

18-
export { myShowThing, wrapper };
22+
export { myShow, myShowThing, wrapper };

tests/snapshots/codegen__codegen_ConstrainedFunctions.snap

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ var describeTwo = function(dictDescribable) {
1818
};
1919
};
2020

21+
var describe = function(dict) {
22+
return dict.describe;
23+
};
24+
25+
var myEq = function(dict) {
26+
return dict.myEq;
27+
};
28+
2129
var describableBool = {
2230
describe: function($arg0_1) {
2331
if ($arg0_1 === true) {
@@ -45,4 +53,4 @@ var myEqInt = {
4553
};
4654

4755

48-
export { describableBool, describableInt, describeTwo, myEqInt, showDesc };
56+
export { describableBool, describableInt, describe, describeTwo, myEq, myEqInt, showDesc };

0 commit comments

Comments
 (0)