| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Agda.Syntax.Fixity
Description
Definitions for fixity, precedence levels, and declared syntax.
Synopsis
- data Fixity' = Fixity' {
- theFixity :: !Fixity
- theNotation :: Notation
- theNameRange :: Range
- data ThingWithFixity x = ThingWithFixity x Fixity'
- data NewNotation = NewNotation {}
- namesToNotation :: QName -> Name -> NewNotation
- useDefaultFixity :: NewNotation -> NewNotation
- notationNames :: NewNotation -> [QName]
- syntaxOf :: Name -> Notation
- noFixity' :: Fixity'
- mergeNotations :: [NewNotation] -> [NewNotation]
- data NotationSection = NotationSection {}
- noSection :: NewNotation -> NotationSection
- data PrecedenceLevel
- data Associativity
- data Fixity = Fixity {}
- noFixity :: Fixity
- defaultFixity :: Fixity
- data ParenPreference
- preferParen :: ParenPreference -> Bool
- preferParenless :: ParenPreference -> Bool
- data Precedence
- type PrecedenceStack = [Precedence]
- pushPrecedence :: Precedence -> PrecedenceStack -> PrecedenceStack
- headPrecedence :: PrecedenceStack -> Precedence
- argumentCtx_ :: Precedence
- opBrackets :: Fixity -> PrecedenceStack -> Bool
- opBrackets' :: Bool -> Fixity -> PrecedenceStack -> Bool
- lamBrackets :: PrecedenceStack -> Bool
- appBrackets :: PrecedenceStack -> Bool
- appBrackets' :: Bool -> PrecedenceStack -> Bool
- withAppBrackets :: PrecedenceStack -> Bool
- piBrackets :: PrecedenceStack -> Bool
- roundFixBrackets :: PrecedenceStack -> Bool
- _notaFixity :: Lens' Fixity NewNotation
- _fixityAssoc :: Lens' Associativity Fixity
- _fixityLevel :: Lens' PrecedenceLevel Fixity
Notation coupled with Fixity
The notation is handled as the fixity in the renamer. Hence, they are grouped together in this type.
Constructors
| Fixity' | |
Fields
| |
Instances
| Eq Fixity' # | |
| Data Fixity' # | |
Defined in Agda.Syntax.Fixity Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Fixity' -> c Fixity' # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Fixity' # toConstr :: Fixity' -> Constr # dataTypeOf :: Fixity' -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Fixity') # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity') # gmapT :: (forall b. Data b => b -> b) -> Fixity' -> Fixity' # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixity' -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixity' -> r # gmapQ :: (forall d. Data d => d -> u) -> Fixity' -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixity' -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Fixity' -> m Fixity' # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixity' -> m Fixity' # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixity' -> m Fixity' # | |
| Show Fixity' # | |
| NFData Fixity' # | |
Defined in Agda.Syntax.Fixity | |
| Pretty Fixity' # | |
Defined in Agda.Syntax.Concrete.Pretty | |
| KillRange Fixity' # | |
Defined in Agda.Syntax.Fixity Methods | |
| EmbPrj Fixity' # | |
| ToTerm Fixity' # | |
| PrimTerm Fixity' # | |
data ThingWithFixity x #
Decorating something with Fixity'.
Constructors
| ThingWithFixity x Fixity' |
Instances
data NewNotation #
All the notation information related to a name.
Constructors
| NewNotation | |
Fields
| |
Instances
| Show NewNotation # | |
Defined in Agda.Syntax.Fixity Methods showsPrec :: Int -> NewNotation -> ShowS # show :: NewNotation -> String # showList :: [NewNotation] -> ShowS # | |
namesToNotation :: QName -> Name -> NewNotation #
If an operator has no specific notation, then it is computed from its name.
useDefaultFixity :: NewNotation -> NewNotation #
Replace noFixity by defaultFixity.
notationNames :: NewNotation -> [QName] #
Return the IdParts of a notation, the first part qualified,
the other parts unqualified.
This allows for qualified use of operators, e.g.,
M.for x ∈ xs return e, or x ℕ.+ y.
syntaxOf :: Name -> Notation #
Create a Notation (without binders) from a concrete Name.
Does the obvious thing:
Holes become NormalHoles, Ids become IdParts.
If Name has no Holes, it returns noNotation.
mergeNotations :: [NewNotation] -> [NewNotation] #
Merges NewNotations that have the same precedence level and
notation, with two exceptions:
- Operators and notations coming from syntax declarations are kept separate.
- If all instances of a given
NewNotationhave the same precedence level or are "unrelated", then they are merged. They get the given precedence level, if any, and otherwise they become unrelated (but related to each other).
If NewNotations that are merged have distinct associativities,
then they get NonAssoc as their associativity.
Precondition: No Name may occur in more than one list element.
Every NewNotation must have the same notaName.
Postcondition: No Name occurs in more than one list element.
Sections
data NotationSection #
Sections, as well as non-sectioned operators.
Constructors
| NotationSection | |
Fields
| |
Instances
| Show NotationSection # | |
Defined in Agda.Syntax.Fixity Methods showsPrec :: Int -> NotationSection -> ShowS # show :: NotationSection -> String # showList :: [NotationSection] -> ShowS # | |
noSection :: NewNotation -> NotationSection #
Converts a notation to a (non-)section.
Fixity
data PrecedenceLevel #
Precedence levels for operators.
Instances
data Associativity #
Associativity.
Constructors
| NonAssoc | |
| LeftAssoc | |
| RightAssoc |
Instances
Fixity of operators.
Constructors
| Fixity | |
Fields
| |
Instances
| Eq Fixity # | |
| Data Fixity # | |
Defined in Agda.Syntax.Fixity Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Fixity -> c Fixity # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Fixity # toConstr :: Fixity -> Constr # dataTypeOf :: Fixity -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Fixity) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity) # gmapT :: (forall b. Data b => b -> b) -> Fixity -> Fixity # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r # gmapQ :: (forall d. Data d => d -> u) -> Fixity -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixity -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Fixity -> m Fixity # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixity -> m Fixity # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Fixity -> m Fixity # | |
| Ord Fixity # | |
| Show Fixity # | |
| NFData Fixity # | Ranges are not forced. |
Defined in Agda.Syntax.Fixity | |
| Pretty Fixity # | |
Defined in Agda.Syntax.Concrete.Pretty | |
| KillRange Fixity # | |
Defined in Agda.Syntax.Fixity Methods | |
| HasRange Fixity # | |
Defined in Agda.Syntax.Fixity | |
| EmbPrj Fixity # | |
| ToTerm Fixity # | |
defaultFixity :: Fixity #
data ParenPreference #
Do we prefer parens around arguments like λ x → x or not?
See lamBrackets.
Constructors
| PreferParen | |
| PreferParenless |
Instances
preferParen :: ParenPreference -> Bool #
preferParenless :: ParenPreference -> Bool #
Precendence
data Precedence #
Precedence is associated with a context.
Constructors
| TopCtx | |
| FunctionSpaceDomainCtx | |
| LeftOperandCtx Fixity | |
| RightOperandCtx Fixity ParenPreference | |
| FunctionCtx | |
| ArgumentCtx ParenPreference | |
| InsideOperandCtx | |
| WithFunCtx | |
| WithArgCtx | |
| DotPatternCtx |
Instances
| Eq Precedence # | |
Defined in Agda.Syntax.Fixity | |
| Data Precedence # | |
Defined in Agda.Syntax.Fixity Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Precedence -> c Precedence # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Precedence # toConstr :: Precedence -> Constr # dataTypeOf :: Precedence -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Precedence) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Precedence) # gmapT :: (forall b. Data b => b -> b) -> Precedence -> Precedence # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Precedence -> r # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Precedence -> r # gmapQ :: (forall d. Data d => d -> u) -> Precedence -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Precedence -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Precedence -> m Precedence # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Precedence -> m Precedence # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Precedence -> m Precedence # | |
| Show Precedence # | |
Defined in Agda.Syntax.Fixity Methods showsPrec :: Int -> Precedence -> ShowS # show :: Precedence -> String # showList :: [Precedence] -> ShowS # | |
| Pretty Precedence # | |
Defined in Agda.Syntax.Fixity Methods pretty :: Precedence -> Doc # prettyPrec :: Int -> Precedence -> Doc # prettyList :: [Precedence] -> Doc # | |
| EmbPrj Precedence # | |
Defined in Agda.TypeChecking.Serialise.Instances.Abstract Methods icode :: Precedence -> S Int32 # icod_ :: Precedence -> S Int32 # value :: Int32 -> R Precedence # | |
type PrecedenceStack = [Precedence] #
When printing we keep track of a stack of precedences in order to be able
to decide whether it's safe to leave out parens around lambdas. An empty
stack is equivalent to TopCtx. Invariant: `notElem TopCtx`.
Argument context preferring parens.
opBrackets :: Fixity -> PrecedenceStack -> Bool #
Do we need to bracket an operator application of the given fixity in a context with the given precedence.
opBrackets' :: Bool -> Fixity -> PrecedenceStack -> Bool #
Do we need to bracket an operator application of the given fixity in a context with the given precedence.
lamBrackets :: PrecedenceStack -> Bool #
Does a lambda-like thing (lambda, let or pi) need brackets in the
given context? A peculiar thing with lambdas is that they don't
need brackets in certain right operand contexts. To decide we need to look
at the stack of precedences and not just the current precedence.
Example: m₁ >>= (λ x → x) >>= m₂ (for _>>=_ left associative).
appBrackets :: PrecedenceStack -> Bool #
Does a function application need brackets?
appBrackets' :: Bool -> PrecedenceStack -> Bool #
Does a function application need brackets?
withAppBrackets :: PrecedenceStack -> Bool #
Does a with application need brackets?
piBrackets :: PrecedenceStack -> Bool #
Does a function space need brackets?
roundFixBrackets :: PrecedenceStack -> Bool #