Added class Render which gives methods for converting terms to Data.Tree and drawing terms as ASCII art

#6 Merged
Repository
Deleted repository
Branch
default (6fc8b677155f)
Repository
compdata
Branch
default
Author
  1. Axelsson Emil
Reviewers
Description
No description

Comments (2)

  1. Axelsson Emil author

    Example file:

    {-# LANGUAGE DeriveFoldable #-}
    {-# LANGUAGE DeriveFunctor #-}
    {-# LANGUAGE TemplateHaskell #-}
    
    import Data.Comp
    import Data.Comp.Derive
    import Data.Comp.Render
    
    data Arith a = Int Int | Add a a
      deriving (Functor, Foldable)
    
    derive [makeShowConstr] [''Arith]
    
    instance Render Arith
    
    test = drawTerm $ Term (Add (Term (Int 1)) (Term (Int 2)))
    

    Test:

    *Main> test
    Add
     ├╴Int 1
     └╴Int 2
    
  2. Axelsson Emil author

    Tree rendering is needed an EDSL library that I'm working on (building on compdata). I thought it might be a useful addition to compdata, but I could also put it in my library. Feel free to rename/rearrange stuff as you find suitable.