Rather than our Node constructors containing [Node], they now contain Node in those places, and an additional Node sibling. In a sense this is directly embedding Haskell's singly-linked list into our core AST type, hence the addition of the Fin constructor, equivalent to list Nil. Alternative primed constructors are supplied via patterns, so instead of String x Fin you can write String' x.
With this PR alone it's a relatively neutral change, but it enables more powerful recursion schemes in #171.
Additionally an IsString instance has been added, which can be backported to the previous AST representation if this PR isn't merged. It transforms "xy" directly into Char 'x' (Char 'y' Fin) (previously Plaintext "xy").
Oh, and with us embracing holding chars rather than strings, we can say goodbye to mergePlaintext.
Before (with IsString sugar): ["Hello ", String "name", etc]
Rather than our
Node
constructors containing[Node]
, they now containNode
in those places, and an additionalNode
sibling. In a sense this is directly embedding Haskell's singly-linked list into our core AST type, hence the addition of theFin
constructor, equivalent to listNil
. Alternative primed constructors are supplied via patterns, so instead ofString x Fin
you can writeString' x
.With this PR alone it's a relatively neutral change, but it enables more powerful recursion schemes in #171.
Additionally an
IsString
instance has been added, which can be backported to the previous AST representation if this PR isn't merged. It transforms"xy"
directly intoChar 'x' (Char 'y' Fin)
(previouslyPlaintext "xy"
).Oh, and with us embracing holding chars rather than strings, we can say goodbye to
mergePlaintext
.Before (with
IsString
sugar):["Hello ", String "name", etc]
After:
mconcat ["Hello", String' "name", etc]