summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ljunglöf <peter.ljunglof@heatherleaf.se>2019-03-08 17:57:02 +0100
committerPeter Ljunglöf <peter.ljunglof@heatherleaf.se>2019-03-08 17:57:02 +0100
commit21140fc0c0dce1e7730a3d679815e48db0ab3804 (patch)
treec5209018ed9e3145b2ffcedc5ab3c40867b7b363
parent3328279120ce771c676b30689283cd7f2493c0f6 (diff)
remove case expressions (no particular reason)
-rw-r--r--src/compiler/GF/Grammar/CanonicalJSON.hs80
1 files changed, 38 insertions, 42 deletions
diff --git a/src/compiler/GF/Grammar/CanonicalJSON.hs b/src/compiler/GF/Grammar/CanonicalJSON.hs
index 347af1390..3be47a1a8 100644
--- a/src/compiler/GF/Grammar/CanonicalJSON.hs
+++ b/src/compiler/GF/Grammar/CanonicalJSON.hs
@@ -75,54 +75,50 @@ instance JSON LinDef where
showJSON (LinDef f xs lv) = makeObj [("fun", showJSON f), ("args", showJSON xs), ("lin", showJSON lv)]
instance JSON LinType where
- showJSON lt = case lt of
- -- the basic types (Str, Float, Int) are encoded as strings:
- StrType -> showJSON "Str"
- FloatType -> showJSON "Float"
- IntType -> showJSON "Int"
- -- parameters are also encoded as strings:
- ParamType pt -> showJSON pt
- -- tables/tuples are encoded as JSON objects:
- TableType pt lt -> makeObj [(".tblarg", showJSON pt), (".tblval", showJSON lt)]
- TupleType lts -> makeObj [(".tuple", showJSON lts)]
- -- records are encoded as records:
- RecordType rows -> showJSON rows
+ -- the basic types (Str, Float, Int) are encoded as strings:
+ showJSON (StrType) = showJSON "Str"
+ showJSON (FloatType) = showJSON "Float"
+ showJSON (IntType) = showJSON "Int"
+ -- parameters are also encoded as strings:
+ showJSON (ParamType pt) = showJSON pt
+ -- tables/tuples are encoded as JSON objects:
+ showJSON (TableType pt lt) = makeObj [(".tblarg", showJSON pt), (".tblval", showJSON lt)]
+ showJSON (TupleType lts) = makeObj [(".tuple", showJSON lts)]
+ -- records are encoded as records:
+ showJSON (RecordType rows) = showJSON rows
instance JSON LinValue where
- showJSON lv = case lv of
- LiteralValue l -> showJSON l
- -- concatenation is encoded as a JSON array:
- ConcatValue v v' -> showJSON [showJSON v, showJSON v']
- -- most values are encoded as JSON objects:
- ParamConstant pv -> makeObj [(".param", showJSON pv)]
- PredefValue p -> makeObj [(".predef", showJSON p)]
- TableValue t tvs -> makeObj [(".tblarg", showJSON t), (".tblrows", showJSON tvs)]
- TupleValue lvs -> makeObj [(".tuple", showJSON lvs)]
- VarValue v -> makeObj [(".var", showJSON v)]
- ErrorValue s -> makeObj [(".error", showJSON s)]
- Projection lv l -> makeObj [(".project", showJSON lv), (".label", showJSON l)]
- Selection tv pv -> makeObj [(".select", showJSON tv), (".key", showJSON pv)]
- VariantValue vs -> makeObj [(".variants", showJSON vs)]
- PreValue pre def -> makeObj [(".pre", showJSON pre),(".default", showJSON def)]
- -- records are encoded directly as JSON records:
- RecordValue rows -> showJSON rows
+ showJSON (LiteralValue l ) = showJSON l
+ -- concatenation is encoded as a JSON array:
+ showJSON (ConcatValue v v') = showJSON [showJSON v, showJSON v']
+ -- most values are encoded as JSON objects:
+ showJSON (ParamConstant pv) = makeObj [(".param", showJSON pv)]
+ showJSON (PredefValue p ) = makeObj [(".predef", showJSON p)]
+ showJSON (TableValue t tvs) = makeObj [(".tblarg", showJSON t), (".tblrows", showJSON tvs)]
+ showJSON (TupleValue lvs) = makeObj [(".tuple", showJSON lvs)]
+ showJSON (VarValue v ) = makeObj [(".var", showJSON v)]
+ showJSON (ErrorValue s ) = makeObj [(".error", showJSON s)]
+ showJSON (Projection lv l ) = makeObj [(".project", showJSON lv), (".label", showJSON l)]
+ showJSON (Selection tv pv) = makeObj [(".select", showJSON tv), (".key", showJSON pv)]
+ showJSON (VariantValue vs) = makeObj [(".variants", showJSON vs)]
+ showJSON (PreValue pre def) = makeObj [(".pre", showJSON pre),(".default", showJSON def)]
+ -- records are encoded directly as JSON records:
+ showJSON (RecordValue rows) = showJSON rows
instance JSON LinLiteral where
- showJSON l = case l of
- -- basic values (Str, Float, Int) are encoded as JSON strings/numbers:
- StrConstant s -> showJSON s
- FloatConstant f -> showJSON f
- IntConstant n -> showJSON n
+ -- basic values (Str, Float, Int) are encoded as JSON strings/numbers:
+ showJSON (StrConstant s) = showJSON s
+ showJSON (FloatConstant f) = showJSON f
+ showJSON (IntConstant n) = showJSON n
instance JSON LinPattern where
- showJSON linpat = case linpat of
- -- wildcards and patterns without arguments are encoded as strings:
- WildPattern -> showJSON "_"
- ParamPattern (Param p []) -> showJSON p
- -- complex patterns are encoded as JSON objects:
- ParamPattern pv -> showJSON pv
- -- and records as records:
- RecordPattern r -> showJSON r
+ -- wildcards and patterns without arguments are encoded as strings:
+ showJSON (WildPattern) = showJSON "_"
+ showJSON (ParamPattern (Param p [])) = showJSON p
+ -- complex patterns are encoded as JSON objects:
+ showJSON (ParamPattern pv) = showJSON pv
+ -- and records as records:
+ showJSON (RecordPattern r) = showJSON r
instance JSON arg => JSON (Param arg) where
-- parameters without arguments are encoded as strings: