{-# LANGUAGE DeriveDataTypeable #-}
{-# OPTIONS_GHC -Wno-dodgy-exports #-}
module GHC.Types.Fixity
( Fixity (..)
, FixityDirection (..)
, LexicalFixity (..)
, maxPrecedence
, minPrecedence
, defaultFixity
, negateFixity
, funTyFixity
, compareFixity
, module GHC.Hs.Basic
)
where
import GHC.Prelude
import Language.Haskell.Syntax.Basic (LexicalFixity(..), FixityDirection(..), Fixity(..) )
import GHC.Hs.Basic ()
maxPrecedence, minPrecedence :: Int
maxPrecedence :: Int
maxPrecedence = Int
9
minPrecedence :: Int
minPrecedence = Int
0
defaultFixity :: Fixity
defaultFixity :: Fixity
defaultFixity = Int -> FixityDirection -> Fixity
Fixity Int
maxPrecedence FixityDirection
InfixL
negateFixity, funTyFixity :: Fixity
negateFixity :: Fixity
negateFixity = Int -> FixityDirection -> Fixity
Fixity Int
6 FixityDirection
InfixL
funTyFixity :: Fixity
funTyFixity = Int -> FixityDirection -> Fixity
Fixity (-Int
1) FixityDirection
InfixR
compareFixity :: Fixity -> Fixity
-> (Bool,
Bool)
compareFixity :: Fixity -> Fixity -> (Bool, Bool)
compareFixity (Fixity Int
prec1 FixityDirection
dir1) (Fixity Int
prec2 FixityDirection
dir2)
= case Int
prec1 Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Int
prec2 of
Ordering
GT -> (Bool, Bool)
left
Ordering
LT -> (Bool, Bool)
right
Ordering
EQ -> case (FixityDirection
dir1, FixityDirection
dir2) of
(FixityDirection
InfixR, FixityDirection
InfixR) -> (Bool, Bool)
right
(FixityDirection
InfixL, FixityDirection
InfixL) -> (Bool, Bool)
left
(FixityDirection, FixityDirection)
_ -> (Bool, Bool)
error_please
where
right :: (Bool, Bool)
right = (Bool
False, Bool
True)
left :: (Bool, Bool)
left = (Bool
False, Bool
False)
error_please :: (Bool, Bool)
error_please = (Bool
True, Bool
False)