@@ -2,40 +2,28 @@ module PureScript.Backend.Chez.Syntax where
22
33import Prelude
44
5−import Control.Alternative as Alternative
65import Data.Argonaut as Json
76import Data.Array as Array
87import Data.Array.NonEmpty (NonEmptyArray)
9−import Data.Array.NonEmpty as NEA
108import Data.Array.NonEmpty as NonEmptyArray
11−import Data.Maybe (Maybe(..), maybe)
12−import Data.Newtype (class Newtype, un)
13−import Data.String (Pattern(..), Replacement(..))
14−import Data.String as String
15−import Data.String.Regex as R
16−import Data.String.Regex.Flags as R.Flags
17−import Data.String.Regex.Unsafe as R.Unsafe
18−import Dodo (Doc)
19−import Dodo as D
20−import Partial.Unsafe (unsafeCrashWith)
21−import Prim as Prim
22−import PureScript.Backend.Chez.Constants (libChezSchemePrefix, scmPrefixed)
23−import PureScript.Backend.Optimizer.CoreFn (Ident(..), ModuleName(..), Prop(..), Qualified(..))
24−import PureScript.Backend.Optimizer.Syntax (Level(..))
25−import Safe.Coerce (coerce)
9+import Data.Maybe (Maybe)
10+import Data.Newtype (class Newtype)
11+import Data.Tuple (Tuple)
12+import PureScript.Backend.Chez.Constants (scmPrefixed)
13+import PureScript.Backend.Optimizer.CoreFn (Prop(..))
2614
2715type ChezLibrary =
28− { "#!r6rs" :: Prim.Boolean
29− , "#!chezscheme" :: Prim.Boolean
16+ { "#!r6rs" :: Boolean
17+ , "#!chezscheme" :: Boolean
3018 , name :: LibraryName
31− , exports :: Prim.Array ChezExport
32− , imports :: Prim.Array ChezImport
19+ , exports :: Array ChezExport
20+ , imports :: Array ChezImport
3321 , body :: LibraryBody
3422 }
3523
3624type LibraryName =
37− { identifiers :: NonEmptyArray Prim.String
38− , version :: Prim.Array LibraryVersion
25+ { identifiers :: NonEmptyArray String
26+ , version :: Array LibraryVersion
3927 }
4028
4129newtype LibraryVersion = LibraryVersion Prim.Int
@@ -43,31 +31,31 @@ newtype LibraryVersion = LibraryVersion Prim.Int
4331derive instance Newtype LibraryVersion _
4432
4533data ChezExport
46− = ExportIdentifier Prim.String
47− | ExportRename (Prim.Array { original :: Prim.String, rename :: Prim.String })
34+ = ExportIdentifier String
35+ | ExportRename (Array { original :: String, rename :: String })
4836
4937type LibraryReference =
50− { identifiers :: NonEmptyArray Prim.String
38+ { identifiers :: NonEmptyArray String
5139 , version :: Maybe VersionReference
5240 }
5341
5442data VersionReference
5543 = VersionRef (NonEmptyArray SubVersionReference)
56− | VersionAnd (Prim.Array VersionReference)
57− | VersionOr (Prim.Array VersionReference)
44+ | VersionAnd (Array VersionReference)
45+ | VersionOr (Array VersionReference)
5846 | VersionNot VersionReference
5947
6048data SubVersionReference
6149 = SubVersionRef LibraryVersion
6250 | SubVersionGTE LibraryVersion
6351 | SubVersionLTE LibraryVersion
64− | SubVersionAnd (Prim.Array SubVersionReference)
65− | SubVersionOr (Prim.Array SubVersionReference)
52+ | SubVersionAnd (Array SubVersionReference)
53+ | SubVersionOr (Array SubVersionReference)
6654 | SubVersionNot SubVersionReference
6755
6856data ChezImport
6957 = ImportSet ChezImportSet
70− | ImportFor ChezImportSet (Prim.Array ChezImportLevel)
58+ | ImportFor ChezImportSet (Array ChezImportLevel)
7159
7260data ChezImportLevel
7361 = ImportLevelRun
@@ -76,23 +64,23 @@ data ChezImportLevel
7664
7765data ChezImportSet
7866 = ImportLibrary LibraryReference
79− | ImportOnly ChezImportSet (Prim.Array Prim.String)
80− | ImportExcept ChezImportSet (Prim.Array Prim.String)
81− | ImportPrefix ChezImportSet Prim.String
82− | ImportRename ChezImportSet (Prim.Array { original :: Prim.String, rename :: Prim.String })
67+ | ImportOnly ChezImportSet (Array String)
68+ | ImportExcept ChezImportSet (Array String)
69+ | ImportPrefix ChezImportSet String
70+ | ImportRename ChezImportSet (Array { original :: String, rename :: String })
8371
8472type LibraryBody =
85− { definitions :: Prim.Array ChezDefinition
86− , expressions :: Prim.Array ChezExpr
73+ { definitions :: Array ChezDefinition
74+ , expressions :: Array ChezExpr
8775 }
8876
8977data ChezDefinition
90− = DefineValue Prim.String ChezExpr
91− | DefineCurriedFunction Prim.String (NonEmptyArray Prim.String) ChezExpr
92− | DefineUncurriedFunction Prim.String (Prim.Array Prim.String) ChezExpr
93− | DefineRecordType Prim.String (Prim.Array Prim.String)
78+ = DefineValue String ChezExpr
79+ | DefineCurriedFunction String (NonEmptyArray String) ChezExpr
80+ | DefineUncurriedFunction String (Array String) ChezExpr
81+ | DefineRecordType String (Array String)
9482
95−newtype LiteralDigit = LiteralDigit Prim.String
83+newtype LiteralDigit = LiteralDigit String
9684
9785derive instance Newtype LiteralDigit _
9886derive newtype instance Eq LiteralDigit
@@ -101,394 +89,41 @@ derive newtype instance Ord LiteralDigit
10189data ChezExpr
10290 = Integer LiteralDigit
10391 | Float LiteralDigit
104− | Char Prim.String
105− | String Prim.String
106− | Boolean Prim.Boolean
107− | Identifier Prim.String
108− | List (Prim.Array ChezExpr)
109−
110−definitionIdentifiers :: ChezDefinition -> Prim.Array Prim.String
111−definitionIdentifiers (DefineValue i _) = [ i ]
112−definitionIdentifiers (DefineCurriedFunction i _ _) = [ i ]
113−definitionIdentifiers (DefineUncurriedFunction i _ _) = [ i ]
114−definitionIdentifiers (DefineRecordType i [ x ]) =
115− [ recordTypeCurriedConstructor i
116− , recordTypePredicate i
117− , recordTypeAccessor i x
118− ]
119−definitionIdentifiers (DefineRecordType i fields) =
120− [ recordTypeUncurriedConstructor i
121− , recordTypePredicate i
122− ] <> map (recordTypeAccessor i) fields
123−
124−resolve :: ModuleName -> Qualified Ident -> Prim.String
125−resolve _ (Qualified Nothing (Ident i)) = i
126−resolve currentModule (Qualified (Just m) (Ident i))
127− | currentModule == m = i
128− | otherwise = coerce m <> "." <> i
129−
130−printWrap :: Doc Void -> Doc Void -> Doc Void -> Doc Void
131−printWrap l r x = l <> x <> r
132−
133−printList :: Doc Void -> Doc Void
134−printList = printWrap (D.text "(") (D.text ")")
135−
136−printNamedList :: Prim.String -> Doc Void -> Doc Void
137−printNamedList name body
138− | D.isEmpty body =
139− printList $ D.text name
140− | otherwise =
141− printList $ D.words [ D.text name, body ]
142−
143−printIndentedList :: Doc Void -> Doc Void -> Doc Void
144−printIndentedList ident body
145− | D.isEmpty body =
146− printList ident
147− | otherwise =
148− D.lines
149− [ D.text "(" <> ident
150− , D.indent body <> D.text ")"
151− ]
152−
153−linesSeparated :: Prim.Array (Doc Void) -> Doc Void
154−linesSeparated = Array.intercalate twoLineBreaks
155− where
156− twoLineBreaks = D.break <> D.break
157−
158−escapeIdentifiers :: ChezLibrary -> ChezLibrary
159−escapeIdentifiers lib = lib
160− { name = lib.name { identifiers = map escapeIdent lib.name.identifiers }
161− , exports = map escapeExport lib.exports
162− , imports = map escapeImport lib.imports
163− , body =
164− { definitions: escapeDefinition <$> lib.body.definitions
165− , expressions: escapeExpr <$> lib.body.expressions
166− }
167− }
168− where
169− escapeIdent = String.replaceAll (Pattern "'") (Replacement "$p")
170− escapeExport = case _ of
171− ExportIdentifier x -> ExportIdentifier $ escapeIdent x
172− ExportRename arr -> ExportRename $ arr <#> \r ->
173− { original: escapeIdent r.original, rename: escapeIdent r.rename }
174−
175− escapeImport = case _ of
176− ImportSet set -> ImportSet $ escapeImportSet set
177− ImportFor set lvls -> ImportFor (escapeImportSet set) lvls
178−
179− escapeImportSet = case _ of
180− ImportLibrary libRef ->
181− ImportLibrary $ escapeLibRef libRef
182− ImportOnly set idents ->
183− ImportOnly (escapeImportSet set) $ map escapeIdent idents
184− ImportExcept set idents ->
185− ImportExcept (escapeImportSet set) $ map escapeIdent idents
186− ImportPrefix set ident ->
187− ImportPrefix (escapeImportSet set) $ escapeIdent ident
188− ImportRename set renames ->
189− ImportRename (escapeImportSet set) $ renames <#> \r ->
190− { original: escapeIdent r.original, rename: escapeIdent r.rename }
191−
192− escapeLibRef libRef = libRef { identifiers = map escapeIdent libRef.identifiers }
193−
194− escapeDefinition = case _ of
195− DefineValue i expr -> DefineValue (escapeIdent i) $ escapeExpr expr
196− DefineCurriedFunction i args expr ->
197− DefineCurriedFunction (escapeIdent i) (map escapeIdent args) $ escapeExpr expr
198− DefineUncurriedFunction i args expr ->
199− DefineUncurriedFunction (escapeIdent i) (map escapeIdent args) $ escapeExpr expr
200− DefineRecordType i fields -> DefineRecordType (escapeIdent i) $ map escapeIdent fields
201−
202− escapeExpr = case _ of
203− Identifier i -> Identifier $ escapeIdent i
204− List exprs -> List $ map escapeExpr exprs
205− x@(Integer _) -> x
206− x@(Float _) -> x
207− x@(String _) -> x
208− x@(Char _) -> x
209− x@(Boolean _) -> x
210−
211−printLibrary :: ChezLibrary -> Doc Void
212−printLibrary = escapeIdentifiers >>> printLibrary'
213−
214−printLibrary' :: ChezLibrary -> Doc Void
215−printLibrary' lib =
216− flip append D.break
217− $ D.lines
218− $ Array.catMaybes
219− [ D.text "#!r6rs" <$ Alternative.guard lib."#!r6rs"
220− , D.text "#!chezscheme" <$ Alternative.guard lib."#!chezscheme"
221− , Just $ printNamedIndentedList (D.text "library") $ D.lines
222− [ printLibraryName lib.name
223− , printIndentedList (D.text "export") $ D.lines $ map printExport lib.exports
224− , (printIndentedList (D.text "import") $ D.lines $ map printImport lib.imports)
225− <> D.break
226− , printBody lib.body
227− ]
228− ]
229−
230−printLibraryName :: LibraryName -> Doc Void
231−printLibraryName { identifiers, version } =
232− printList $ D.words
233− [ D.words $ map D.text identifiers
234− , case version of
235− [] -> mempty
236− _ -> printList $ D.words $ map printLibraryVersion version
237− ]
238−
239−printLibraryVersion :: LibraryVersion -> Doc Void
240−printLibraryVersion = D.text <<< show <<< un LibraryVersion
241−
242−printExport :: ChezExport -> Doc Void
243−printExport = case _ of
244− ExportIdentifier s -> D.text s
245− ExportRename arr ->
246− printNamedList "rename"
247− $ D.words
248− $ map (\r -> printList $ D.words [ D.text r.original, D.text r.rename ]) arr
249−
250−printImport :: ChezImport -> Doc Void
251−printImport = case _ of
252− ImportSet is -> printImportSet is
253− ImportFor is lvls ->
254− printNamedList "for" $ D.words
255− [ printImportSet is
256− , D.words $ map printImportLevel lvls
257− ]
258−
259−printImportLevel :: ChezImportLevel -> Doc Void
260−printImportLevel = case _ of
261− ImportLevelRun -> D.text "run"
262− ImportLevelExpand -> D.text "expand"
263− ImportLevelMeta level -> printNamedList "meta" $ D.text $ show level
264−
265−printImportSet :: ChezImportSet -> Doc Void
266−printImportSet = case _ of
267− ImportLibrary libRef ->
268− printLibraryReference libRef
269− ImportOnly impSet identifiers ->
270− printNamedList "only" $ D.words
271− [ printImportSet impSet, D.words $ map D.text identifiers ]
272− ImportExcept impSet identifiers ->
273− printNamedList "except" $ D.words
274− [ printImportSet impSet, D.words $ map D.text identifiers ]
275− ImportPrefix impSet rename ->
276− printNamedList "prefix" $ D.words [ printImportSet impSet, D.text rename ]
277− ImportRename impSet identifiers ->
278− printNamedList "rename" $ D.words
279− [ printImportSet impSet
280− , D.words $ map (\r -> printList $ D.words $ map D.text [ r.original, r.rename ])
281− identifiers
282− ]
283−
284−printLibraryReference :: LibraryReference -> Doc Void
285−printLibraryReference lib = do
286− let
287− printListFn
288− | Array.elem (NEA.head lib.identifiers)
289− [ "for", "library", "only", "except", "prefix", "rename" ] =
290− printNamedList "library"
291− | otherwise =
292− printList
293− printListFn $ D.words
294− [ D.words $ map D.text lib.identifiers
295− , maybe mempty printVersionReference lib.version
296− ]
297−
298−printVersionReference :: VersionReference -> Doc Void
299−printVersionReference = case _ of
300− VersionRef ref ->
301− printList $ D.words $ map printSubVersionReference ref
302− VersionAnd ref ->
303− printNamedList "and" $ D.words $ map printVersionReference ref
304− VersionOr ref ->
305− printNamedList "or" $ D.words $ map printVersionReference ref
306− VersionNot ref ->
307− printNamedList "not" $ printVersionReference ref
308−
309−printSubVersionReference :: SubVersionReference -> Doc Void
310−printSubVersionReference = case _ of
311− SubVersionRef ref -> printList $ printLibraryVersion ref
312− SubVersionGTE ref -> printNamedList ">=" $ printLibraryVersion ref
313− SubVersionLTE ref -> printNamedList "<=" $ printLibraryVersion ref
314− SubVersionAnd ref -> printNamedList "and" $ D.words
315− $ map printSubVersionReference ref
316− SubVersionOr ref -> printNamedList "or" $ D.words
317− $ map printSubVersionReference ref
318− SubVersionNot ref -> printNamedList "not" $ printSubVersionReference ref
319−
320−printBody :: LibraryBody -> Doc Void
321−printBody lib = do
322− let
323− defs = map printDefinition lib.definitions
324− exprs = map printChezExpr lib.expressions
325− linesSeparated $ defs <> exprs
326−
327−printNamedIndentedList :: Doc Void -> Doc Void -> Doc Void
328−printNamedIndentedList firstLine body
329− | D.isEmpty body =
330− printList firstLine
331− | otherwise =
332− D.lines
333− [ D.text "(" <> firstLine
334− , D.indent $ body <> D.text ")"
335− ]
336−
337−printDefinition :: ChezDefinition -> Doc Void
338−printDefinition = case _ of
339− DefineValue ident expr ->
340− printNamedIndentedList (D.words [ D.text $ scmPrefixed "define", D.text ident ])
341− $ printChezExpr expr
342− DefineCurriedFunction ident args expr ->
343− printNamedIndentedList (D.text (scmPrefixed "define ") <> D.text ident)
344− $ printCurriedAbs (NEA.toArray args) expr
345− DefineUncurriedFunction ident args expr ->
346− printNamedIndentedList (D.text (scmPrefixed "define ") <> D.text ident)
347− $ printNamedIndentedList
348− (D.text (scmPrefixed "lambda ") <> printList (D.words $ map D.text args))
349− (printChezExpr expr)
350− DefineRecordType ident [ field ] ->
351− printRecordDefinition
352− ident
353− (recordTypeName ident)
354− (recordTypeCurriedConstructor ident)
355− (recordTypePredicate ident)
356− [ field ]
357− DefineRecordType ident fields ->
358− printRecordDefinition
359− ident
360− (recordTypeName ident)
361− (recordTypeUncurriedConstructor ident)
362− (recordTypePredicate ident)
363− fields
364−
365−printCurriedAbs :: Prim.Array Prim.String -> ChezExpr -> Doc Void
366−printCurriedAbs args body = Array.foldr foldFn (printChezExpr body) args
367− where
368− foldFn next bodyOrRest =
369− printNamedIndentedList
370− (D.words [ D.text $ scmPrefixed "lambda", printList (D.text next) ])
371− bodyOrRest
372−
373−printChezExpr :: forall a. ChezExpr -> Doc a
374−printChezExpr e = case e of
375− Integer (LiteralDigit x) -> D.text x
376− Float (LiteralDigit x) -> D.text x
377− Char x -> D.text x
378− String x -> D.text x
379− Boolean x -> D.text $ if x then "#t" else "#f"
380− Identifier x -> D.text x
381− List xs -> D.text "(" <> D.words (printChezExpr <$> xs) <> D.text ")"
382−
383−printRecordDefinition
384− :: Prim.String
385− -> Prim.String
386− -> Prim.String
387− -> Prim.String
388− -> Prim.Array Prim.String
389− -> Doc Void
390−printRecordDefinition ident name constructor predicate fields =
391− printNamedIndentedList defineForm fieldsForm
392− where
393− defineForm :: Doc Void
394− defineForm = D.words
395− [ D.text $ scmPrefixed "define-record-type"
396− , printList $ D.words $ map D.text [ name, constructor, predicate ]
397− ]
398−
399− fieldForm :: Prim.String -> Doc Void
400− fieldForm field = printList $ D.words
401− $ map D.text [ scmPrefixed "immutable", field, recordTypeAccessor ident field ]
402−
403− fieldsForm :: Doc Void
404− fieldsForm = printList $ D.words $ Array.cons (D.text $ scmPrefixed "fields")
405− $ map fieldForm fields
406−
407−toChezIdent :: Maybe Ident -> Level -> Prim.String
408−toChezIdent i (Level l) = case i of
409− Just (Ident i') -> case i' of
410− "$__unused" -> "_"
411− _ -> i' <> show l
412− Nothing -> "_" <> show l
413−
414−jsonToChezString :: Prim.String -> Prim.String
415−jsonToChezString str = unicodeReplace str
416− where
417− unicodeRegex :: R.Regex
418− unicodeRegex = R.Unsafe.unsafeRegex """\\u([A-F\d]{4})""" R.Flags.global
419−
420− unicodeReplace :: Prim.String -> Prim.String
421− unicodeReplace s = R.replace' unicodeRegex unicodeReplaceMatch s
422−
423− unicodeReplaceMatch
424− :: Prim.String
425− -> Prim.Array (Maybe Prim.String)
426− -> Prim.String
427− unicodeReplaceMatch _ = case _ of
428− [ (Just x) ] -> "\\x" <> x <> ";"
429− _ -> unsafeCrashWith "Error matching at unicodeReplaceMatch in jsonToChezString"
92+ | Char String
93+ | StringExpr String
94+ | Bool Boolean
95+ | Identifier String
96+ | List (Array ChezExpr)
97+ | Cond (NonEmptyArray (Tuple ChezExpr ChezExpr)) (Maybe ChezExpr)
98+ | Let Boolean (NonEmptyArray (Tuple String ChezExpr)) ChezExpr
99+ | Lambda (Array String) ChezExpr
430100
431101--
432102
433−chezCond :: NonEmptyArray { c :: ChezExpr, e :: ChezExpr } -> Maybe ChezExpr -> ChezExpr
434−chezCond b o =
435− let
436− b' :: Prim.Array ChezExpr
437− b' = NonEmptyArray.toArray b <#> \{ c, e } -> List [ c, e ]
438−
439− o' :: Prim.Array ChezExpr
440− o' = Array.fromFoldable o <#> \x -> List [ Identifier $ scmPrefixed "else", x ]
441− in
442− List $ [ Identifier $ scmPrefixed "cond" ] <> b' <> o'
443−
444−chezUncurriedApplication :: ChezExpr -> Prim.Array ChezExpr -> ChezExpr
445−chezUncurriedApplication f s = List $ Array.cons f s
103+runUncurriedFn :: ChezExpr -> Array ChezExpr -> ChezExpr
104+runUncurriedFn f s = List $ Array.cons f s
446105
447−chezUncurriedFunction :: Prim.Array Prim.String -> ChezExpr -> ChezExpr
448−chezUncurriedFunction a e = List
449− [ Identifier $ scmPrefixed "lambda", List $ Identifier <$> a, e ]
106+mkUncurriedFn :: Array String -> ChezExpr -> ChezExpr
107+mkUncurriedFn a e = Lambda a e
450108
451−chezCurriedApplication :: ChezExpr -> NonEmptyArray ChezExpr -> ChezExpr
452−chezCurriedApplication f s = NonEmptyArray.foldl1 app $ NonEmptyArray.cons f s
109+runCurriedFn :: ChezExpr -> NonEmptyArray ChezExpr -> ChezExpr
110+runCurriedFn f s = NonEmptyArray.foldl1 app $ NonEmptyArray.cons f s
453111
454−chezCurriedFunction :: NonEmptyArray Prim.String -> ChezExpr -> ChezExpr
455−chezCurriedFunction a e = Array.foldr lambda e $ NonEmptyArray.toArray a
112+mkCurriedFn :: NonEmptyArray String -> ChezExpr -> ChezExpr
113+mkCurriedFn a e = Array.foldr (Lambda <<< Array.singleton) e $ NonEmptyArray.toArray a
456114
457−chezThunk :: ChezExpr -> ChezExpr
458−chezThunk e = List [ Identifier $ scmPrefixed "lambda", List [], e ]
115+thunk :: ChezExpr -> ChezExpr
116+thunk e = Lambda [] e
459117
460−chezUnthunk :: ChezExpr -> ChezExpr
461−chezUnthunk e = List [ e ]
118+unthunk :: ChezExpr -> ChezExpr
119+unthunk e = List [ e ]
462120
463121--
464122
465123app :: ChezExpr -> ChezExpr -> ChezExpr
466124app f x = List [ f, x ]
467125
468−define :: Ident -> ChezExpr -> ChezExpr
469−define i e = List [ Identifier $ scmPrefixed "define", Identifier $ coerce i, e ]
470−
471−library :: ModuleName -> Prim.Array Ident -> Prim.Array ChezExpr -> ChezExpr
472−library moduleName exports bindings =
473− List $
474− [ Identifier "library"
475− , Identifier $ "(" <> coerce moduleName <> " lib" <> ")"
476− , List $
477− [ Identifier "export"
478− ] <> (Identifier <$> coerce exports)
479− , List
480− [ Identifier "import"
481− , List
482− [ Identifier "prefix"
483− , List
484− [ Identifier "chezscheme"
485− ]
486− , Identifier libChezSchemePrefix
487− ]
488− ]
489− ] <> bindings
490−
491−record :: Prim.Array (Prop ChezExpr) -> ChezExpr
126+record :: Array (Prop ChezExpr) -> ChezExpr
492127record r =
493128 let
494129 field :: Prop ChezExpr -> ChezExpr
@@ -496,7 +131,7 @@ record r =
496131 List
497132 [ Identifier $ scmPrefixed "hashtable-set!"
498133 , Identifier "$record"
499− , String $ Json.stringify $ Json.fromString k
134+ , StringExpr $ Json.stringify $ Json.fromString k
500135 , v
501136 ]
502137 in
@@ -518,29 +153,26 @@ quote :: ChezExpr -> ChezExpr
518153quote e = app (Identifier $ scmPrefixed "quote") e
519154
520155eqQ :: ChezExpr -> ChezExpr -> ChezExpr
521−eqQ x y = chezUncurriedApplication (Identifier $ scmPrefixed "eq?") [ x, y ]
522−
523−lambda :: Prim.String -> ChezExpr -> ChezExpr
524−lambda a e = List [ Identifier $ scmPrefixed "lambda", List [ Identifier a ], e ]
156+eqQ x y = runUncurriedFn (Identifier $ scmPrefixed "eq?") [ x, y ]
525157
526−vector :: Prim.Array ChezExpr -> ChezExpr
158+vector :: Array ChezExpr -> ChezExpr
527159vector = List <<< Array.cons (Identifier $ scmPrefixed "vector")
528160
529−recordTypeName :: Prim.String -> Prim.String
161+recordTypeName :: String -> String
530162recordTypeName i = i <> "$"
531163
532−recordTypeCurriedConstructor :: Prim.String -> Prim.String
164+recordTypeCurriedConstructor :: String -> String
533165recordTypeCurriedConstructor i = i
534166
535−recordTypeUncurriedConstructor :: Prim.String -> Prim.String
167+recordTypeUncurriedConstructor :: String -> String
536168recordTypeUncurriedConstructor i = i <> "*"
537169
538−recordTypePredicate :: Prim.String -> Prim.String
170+recordTypePredicate :: String -> String
539171recordTypePredicate i = i <> "?"
540172
541−recordTypeAccessor :: Prim.String -> Prim.String -> Prim.String
173+recordTypeAccessor :: String -> String -> String
542174recordTypeAccessor i field = i <> "-" <> field
543175
544−recordAccessor :: ChezExpr -> Prim.String -> Prim.String -> ChezExpr
176+recordAccessor :: ChezExpr -> String -> String -> ChezExpr
545177recordAccessor expr name field =
546− chezUncurriedApplication (Identifier $ recordTypeAccessor name field) [ expr ]
178+ runUncurriedFn (Identifier $ recordTypeAccessor name field) [ expr ]