diff options
author | Eduardo Julian | 2017-09-05 18:36:09 -0400 |
---|---|---|
committer | Eduardo Julian | 2017-09-05 18:36:09 -0400 |
commit | 50cc5fbe7cc8abde05085944393fcec4c791402f (patch) | |
tree | da706b648b3bb5e0485475a81d5b4da242aa04f5 /new-luxc/source/luxc/analyser/structure.lux | |
parent | 3add4d6996591897020236b5581f6ca21d4c2af8 (diff) |
- Updated new compiler's code to the recent changes in the language.
- WIP: Some other changes/additions to the new compiler.
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/analyser/structure.lux | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/new-luxc/source/luxc/analyser/structure.lux b/new-luxc/source/luxc/analyser/structure.lux index 267dfec84..ad7ad2a7a 100644 --- a/new-luxc/source/luxc/analyser/structure.lux +++ b/new-luxc/source/luxc/analyser/structure.lux @@ -1,6 +1,6 @@ (;module: lux - (lux (control monad + (lux (control [monad #+ do] pipe) [io #- run] [function] @@ -154,8 +154,8 @@ (analyse-product analyse membersC))) ## Must do inference... (do @ - [membersTA (mapM @ (|>. analyse &common;with-unknown-type) - membersC) + [membersTA (monad;map @ (|>. analyse &common;with-unknown-type) + membersC) _ (&;within-type-env (TC;check expected (type;tuple (L/map product;left membersTA))))] @@ -198,17 +198,17 @@ ## canonical form (with their corresponding module identified). (def: #export (normalize record) (-> (List [Code Code]) (Lux (List [Ident Code]))) - (mapM Monad<Lux> - (function [[key val]] - (case key - [_ (#;Tag key)] - (do Monad<Lux> - [key (macro;normalize key)] - (wrap [key val])) + (monad;map Monad<Lux> + (function [[key val]] + (case key + [_ (#;Tag key)] + (do Monad<Lux> + [key (macro;normalize key)] + (wrap [key val])) - _ - (&;fail (format "Cannot use non-tag tokens in key positions in records: " (%code key))))) - record)) + _ + (&;fail (format "Cannot use non-tag tokens in key positions in records: " (%code key))))) + record)) ## Lux already possesses the means to analyse tuples, so ## re-implementing the same functionality for records makes no sense. @@ -234,22 +234,22 @@ "For type: " (%type recordT)))) #let [tuple-range (list;n.range +0 (n.dec size-ts)) tag->idx (D;from-list ident;Hash<Ident> (list;zip2 tag-set tuple-range))] - idx->val (foldM @ - (function [[key val] idx->val] - (do @ - [key (macro;normalize key)] - (case (D;get key tag->idx) - #;None - (&;fail (format "Tag " (%code (code;tag key)) - " does not belong to tag-set for type " (%type recordT))) + idx->val (monad;fold @ + (function [[key val] idx->val] + (do @ + [key (macro;normalize key)] + (case (D;get key tag->idx) + #;None + (&;fail (format "Tag " (%code (code;tag key)) + " does not belong to tag-set for type " (%type recordT))) - (#;Some idx) - (if (D;contains? idx idx->val) - (&;fail (format "Cannot repeat tag inside record: " (%code (code;tag key)))) - (wrap (D;put idx val idx->val)))))) - (: (D;Dict Nat Code) - (D;new number;Hash<Nat>)) - record) + (#;Some idx) + (if (D;contains? idx idx->val) + (&;fail (format "Cannot repeat tag inside record: " (%code (code;tag key)))) + (wrap (D;put idx val idx->val)))))) + (: (D;Dict Nat Code) + (D;new number;Hash<Nat>)) + record) #let [ordered-tuple (L/map (function [idx] (assume (D;get idx idx->val))) tuple-range)]] (wrap [ordered-tuple recordT])) |