From 50cc5fbe7cc8abde05085944393fcec4c791402f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 5 Sep 2017 18:36:09 -0400 Subject: - Updated new compiler's code to the recent changes in the language. - WIP: Some other changes/additions to the new compiler. --- new-luxc/source/luxc/analyser/structure.lux | 56 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'new-luxc/source/luxc/analyser/structure.lux') 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 - (function [[key val]] - (case key - [_ (#;Tag key)] - (do Monad - [key (macro;normalize key)] - (wrap [key val])) + (monad;map Monad + (function [[key val]] + (case key + [_ (#;Tag key)] + (do Monad + [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 (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)) - 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)) + record) #let [ordered-tuple (L/map (function [idx] (assume (D;get idx idx->val))) tuple-range)]] (wrap [ordered-tuple recordT])) -- cgit v1.2.3