Idris-dev/samples/TreeTag.idr
Jan de Muijnck-Hughes af72159e60 Sphinx Based Documentation for Idris.
Sphinx provides a retargatable documentation system for documentation, and code. Allowing for HTML, LaTeX, and ePub documents to be generated from a single source.
ReadTheDocs is a free service for Open Source Projects that provides continuous delivery of documents that use either Sphinx or MakeDoc.

This commit provides Sphinx based versions of:

+ The Idris Tutorial
+ The Effects Tutorial
+ Select articles from the Wiki to begin a language reference
+ Select articles from the Wiki to begin short guides.

The examples from the effect tutorial have been integrated as well.

In the `docs` folder see `README.md` for dependencies, Sphinx is easily obtainable from all major Linux ditributions and through brew on Mac OS X.

+ Running `make html` will produce a monolithic html website for use with readthedocs.
+ Running `make latexpdf` will produce individual PDFs for each of the above tutorials.
+ Running `make epub` will produce a monolithic epub. This will need to be adapted to either produce one of the above document sets, or individual epubs.

Future work will be to:

+ Integrate idris with readthedocs for documentation generation for tagged released..
+ Add latex and html generation to the travis builds.
+ Add
2015-03-17 16:19:11 +00:00

41 lines
1.0 KiB
Idris

module Main
import Effects
import Effect.State
data BTree a = Leaf
| Node (BTree a) a (BTree a)
instance Show a => Show (BTree a) where
show Leaf = "[]"
show (Node l x r) = "[" ++ show l ++ " "
++ show x ++ " "
++ show r ++ "]"
testTree : BTree String
testTree = Node (Node Leaf "Jim" Leaf)
"Fred"
(Node (Node Leaf "Alice" Leaf)
"Sheila"
(Node Leaf "Bob" Leaf))
treeTagAux : BTree a -> { [STATE Int] } Eff (BTree (Int, a))
treeTagAux Leaf = return Leaf
treeTagAux (Node l x r)
= do l' <- treeTagAux l
i <- get
put (i + 1)
r' <- treeTagAux r
return (Node l' (i, x) r')
treeTag : (i : Int) -> BTree a -> BTree (Int, a)
treeTag i x = runPure (do put i
treeTagAux x)
treeTagIO : (i : Int) -> BTree a -> IO (BTree (Int, a))
treeTagIO i x = run (do put i
treeTagAux x)
main : IO ()
main = print (treeTag 1 testTree)