diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/lux.lux | 489 |
1 files changed, 234 insertions, 255 deletions
diff --git a/source/lux.lux b/source/lux.lux index 4120b262c..7c5fd5c8d 100644 --- a/source/lux.lux +++ b/source/lux.lux @@ -11,51 +11,50 @@ ("apply" ["java.lang.Object"] "java.lang.Object" ["public" "abstract"])) ## Basic types -(_lux_def Bool (9 ["lux" "Bool"] - (0 "java.lang.Boolean"))) +(_lux_def Bool (11 ["lux" "Bool"] + (4 "java.lang.Boolean"))) (_lux_export Bool) -(_lux_def Int (9 ["lux" "Int"] - (0 "java.lang.Long"))) +(_lux_def Int (11 ["lux" "Int"] + (4 "java.lang.Long"))) (_lux_export Int) -(_lux_def Real (9 ["lux" "Real"] - (0 "java.lang.Double"))) +(_lux_def Real (11 ["lux" "Real"] + (4 "java.lang.Double"))) (_lux_export Real) -(_lux_def Char (9 ["lux" "Char"] - (0 "java.lang.Character"))) +(_lux_def Char (11 ["lux" "Char"] + (4 "java.lang.Character"))) (_lux_export Char) -(_lux_def Text (9 ["lux" "Text"] - (0 "java.lang.String"))) +(_lux_def Text (11 ["lux" "Text"] + (4 "java.lang.String"))) (_lux_export Text) -(_lux_def Unit (9 ["lux" "Unit"] - (2 (0)))) -(_lux_export Unit) - -(_lux_def Void (9 ["lux" "Void"] - (1 (0)))) +(_lux_def Void (11 ["lux" "Void"] + (0 []))) (_lux_export Void) -(_lux_def Ident (9 ["lux" "Ident"] - (2 (1 Text (1 Text (0)))))) +(_lux_def Unit (11 ["lux" "Unit"] + (1 []))) +(_lux_export Unit) + +(_lux_def Ident (11 ["lux" "Ident"] + (3 Text Text))) (_lux_export Ident) ## (deftype (List a) ## (| #Nil ## (#Cons a (List a)))) (_lux_def List - (9 ["lux" "List"] - (7 (1 (0)) "lux;List" "a" - (1 (1 ## "lux;Nil" - (2 (0)) - (1 ## "lux;Cons" - (2 (1 (4 "a") - (1 (8 (4 "lux;List") (4 "a")) - (0)))) - (0))))))) + (11 ["lux" "List"] + (9 (1 (0)) "lux;List" "a" + (2 ## "lux;Nil" + Unit + ## "lux;Cons" + (3 (6 "a") + (10 (6 "lux;List") (6 "a"))) + )))) (_lux_export List) (_lux_declare-tags [#Nil #Cons] List) @@ -63,76 +62,78 @@ ## (| #None ## (1 a))) (_lux_def Maybe - (9 ["lux" "Maybe"] - (7 (1 (0)) "lux;Maybe" "a" - (1 (1 ## "lux;None" - (2 (0)) - (1 ## "lux;Some" - (4 "a") - (0))))))) + (11 ["lux" "Maybe"] + (9 (1 (0)) "lux;Maybe" "a" + (2 ## "lux;None" + Unit + ## "lux;Some" + (6 "a") + )))) (_lux_export Maybe) (_lux_declare-tags [#None #Some] Maybe) ## (deftype #rec Type -## (| (#DataT Text) -## (#VariantT (List Type)) -## (#TupleT (List Type)) +## (| #VoidT +## #UnitT +## (#SumT Type Type) +## (#ProdT Type Type) +## (#DataT Text) ## (#LambdaT Type Type) ## (#BoundT Text) ## (#VarT Int) +## (#ExT Int) ## (#AllT (Maybe (List (, Text Type))) Text Text Type) ## (#AppT Type Type) ## (#NamedT Ident Type) -## )) +## )) (_lux_def Type - (9 ["lux" "Type"] - (_lux_case (8 (4 "Type") (4 "_")) - Type - (_lux_case (8 List (2 (1 Text (1 Type (0))))) - TypeEnv - (_lux_case (8 List Type) - TypeList - (8 (7 (1 (0)) "Type" "_" - (1 (1 ## "lux;DataT" - Text - (1 ## "lux;VariantT" - TypeList - (1 ## "lux;TupleT" - TypeList - (1 ## "lux;LambdaT" - (2 (1 Type (1 Type (0)))) - (1 ## "lux;BoundT" - Text - (1 ## "lux;VarT" + (11 ["lux" "Type"] + (_lux_case (10 (6 "Type") (6 "_")) + Type + (_lux_case (10 List (3 Text Type)) + TypeEnv + (10 (9 (1 (0)) "Type" "_" + (2 ## lux;VoidT + Unit + (2 ## lux;UnitT + Unit + (2 ## lux;SumT + (3 Type Type) + (2 ## lux;ProdT + (3 Type Type) + (2 ## "lux;DataT" + Text + (2 ## "lux;LambdaT" + (3 Type Type) + (2 ## "lux;BoundT" + Text + (2 ## "lux;VarT" + Int + (2 ## "lux;ExT" Int - (1 ## "lux;ExT" - Int - (1 ## "lux;AllT" - (2 (1 (8 Maybe TypeEnv) (1 Text (1 Text (1 Type (0)))))) - (1 ## "lux;AppT" - (2 (1 Type (1 Type (0)))) - (1 ## "lux;NamedT" - (2 (1 Ident (1 Type (0)))) - (0))))))))))))) - Void)))))) + (2 ## "lux;AllT" + (3 (10 Maybe TypeEnv) (3 Text (3 Text Type))) + (2 ## "lux;AppT" + (3 Type Type) + ## "lux;NamedT" + (3 Ident Type))))))))))))) + Void))))) (_lux_export Type) -(_lux_declare-tags [#DataT #VariantT #TupleT #LambdaT #BoundT #VarT #ExT #AllT #AppT #NamedT] Type) +(_lux_declare-tags [#VoidT #UnitT #SumT #ProdT #DataT #LambdaT #BoundT #VarT #ExT #AllT #AppT #NamedT] Type) ## (deftype (Bindings k v) ## (& #counter Int ## #mappings (List (, k v)))) (_lux_def Bindings (#NamedT ["lux" "Bindings"] - (#AllT [(#Some #Nil) "lux;Bindings" "k" - (#AllT [#None "" "v" - (#TupleT (#Cons ## "lux;counter" - Int - (#Cons ## "lux;mappings" - (#AppT [List - (#TupleT (#Cons [(#BoundT "k") - (#Cons [(#BoundT "v") - #Nil])]))]) - #Nil)))])]))) + (#AllT (#Some #Nil) "lux;Bindings" "k" + (#AllT #None "" "v" + (#ProdT ## lux;counter + Int + ## lux;mappings + (#AppT List + (#ProdT (#BoundT "k") + (#BoundT "v")))))))) (_lux_export Bindings) (_lux_declare-tags [#counter #mappings] Bindings) @@ -145,17 +146,16 @@ (#NamedT ["lux" "Env"] (#AllT (#Some #Nil) "lux;Env" "k" (#AllT #None "" "v" - (#TupleT (#Cons ## "lux;name" - Text - (#Cons ## "lux;inner-closures" - Int - (#Cons ## "lux;locals" - (#AppT (#AppT Bindings (#BoundT "k")) - (#BoundT "v")) - (#Cons ## "lux;closure" - (#AppT (#AppT Bindings (#BoundT "k")) - (#BoundT "v")) - #Nil))))))))) + (#ProdT ## "lux;name" + Text + (#ProdT ## "lux;inner-closures" + Int + (#ProdT ## "lux;locals" + (#AppT (#AppT Bindings (#BoundT "k")) + (#BoundT "v")) + ## "lux;closure" + (#AppT (#AppT Bindings (#BoundT "k")) + (#BoundT "v"))))))))) (_lux_export Env) (_lux_declare-tags [#name #inner-closures #locals #closure] Env) @@ -163,7 +163,7 @@ ## (, Text Int Int)) (_lux_def Cursor (#NamedT ["lux" "Cursor"] - (#TupleT (#Cons Text (#Cons Int (#Cons Int #Nil)))))) + (#ProdT Text (#ProdT Int Int)))) (_lux_export Cursor) ## (deftype (Meta m v) @@ -172,13 +172,9 @@ (#NamedT ["lux" "Meta"] (#AllT (#Some #Nil) "lux;Meta" "m" (#AllT #None "" "v" - (#VariantT (#Cons ## "lux;Meta" - (#TupleT (#Cons (#BoundT "m") - (#Cons (#BoundT "v") - #Nil))) - #Nil)))))) + (#ProdT (#BoundT "m") + (#BoundT "v")))))) (_lux_export Meta) -(_lux_declare-tags [#Meta] Meta) ## (deftype (AST' w) ## (| (#BoolS Bool) @@ -200,29 +196,28 @@ (_lux_case (#AppT [List AST]) ASTList (#AllT (#Some #Nil) "lux;AST'" "w" - (#VariantT (#Cons ## "lux;BoolS" - Bool - (#Cons ## "lux;IntS" - Int - (#Cons ## "lux;RealS" - Real - (#Cons ## "lux;CharS" - Char - (#Cons ## "lux;TextS" - Text - (#Cons ## "lux;SymbolS" - Ident - (#Cons ## "lux;TagS" - Ident - (#Cons ## "lux;FormS" - ASTList - (#Cons ## "lux;TupleS" - ASTList - (#Cons ## "lux;RecordS" - (#AppT List (#TupleT (#Cons AST (#Cons AST #Nil)))) - #Nil) - ))))))))) - )))))) + (#SumT ## "lux;BoolS" + Bool + (#SumT ## "lux;IntS" + Int + (#SumT ## "lux;RealS" + Real + (#SumT ## "lux;CharS" + Char + (#SumT ## "lux;TextS" + Text + (#SumT ## "lux;SymbolS" + Ident + (#SumT ## "lux;TagS" + Ident + (#SumT ## "lux;FormS" + ASTList + (#SumT ## "lux;TupleS" + ASTList + ## "lux;RecordS" + (#AppT List (#ProdT AST AST)) + )))))))) + )))))) (_lux_export AST') (_lux_declare-tags [#BoolS #IntS #RealS #CharS #TextS #SymbolS #TagS #FormS #TupleS #RecordS] AST') @@ -244,32 +239,30 @@ (#NamedT ["lux" "Either"] (#AllT (#Some #Nil) "lux;Either" "l" (#AllT #None "" "r" - (#VariantT (#Cons ## "lux;Left" - (#BoundT "l") - (#Cons ## "lux;Right" - (#BoundT "r") - #Nil))))))) + (#SumT ## "lux;Left" + (#BoundT "l") + ## "lux;Right" + (#BoundT "r")))))) (_lux_export Either) (_lux_declare-tags [#Left #Right] Either) ## (deftype (StateE s a) ## (-> s (Either Text (, s a)))) (_lux_def StateE - (#AllT [(#Some #Nil) "lux;StateE" "s" - (#AllT [#None "" "a" - (#LambdaT [(#BoundT "s") - (#AppT [(#AppT [Either Text]) - (#TupleT (#Cons [(#BoundT "s") - (#Cons [(#BoundT "a") - #Nil])]))])])])])) + (#AllT (#Some #Nil) "lux;StateE" "s" + (#AllT #None "" "a" + (#LambdaT (#BoundT "s") + (#AppT (#AppT [Either Text]) + (#ProdT (#BoundT "s") + (#BoundT "a"))))))) ## (deftype Source ## (List (Meta Cursor Text))) (_lux_def Source (#NamedT ["lux" "Source"] - (#AppT [List - (#AppT [(#AppT [Meta Cursor]) - Text])]))) + (#AppT List + (#AppT (#AppT Meta Cursor) + Text)))) (_lux_export Source) ## (deftype Host @@ -278,13 +271,12 @@ ## #classes (^ clojure.lang.Atom))) (_lux_def Host (#NamedT ["lux" "Host"] - (#TupleT (#Cons [## "lux;writer" - (#DataT "org.objectweb.asm.ClassWriter") - (#Cons [## "lux;loader" - (#DataT "java.lang.ClassLoader") - (#Cons [## "lux;classes" - (#DataT "clojure.lang.Atom") - #Nil])])])))) + (#ProdT ## "lux;writer" + (#DataT "org.objectweb.asm.ClassWriter") + (#ProdT ## "lux;loader" + (#DataT "java.lang.ClassLoader") + ## "lux;classes" + (#DataT "clojure.lang.Atom"))))) (_lux_declare-tags [#writer #loader #classes] Host) ## (deftype (DefData' m) @@ -295,17 +287,15 @@ (_lux_def DefData' (#NamedT ["lux" "DefData'"] (#AllT [(#Some #Nil) "lux;DefData'" "" - (#VariantT (#Cons [## "lux;ValueD" - (#TupleT (#Cons [Type - (#Cons [Unit - #Nil])])) - (#Cons [## "lux;TypeD" - Type - (#Cons [## "lux;MacroD" - (#BoundT "") - (#Cons [## "lux;AliasD" - Ident - #Nil])])])]))]))) + (#SumT ## "lux;ValueD" + (#ProdT Type + Unit) + (#SumT ## "lux;TypeD" + Type + (#SumT ## "lux;MacroD" + (#BoundT "") + ## "lux;AliasD" + Ident)))]))) (_lux_export DefData') (_lux_declare-tags [#ValueD #TypeD #MacroD #AliasD] DefData') @@ -314,11 +304,10 @@ ## (#Global Ident))) (_lux_def LuxVar (#NamedT ["lux" "LuxVar"] - (#VariantT (#Cons [## "lux;Local" - Int - (#Cons [## "lux;Global" - Ident - #Nil])])))) + (#SumT ## "lux;Local" + Int + ## "lux;Global" + Ident))) (_lux_export LuxVar) (_lux_declare-tags [#Local #Global] LuxVar) @@ -331,34 +320,28 @@ ## )) (_lux_def Module (#NamedT ["lux" "Module"] - (#AllT [(#Some #Nil) "lux;Module" "Compiler" - (#TupleT (#Cons [## "lux;module-aliases" - (#AppT [List (#TupleT (#Cons [Text (#Cons [Text #Nil])]))]) - (#Cons [## "lux;defs" - (#AppT [List (#TupleT (#Cons [Text - (#Cons [(#TupleT (#Cons [Bool (#Cons [(#AppT [DefData' (#LambdaT [ASTList - (#AppT [(#AppT [StateE (#BoundT "Compiler")]) - ASTList])])]) - #Nil])])) - #Nil])]))]) - (#Cons [## "lux;imports" - (#AppT [List Text]) - (#Cons [## "lux;tags" - (#AppT [List - (#TupleT (#Cons Text - (#Cons (#TupleT (#Cons Int - (#Cons (#AppT [List Ident]) - (#Cons Type - #Nil)))) - #Nil)))]) - (#Cons [## "lux;types" - (#AppT [List - (#TupleT (#Cons Text - (#Cons (#TupleT (#Cons (#AppT [List Ident]) - (#Cons Type - #Nil))) - #Nil)))]) - #Nil])])])])]))]))) + (#AllT (#Some #Nil) "lux;Module" "Compiler" + (#ProdT ## "lux;module-aliases" + (#AppT List (#ProdT Text Text)) + (#ProdT ## "lux;defs" + (#AppT List (#ProdT Text + (#ProdT Bool + (#AppT DefData' (#LambdaT ASTList + (#AppT (#AppT StateE (#BoundT "Compiler")) + ASTList)))))) + (#ProdT ## "lux;imports" + (#AppT List Text) + (#ProdT ## "lux;tags" + (#AppT List + (#ProdT Text + (#ProdT Int + (#ProdT (#AppT List Ident) + Type)))) + ## "lux;types" + (#AppT List + (#ProdT Text + (#ProdT (#AppT List Ident) + Type)))))))))) (_lux_export Module) (_lux_declare-tags [#module-aliases #defs #imports #tags #types] Module) @@ -375,30 +358,28 @@ ## )) (_lux_def Compiler (#NamedT ["lux" "Compiler"] - (#AppT [(#AllT [(#Some #Nil) "lux;Compiler" "" - (#TupleT (#Cons [## "lux;source" - Source - (#Cons [## "lux;cursor" - Cursor - (#Cons [## "lux;modules" - (#AppT [List (#TupleT (#Cons [Text - (#Cons [(#AppT [Module (#AppT [(#BoundT "lux;Compiler") (#BoundT "")])]) - #Nil])]))]) - (#Cons [## "lux;envs" - (#AppT [List (#AppT [(#AppT [Env Text]) - (#TupleT (#Cons [LuxVar (#Cons [Type #Nil])]))])]) - (#Cons [## "lux;type-vars" - (#AppT [(#AppT [Bindings Int]) Type]) - (#Cons [## "lux;expected" - Type - (#Cons [## "lux;seed" - Int - (#Cons [## "lux;eval?" - Bool - (#Cons [## "lux;host" - Host - #Nil])])])])])])])])]))]) - Void]))) + (#AppT (#AllT (#Some #Nil) "lux;Compiler" "" + (#ProdT ## "lux;source" + Source + (#ProdT ## "lux;cursor" + Cursor + (#ProdT ## "lux;modules" + (#AppT List (#ProdT Text + (#AppT Module (#AppT (#BoundT "lux;Compiler") (#BoundT ""))))) + (#ProdT ## "lux;envs" + (#AppT List (#AppT (#AppT [Env Text]) + (#ProdT LuxVar Type))) + (#ProdT ## "lux;type-vars" + (#AppT (#AppT Bindings Int) Type) + (#ProdT ## "lux;expected" + Type + (#ProdT ## "lux;seed" + Int + (#ProdT ## "lux;eval?" + Bool + ## "lux;host" + Host))))))))) + Void))) (_lux_export Compiler) (_lux_declare-tags [#source #cursor #modules #envs #type-vars #expected #seed #eval? #host] Compiler) @@ -426,7 +407,7 @@ (#AppT Meta Cursor)) AST) (_lux_lambda _ data - (#Meta _cursor data)))) + [_cursor data]))) ## (def (return x) ## (All [a] @@ -438,9 +419,8 @@ (#LambdaT (#BoundT "a") (#LambdaT Compiler (#AppT (#AppT Either Text) - (#TupleT (#Cons Compiler - (#Cons (#BoundT "a") - #Nil))))))) + (#ProdT Compiler + (#BoundT "a")))))) (_lux_lambda _ val (_lux_lambda _ state (#Right state val))))) @@ -455,9 +435,8 @@ (#LambdaT Text (#LambdaT Compiler (#AppT (#AppT Either Text) - (#TupleT (#Cons Compiler - (#Cons (#BoundT "a") - #Nil))))))) + (#ProdT Compiler + (#BoundT "a")))))) (_lux_lambda _ msg (_lux_lambda _ state (#Left msg))))) @@ -493,7 +472,7 @@ (_meta (#TupleS tokens))))) (_lux_def record$ - (_lux_: (#LambdaT (#AppT List (#TupleT (#Cons AST (#Cons AST #Nil)))) AST) + (_lux_: (#LambdaT (#AppT List (#ProdT AST AST)) AST) (_lux_lambda _ tokens (_meta (#RecordS tokens))))) @@ -1068,30 +1047,30 @@ ($' Monad Maybe) {#return (lambda' return [x] - (#Some x)) + (#Some x)) #bind (lambda' [f ma] - (_lux_case ma - #None #None - (#Some a) (f a)))}) + (_lux_case ma + #None #None + (#Some a) (f a)))}) (def''' Lux/Monad ($' Monad Lux) {#return (lambda' [x] - (lambda' [state] - (#Right state x))) + (lambda' [state] + (#Right state x))) #bind (lambda' [f ma] - (lambda' [state] - (_lux_case (ma state) - (#Left msg) - (#Left msg) + (lambda' [state] + (_lux_case (ma state) + (#Left msg) + (#Left msg) - (#Right state' a) - (f a state'))))}) + (#Right state' a) + (f a state'))))}) (defmacro #export (^ tokens) (_lux_case tokens @@ -1119,16 +1098,16 @@ (#Cons monad (#Cons (#Meta _ (#TupleS bindings)) (#Cons body #Nil))) (let' [body' (foldL (_lux_: (-> AST (, AST AST) AST) (lambda' [body' binding] - (let' [[var value] binding] - (_lux_case var - (#Meta _ (#TagS "" "let")) - (`' (;let' (~ value) (~ body'))) - - _ - (`' (bind (_lux_lambda (~ (symbol$ ["" ""])) - (~ var) - (~ body')) - (~ value))))))) + (let' [[var value] binding] + (_lux_case var + (#Meta _ (#TagS "" "let")) + (`' (;let' (~ value) (~ body'))) + + _ + (`' (bind (_lux_lambda (~ (symbol$ ["" ""])) + (~ var) + (~ body')) + (~ value))))))) body (reverse (as-pairs bindings)))] (return (list (`' (_lux_case (~ monad) @@ -2483,10 +2462,10 @@ (: (-> AST (Lux AST)) (lambda [token] (case token - (#Meta _ (#SymbolS "" sub-name)) + [_ (#SymbolS "" sub-name)] (return (symbol$ ["" ($ text:++ super-name "/" sub-name)])) - (\ (#Meta _ (#FormS (list& (#Meta _ (#SymbolS "" sub-name)) parts)))) + (\ [_ (#FormS (list& [_ (#SymbolS "" sub-name)] parts))]) (return (form$ (list& (symbol$ ["" ($ text:++ super-name "/" sub-name)]) parts))) _ @@ -2500,10 +2479,10 @@ (: (-> AST (Lux (List Import))) (lambda [token] (case token - (#Meta _ (#SymbolS "" m-name)) + [_ (#SymbolS "" m-name)] (wrap (list [m-name #None #All #None])) - (\ (#Meta _ (#FormS (list& (#Meta _ (#SymbolS "" m-name)) extra)))) + (\ [_ (#FormS (list& [_ (#SymbolS "" m-name)] extra))]) (do Lux/Monad [alias+extra (parse-alias extra) #let [[alias extra] alias+extra] @@ -2848,7 +2827,7 @@ (case tokens (\ (list struct body)) (case struct - (#Meta _ (#SymbolS name)) + [_ (#SymbolS name)] (do Lux/Monad [struct-type (find-var-type name) output (resolve-type-tags struct-type)] @@ -2910,7 +2889,7 @@ (defmacro #export (get@ tokens) (case tokens - (\ (list (#Meta _ (#TagS slot')) record)) + (\ (list [_ (#TagS slot')] record)) (do Lux/Monad [slot (normalize slot') output (resolve-tag slot) @@ -2952,11 +2931,11 @@ (defmacro #export (open tokens) (case tokens - (\ (list& (#Meta _ (#SymbolS struct-name)) tokens')) + (\ (list& [_ (#SymbolS struct-name)] tokens')) (do Lux/Monad [@module get-module-name #let [prefix (case tokens' - (\ (list (#Meta _ (#TextS prefix)))) + (\ (list [_ (#TextS prefix)])) prefix _ @@ -2999,10 +2978,10 @@ (: (-> AST AST (Lux AST)) (lambda [so-far part] (case part - (#Meta _ (#SymbolS slot)) + [_ (#SymbolS slot)] (return (` (get@ (~ (tag$ slot)) (~ so-far)))) - (\ (#Meta _ (#FormS (list& (#Meta _ (#SymbolS slot)) args)))) + (\ [_ (#FormS (list& [_ (#SymbolS slot)] args))]) (return (` ((get@ (~ (tag$ slot)) (~ so-far)) (~@ args)))) @@ -3016,7 +2995,7 @@ (defmacro #export (set@ tokens) (case tokens - (\ (list (#Meta _ (#TagS slot')) value record)) + (\ (list [_ (#TagS slot')] value record)) (do Lux/Monad [slot (normalize slot') output (resolve-tag slot) @@ -3051,7 +3030,7 @@ (defmacro #export (update@ tokens) (case tokens - (\ (list (#Meta _ (#TagS slot')) fun record)) + (\ (list [_ (#TagS slot')] fun record)) (do Lux/Monad [slot (normalize slot') output (resolve-tag slot) @@ -3086,9 +3065,9 @@ (defmacro #export (\template tokens) (case tokens - (\ (list (#Meta _ (#TupleS data)) - (#Meta _ (#TupleS bindings)) - (#Meta _ (#TupleS templates)))) + (\ (list [_ (#TupleS data)] + [_ (#TupleS bindings)] + [_ (#TupleS templates)])) (case (: (Maybe (List AST)) (do Maybe/Monad [bindings' (map% Maybe/Monad get-name bindings) @@ -3171,7 +3150,7 @@ (defmacro #export (loop tokens) (case tokens - (\ (list (#Meta _ (#TupleS bindings)) body)) + (\ (list [_ (#TupleS bindings)] body)) (let [pairs (as-pairs bindings) vars (map first pairs) inits (map second pairs)] |