diff options
author | Greg Brown <greg.brown01@ed.ac.uk> | 2022-12-21 20:32:56 +0000 |
---|---|---|
committer | Greg Brown <greg.brown01@ed.ac.uk> | 2022-12-21 20:32:56 +0000 |
commit | a8a4ef9933a1a07b6fbf2d257df2a5fb40b1e87d (patch) | |
tree | 5eeaa04614d2a1ad5d3e98bc9e9bd5af2f9bdbd5 /src/Obs/Syntax.idr | |
parent | 4bad0e68e4b984db004d75ab87ca5a181d223190 (diff) |
Add sum types.
Diffstat (limited to 'src/Obs/Syntax.idr')
-rw-r--r-- | src/Obs/Syntax.idr | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Obs/Syntax.idr b/src/Obs/Syntax.idr index 36b1b9f..9f64c38 100644 --- a/src/Obs/Syntax.idr +++ b/src/Obs/Syntax.idr @@ -23,6 +23,11 @@ data Syntax : Type where Pair : WithBounds Syntax -> WithBounds Syntax -> Syntax Fst : WithBounds Syntax -> Syntax Snd : WithBounds Syntax -> Syntax + -- Disjoint Coproducts + Sum : WithBounds Syntax -> WithBounds Syntax -> Syntax + Left : WithBounds Syntax -> Syntax + Right : WithBounds Syntax -> Syntax + Case : WithBounds Syntax -> WithBounds Syntax -> WithBounds Syntax -> WithBounds Syntax -> WithBounds Syntax -> Syntax -- True Top : Syntax Point : Syntax @@ -84,6 +89,22 @@ prettyPrec d (Snd t) = parenthesise (d >= App) $ group $ fillSep [pretty "snd", prettyPrecBounds App t] +prettyPrec d (Sum a b) = + parenthesise (d >= App) $ + group $ + fillSep [pretty "Either", prettyPrecBounds App a, prettyPrecBounds App b] +prettyPrec d (Left t) = + parenthesise (d >= App) $ + group $ + fillSep [pretty "Left", prettyPrecBounds App t] +prettyPrec d (Right t) = + parenthesise (d >= App) $ + group $ + fillSep [pretty "Right", prettyPrecBounds App t] +prettyPrec d (Case t s b f g) = + parenthesise (d >= App) $ + group $ + fillSep [pretty "case", prettyPrecBounds App t, prettyPrecBounds App s, prettyPrecBounds App b, prettyPrecBounds App f, prettyPrecBounds App g] prettyPrec d Top = pretty "()" prettyPrec d Point = pretty "tt" prettyPrec d Bottom = pretty "Void" |