From 303c462daf461c20f41edba3d0921062c8535fda Mon Sep 17 00:00:00 2001
From: Eduardo Julian
Date: Thu, 4 Jan 2018 23:59:40 -0400
Subject: - Fixed inference involving existentials.
---
new-luxc/source/luxc/lang/analysis/inference.lux | 27 +++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
(limited to 'new-luxc/source/luxc/lang')
diff --git a/new-luxc/source/luxc/lang/analysis/inference.lux b/new-luxc/source/luxc/lang/analysis/inference.lux
index 881eee4a6..3919ff78d 100644
--- a/new-luxc/source/luxc/lang/analysis/inference.lux
+++ b/new-luxc/source/luxc/lang/analysis/inference.lux
@@ -60,6 +60,17 @@
_
type))
+(def: new-named-type
+ (Meta Type)
+ (do macro.Monad
+ [[_module _line _column] macro.cursor
+ [ex-id exT] (&.with-type-env tc.existential)]
+ (wrap (#.Primitive (format "{New Type @ " (%t _module)
+ "," (%n _line)
+ "," (%n _column)
+ "} " (%n ex-id))
+ (list)))))
+
## Type-inference works by applying some (potentially quantified) type
## to a sequence of values.
## Function types are used for this, although inference is not always
@@ -87,9 +98,19 @@
(#.ExQ _)
(do macro.Monad
- [[ex-id exT] (&.with-type-env
- tc.existential)]
- (general analyse (maybe.assume (type.apply (list exT) inferT)) args))
+ [[var-id varT] (&.with-type-env tc.var)
+ output (general analyse
+ (maybe.assume (type.apply (list varT) inferT))
+ args)
+ bound? (&.with-type-env
+ (tc.bound? var-id))
+ _ (if bound?
+ (wrap [])
+ (do @
+ [newT new-named-type]
+ (&.with-type-env
+ (tc.check varT newT))))]
+ (wrap output))
(#.Apply inputT transT)
(case (type.apply (list inputT) transT)
--
cgit v1.2.3