Pull requests

#6 Merged
Repository
Deleted repository
Branch
default (6fc8b677155f)
Repository
paba/compdata compdata
Branch
default

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

Author
  1. Emil Axelsson
Reviewers
Description
No description
  • Learn about pull requests

Comments (2)

  1. Emil Axelsson 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. Emil Axelsson 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.