mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-20 02:09:32 -06:00
Translating linearization functions to Haskell: move a common record type to PGF.Haskell
Move the Haskell representation of the common linearization type {s:T} to the
shared module PGF.Haskell, so that the same overloaded projection function
proj_s can be used for all concrete syntaxes.
This commit is contained in:
@@ -38,11 +38,16 @@ concrete2haskell opts gr cenv absname cnc modinfo =
|
||||
"--- Linearization types and linearization functions ---" $$
|
||||
vcat (map ppDef defs) $$ "" $$
|
||||
"--- Type classes for projection functions ---" $$
|
||||
vcat (map labelClass (S.toList (S.unions (map S.fromList rs)))) $$ "" $$
|
||||
vcat (map labelClass (S.toList labels)) $$ "" $$
|
||||
"--- Record types ---" $$
|
||||
vcat (map recordType rs)
|
||||
vcat (map recordType recs)
|
||||
where
|
||||
rs = S.toList (S.insert [ident2label (identS "s")] (records rhss))
|
||||
labels = S.difference (S.unions (map S.fromList recs)) common_labels
|
||||
recs = S.toList (S.difference (records rhss) common_records)
|
||||
common_records = S.fromList [[label_s]]
|
||||
common_labels = S.fromList [label_s]
|
||||
label_s = ident2label (identS "s")
|
||||
|
||||
rhss = map (snd.snd) defs
|
||||
defs = sortBy (compare `on` fst) .
|
||||
concatMap (toHaskell gId gr absname cenv) .
|
||||
|
||||
Reference in New Issue
Block a user