Language.Haskell.Exts.Fixity

haskell-src-exts-1.18.2: Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer

Copyright | (c) Niklas Broberg 2009
License | BSD-style (see the file LICENSE.txt)
Maintainer | Niklas Broberg, d00nibro@chalmers.se
Stability | stable
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Language.Haskell.Exts.Fixity

Contents

- Fixity representation
  - Collections of fixities
- Applying fixities to an AST

Description

Fixity information to give the parser so that infix operators can be parsed properly.

Synopsis

- data Fixity = Fixity (Assoc ()) Int (QName ())
- infix_ :: Int -> [String] -> [Fixity]
- infixl_ :: Int -> [String] -> [Fixity]
- infixr_ :: Int -> [String] -> [Fixity]
- preludeFixities :: [Fixity]
- baseFixities :: [Fixity]
- class AppFixity ast where

# Fixity representation

data Fixity #

Operator fixities are represented by their associativity (left, right or none) and their precedence (0-9).

Constructors

Fixity (Assoc ()) Int (QName ()) |

Instances

Eq Fixity # |
Methods (==) :: Fixity -> Fixity -> Bool # (/=) :: Fixity -> Fixity -> Bool #
Data 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 # |
Methods compare :: Fixity -> Fixity -> Ordering # (<) :: Fixity -> Fixity -> Bool # (<=) :: Fixity -> Fixity -> Bool # (>) :: Fixity -> Fixity -> Bool # (>=) :: Fixity -> Fixity -> Bool # max :: Fixity -> Fixity -> Fixity # min :: Fixity -> Fixity -> Fixity #
Show Fixity # |
Methods showsPrec :: Int -> Fixity -> ShowS # show :: Fixity -> String # showList :: [Fixity] -> ShowS #

The following three functions all create lists of fixities from textual representations of operators. The intended usage is e.g.

    fixs = infixr_ 0  ["$","$!","`seq`"]

Note that the operators are expected as you would write them infix, i.e. with ` characters surrounding varid operators, and varsym operators written as is.

infix_ :: Int -> [String] -> [Fixity] #

infixl_ :: Int -> [String] -> [Fixity] #

infixr_ :: Int -> [String] -> [Fixity] #

## Collections of fixities

preludeFixities :: [Fixity] #

All fixities defined in the Prelude.

baseFixities :: [Fixity] #

All fixities defined in the base package.

Note that the `+++` operator appears in both Control.Arrows and Text.ParserCombinators.ReadP. The listed precedence for `+++` in this list is that of Control.Arrows.

# Applying fixities to an AST

class AppFixity ast where #

All AST elements that may include expressions which in turn may need fixity tweaking will be instances of this class.

Minimal complete definition

applyFixities

Methods

applyFixities :: Monad m => [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo) #

Tweak any expressions in the element to account for the fixities given. Assumes that all operator expressions are fully left associative chains to begin with.

Instances

AppFixity Alt # |
Methods applyFixities :: Monad m => [Fixity] -> Alt SrcSpanInfo -> m (Alt SrcSpanInfo) #
AppFixity FieldUpdate # |
Methods applyFixities :: Monad m => [Fixity] -> FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo) #
AppFixity QualStmt # |
Methods applyFixities :: Monad m => [Fixity] -> QualStmt SrcSpanInfo -> m (QualStmt SrcSpanInfo) #
AppFixity Stmt # |
Methods applyFixities :: Monad m => [Fixity] -> Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo) #
AppFixity PatField # |
Methods applyFixities :: Monad m => [Fixity] -> PatField SrcSpanInfo -> m (PatField SrcSpanInfo) #
AppFixity RPat # |
Methods applyFixities :: Monad m => [Fixity] -> RPat SrcSpanInfo -> m (RPat SrcSpanInfo) #
AppFixity PXAttr # |
Methods applyFixities :: Monad m => [Fixity] -> PXAttr SrcSpanInfo -> m (PXAttr SrcSpanInfo) #
AppFixity Pat # |
Methods applyFixities :: Monad m => [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo) #
AppFixity Splice # |
Methods applyFixities :: Monad m => [Fixity] -> Splice SrcSpanInfo -> m (Splice SrcSpanInfo) #
AppFixity Bracket # |
Methods applyFixities :: Monad m => [Fixity] -> Bracket SrcSpanInfo -> m (Bracket SrcSpanInfo) #
AppFixity XAttr # |
Methods applyFixities :: Monad m => [Fixity] -> XAttr SrcSpanInfo -> m (XAttr SrcSpanInfo) #
AppFixity Exp # |
Methods applyFixities :: Monad m => [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo) #
AppFixity GuardedRhs # |
Methods applyFixities :: Monad m => [Fixity] -> GuardedRhs SrcSpanInfo -> m (GuardedRhs SrcSpanInfo) #
AppFixity Rhs # |
Methods applyFixities :: Monad m => [Fixity] -> Rhs SrcSpanInfo -> m (Rhs SrcSpanInfo) #
AppFixity InstDecl # |
Methods applyFixities :: Monad m => [Fixity] -> InstDecl SrcSpanInfo -> m (InstDecl SrcSpanInfo) #
AppFixity ClassDecl # |
Methods applyFixities :: Monad m => [Fixity] -> ClassDecl SrcSpanInfo -> m (ClassDecl SrcSpanInfo) #
AppFixity Match # |
Methods applyFixities :: Monad m => [Fixity] -> Match SrcSpanInfo -> m (Match SrcSpanInfo) #
AppFixity IPBind # |
Methods applyFixities :: Monad m => [Fixity] -> IPBind SrcSpanInfo -> m (IPBind SrcSpanInfo) #
AppFixity Binds # |
Methods applyFixities :: Monad m => [Fixity] -> Binds SrcSpanInfo -> m (Binds SrcSpanInfo) #
AppFixity Annotation # |
Methods applyFixities :: Monad m => [Fixity] -> Annotation SrcSpanInfo -> m (Annotation SrcSpanInfo) #
AppFixity PatternSynDirection # |
Methods applyFixities :: Monad m => [Fixity] -> PatternSynDirection SrcSpanInfo -> m (PatternSynDirection SrcSpanInfo) #
AppFixity Decl # |
Methods applyFixities :: Monad m => [Fixity] -> Decl SrcSpanInfo -> m (Decl SrcSpanInfo) #
AppFixity Module # |
Methods applyFixities :: Monad m => [Fixity] -> Module SrcSpanInfo -> m (Module SrcSpanInfo) #