On Outlines, Rose Trees and Zippers

Image for post
Image for post

Introduction

Vertebrates
Cold-blooded
Frogs
Salamanders
Snakes
Turtles
Warm-blooded
Dogs
Cats
Horses
type alias Outline = List (String, Int),
[(“Vertebrates”, 0), (“Cold-blooded”, 1), 
(“Frogs”, 2), (“Salamanders”, 2),
{“Snakes”, 2), (“Turtles”, 2),
(“Warm-blooded”, 1), (“Dogs”, 2),
(“Cats”, 2), (“Horses”, 2)]
   if e is a list element and e' is the next element, 
then level(e') <= level(e) + 1
Image for post
Image for post
Vertebrate rose tree
type Tree a = Tree { label : a, children : List (Tree a) }

Using rose trees

# Philosophy notes*Monday*> **Nature of reality?**   Why something rather than nothing. 

If nothing, no one to ask this question.

Tree in forest / fall
Confusing.
[ (DOCUMENT, Root, 0)
, (Philosophy…, Heading 1, 1)
, (Monday, Italic, 1)
, (Nature …, Quotation, 1)
, (Why …, Paragraph, 2)
, (If …, Paragraph, 2)
, (Tree …, Paragraph, 2)
, (Confusing …, Paragraph, 1)
]
Image for post
Image for post
Parse tree

Building rose trees

{-| Represents a location within a tree,
always pointing at the root or one of
its descendant trees.
-}
type Zipper a
= Zipper
{ focus : Tree a
, before : List (Tree a)
, after : List (Tree a)
, …
}

Table of contents

Vertebrates
+ Cold-blooded
+ Warm-blooded
Vertebrates
Cold-blooded
Frogs
Salamanders
Snakes
Turtles
+ Warm-blooded
Vertebrates
+ Cold-blooded
Warm-blooded
Dogs
Cats
Horses

Diffing and Merging

Equation AEquation B
Equation AEquation BB
Image for post
Image for post
First tree
Image for post
Image for post
Second parse tree
Image for post
Image for post
New tree: diffed and merged

Written by

jxxcarlson on elm slack, http://jxxcarlson.github.io

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store