sifflet-2.3.0: Simple, visual, functional language for learning about recursion.

Safe HaskellSafe
LanguageHaskell2010

Data.Sifflet.Tree

Synopsis

Documentation

data Tree a :: * -> *

Multi-way trees, also known as rose trees.

Constructors

Node 

Fields

rootLabel :: a

label value

subForest :: Forest a

zero or more child trees

Instances

tree :: e -> Forest e -> Tree e Source

leaf :: e -> Tree e Source

class Repr a where Source

class Repr: representable by a String or a list of Strings

repr x is a String representation of x. reprl x is a [String] representation of x, where the first element should be the same as repr x, and the rest provide auxiliary information that you want to be shown with x. reprs x is a reduction of reprl x to a single String. reprList prefix infix postfix xs is the representation of a list of xs

Minimal complete implementation: define repr, or define reprl. The normal way is to define repr. Define reprl instead, if for some reason you want to include additional information such as the value of an expression in an expression node.

Examples: - (3 :: Int) has repr => "3", reprl => ["3"], reprs => "3" - In Language.Sifflet.Expr, (ENode (NSymbol "x") (EvalOk (3 :: Int) has reprl => ["x", "3"], reprs => "x 3", and repr => "x". - reprList "(" " " ")" [3 :: Int, 4, 5] => "(3 4 5)"

Minimal complete definition

Nothing

Methods

repr :: a -> String Source

reprl :: a -> [String] Source

reprs :: a -> String Source

reprList :: String -> String -> String -> [a] -> String Source

putTree :: Show e => Tree e -> IO () Source

putTreeR :: Repr e => Tree e -> IO () Source

putTreeRs :: Repr e => Tree e -> IO () Source

putTreeS :: Show e => Tree e -> IO () Source