Top

This file has been processed with:

ocamlorn --library stdlib.mli \ --library desorn_listlist.in.ml --input desorn_listlist.in.ml --lifting desorn_listlist.lif.ml \ > desorn_listlist.out.ml

Desornamentation of lists to other lists

This example demonstrates an ornament that features the addition of an argument and the deletion of another argument at the same time on the same constructor. While this example is not very useful, it shows that the transformations that can be defined are more general than classical ornaments.

type 'a list' = | Nil' | Cons' of 'a * 'a list' let rec concat m n = match m with | Nil' -> n | Cons' (a, q) -> Cons' (a, concat q n)
type 'a list = | Nil | Cons of 'a * 'a list
type ornament ('c, 'b) listlist : 'c list' => 'b list with | Nil' => Nil | Cons'(_, xs) => Cons(_, xs) when xs : ('c, 'b) listlist let add_gen = lifting concat: ('a, 'b) listlist -> ('a, 'b) listlist -> ('a, 'b) listlist let add = lifting concat: ('a, 'b) listlist -> ('a, 'b) listlist -> ('a, 'b) listlist with patch #3[match m with | Cons(a, _) -> a]
let rec add_gen m n = match m with | Nil -> n | Cons(_, q) -> Cons(#3, add_gen q n) let rec add m n = match m with | Nil -> n | Cons(a, q) -> Cons(a, add q n)