Got rid of small uses of RecordWildCards
Getty Ritter
10 years ago
| 1 | {-# LANGUAGE RecordWildCards #-} | |
| 2 | 1 | {-# LANGUAGE ViewPatterns #-} |
| 3 | 2 | {-# LANGUAGE OverloadedStrings #-} |
| 4 | 3 | |
| 229 | 228 | -- will fail: for those cases, use 'decode', which returns a list of |
| 230 | 229 | -- all the S-expressions found at the top level. |
| 231 | 230 | decodeOne :: SExprSpec atom carrier -> Text -> Either String carrier |
| 232 | decodeOne SExprSpec { .. } = parseOnly (parser <* endOfInput) >=> postparse | |
| 233 | where parser = parseGenericSExpr sesPAtom readerMap (buildSkip comment) | |
| 231 | decodeOne spec = parseOnly (parser <* endOfInput) >=> (postparse spec) | |
| 232 | where parser = parseGenericSExpr | |
| 233 | (sesPAtom spec) | |
| 234 | (readerMap spec) | |
| 235 | (buildSkip (comment spec)) | |
| 234 | 236 | |
| 235 | 237 | -- | Decode several S-expressions according to a given 'SExprSpec'. This |
| 236 | 238 | -- will return a list of every S-expression that appears at the top-level |
| 237 | 239 | -- of the document. |
| 238 | 240 | decode :: SExprSpec atom carrier -> Text -> Either String [carrier] |
| 239 | decode SExprSpec { .. } = | |
| 240 | parseOnly (many1 parser <* endOfInput) >=> mapM postparse | |
| 241 | where parser = parseGenericSExpr sesPAtom readerMap (buildSkip comment) | |
| 241 | decode spec = | |
| 242 | parseOnly (many1 parser <* endOfInput) >=> mapM (postparse spec) | |
| 243 | where parser = parseGenericSExpr | |
| 244 | (sesPAtom spec) | |
| 245 | (readerMap spec) | |
| 246 | (buildSkip (comment spec)) | |
| 242 | 247 | |
| 243 | 248 | -- | Encode (without newlines) a single S-expression. |
| 244 | 249 | encodeSExpr :: SExpr atom -> (atom -> Text) -> Text |
| 252 | 257 | -- | Emit an S-Expression in a machine-readable way. This does no |
| 253 | 258 | -- pretty-printing or indentation, and produces no comments. |
| 254 | 259 | encodeOne :: SExprSpec atom carrier -> carrier -> Text |
| 255 |
encodeOne |
|
| 260 | encodeOne spec c = encodeSExpr (preserial spec c) (sesSAtom spec) | |
| 256 | 261 | |
| 257 | 262 | encode :: SExprSpec atom carrier -> [carrier] -> Text |
| 258 | 263 | encode spec cs = T.concat (map (encodeOne spec) cs) |