diff options
author | Eduardo Julian | 2017-11-14 01:14:26 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-11-14 01:14:26 -0400 |
commit | 290c2389bc762dfaf625d72a76a675ce15119985 (patch) | |
tree | c0eba13fc1de598b629752d2d7ab9760568fd059 /new-luxc/source/luxc/lang/analysis/structure.lux | |
parent | 530a14bfe7714f94babdb34c237b88321408a685 (diff) |
- Yet more refactoring.
Diffstat (limited to 'new-luxc/source/luxc/lang/analysis/structure.lux')
-rw-r--r-- | new-luxc/source/luxc/lang/analysis/structure.lux | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/new-luxc/source/luxc/lang/analysis/structure.lux b/new-luxc/source/luxc/lang/analysis/structure.lux index e1f4de1d7..1f1ef15d7 100644 --- a/new-luxc/source/luxc/lang/analysis/structure.lux +++ b/new-luxc/source/luxc/lang/analysis/structure.lux @@ -1,17 +1,13 @@ (;module: lux (lux (control [monad #+ do] - ["ex" exception #+ exception:] - pipe) - [function] - (concurrency ["A" atom]) + ["ex" exception #+ exception:]) (data [ident] [number] [product] [maybe] (coll [list "list/" Functor<List>] [dict #+ Dict]) - [text] text/format) [meta] (meta [code] @@ -63,20 +59,21 @@ (#;Var id) (do @ - [concrete? (&;with-type-env - (tc;concrete? id))] - (if concrete? - (do @ - [expectedT' (&;with-type-env - (tc;read id))] - (&;with-expected-type expectedT' - (analyse-sum analyse tag valueC))) + [?expectedT' (&;with-type-env + (tc;read id))] + (case ?expectedT' + (#;Some expectedT') + (&;with-expected-type expectedT' + (analyse-sum analyse tag valueC)) + + _ ## Cannot do inference when the tag is numeric. ## This is because there is no way of knowing how many ## cases the inferred sum type would have. (&;throw Cannot-Infer-Numeric-Tag (format " Tag: " (%n tag) "\n" "Value: " (%code valueC) "\n" - " Type: " (%type expectedT))))) + " Type: " (%type expectedT))) + )) (^template [<tag> <instancer>] (<tag> _) @@ -166,14 +163,14 @@ (#;Var id) (do @ - [concrete? (&;with-type-env - (tc;concrete? id))] - (if concrete? - (do @ - [expectedT' (&;with-type-env - (tc;read id))] - (&;with-expected-type expectedT' - (analyse-product analyse membersC))) + [?expectedT' (&;with-type-env + (tc;read id))] + (case ?expectedT' + (#;Some expectedT') + (&;with-expected-type expectedT' + (analyse-product analyse membersC)) + + _ ## Must do inference... (do @ [membersTA (monad;map @ (|>. analyse &common;with-unknown-type) |