remove case expressions (no particular reason)

This commit is contained in:
Peter Ljunglöf
2019-03-08 17:57:02 +01:00
parent 3328279120
commit 21140fc0c0

View File

@@ -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:
StrType -> showJSON "Str" showJSON (StrType) = showJSON "Str"
FloatType -> showJSON "Float" showJSON (FloatType) = showJSON "Float"
IntType -> showJSON "Int" showJSON (IntType) = showJSON "Int"
-- parameters are also encoded as strings: -- parameters are also encoded as strings:
ParamType pt -> showJSON pt showJSON (ParamType pt) = showJSON pt
-- tables/tuples are encoded as JSON objects: -- tables/tuples are encoded as JSON objects:
TableType pt lt -> makeObj [(".tblarg", showJSON pt), (".tblval", showJSON lt)] showJSON (TableType pt lt) = makeObj [(".tblarg", showJSON pt), (".tblval", showJSON lt)]
TupleType lts -> makeObj [(".tuple", showJSON lts)] showJSON (TupleType lts) = makeObj [(".tuple", showJSON lts)]
-- records are encoded as records: -- records are encoded as records:
RecordType rows -> showJSON rows showJSON (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:
ConcatValue v v' -> showJSON [showJSON v, showJSON v'] showJSON (ConcatValue v v') = showJSON [showJSON v, showJSON v']
-- most values are encoded as JSON objects: -- most values are encoded as JSON objects:
ParamConstant pv -> makeObj [(".param", showJSON pv)] showJSON (ParamConstant pv) = makeObj [(".param", showJSON pv)]
PredefValue p -> makeObj [(".predef", showJSON p)] showJSON (PredefValue p ) = makeObj [(".predef", showJSON p)]
TableValue t tvs -> makeObj [(".tblarg", showJSON t), (".tblrows", showJSON tvs)] showJSON (TableValue t tvs) = makeObj [(".tblarg", showJSON t), (".tblrows", showJSON tvs)]
TupleValue lvs -> makeObj [(".tuple", showJSON lvs)] showJSON (TupleValue lvs) = makeObj [(".tuple", showJSON lvs)]
VarValue v -> makeObj [(".var", showJSON v)] showJSON (VarValue v ) = makeObj [(".var", showJSON v)]
ErrorValue s -> makeObj [(".error", showJSON s)] showJSON (ErrorValue s ) = makeObj [(".error", showJSON s)]
Projection lv l -> makeObj [(".project", showJSON lv), (".label", showJSON l)] showJSON (Projection lv l ) = makeObj [(".project", showJSON lv), (".label", showJSON l)]
Selection tv pv -> makeObj [(".select", showJSON tv), (".key", showJSON pv)] showJSON (Selection tv pv) = makeObj [(".select", showJSON tv), (".key", showJSON pv)]
VariantValue vs -> makeObj [(".variants", showJSON vs)] showJSON (VariantValue vs) = makeObj [(".variants", showJSON vs)]
PreValue pre def -> makeObj [(".pre", showJSON pre),(".default", showJSON def)] showJSON (PreValue pre def) = makeObj [(".pre", showJSON pre),(".default", showJSON def)]
-- records are encoded directly as JSON records: -- records are encoded directly as JSON records:
RecordValue rows -> showJSON rows showJSON (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:
StrConstant s -> showJSON s showJSON (StrConstant s) = showJSON s
FloatConstant f -> showJSON f showJSON (FloatConstant f) = showJSON f
IntConstant n -> showJSON n showJSON (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:
WildPattern -> showJSON "_" showJSON (WildPattern) = showJSON "_"
ParamPattern (Param p []) -> showJSON p showJSON (ParamPattern (Param p [])) = showJSON p
-- complex patterns are encoded as JSON objects: -- complex patterns are encoded as JSON objects:
ParamPattern pv -> showJSON pv showJSON (ParamPattern pv) = showJSON pv
-- and records as records: -- and records as records:
RecordPattern r -> showJSON r showJSON (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: