Minor wording changes to repr section
Getty Ritter
10 years ago
| 55 | 55 | | WFSAtom atom |
| 56 | 56 | ~~~~ |
| 57 | 57 | |
| 58 | In the above, an `RSList [a, b, c]` and a | |
| 59 | `WFList [a, b, c]` both correspond to the structure | |
| 60 | `SCons a (SCons b (SCons d SNil))`, which corresponds to an | |
| 61 | S-expression which can be written as | |
| 62 | `(a b c)` or as `(a . (b . (c . ())))`. A `RSDotList` | |
| 63 | corresponds to an sequence of conses that does not terminate | |
| 64 | in an empty list, e.g. `RSDotList [a, b] c` corresponds to | |
| 65 | `SCons a (SCons b (SAtom c))`, which in turn corresponds to | |
| 66 | a structure like `(a b . c)` or `(a . (b . c))`. | |
| 58 | The `WellFormedSExpr` representation should be structurally | |
| 59 | identical to the `RichSExpr` representation in all cases where | |
| 60 | no improper lists appear in the source. Both of those are | |
| 61 | often more convenient than writing multiple nested `SCons` | |
| 62 | constructors in Haskell. | |
| 67 | 63 | |
| 68 | 64 | Functions for converting back and forth between |
| 69 | 65 | representations are provided, but you can also modify a |
| 72 | 68 | functions. |
| 73 | 69 | |
| 74 | 70 | ~~~~ |
| 75 | *Data.SCargot.General> decode spec "(a b c)" | |
| 76 | Right [SCons (SAtom "a") (SCons (SAtom "b") (SCons (SAtom "c") SNil))] | |
| 77 | *Data.SCargot.General> decode (asRich spec) "(a b c)" | |
| 78 | Right [RSList [RSAtom "a",RSAtom "b",RSAtom "c"]] | |
| 79 | *Data.SCargot.General> decode (asWellFormed spec) "(a b c)" | |
| 80 | Right [WFSList [WFSAtom "a",WFSAtom "b",WFSAtom "c"]] | |
| 71 | *Data.SCargot.General> decode spec "(a b)" | |
| 72 | Right [SCons (SAtom "a") (SCons (SAtom "b") SNil)] | |
| 73 | *Data.SCargot.General> decode (asRich spec) "(a b)" | |
| 74 | Right [RSList [RSAtom "a",RSAtom "b"]] | |
| 75 | *Data.SCargot.General> decode (asWellFormed spec) "(a b)" | |
| 76 | Right [WFSList [WFSAtom "a",WFSAtom "b"]] | |
| 81 | 77 | *Data.SCargot.General> decode spec "(a . b)" |
| 82 | 78 | Right [SCons (SAtom "a") (SAtom "b")] |
| 83 | 79 | *Data.SCargot.General> decode (asRich spec) "(a . b)" |