@@ -201,6 +201,7 @@ The shape of |Parser2|, can be seen in |ParserF| where the |f a| marks the recur
201
201
> ApF :: f (a -> b ) -> f a -> ParserF f b
202
202
> OrF :: f a -> f a -> ParserF f a
203
203
204
+
204
205
The |IFunctor | instance can be found in the appendix~\ref {app:ifunctor-parserf }.
205
206
It follows the same structure as a standard |Functor | instance.
206
207
@@ -218,7 +219,7 @@ It provides the structure needed to allow the datatype to recursive.
218
219
219
220
A mechanism is now required for folding this abstract datatype.
220
221
This is possible through the use of a \textit {catamorphism }, which is a generalised way of folding an abstract datatype.
221
- The commutative diagram below describes how a \textit {catamorphism } can be defined.
222
+ The commutative diagram below describes how a \textit {catamorphism } can be defined, that folds a | Fix iF a| to |f a| .
222
223
Firstly, a layer of |Fix | is peeled off by removing an |In | to give |iF (Fix iF) a|.
223
224
Then a recursive call is made to fold the structure below in the AST.
224
225
This results in a item of type |iF f a|.
@@ -262,7 +263,6 @@ It allows a type with kind |*| to have kind |* -> *|, in a similar way to how th
262
263
263
264
Now, all the building blocks have been defined that allow for the folding of the parser DSL.
264
265
|size| can be redefined as a fold, that is determined by the |sizeAlg|.
265
- Due to parsers being a typed language, a constant functor is required to preserve the type indices.
266
266
267
267
% format size4
268
268
@@ -343,7 +343,7 @@ with the corresponding constructor from the deep embedding, for example:
343
343
344
344
\subsection {Dependent Interpretations }
345
345
346
- In a more complex parser combinator library that perform optimisations on a deep embedding,
346
+ In a more complex parser combinator library that performs optimisations on a deep embedding,
347
347
it could also be possible that there is a primary fold that depends on other secondary folds on parts of the AST.
348
348
Folds such as this are named \textit {zygomorphisms }~\cite {Fokkinga1989TuplingAM } - a special case of a \textit {mutomorphism } -
349
349
they can be implemented by tupling the functions in the fold.
@@ -602,7 +602,7 @@ Two examples are given, the other smart constructors can be found in Appendix~\r
602
602
> or10 px py = In (inj (Or10 px py))
603
603
604
604
Now the smart constructors can be used to form an expression |aorb10'|.
605
- The type contraints on this expression allow for |f | to be flexible, so long as |Or10 | and |Satisfy10 | are subtypes of the functor |f |.
605
+ The type contraints on this expression allow for |iF | to be flexible, so long as |Or10 | and |Satisfy10 | are subtypes of the | IFunctor | |iF |.
606
606
607
607
> aorb10' :: (Or10 :<: iF , Satisfy10 :<: iF ) => Fix iF Char
608
608
> aorb10' = satisfy10 (== ' a' ) `or10` satisfy10 (== ' b' )
@@ -627,7 +627,7 @@ A type class can be defined that provides the algebra to fold each constructor.
627
627
628
628
One benefit to this approach is that if an interpretation is only needed for parsers that use |or10| and |satisfy10|,
629
629
then only those instances need to be defined.
630
- Take calculating the size of the parser |aorb10'|, only the two instances need to be defined to do so.
630
+ Take calculating the size of the parser |aorb10'| as an example , only the two instances need to be defined to do so.
631
631
632
632
633
633
> instance SizeAlg Or10 where
0 commit comments