symantic-grammar-0.0.0.20170623: Library for symantic grammars.

Safe HaskellNone
LanguageHaskell2010

Language.Symantic.Grammar.Fixity

Contents

Synopsis

Type Fixity

Type Unifix

Type Infix

needsParenInfix :: (Infix, Side) -> Infix -> Bool Source #

Given Precedence and Associativity of its parent operator, and the operand Side it is in, return whether an Infix operator needs to be enclosed by parenthesis.

parenInfix :: (Semigroup s, IsString s) => (Infix, Side) -> Infix -> s -> s Source #

If needsParenInfix is True, enclose the given IsString by parenthesis, otherwise returns the same IsString.

Type Precedence

Class PrecedenceOf

Type Associativity

data Associativity Source #

Constructors

AssocL

Associate to the left: a ¹ b ² c == (a ¹ b) ² c

AssocR

Associate to the right: a ¹ b ² c == a ¹ (b ² c)

AssocB Side

Associate to both sides, but to Side when reading.

Type Side

data Side Source #

Constructors

SideL

Left

SideR

Right

Instances

Eq Side Source # 

Methods

(==) :: Side -> Side -> Bool #

(/=) :: Side -> Side -> Bool #

Show Side Source # 

Methods

showsPrec :: Int -> Side -> ShowS #

show :: Side -> String #

showList :: [Side] -> ShowS #