Essay on A Note On Deep Embedding

1334 Words Dec 19th, 2016 6 Pages
The above situation, the recursion remains the same feature but is isolated by defining their data type. This function can only apply in Deep embedding (instead of Shallow embedding) due to its syntax tree feature, which allow programmers to define the data type. Alternatively, Shallowing embedding represents the semantical language constructs, which does not matter the details, including the datatype [9]. Thus, programmers are unable to implement to recursion in Shallow embedding.
Continuation with in and Fix[7]
Data List’ a k = Empty | Cons’ a k
As compared with the direct recursion, this case adds a new variable k in the constructor List’ a. This variable can be used to continue the function.
Data Fix f = In(f (Fix f))
We define the data Fix f above, the second ‘f’ is exactly the same of first ‘f’, and the ‘Fix f’ in the same as first ‘Fix f’ which can occur the recursion.

The idea of writing the value of type fix List’ a is shown as below:
As compared with List a and List’ a. we can make an assumption of:
List a ≅ List’ a k ≅ (Fix (List’ a))

By applying the assumption into Empty and Cons,
Empty’ :: List’ a k
Empty’ :: List’ a (Fix(List’ a))
Cons’ :: a -> k -> List’ a k

By substituting an integer, 20, into a and Empty’ into k,
Cons’ 20 Empty’ :: List’ Int (List’ a k)

Instead of this presentation, we want to make this in one level deeper via In,
Cons’ 20 (In Empty’) :: List’ Int (Fix (List’a))
In Cons’ 20 (In Empty’) :: Fix (List’a)


Related Documents