mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 17:42:51 -06:00
remove case expressions (no particular reason)
This commit is contained in:
@@ -75,54 +75,50 @@ instance JSON LinDef where
|
|||||||
showJSON (LinDef f xs lv) = makeObj [("fun", showJSON f), ("args", showJSON xs), ("lin", showJSON lv)]
|
showJSON (LinDef f xs lv) = makeObj [("fun", showJSON f), ("args", showJSON xs), ("lin", showJSON lv)]
|
||||||
|
|
||||||
instance JSON LinType where
|
instance JSON LinType where
|
||||||
showJSON lt = case lt of
|
-- the basic types (Str, Float, Int) are encoded as strings:
|
||||||
-- the basic types (Str, Float, Int) are encoded as strings:
|
showJSON (StrType) = showJSON "Str"
|
||||||
StrType -> showJSON "Str"
|
showJSON (FloatType) = showJSON "Float"
|
||||||
FloatType -> showJSON "Float"
|
showJSON (IntType) = showJSON "Int"
|
||||||
IntType -> showJSON "Int"
|
-- parameters are also encoded as strings:
|
||||||
-- parameters are also encoded as strings:
|
showJSON (ParamType pt) = showJSON pt
|
||||||
ParamType pt -> showJSON pt
|
-- tables/tuples are encoded as JSON objects:
|
||||||
-- tables/tuples are encoded as JSON objects:
|
showJSON (TableType pt lt) = makeObj [(".tblarg", showJSON pt), (".tblval", showJSON lt)]
|
||||||
TableType pt lt -> makeObj [(".tblarg", showJSON pt), (".tblval", showJSON lt)]
|
showJSON (TupleType lts) = makeObj [(".tuple", showJSON lts)]
|
||||||
TupleType lts -> makeObj [(".tuple", showJSON lts)]
|
-- records are encoded as records:
|
||||||
-- records are encoded as records:
|
showJSON (RecordType rows) = showJSON rows
|
||||||
RecordType rows -> showJSON rows
|
|
||||||
|
|
||||||
instance JSON LinValue where
|
instance JSON LinValue where
|
||||||
showJSON lv = case lv of
|
showJSON (LiteralValue l ) = showJSON l
|
||||||
LiteralValue l -> showJSON l
|
-- concatenation is encoded as a JSON array:
|
||||||
-- concatenation is encoded as a JSON array:
|
showJSON (ConcatValue v v') = showJSON [showJSON v, showJSON v']
|
||||||
ConcatValue v v' -> showJSON [showJSON v, showJSON v']
|
-- most values are encoded as JSON objects:
|
||||||
-- most values are encoded as JSON objects:
|
showJSON (ParamConstant pv) = makeObj [(".param", showJSON pv)]
|
||||||
ParamConstant pv -> makeObj [(".param", showJSON pv)]
|
showJSON (PredefValue p ) = makeObj [(".predef", showJSON p)]
|
||||||
PredefValue p -> makeObj [(".predef", showJSON p)]
|
showJSON (TableValue t tvs) = makeObj [(".tblarg", showJSON t), (".tblrows", showJSON tvs)]
|
||||||
TableValue t tvs -> makeObj [(".tblarg", showJSON t), (".tblrows", showJSON tvs)]
|
showJSON (TupleValue lvs) = makeObj [(".tuple", showJSON lvs)]
|
||||||
TupleValue lvs -> makeObj [(".tuple", showJSON lvs)]
|
showJSON (VarValue v ) = makeObj [(".var", showJSON v)]
|
||||||
VarValue v -> makeObj [(".var", showJSON v)]
|
showJSON (ErrorValue s ) = makeObj [(".error", showJSON s)]
|
||||||
ErrorValue s -> makeObj [(".error", showJSON s)]
|
showJSON (Projection lv l ) = makeObj [(".project", showJSON lv), (".label", showJSON l)]
|
||||||
Projection lv l -> makeObj [(".project", showJSON lv), (".label", showJSON l)]
|
showJSON (Selection tv pv) = makeObj [(".select", showJSON tv), (".key", showJSON pv)]
|
||||||
Selection tv pv -> makeObj [(".select", showJSON tv), (".key", showJSON pv)]
|
showJSON (VariantValue vs) = makeObj [(".variants", showJSON vs)]
|
||||||
VariantValue vs -> makeObj [(".variants", showJSON vs)]
|
showJSON (PreValue pre def) = makeObj [(".pre", showJSON pre),(".default", showJSON def)]
|
||||||
PreValue pre def -> makeObj [(".pre", showJSON pre),(".default", showJSON def)]
|
-- records are encoded directly as JSON records:
|
||||||
-- records are encoded directly as JSON records:
|
showJSON (RecordValue rows) = showJSON rows
|
||||||
RecordValue rows -> showJSON rows
|
|
||||||
|
|
||||||
instance JSON LinLiteral where
|
instance JSON LinLiteral where
|
||||||
showJSON l = case l of
|
-- basic values (Str, Float, Int) are encoded as JSON strings/numbers:
|
||||||
-- basic values (Str, Float, Int) are encoded as JSON strings/numbers:
|
showJSON (StrConstant s) = showJSON s
|
||||||
StrConstant s -> showJSON s
|
showJSON (FloatConstant f) = showJSON f
|
||||||
FloatConstant f -> showJSON f
|
showJSON (IntConstant n) = showJSON n
|
||||||
IntConstant n -> showJSON n
|
|
||||||
|
|
||||||
instance JSON LinPattern where
|
instance JSON LinPattern where
|
||||||
showJSON linpat = case linpat of
|
-- wildcards and patterns without arguments are encoded as strings:
|
||||||
-- wildcards and patterns without arguments are encoded as strings:
|
showJSON (WildPattern) = showJSON "_"
|
||||||
WildPattern -> showJSON "_"
|
showJSON (ParamPattern (Param p [])) = showJSON p
|
||||||
ParamPattern (Param p []) -> showJSON p
|
-- complex patterns are encoded as JSON objects:
|
||||||
-- complex patterns are encoded as JSON objects:
|
showJSON (ParamPattern pv) = showJSON pv
|
||||||
ParamPattern pv -> showJSON pv
|
-- and records as records:
|
||||||
-- and records as records:
|
showJSON (RecordPattern r) = showJSON r
|
||||||
RecordPattern r -> showJSON r
|
|
||||||
|
|
||||||
instance JSON arg => JSON (Param arg) where
|
instance JSON arg => JSON (Param arg) where
|
||||||
-- parameters without arguments are encoded as strings:
|
-- parameters without arguments are encoded as strings:
|
||||||
|
|||||||
Reference in New Issue
Block a user