{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE CPP #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Language.Haskell.Exts.Fixity
-- Copyright   :  (c) Niklas Broberg 2009
-- License     :  BSD-style (see the file LICENSE.txt)
--
-- Maintainer  :  Niklas Broberg, d00nibro@chalmers.se
-- Stability   :  stable
-- Portability :  portable
--
-- Fixity information to give the parser so that infix operators can
-- be parsed properly.
--
-----------------------------------------------------------------------------
module Language.Haskell.Exts.Fixity
    (
    -- * Fixity representation
      Fixity(..)
    -- | 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_, infixl_, infixr_
    -- ** Collections of fixities
    , preludeFixities, baseFixities

    -- * Applying fixities to an AST
    , AppFixity(..)
    ) where

import Language.Haskell.Exts.Syntax
import Language.Haskell.Exts.SrcLoc

import Control.Monad (when, (<=<), liftM, liftM2, liftM3, liftM4)
import qualified Control.Monad.Fail as Fail
import Data.Traversable (mapM)
import Data.Maybe (fromMaybe)
import Data.Typeable
import Data.Data hiding (Fixity)
#if __GLASGOW_HASKELL__ < 710
import Control.Applicative ((<$))
#endif
import Prelude hiding (mapM)

-- | Operator fixities are represented by their associativity
--   (left, right or none) and their precedence (0-9).
data Fixity = Fixity (Assoc ()) Int (QName ())
  deriving (Fixity -> Fixity -> Bool
(Fixity -> Fixity -> Bool)
-> (Fixity -> Fixity -> Bool) -> Eq Fixity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Fixity -> Fixity -> Bool
$c/= :: Fixity -> Fixity -> Bool
== :: Fixity -> Fixity -> Bool
$c== :: Fixity -> Fixity -> Bool
Eq,Eq Fixity
Eq Fixity
-> (Fixity -> Fixity -> Ordering)
-> (Fixity -> Fixity -> Bool)
-> (Fixity -> Fixity -> Bool)
-> (Fixity -> Fixity -> Bool)
-> (Fixity -> Fixity -> Bool)
-> (Fixity -> Fixity -> Fixity)
-> (Fixity -> Fixity -> Fixity)
-> Ord Fixity
Fixity -> Fixity -> Bool
Fixity -> Fixity -> Ordering
Fixity -> Fixity -> Fixity
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Fixity -> Fixity -> Fixity
$cmin :: Fixity -> Fixity -> Fixity
max :: Fixity -> Fixity -> Fixity
$cmax :: Fixity -> Fixity -> Fixity
>= :: Fixity -> Fixity -> Bool
$c>= :: Fixity -> Fixity -> Bool
> :: Fixity -> Fixity -> Bool
$c> :: Fixity -> Fixity -> Bool
<= :: Fixity -> Fixity -> Bool
$c<= :: Fixity -> Fixity -> Bool
< :: Fixity -> Fixity -> Bool
$c< :: Fixity -> Fixity -> Bool
compare :: Fixity -> Fixity -> Ordering
$ccompare :: Fixity -> Fixity -> Ordering
$cp1Ord :: Eq Fixity
Ord,Int -> Fixity -> ShowS
[Fixity] -> ShowS
Fixity -> String
(Int -> Fixity -> ShowS)
-> (Fixity -> String) -> ([Fixity] -> ShowS) -> Show Fixity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Fixity] -> ShowS
$cshowList :: [Fixity] -> ShowS
show :: Fixity -> String
$cshow :: Fixity -> String
showsPrec :: Int -> Fixity -> ShowS
$cshowsPrec :: Int -> Fixity -> ShowS
Show,Typeable,Typeable Fixity
DataType
Constr
Typeable Fixity
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Fixity -> c Fixity)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Fixity)
-> (Fixity -> Constr)
-> (Fixity -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Fixity))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity))
-> ((forall b. Data b => b -> b) -> Fixity -> Fixity)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Fixity -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Fixity -> r)
-> (forall u. (forall d. Data d => d -> u) -> Fixity -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Fixity -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Fixity -> m Fixity)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Fixity -> m Fixity)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Fixity -> m Fixity)
-> Data Fixity
Fixity -> DataType
Fixity -> Constr
(forall b. Data b => b -> b) -> Fixity -> Fixity
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Fixity -> c Fixity
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Fixity
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Fixity -> u
forall u. (forall d. Data d => d -> u) -> Fixity -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Fixity -> m Fixity
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Fixity -> m Fixity
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Fixity
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Fixity -> c Fixity
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Fixity)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity)
$cFixity :: Constr
$tFixity :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Fixity -> m Fixity
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Fixity -> m Fixity
gmapMp :: (forall d. Data d => d -> m d) -> Fixity -> m Fixity
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Fixity -> m Fixity
gmapM :: (forall d. Data d => d -> m d) -> Fixity -> m Fixity
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Fixity -> m Fixity
gmapQi :: Int -> (forall d. Data d => d -> u) -> Fixity -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Fixity -> u
gmapQ :: (forall d. Data d => d -> u) -> Fixity -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Fixity -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Fixity -> r
gmapT :: (forall b. Data b => b -> b) -> Fixity -> Fixity
$cgmapT :: (forall b. Data b => b -> b) -> Fixity -> Fixity
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Fixity)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Fixity)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Fixity)
dataTypeOf :: Fixity -> DataType
$cdataTypeOf :: Fixity -> DataType
toConstr :: Fixity -> Constr
$ctoConstr :: Fixity -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Fixity
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Fixity
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Fixity -> c Fixity
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Fixity -> c Fixity
$cp1Data :: Typeable Fixity
Data)

-- | All AST elements that may include expressions which in turn may
--   need fixity tweaking will be instances of this class.
class AppFixity ast where
  -- | 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.
  applyFixities :: Fail.MonadFail m => [Fixity]  -- ^ The fixities to account for.
                    -> ast SrcSpanInfo           -- ^ The element to tweak.
                    -> m (ast SrcSpanInfo)       -- ^ The same element, but with operator expressions updated, or a failure.

assocNone, assocLeft, assocRight :: Assoc ()
assocNone :: Assoc ()
assocNone = () -> Assoc ()
forall l. l -> Assoc l
AssocNone ()
assocLeft :: Assoc ()
assocLeft = () -> Assoc ()
forall l. l -> Assoc l
AssocLeft ()
assocRight :: Assoc ()
assocRight = () -> Assoc ()
forall l. l -> Assoc l
AssocRight ()

instance AppFixity Exp where
  applyFixities :: [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
applyFixities [Fixity]
fixs' = [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
infFix [Fixity]
fixs' (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> Exp SrcSpanInfo
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
leafFix [Fixity]
fixs'
    where -- This is the real meat case. We can assume a left-associative list to begin with.
          infFix :: [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
infFix [Fixity]
fixs (InfixApp SrcSpanInfo
l2 Exp SrcSpanInfo
a QOp SrcSpanInfo
op2 Exp SrcSpanInfo
z) = do
              Exp SrcSpanInfo
e <- [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
infFix [Fixity]
fixs Exp SrcSpanInfo
a
              let fixup :: (Assoc (), a)
-> (Assoc (), a)
-> Exp SrcSpanInfo
-> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
fixup (Assoc ()
a1,a
p1) (Assoc ()
a2,a
p2) Exp SrcSpanInfo
y Exp SrcSpanInfo -> Exp SrcSpanInfo
pre = do
                      Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (a
p1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
p2 Bool -> Bool -> Bool
&& (Assoc ()
a1 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
/= Assoc ()
a2 Bool -> Bool -> Bool
|| Assoc ()
a1 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
== Assoc ()
assocNone)) -- Ambiguous infix expression!
                           (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> m ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Ambiguous infix expression"
                      if a
p1 a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
p2 Bool -> Bool -> Bool
|| a
p1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
p2 Bool -> Bool -> Bool
&& (Assoc ()
a1 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
== Assoc ()
assocLeft Bool -> Bool -> Bool
|| Assoc ()
a2 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
== Assoc ()
assocNone) -- Already right order
                       then Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> Exp SrcSpanInfo
-> QOp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> QOp l -> Exp l -> Exp l
InfixApp SrcSpanInfo
l2 Exp SrcSpanInfo
e QOp SrcSpanInfo
op2 Exp SrcSpanInfo
z
                       else (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Exp SrcSpanInfo -> Exp SrcSpanInfo
pre ([Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
infFix [Fixity]
fixs (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> Exp SrcSpanInfo
-> QOp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> QOp l -> Exp l -> Exp l
InfixApp (Exp SrcSpanInfo -> SrcSpanInfo
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Exp SrcSpanInfo
y SrcSpanInfo -> SrcSpanInfo -> SrcSpanInfo
<++> Exp SrcSpanInfo -> SrcSpanInfo
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Exp SrcSpanInfo
z) Exp SrcSpanInfo
y QOp SrcSpanInfo
op2 Exp SrcSpanInfo
z)
              case Exp SrcSpanInfo
e of
               InfixApp SrcSpanInfo
_ Exp SrcSpanInfo
x QOp SrcSpanInfo
op1 Exp SrcSpanInfo
y -> (Assoc (), Int)
-> (Assoc (), Int)
-> Exp SrcSpanInfo
-> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall a.
Ord a =>
(Assoc (), a)
-> (Assoc (), a)
-> Exp SrcSpanInfo
-> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
fixup ([Fixity] -> QOp SrcSpanInfo -> (Assoc (), Int)
forall l. [Fixity] -> QOp l -> (Assoc (), Int)
askFixity [Fixity]
fixs QOp SrcSpanInfo
op1) ([Fixity] -> QOp SrcSpanInfo -> (Assoc (), Int)
forall l. [Fixity] -> QOp l -> (Assoc (), Int)
askFixity [Fixity]
fixs QOp SrcSpanInfo
op2) Exp SrcSpanInfo
y (SrcSpanInfo
-> Exp SrcSpanInfo
-> QOp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> QOp l -> Exp l -> Exp l
InfixApp SrcSpanInfo
l2 Exp SrcSpanInfo
x QOp SrcSpanInfo
op1)
               NegApp   SrcSpanInfo
_       Exp SrcSpanInfo
y -> (Assoc (), Int)
-> (Assoc (), Int)
-> Exp SrcSpanInfo
-> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall a.
Ord a =>
(Assoc (), a)
-> (Assoc (), a)
-> Exp SrcSpanInfo
-> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
fixup (Assoc (), Int)
prefixMinusFixity    ([Fixity] -> QOp SrcSpanInfo -> (Assoc (), Int)
forall l. [Fixity] -> QOp l -> (Assoc (), Int)
askFixity [Fixity]
fixs QOp SrcSpanInfo
op2) Exp SrcSpanInfo
y (SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l
NegApp SrcSpanInfo
l2)
               Exp SrcSpanInfo
_  -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> Exp SrcSpanInfo
-> QOp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> QOp l -> Exp l -> Exp l
InfixApp SrcSpanInfo
l2 Exp SrcSpanInfo
e QOp SrcSpanInfo
op2 Exp SrcSpanInfo
z

          infFix [Fixity]
_ Exp SrcSpanInfo
e = Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Exp SrcSpanInfo
e

--ambOps l = ParseFailed (getPointLoc l) $ "Ambiguous infix expression"

instance AppFixity Pat where
  applyFixities :: [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
applyFixities [Fixity]
fixs' = [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
infFix [Fixity]
fixs' (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> Pat SrcSpanInfo
-> m (Pat SrcSpanInfo)
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
leafFixP [Fixity]
fixs'
    where -- This is the real meat case. We can assume a left-associative list to begin with.
          infFix :: [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
infFix [Fixity]
fixs (PInfixApp SrcSpanInfo
l2 Pat SrcSpanInfo
a QName SrcSpanInfo
op2 Pat SrcSpanInfo
z) = do
              Pat SrcSpanInfo
p <- [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
infFix [Fixity]
fixs Pat SrcSpanInfo
a
              let fixup :: (Assoc (), a)
-> (Assoc (), a)
-> Pat SrcSpanInfo
-> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
fixup (Assoc ()
a1,a
p1) (Assoc ()
a2,a
p2) Pat SrcSpanInfo
y Pat SrcSpanInfo -> Pat SrcSpanInfo
pre = do
                      Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (a
p1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
p2 Bool -> Bool -> Bool
&& (Assoc ()
a1 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
/= Assoc ()
a2 Bool -> Bool -> Bool
|| Assoc ()
a1 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
== Assoc ()
assocNone )) -- Ambiguous infix expression!
                           (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> m ()
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Ambiguous infix expression"
                      if a
p1 a -> a -> Bool
forall a. Ord a => a -> a -> Bool
> a
p2 Bool -> Bool -> Bool
|| a
p1 a -> a -> Bool
forall a. Eq a => a -> a -> Bool
== a
p2 Bool -> Bool -> Bool
&& (Assoc ()
a1 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
== Assoc ()
assocLeft Bool -> Bool -> Bool
|| Assoc ()
a2 Assoc () -> Assoc () -> Bool
forall a. Eq a => a -> a -> Bool
== Assoc ()
assocNone) -- Already right order
                       then Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> Pat SrcSpanInfo
-> QName SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
forall l. l -> Pat l -> QName l -> Pat l -> Pat l
PInfixApp SrcSpanInfo
l2 Pat SrcSpanInfo
p QName SrcSpanInfo
op2 Pat SrcSpanInfo
z
                       else (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM Pat SrcSpanInfo -> Pat SrcSpanInfo
pre ([Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
infFix [Fixity]
fixs (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> Pat SrcSpanInfo
-> QName SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
forall l. l -> Pat l -> QName l -> Pat l -> Pat l
PInfixApp (Pat SrcSpanInfo -> SrcSpanInfo
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Pat SrcSpanInfo
y SrcSpanInfo -> SrcSpanInfo -> SrcSpanInfo
<++> Pat SrcSpanInfo -> SrcSpanInfo
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Pat SrcSpanInfo
z) Pat SrcSpanInfo
y QName SrcSpanInfo
op2 Pat SrcSpanInfo
z)
              case Pat SrcSpanInfo
p of
               PInfixApp SrcSpanInfo
_ Pat SrcSpanInfo
x QName SrcSpanInfo
op1 Pat SrcSpanInfo
y -> (Assoc (), Int)
-> (Assoc (), Int)
-> Pat SrcSpanInfo
-> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
forall a.
Ord a =>
(Assoc (), a)
-> (Assoc (), a)
-> Pat SrcSpanInfo
-> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
fixup ([Fixity] -> QName SrcSpanInfo -> (Assoc (), Int)
forall l. [Fixity] -> QName l -> (Assoc (), Int)
askFixityP [Fixity]
fixs QName SrcSpanInfo
op1) ([Fixity] -> QName SrcSpanInfo -> (Assoc (), Int)
forall l. [Fixity] -> QName l -> (Assoc (), Int)
askFixityP [Fixity]
fixs QName SrcSpanInfo
op2) Pat SrcSpanInfo
y (SrcSpanInfo
-> Pat SrcSpanInfo
-> QName SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
forall l. l -> Pat l -> QName l -> Pat l -> Pat l
PInfixApp SrcSpanInfo
l2 Pat SrcSpanInfo
x QName SrcSpanInfo
op1)
               Pat SrcSpanInfo
_  -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> Pat SrcSpanInfo
-> QName SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
forall l. l -> Pat l -> QName l -> Pat l -> Pat l
PInfixApp SrcSpanInfo
l2 Pat SrcSpanInfo
p QName SrcSpanInfo
op2 Pat SrcSpanInfo
z

          infFix [Fixity]
_ Pat SrcSpanInfo
p = Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Pat SrcSpanInfo
p

-- Internal: lookup associativity and precedence of an operator
askFixity :: [Fixity] -> QOp l -> (Assoc (), Int)
askFixity :: [Fixity] -> QOp l -> (Assoc (), Int)
askFixity [Fixity]
xs QOp l
k = [Fixity] -> QName () -> (Assoc (), Int)
forall l. [Fixity] -> QName l -> (Assoc (), Int)
askFix [Fixity]
xs (QOp () -> QName ()
f (() () -> QOp l -> QOp ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ QOp l
k))
    where
        f :: QOp () -> QName ()
f (QVarOp ()
_ QName ()
x) = QName () -> QName ()
g QName ()
x
        f (QConOp ()
_ QName ()
x) = QName () -> QName ()
g QName ()
x

        g :: QName () -> QName ()
g (Special ()
_ (Cons ()
_)) = () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () (() -> String -> Name ()
forall l. l -> String -> Name l
Symbol () String
":")
        g QName ()
x                  = QName ()
x

-- Same using patterns
askFixityP :: [Fixity] -> QName l -> (Assoc (), Int)
askFixityP :: [Fixity] -> QName l -> (Assoc (), Int)
askFixityP [Fixity]
xs QName l
qn = [Fixity] -> QName () -> (Assoc (), Int)
forall l. [Fixity] -> QName l -> (Assoc (), Int)
askFix [Fixity]
xs (QName () -> QName ()
g (() () -> QName l -> QName ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ QName l
qn))
    where
        g :: QName () -> QName ()
g (Special ()
_ (Cons ()
_)) = () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () (() -> String -> Name ()
forall l. l -> String -> Name l
Symbol () String
":")
        g QName ()
x                  = QName ()
x

askFix :: [Fixity] -> QName l -> (Assoc (), Int)
askFix :: [Fixity] -> QName l -> (Assoc (), Int)
askFix [Fixity]
xs = \QName l
k -> (Assoc (), Int)
-> QName () -> [(QName (), (Assoc (), Int))] -> (Assoc (), Int)
forall a a. Eq a => a -> a -> [(a, a)] -> a
lookupWithDefault (Assoc ()
assocLeft, Int
9) (() () -> QName l -> QName ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ QName l
k) [(QName (), (Assoc (), Int))]
mp
    where
        lookupWithDefault :: a -> a -> [(a, a)] -> a
lookupWithDefault a
def a
k [(a, a)]
mp' = a -> Maybe a -> a
forall a. a -> Maybe a -> a
fromMaybe a
def (Maybe a -> a) -> Maybe a -> a
forall a b. (a -> b) -> a -> b
$ a -> [(a, a)] -> Maybe a
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup a
k [(a, a)]
mp'

        mp :: [(QName (), (Assoc (), Int))]
mp = [(QName ()
x,(Assoc ()
a,Int
p)) | Fixity Assoc ()
a Int
p QName ()
x <- [Fixity]
xs]



-- | Built-in fixity for prefix minus
prefixMinusFixity :: (Assoc (), Int)
prefixMinusFixity :: (Assoc (), Int)
prefixMinusFixity = (() -> Assoc ()
forall l. l -> Assoc l
AssocLeft (), Int
6)

-- | All fixities defined in the Prelude.
preludeFixities :: [Fixity]
preludeFixities :: [Fixity]
preludeFixities = [[Fixity]] -> [Fixity]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
    [Int -> [String] -> [Fixity]
infixr_ Int
9  [String
"."]
    ,Int -> [String] -> [Fixity]
infixl_ Int
9  [String
"!!"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
8  [String
"^",String
"^^",String
"**"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
7  [String
"*",String
"/",String
"`quot`",String
"`rem`",String
"`div`",String
"`mod`"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
6  [String
"+",String
"-"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
5  [String
":",String
"++"]
    ,Int -> [String] -> [Fixity]
infix_  Int
4  [String
"==",String
"/=",String
"<",String
"<=",String
">=",String
">",String
"`elem`",String
"`notElem`"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
4  [String
"<$>",String
"<$",String
"<*>",String
"<*",String
"*>"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
3  [String
"&&"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
2  [String
"||"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
1  [String
">>",String
">>="]
    ,Int -> [String] -> [Fixity]
infixr_ Int
1  [String
"=<<"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
0  [String
"$",String
"$!",String
"`seq`"]
    ]

-- | 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.
baseFixities :: [Fixity]
baseFixities :: [Fixity]
baseFixities = [Fixity]
preludeFixities [Fixity] -> [Fixity] -> [Fixity]
forall a. [a] -> [a] -> [a]
++ [[Fixity]] -> [Fixity]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
    [Int -> [String] -> [Fixity]
infixl_ Int
9 [String
"!",String
"//",String
"!:"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
9 [String
"`Compose`"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
8 [String
"`shift`",String
"`rotate`",String
"`shiftL`",String
"`shiftR`",String
"`rotateL`",String
"`rotateR`"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
7 [String
".&.",String
"%"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
6 [String
"<>"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
6 [String
"`xor`"]
    ,Int -> [String] -> [Fixity]
infix_  Int
6 [String
":+"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
5 [String
".|."]
    ,Int -> [String] -> [Fixity]
infixr_ Int
5 [String
"+:+",String
"<++",String
"<+>",String
"<|"] -- fixity conflict for +++ between ReadP and Arrow
    ,Int -> [String] -> [Fixity]
infix_  Int
5 [String
"\\\\"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
4 [String
"<**>",String
"$>",String
"<$",String
"<$!>"]
    ,Int -> [String] -> [Fixity]
infix_  Int
4 [String
"`elemP`",String
"`notElemP`",String
":~:",String
":~~:"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
3 [String
"<|>"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
3 [String
"&&&",String
"***"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
2 [String
"+++",String
"|||"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
1 [String
"<=<",String
">=>",String
">>>",String
"<<<",String
"^<<",String
"<<^",String
"^>>",String
">>^"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
1 [String
"&"]
    ,Int -> [String] -> [Fixity]
infixl_ Int
0 [String
"`on`"]
    ,Int -> [String] -> [Fixity]
infixr_ Int
0 [String
"`par`",String
"`pseq`"]
    ]

infixr_, infixl_, infix_ :: Int -> [String] -> [Fixity]
infixr_ :: Int -> [String] -> [Fixity]
infixr_ = Assoc () -> Int -> [String] -> [Fixity]
fixity  Assoc ()
assocRight
infixl_ :: Int -> [String] -> [Fixity]
infixl_ = Assoc () -> Int -> [String] -> [Fixity]
fixity  Assoc ()
assocLeft
infix_ :: Int -> [String] -> [Fixity]
infix_  = Assoc () -> Int -> [String] -> [Fixity]
fixity  Assoc ()
assocNone

-- Internal: help function for the above definitions.
fixity :: Assoc () -> Int -> [String] -> [Fixity]
fixity :: Assoc () -> Int -> [String] -> [Fixity]
fixity Assoc ()
a Int
p = (String -> Fixity) -> [String] -> [Fixity]
forall a b. (a -> b) -> [a] -> [b]
map (Assoc () -> Int -> QName () -> Fixity
Fixity Assoc ()
a Int
p (QName () -> Fixity) -> (String -> QName ()) -> String -> Fixity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> QName ()
op)
    where
        op :: String -> QName ()
op (Char
'`':String
xs) = () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () (Name () -> QName ()) -> Name () -> QName ()
forall a b. (a -> b) -> a -> b
$ () -> String -> Name ()
forall l. l -> String -> Name l
Ident () (String -> Name ()) -> String -> Name ()
forall a b. (a -> b) -> a -> b
$ ShowS
forall a. [a] -> [a]
init String
xs
        op String
xs = () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () (Name () -> QName ()) -> Name () -> QName ()
forall a b. (a -> b) -> a -> b
$ () -> String -> Name ()
forall l. l -> String -> Name l
Symbol () String
xs








-------------------------------------------------------------------
-- Boilerplate - yuck!! Everything below here is internal stuff

instance AppFixity Module where
    applyFixities :: [Fixity] -> Module SrcSpanInfo -> m (Module SrcSpanInfo)
applyFixities [Fixity]
fixs (Module SrcSpanInfo
l Maybe (ModuleHead SrcSpanInfo)
mmh [ModulePragma SrcSpanInfo]
prs [ImportDecl SrcSpanInfo]
imp [Decl SrcSpanInfo]
decls) =
        ([Decl SrcSpanInfo] -> Module SrcSpanInfo)
-> m [Decl SrcSpanInfo] -> m (Module SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Maybe (ModuleHead SrcSpanInfo)
-> [ModulePragma SrcSpanInfo]
-> [ImportDecl SrcSpanInfo]
-> [Decl SrcSpanInfo]
-> Module SrcSpanInfo
forall l.
l
-> Maybe (ModuleHead l)
-> [ModulePragma l]
-> [ImportDecl l]
-> [Decl l]
-> Module l
Module SrcSpanInfo
l Maybe (ModuleHead SrcSpanInfo)
mmh [ModulePragma SrcSpanInfo]
prs [ImportDecl SrcSpanInfo]
imp) (m [Decl SrcSpanInfo] -> m (Module SrcSpanInfo))
-> m [Decl SrcSpanInfo] -> m (Module SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
forall (m :: * -> *).
MonadFail m =>
Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
appFixDecls Maybe (ModuleName SrcSpanInfo)
mmn [Fixity]
fixs [Decl SrcSpanInfo]
decls
      where mmn :: Maybe (ModuleName SrcSpanInfo)
mmn = Maybe (ModuleHead SrcSpanInfo) -> Maybe (ModuleName SrcSpanInfo)
forall l. Maybe (ModuleHead l) -> Maybe (ModuleName l)
getMmn Maybe (ModuleHead SrcSpanInfo)
mmh
            getMmn :: Maybe (ModuleHead l) -> Maybe (ModuleName l)
getMmn (Just (ModuleHead l
_ ModuleName l
n Maybe (WarningText l)
_ Maybe (ExportSpecList l)
_)) = ModuleName l -> Maybe (ModuleName l)
forall a. a -> Maybe a
Just ModuleName l
n
            getMmn Maybe (ModuleHead l)
_ = Maybe (ModuleName l)
forall a. Maybe a
Nothing
    applyFixities [Fixity]
fixs (XmlPage SrcSpanInfo
l ModuleName SrcSpanInfo
mn [ModulePragma SrcSpanInfo]
os XName SrcSpanInfo
xn [XAttr SrcSpanInfo]
xas Maybe (Exp SrcSpanInfo)
mexp [Exp SrcSpanInfo]
cs) =
        ([XAttr SrcSpanInfo]
 -> Maybe (Exp SrcSpanInfo)
 -> [Exp SrcSpanInfo]
 -> Module SrcSpanInfo)
-> m [XAttr SrcSpanInfo]
-> m (Maybe (Exp SrcSpanInfo))
-> m [Exp SrcSpanInfo]
-> m (Module SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> ModuleName SrcSpanInfo
-> [ModulePragma SrcSpanInfo]
-> XName SrcSpanInfo
-> [XAttr SrcSpanInfo]
-> Maybe (Exp SrcSpanInfo)
-> [Exp SrcSpanInfo]
-> Module SrcSpanInfo
forall l.
l
-> ModuleName l
-> [ModulePragma l]
-> XName l
-> [XAttr l]
-> Maybe (Exp l)
-> [Exp l]
-> Module l
XmlPage SrcSpanInfo
l ModuleName SrcSpanInfo
mn [ModulePragma SrcSpanInfo]
os XName SrcSpanInfo
xn) ([XAttr SrcSpanInfo] -> m [XAttr SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) (ast :: * -> *).
(Traversable t, AppFixity ast, MonadFail m) =>
t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fix [XAttr SrcSpanInfo]
xas) (Maybe (Exp SrcSpanInfo) -> m (Maybe (Exp SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) (ast :: * -> *).
(Traversable t, AppFixity ast, MonadFail m) =>
t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fix Maybe (Exp SrcSpanInfo)
mexp) ([Exp SrcSpanInfo] -> m [Exp SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) (ast :: * -> *).
(Traversable t, AppFixity ast, MonadFail m) =>
t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fix [Exp SrcSpanInfo]
cs)
      where fix :: t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fix t (ast SrcSpanInfo)
xs = (ast SrcSpanInfo -> m (ast SrcSpanInfo))
-> t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ([Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs) t (ast SrcSpanInfo)
xs
    applyFixities [Fixity]
fixs (XmlHybrid SrcSpanInfo
l Maybe (ModuleHead SrcSpanInfo)
mmh [ModulePragma SrcSpanInfo]
prs [ImportDecl SrcSpanInfo]
imp [Decl SrcSpanInfo]
decls XName SrcSpanInfo
xn [XAttr SrcSpanInfo]
xas Maybe (Exp SrcSpanInfo)
mexp [Exp SrcSpanInfo]
cs) =
        ([Decl SrcSpanInfo]
 -> [XAttr SrcSpanInfo]
 -> Maybe (Exp SrcSpanInfo)
 -> [Exp SrcSpanInfo]
 -> Module SrcSpanInfo)
-> m [Decl SrcSpanInfo]
-> m [XAttr SrcSpanInfo]
-> m (Maybe (Exp SrcSpanInfo))
-> m [Exp SrcSpanInfo]
-> m (Module SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 (([Decl SrcSpanInfo]
 -> XName SrcSpanInfo
 -> [XAttr SrcSpanInfo]
 -> Maybe (Exp SrcSpanInfo)
 -> [Exp SrcSpanInfo]
 -> Module SrcSpanInfo)
-> XName SrcSpanInfo
-> [Decl SrcSpanInfo]
-> [XAttr SrcSpanInfo]
-> Maybe (Exp SrcSpanInfo)
-> [Exp SrcSpanInfo]
-> Module SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Maybe (ModuleHead SrcSpanInfo)
-> [ModulePragma SrcSpanInfo]
-> [ImportDecl SrcSpanInfo]
-> [Decl SrcSpanInfo]
-> XName SrcSpanInfo
-> [XAttr SrcSpanInfo]
-> Maybe (Exp SrcSpanInfo)
-> [Exp SrcSpanInfo]
-> Module SrcSpanInfo
forall l.
l
-> Maybe (ModuleHead l)
-> [ModulePragma l]
-> [ImportDecl l]
-> [Decl l]
-> XName l
-> [XAttr l]
-> Maybe (Exp l)
-> [Exp l]
-> Module l
XmlHybrid SrcSpanInfo
l Maybe (ModuleHead SrcSpanInfo)
mmh [ModulePragma SrcSpanInfo]
prs [ImportDecl SrcSpanInfo]
imp) XName SrcSpanInfo
xn) (Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
forall (m :: * -> *).
MonadFail m =>
Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
appFixDecls Maybe (ModuleName SrcSpanInfo)
mmn [Fixity]
fixs [Decl SrcSpanInfo]
decls)
                ([XAttr SrcSpanInfo] -> m [XAttr SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) (ast :: * -> *).
(Traversable t, AppFixity ast, MonadFail m) =>
t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fixe [XAttr SrcSpanInfo]
xas) (Maybe (Exp SrcSpanInfo) -> m (Maybe (Exp SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) (ast :: * -> *).
(Traversable t, AppFixity ast, MonadFail m) =>
t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fixe Maybe (Exp SrcSpanInfo)
mexp) ([Exp SrcSpanInfo] -> m [Exp SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) (ast :: * -> *).
(Traversable t, AppFixity ast, MonadFail m) =>
t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fixe [Exp SrcSpanInfo]
cs)
      where mmn :: Maybe (ModuleName SrcSpanInfo)
mmn = Maybe (ModuleHead SrcSpanInfo) -> Maybe (ModuleName SrcSpanInfo)
forall l. Maybe (ModuleHead l) -> Maybe (ModuleName l)
getMmn Maybe (ModuleHead SrcSpanInfo)
mmh
            getMmn :: Maybe (ModuleHead l) -> Maybe (ModuleName l)
getMmn (Just (ModuleHead l
_ ModuleName l
n Maybe (WarningText l)
_ Maybe (ExportSpecList l)
_)) = ModuleName l -> Maybe (ModuleName l)
forall a. a -> Maybe a
Just ModuleName l
n
            getMmn Maybe (ModuleHead l)
_ = Maybe (ModuleName l)
forall a. Maybe a
Nothing
            fixe :: t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
fixe t (ast SrcSpanInfo)
xs = let extraFixs :: [Fixity]
extraFixs = Maybe (ModuleName SrcSpanInfo) -> [Decl SrcSpanInfo] -> [Fixity]
forall l. Maybe (ModuleName l) -> [Decl l] -> [Fixity]
getFixities Maybe (ModuleName SrcSpanInfo)
mmn [Decl SrcSpanInfo]
decls
                       in (ast SrcSpanInfo -> m (ast SrcSpanInfo))
-> t (ast SrcSpanInfo) -> m (t (ast SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ([Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities ([Fixity]
fixs[Fixity] -> [Fixity] -> [Fixity]
forall a. [a] -> [a] -> [a]
++[Fixity]
extraFixs)) t (ast SrcSpanInfo)
xs

instance AppFixity Decl where
    applyFixities :: [Fixity] -> Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
applyFixities [Fixity]
fixs Decl SrcSpanInfo
decl = case Decl SrcSpanInfo
decl of
        ClassDecl SrcSpanInfo
l Maybe (Context SrcSpanInfo)
ctxt DeclHead SrcSpanInfo
dh [FunDep SrcSpanInfo]
deps Maybe [ClassDecl SrcSpanInfo]
cdecls   -> (Maybe [ClassDecl SrcSpanInfo] -> Decl SrcSpanInfo)
-> m (Maybe [ClassDecl SrcSpanInfo]) -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Maybe (Context SrcSpanInfo)
-> DeclHead SrcSpanInfo
-> [FunDep SrcSpanInfo]
-> Maybe [ClassDecl SrcSpanInfo]
-> Decl SrcSpanInfo
forall l.
l
-> Maybe (Context l)
-> DeclHead l
-> [FunDep l]
-> Maybe [ClassDecl l]
-> Decl l
ClassDecl SrcSpanInfo
l Maybe (Context SrcSpanInfo)
ctxt DeclHead SrcSpanInfo
dh [FunDep SrcSpanInfo]
deps) (m (Maybe [ClassDecl SrcSpanInfo]) -> m (Decl SrcSpanInfo))
-> m (Maybe [ClassDecl SrcSpanInfo]) -> m (Decl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ ([ClassDecl SrcSpanInfo] -> m [ClassDecl SrcSpanInfo])
-> Maybe [ClassDecl SrcSpanInfo]
-> m (Maybe [ClassDecl SrcSpanInfo])
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ClassDecl SrcSpanInfo -> m (ClassDecl SrcSpanInfo))
-> [ClassDecl SrcSpanInfo] -> m [ClassDecl SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ClassDecl SrcSpanInfo -> m (ClassDecl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix) Maybe [ClassDecl SrcSpanInfo]
cdecls
        InstDecl  SrcSpanInfo
l Maybe (Overlap SrcSpanInfo)
olp InstRule SrcSpanInfo
ih Maybe [InstDecl SrcSpanInfo]
idecls         -> (Maybe [InstDecl SrcSpanInfo] -> Decl SrcSpanInfo)
-> m (Maybe [InstDecl SrcSpanInfo]) -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Maybe (Overlap SrcSpanInfo)
-> InstRule SrcSpanInfo
-> Maybe [InstDecl SrcSpanInfo]
-> Decl SrcSpanInfo
forall l.
l
-> Maybe (Overlap l) -> InstRule l -> Maybe [InstDecl l] -> Decl l
InstDecl  SrcSpanInfo
l Maybe (Overlap SrcSpanInfo)
olp InstRule SrcSpanInfo
ih)  (m (Maybe [InstDecl SrcSpanInfo]) -> m (Decl SrcSpanInfo))
-> m (Maybe [InstDecl SrcSpanInfo]) -> m (Decl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ ([InstDecl SrcSpanInfo] -> m [InstDecl SrcSpanInfo])
-> Maybe [InstDecl SrcSpanInfo] -> m (Maybe [InstDecl SrcSpanInfo])
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((InstDecl SrcSpanInfo -> m (InstDecl SrcSpanInfo))
-> [InstDecl SrcSpanInfo] -> m [InstDecl SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM InstDecl SrcSpanInfo -> m (InstDecl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix) Maybe [InstDecl SrcSpanInfo]
idecls
        SpliceDecl SrcSpanInfo
l Exp SrcSpanInfo
spl        -> (Exp SrcSpanInfo -> Decl SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Decl SrcSpanInfo
forall l. l -> Exp l -> Decl l
SpliceDecl SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Decl SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Decl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
spl
        FunBind SrcSpanInfo
l [Match SrcSpanInfo]
matches       -> ([Match SrcSpanInfo] -> Decl SrcSpanInfo)
-> m [Match SrcSpanInfo] -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Match SrcSpanInfo] -> Decl SrcSpanInfo
forall l. l -> [Match l] -> Decl l
FunBind SrcSpanInfo
l) (m [Match SrcSpanInfo] -> m (Decl SrcSpanInfo))
-> m [Match SrcSpanInfo] -> m (Decl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Match SrcSpanInfo -> m (Match SrcSpanInfo))
-> [Match SrcSpanInfo] -> m [Match SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Match SrcSpanInfo -> m (Match SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Match SrcSpanInfo]
matches
        PatBind SrcSpanInfo
l Pat SrcSpanInfo
p Rhs SrcSpanInfo
rhs Maybe (Binds SrcSpanInfo)
bs      ->
         let extraFix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities ([Fixity]
fixs [Fixity] -> [Fixity] -> [Fixity]
forall a. [a] -> [a] -> [a]
++ [Fixity]
-> (Binds SrcSpanInfo -> [Fixity])
-> Maybe (Binds SrcSpanInfo)
-> [Fixity]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Binds SrcSpanInfo -> [Fixity]
forall l. Binds l -> [Fixity]
getBindFixities Maybe (Binds SrcSpanInfo)
bs) ast SrcSpanInfo
x
          in (Pat SrcSpanInfo
 -> Rhs SrcSpanInfo
 -> Maybe (Binds SrcSpanInfo)
 -> Decl SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Rhs SrcSpanInfo)
-> m (Maybe (Binds SrcSpanInfo))
-> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> Pat SrcSpanInfo
-> Rhs SrcSpanInfo
-> Maybe (Binds SrcSpanInfo)
-> Decl SrcSpanInfo
forall l. l -> Pat l -> Rhs l -> Maybe (Binds l) -> Decl l
PatBind SrcSpanInfo
l) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix Pat SrcSpanInfo
p) (Rhs SrcSpanInfo -> m (Rhs SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix Rhs SrcSpanInfo
rhs) ((Binds SrcSpanInfo -> m (Binds SrcSpanInfo))
-> Maybe (Binds SrcSpanInfo) -> m (Maybe (Binds SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix Maybe (Binds SrcSpanInfo)
bs)
        AnnPragma SrcSpanInfo
l Annotation SrcSpanInfo
ann'         -> (Annotation SrcSpanInfo -> Decl SrcSpanInfo)
-> m (Annotation SrcSpanInfo) -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Annotation SrcSpanInfo -> Decl SrcSpanInfo
forall l. l -> Annotation l -> Decl l
AnnPragma SrcSpanInfo
l) (m (Annotation SrcSpanInfo) -> m (Decl SrcSpanInfo))
-> m (Annotation SrcSpanInfo) -> m (Decl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Annotation SrcSpanInfo -> m (Annotation SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Annotation SrcSpanInfo
ann'
        PatSyn SrcSpanInfo
l Pat SrcSpanInfo
p1 Pat SrcSpanInfo
p2 PatternSynDirection SrcSpanInfo
dir -> (PatternSynDirection SrcSpanInfo -> Decl SrcSpanInfo)
-> m (PatternSynDirection SrcSpanInfo) -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
-> PatternSynDirection SrcSpanInfo
-> Decl SrcSpanInfo
forall l. l -> Pat l -> Pat l -> PatternSynDirection l -> Decl l
PatSyn SrcSpanInfo
l Pat SrcSpanInfo
p1 Pat SrcSpanInfo
p2) (PatternSynDirection SrcSpanInfo
-> m (PatternSynDirection SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix PatternSynDirection SrcSpanInfo
dir)
        Decl SrcSpanInfo
_                       -> Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Decl SrcSpanInfo
decl
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity PatternSynDirection where
  applyFixities :: [Fixity]
-> PatternSynDirection SrcSpanInfo
-> m (PatternSynDirection SrcSpanInfo)
applyFixities [Fixity]
fixs PatternSynDirection SrcSpanInfo
dir = case PatternSynDirection SrcSpanInfo
dir of
    ExplicitBidirectional SrcSpanInfo
l [Decl SrcSpanInfo]
ds -> ([Decl SrcSpanInfo] -> PatternSynDirection SrcSpanInfo)
-> m [Decl SrcSpanInfo] -> m (PatternSynDirection SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> [Decl SrcSpanInfo] -> PatternSynDirection SrcSpanInfo
forall l. l -> [Decl l] -> PatternSynDirection l
ExplicitBidirectional SrcSpanInfo
l) ((Decl SrcSpanInfo -> m (Decl SrcSpanInfo))
-> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Decl SrcSpanInfo]
ds)
    PatternSynDirection SrcSpanInfo
_ -> PatternSynDirection SrcSpanInfo
-> m (PatternSynDirection SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return PatternSynDirection SrcSpanInfo
dir
    where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

appFixDecls :: Fail.MonadFail m => Maybe (ModuleName SrcSpanInfo) -> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
appFixDecls :: Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
appFixDecls Maybe (ModuleName SrcSpanInfo)
mmdl [Fixity]
fixs [Decl SrcSpanInfo]
decls =
    let extraFixs :: [Fixity]
extraFixs = Maybe (ModuleName SrcSpanInfo) -> [Decl SrcSpanInfo] -> [Fixity]
forall l. Maybe (ModuleName l) -> [Decl l] -> [Fixity]
getFixities Maybe (ModuleName SrcSpanInfo)
mmdl [Decl SrcSpanInfo]
decls
     in (Decl SrcSpanInfo -> m (Decl SrcSpanInfo))
-> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ([Fixity] -> Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities ([Fixity]
fixs[Fixity] -> [Fixity] -> [Fixity]
forall a. [a] -> [a] -> [a]
++[Fixity]
extraFixs)) [Decl SrcSpanInfo]
decls

getFixities :: Maybe (ModuleName l) -> [Decl l] -> [Fixity]
getFixities :: Maybe (ModuleName l) -> [Decl l] -> [Fixity]
getFixities Maybe (ModuleName l)
mmdl = (Decl l -> [Fixity]) -> [Decl l] -> [Fixity]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Maybe (ModuleName l) -> Decl l -> [Fixity]
forall l. Maybe (ModuleName l) -> Decl l -> [Fixity]
getFixity Maybe (ModuleName l)
mmdl)

getFixity :: Maybe (ModuleName l) -> Decl l -> [Fixity]
getFixity :: Maybe (ModuleName l) -> Decl l -> [Fixity]
getFixity Maybe (ModuleName l)
mmdl Decl l
d =
  case Decl l
d of
    InfixDecl l
_ Assoc l
a Maybe Int
mp [Op l]
ops  -> let p :: Int
p = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
9 Maybe Int
mp
                              in (QName () -> Fixity) -> [QName ()] -> [Fixity]
forall a b. (a -> b) -> [a] -> [b]
map (Assoc () -> Int -> QName () -> Fixity
Fixity (Assoc l -> Assoc ()
forall (f :: * -> *) a. Functor f => f a -> f ()
scrub Assoc l
a) Int
p) ((Op () -> [QName ()]) -> [Op ()] -> [QName ()]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Op () -> [QName ()]
g ((Op l -> Op ()) -> [Op l] -> [Op ()]
forall a b. (a -> b) -> [a] -> [b]
map Op l -> Op ()
forall (f :: * -> *) a. Functor f => f a -> f ()
scrub [Op l]
ops))
    ClassDecl l
_ Maybe (Context l)
_ DeclHead l
_ [FunDep l]
_ Maybe [ClassDecl l]
cds -> [Fixity]
-> ([ClassDecl l] -> [Fixity]) -> Maybe [ClassDecl l] -> [Fixity]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ClassDecl l -> [Fixity]) -> [ClassDecl l] -> [Fixity]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ClassDecl l -> [Fixity]
getClassFixity) Maybe [ClassDecl l]
cds
    Decl l
_ -> []
  where g :: Op () -> [QName ()]
g (VarOp ()
_ Name ()
x) = Name () -> [QName ()]
f Name ()
x
        g (ConOp ()
_ Name ()
x) = Name () -> [QName ()]
f Name ()
x
        f :: Name () -> [QName ()]
f Name ()
x = case Maybe (ModuleName l)
mmdl of
              Maybe (ModuleName l)
Nothing -> [() -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () Name ()
x]
              Just ModuleName l
m  -> [() -> ModuleName () -> Name () -> QName ()
forall l. l -> ModuleName l -> Name l -> QName l
Qual () (ModuleName l -> ModuleName ()
forall (f :: * -> *) a. Functor f => f a -> f ()
scrub ModuleName l
m) Name ()
x, () -> Name () -> QName ()
forall l. l -> Name l -> QName l
UnQual () Name ()
x]
        getClassFixity :: ClassDecl l -> [Fixity]
getClassFixity (ClsDecl l
_ Decl l
cd) = Maybe (ModuleName l) -> Decl l -> [Fixity]
forall l. Maybe (ModuleName l) -> Decl l -> [Fixity]
getFixity Maybe (ModuleName l)
mmdl Decl l
cd
        getClassFixity ClassDecl l
_              = []

scrub :: Functor f => f a -> f ()
scrub :: f a -> f ()
scrub f a
f = () () -> f a -> f ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ f a
f

getBindFixities :: Binds l -> [Fixity]
getBindFixities :: Binds l -> [Fixity]
getBindFixities Binds l
bs = case Binds l
bs of
                        BDecls l
_ [Decl l]
ds -> Maybe (ModuleName l) -> [Decl l] -> [Fixity]
forall l. Maybe (ModuleName l) -> [Decl l] -> [Fixity]
getFixities Maybe (ModuleName l)
forall a. Maybe a
Nothing [Decl l]
ds
                        Binds l
_           -> []

instance AppFixity Annotation where
    applyFixities :: [Fixity] -> Annotation SrcSpanInfo -> m (Annotation SrcSpanInfo)
applyFixities [Fixity]
fixs Annotation SrcSpanInfo
ann' = case Annotation SrcSpanInfo
ann' of
        Ann     SrcSpanInfo
l Name SrcSpanInfo
n Exp SrcSpanInfo
e   -> (Exp SrcSpanInfo -> Annotation SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Name SrcSpanInfo -> Exp SrcSpanInfo -> Annotation SrcSpanInfo
forall l. l -> Name l -> Exp l -> Annotation l
Ann SrcSpanInfo
l Name SrcSpanInfo
n) (m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
        TypeAnn SrcSpanInfo
l Name SrcSpanInfo
n Exp SrcSpanInfo
e   -> (Exp SrcSpanInfo -> Annotation SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Name SrcSpanInfo -> Exp SrcSpanInfo -> Annotation SrcSpanInfo
forall l. l -> Name l -> Exp l -> Annotation l
TypeAnn SrcSpanInfo
l Name SrcSpanInfo
n) (m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
        ModuleAnn SrcSpanInfo
l Exp SrcSpanInfo
e   -> (Exp SrcSpanInfo -> Annotation SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Annotation SrcSpanInfo
forall l. l -> Exp l -> Annotation l
ModuleAnn SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Annotation SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity ClassDecl where
    applyFixities :: [Fixity] -> ClassDecl SrcSpanInfo -> m (ClassDecl SrcSpanInfo)
applyFixities [Fixity]
fixs (ClsDecl SrcSpanInfo
l Decl SrcSpanInfo
decl) = (Decl SrcSpanInfo -> ClassDecl SrcSpanInfo)
-> m (Decl SrcSpanInfo) -> m (ClassDecl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Decl SrcSpanInfo -> ClassDecl SrcSpanInfo
forall l. l -> Decl l -> ClassDecl l
ClsDecl SrcSpanInfo
l) (m (Decl SrcSpanInfo) -> m (ClassDecl SrcSpanInfo))
-> m (Decl SrcSpanInfo) -> m (ClassDecl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Decl SrcSpanInfo
decl
    applyFixities [Fixity]
_ ClassDecl SrcSpanInfo
cdecl = ClassDecl SrcSpanInfo -> m (ClassDecl SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return ClassDecl SrcSpanInfo
cdecl

instance AppFixity InstDecl where
    applyFixities :: [Fixity] -> InstDecl SrcSpanInfo -> m (InstDecl SrcSpanInfo)
applyFixities [Fixity]
fixs (InsDecl SrcSpanInfo
l Decl SrcSpanInfo
decl) = (Decl SrcSpanInfo -> InstDecl SrcSpanInfo)
-> m (Decl SrcSpanInfo) -> m (InstDecl SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Decl SrcSpanInfo -> InstDecl SrcSpanInfo
forall l. l -> Decl l -> InstDecl l
InsDecl SrcSpanInfo
l) (m (Decl SrcSpanInfo) -> m (InstDecl SrcSpanInfo))
-> m (Decl SrcSpanInfo) -> m (InstDecl SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Decl SrcSpanInfo
decl
    applyFixities [Fixity]
_ InstDecl SrcSpanInfo
idecl = InstDecl SrcSpanInfo -> m (InstDecl SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return InstDecl SrcSpanInfo
idecl

instance AppFixity Match where
    applyFixities :: [Fixity] -> Match SrcSpanInfo -> m (Match SrcSpanInfo)
applyFixities [Fixity]
fixs Match SrcSpanInfo
match = case Match SrcSpanInfo
match of
        Match SrcSpanInfo
l Name SrcSpanInfo
n [Pat SrcSpanInfo]
ps Rhs SrcSpanInfo
rhs Maybe (Binds SrcSpanInfo)
bs -> ([Pat SrcSpanInfo]
 -> Rhs SrcSpanInfo
 -> Maybe (Binds SrcSpanInfo)
 -> Match SrcSpanInfo)
-> m [Pat SrcSpanInfo]
-> m (Rhs SrcSpanInfo)
-> m (Maybe (Binds SrcSpanInfo))
-> m (Match SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> Name SrcSpanInfo
-> [Pat SrcSpanInfo]
-> Rhs SrcSpanInfo
-> Maybe (Binds SrcSpanInfo)
-> Match SrcSpanInfo
forall l.
l -> Name l -> [Pat l] -> Rhs l -> Maybe (Binds l) -> Match l
Match SrcSpanInfo
l Name SrcSpanInfo
n) ((Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Maybe (Binds SrcSpanInfo) -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs) [Pat SrcSpanInfo]
ps) (Maybe (Binds SrcSpanInfo) -> Rhs SrcSpanInfo -> m (Rhs SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs Rhs SrcSpanInfo
rhs) ((Binds SrcSpanInfo -> m (Binds SrcSpanInfo))
-> Maybe (Binds SrcSpanInfo) -> m (Maybe (Binds SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Maybe (Binds SrcSpanInfo)
-> Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs) Maybe (Binds SrcSpanInfo)
bs)
        InfixMatch SrcSpanInfo
l Pat SrcSpanInfo
a Name SrcSpanInfo
n [Pat SrcSpanInfo]
ps Rhs SrcSpanInfo
rhs Maybe (Binds SrcSpanInfo)
bs -> (Pat SrcSpanInfo
 -> [Pat SrcSpanInfo]
 -> Rhs SrcSpanInfo
 -> Maybe (Binds SrcSpanInfo)
 -> Match SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m [Pat SrcSpanInfo]
-> m (Rhs SrcSpanInfo)
-> m (Maybe (Binds SrcSpanInfo))
-> m (Match SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 a4 r.
Monad m =>
(a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
liftM4 ((Pat SrcSpanInfo
 -> Name SrcSpanInfo
 -> [Pat SrcSpanInfo]
 -> Rhs SrcSpanInfo
 -> Maybe (Binds SrcSpanInfo)
 -> Match SrcSpanInfo)
-> Name SrcSpanInfo
-> Pat SrcSpanInfo
-> [Pat SrcSpanInfo]
-> Rhs SrcSpanInfo
-> Maybe (Binds SrcSpanInfo)
-> Match SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Pat SrcSpanInfo
-> Name SrcSpanInfo
-> [Pat SrcSpanInfo]
-> Rhs SrcSpanInfo
-> Maybe (Binds SrcSpanInfo)
-> Match SrcSpanInfo
forall l.
l
-> Pat l
-> Name l
-> [Pat l]
-> Rhs l
-> Maybe (Binds l)
-> Match l
InfixMatch SrcSpanInfo
l) Name SrcSpanInfo
n) (Maybe (Binds SrcSpanInfo) -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs Pat SrcSpanInfo
a) ((Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Maybe (Binds SrcSpanInfo) -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs) [Pat SrcSpanInfo]
ps) (Maybe (Binds SrcSpanInfo) -> Rhs SrcSpanInfo -> m (Rhs SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs Rhs SrcSpanInfo
rhs) ((Binds SrcSpanInfo -> m (Binds SrcSpanInfo))
-> Maybe (Binds SrcSpanInfo) -> m (Maybe (Binds SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Maybe (Binds SrcSpanInfo)
-> Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *) l.
(AppFixity ast, MonadFail m) =>
Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs) Maybe (Binds SrcSpanInfo)
bs)
      where fix :: Maybe (Binds l) -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds l)
bs ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs' ast SrcSpanInfo
x
             where fixs' :: [Fixity]
fixs' = [Fixity]
fixs [Fixity] -> [Fixity] -> [Fixity]
forall a. [a] -> [a] -> [a]
++ [Fixity] -> (Binds l -> [Fixity]) -> Maybe (Binds l) -> [Fixity]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Binds l -> [Fixity]
forall l. Binds l -> [Fixity]
getBindFixities Maybe (Binds l)
bs

instance AppFixity Rhs where
    applyFixities :: [Fixity] -> Rhs SrcSpanInfo -> m (Rhs SrcSpanInfo)
applyFixities [Fixity]
fixs Rhs SrcSpanInfo
rhs = case Rhs SrcSpanInfo
rhs of
        UnGuardedRhs SrcSpanInfo
l Exp SrcSpanInfo
e      -> (Exp SrcSpanInfo -> Rhs SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Rhs SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Rhs SrcSpanInfo
forall l. l -> Exp l -> Rhs l
UnGuardedRhs SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Rhs SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Rhs SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
        GuardedRhss SrcSpanInfo
l [GuardedRhs SrcSpanInfo]
grhss   -> ([GuardedRhs SrcSpanInfo] -> Rhs SrcSpanInfo)
-> m [GuardedRhs SrcSpanInfo] -> m (Rhs SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [GuardedRhs SrcSpanInfo] -> Rhs SrcSpanInfo
forall l. l -> [GuardedRhs l] -> Rhs l
GuardedRhss SrcSpanInfo
l) (m [GuardedRhs SrcSpanInfo] -> m (Rhs SrcSpanInfo))
-> m [GuardedRhs SrcSpanInfo] -> m (Rhs SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (GuardedRhs SrcSpanInfo -> m (GuardedRhs SrcSpanInfo))
-> [GuardedRhs SrcSpanInfo] -> m [GuardedRhs SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM GuardedRhs SrcSpanInfo -> m (GuardedRhs SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [GuardedRhs SrcSpanInfo]
grhss
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity GuardedRhs where
    applyFixities :: [Fixity] -> GuardedRhs SrcSpanInfo -> m (GuardedRhs SrcSpanInfo)
applyFixities [Fixity]
fixs (GuardedRhs SrcSpanInfo
l [Stmt SrcSpanInfo]
stmts Exp SrcSpanInfo
e) = ([Stmt SrcSpanInfo] -> Exp SrcSpanInfo -> GuardedRhs SrcSpanInfo)
-> m [Stmt SrcSpanInfo]
-> m (Exp SrcSpanInfo)
-> m (GuardedRhs SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> [Stmt SrcSpanInfo] -> Exp SrcSpanInfo -> GuardedRhs SrcSpanInfo
forall l. l -> [Stmt l] -> Exp l -> GuardedRhs l
GuardedRhs SrcSpanInfo
l) ((Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo))
-> [Stmt SrcSpanInfo] -> m [Stmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Stmt SrcSpanInfo]
stmts) (m (Exp SrcSpanInfo) -> m (GuardedRhs SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (GuardedRhs SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity PatField where
    applyFixities :: [Fixity] -> PatField SrcSpanInfo -> m (PatField SrcSpanInfo)
applyFixities [Fixity]
fixs (PFieldPat SrcSpanInfo
l QName SrcSpanInfo
n Pat SrcSpanInfo
p) = (Pat SrcSpanInfo -> PatField SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (PatField SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> QName SrcSpanInfo -> Pat SrcSpanInfo -> PatField SrcSpanInfo
forall l. l -> QName l -> Pat l -> PatField l
PFieldPat SrcSpanInfo
l QName SrcSpanInfo
n) (m (Pat SrcSpanInfo) -> m (PatField SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (PatField SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Pat SrcSpanInfo
p
    applyFixities [Fixity]
_ PatField SrcSpanInfo
pf = PatField SrcSpanInfo -> m (PatField SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return PatField SrcSpanInfo
pf

instance AppFixity RPat where
    applyFixities :: [Fixity] -> RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
applyFixities [Fixity]
fixs RPat SrcSpanInfo
rp' = case RPat SrcSpanInfo
rp' of
        RPOp SrcSpanInfo
l RPat SrcSpanInfo
rp RPatOp SrcSpanInfo
op          -> (RPat SrcSpanInfo -> RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ((RPat SrcSpanInfo -> RPatOp SrcSpanInfo -> RPat SrcSpanInfo)
-> RPatOp SrcSpanInfo -> RPat SrcSpanInfo -> RPat SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> RPat SrcSpanInfo -> RPatOp SrcSpanInfo -> RPat SrcSpanInfo
forall l. l -> RPat l -> RPatOp l -> RPat l
RPOp SrcSpanInfo
l) RPatOp SrcSpanInfo
op) (m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo))
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix RPat SrcSpanInfo
rp
        RPEither SrcSpanInfo
l RPat SrcSpanInfo
a RPat SrcSpanInfo
b        -> (RPat SrcSpanInfo -> RPat SrcSpanInfo -> RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> RPat SrcSpanInfo -> RPat SrcSpanInfo -> RPat SrcSpanInfo
forall l. l -> RPat l -> RPat l -> RPat l
RPEither SrcSpanInfo
l) (RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix RPat SrcSpanInfo
a) (RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix RPat SrcSpanInfo
b)
        RPSeq SrcSpanInfo
l [RPat SrcSpanInfo]
rps           -> ([RPat SrcSpanInfo] -> RPat SrcSpanInfo)
-> m [RPat SrcSpanInfo] -> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [RPat SrcSpanInfo] -> RPat SrcSpanInfo
forall l. l -> [RPat l] -> RPat l
RPSeq SrcSpanInfo
l) (m [RPat SrcSpanInfo] -> m (RPat SrcSpanInfo))
-> m [RPat SrcSpanInfo] -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (RPat SrcSpanInfo -> m (RPat SrcSpanInfo))
-> [RPat SrcSpanInfo] -> m [RPat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [RPat SrcSpanInfo]
rps
        RPGuard SrcSpanInfo
l Pat SrcSpanInfo
p [Stmt SrcSpanInfo]
stmts     -> (Pat SrcSpanInfo -> [Stmt SrcSpanInfo] -> RPat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m [Stmt SrcSpanInfo]
-> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Pat SrcSpanInfo -> [Stmt SrcSpanInfo] -> RPat SrcSpanInfo
forall l. l -> Pat l -> [Stmt l] -> RPat l
RPGuard SrcSpanInfo
l) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p) (m [Stmt SrcSpanInfo] -> m (RPat SrcSpanInfo))
-> m [Stmt SrcSpanInfo] -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo))
-> [Stmt SrcSpanInfo] -> m [Stmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Stmt SrcSpanInfo]
stmts
        RPCAs SrcSpanInfo
l Name SrcSpanInfo
n RPat SrcSpanInfo
rp          -> (RPat SrcSpanInfo -> RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Name SrcSpanInfo -> RPat SrcSpanInfo -> RPat SrcSpanInfo
forall l. l -> Name l -> RPat l -> RPat l
RPCAs SrcSpanInfo
l Name SrcSpanInfo
n) (m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo))
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix RPat SrcSpanInfo
rp
        RPAs SrcSpanInfo
l Name SrcSpanInfo
n RPat SrcSpanInfo
rp           -> (RPat SrcSpanInfo -> RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Name SrcSpanInfo -> RPat SrcSpanInfo -> RPat SrcSpanInfo
forall l. l -> Name l -> RPat l -> RPat l
RPAs SrcSpanInfo
l Name SrcSpanInfo
n) (m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo))
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix RPat SrcSpanInfo
rp
        RPParen SrcSpanInfo
l RPat SrcSpanInfo
rp          -> (RPat SrcSpanInfo -> RPat SrcSpanInfo)
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> RPat SrcSpanInfo -> RPat SrcSpanInfo
forall l. l -> RPat l -> RPat l
RPParen SrcSpanInfo
l) (m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo))
-> m (RPat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix RPat SrcSpanInfo
rp
        RPPat SrcSpanInfo
l Pat SrcSpanInfo
p             -> (Pat SrcSpanInfo -> RPat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Pat SrcSpanInfo -> RPat SrcSpanInfo
forall l. l -> Pat l -> RPat l
RPPat SrcSpanInfo
l) (m (Pat SrcSpanInfo) -> m (RPat SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (RPat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity PXAttr where
    applyFixities :: [Fixity] -> PXAttr SrcSpanInfo -> m (PXAttr SrcSpanInfo)
applyFixities [Fixity]
fixs (PXAttr SrcSpanInfo
l XName SrcSpanInfo
n Pat SrcSpanInfo
p) = (Pat SrcSpanInfo -> PXAttr SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (PXAttr SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> XName SrcSpanInfo -> Pat SrcSpanInfo -> PXAttr SrcSpanInfo
forall l. l -> XName l -> Pat l -> PXAttr l
PXAttr SrcSpanInfo
l XName SrcSpanInfo
n) (m (Pat SrcSpanInfo) -> m (PXAttr SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (PXAttr SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Pat SrcSpanInfo
p

instance AppFixity Stmt where
    applyFixities :: [Fixity] -> Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
applyFixities [Fixity]
fixs Stmt SrcSpanInfo
stmt = case Stmt SrcSpanInfo
stmt of
        Generator SrcSpanInfo
l Pat SrcSpanInfo
p Exp SrcSpanInfo
e       -> (Pat SrcSpanInfo -> Exp SrcSpanInfo -> Stmt SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Stmt SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Pat SrcSpanInfo -> Exp SrcSpanInfo -> Stmt SrcSpanInfo
forall l. l -> Pat l -> Exp l -> Stmt l
Generator SrcSpanInfo
l) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
        Qualifier SrcSpanInfo
l Exp SrcSpanInfo
e         -> (Exp SrcSpanInfo -> Stmt SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Stmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Stmt SrcSpanInfo
forall l. l -> Exp l -> Stmt l
Qualifier SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Stmt SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Stmt SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
        LetStmt SrcSpanInfo
l Binds SrcSpanInfo
bs          -> (Binds SrcSpanInfo -> Stmt SrcSpanInfo)
-> m (Binds SrcSpanInfo) -> m (Stmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Binds SrcSpanInfo -> Stmt SrcSpanInfo
forall l. l -> Binds l -> Stmt l
LetStmt SrcSpanInfo
l) (m (Binds SrcSpanInfo) -> m (Stmt SrcSpanInfo))
-> m (Binds SrcSpanInfo) -> m (Stmt SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Binds SrcSpanInfo
bs    -- special behavior
        RecStmt SrcSpanInfo
l [Stmt SrcSpanInfo]
stmts       -> ([Stmt SrcSpanInfo] -> Stmt SrcSpanInfo)
-> m [Stmt SrcSpanInfo] -> m (Stmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Stmt SrcSpanInfo] -> Stmt SrcSpanInfo
forall l. l -> [Stmt l] -> Stmt l
RecStmt SrcSpanInfo
l) (m [Stmt SrcSpanInfo] -> m (Stmt SrcSpanInfo))
-> m [Stmt SrcSpanInfo] -> m (Stmt SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo))
-> [Stmt SrcSpanInfo] -> m [Stmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Stmt SrcSpanInfo]
stmts
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity Binds where
    applyFixities :: [Fixity] -> Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
applyFixities [Fixity]
fixs Binds SrcSpanInfo
bs = case Binds SrcSpanInfo
bs of
        BDecls SrcSpanInfo
l [Decl SrcSpanInfo]
decls        -> ([Decl SrcSpanInfo] -> Binds SrcSpanInfo)
-> m [Decl SrcSpanInfo] -> m (Binds SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Decl SrcSpanInfo] -> Binds SrcSpanInfo
forall l. l -> [Decl l] -> Binds l
BDecls SrcSpanInfo
l) (m [Decl SrcSpanInfo] -> m (Binds SrcSpanInfo))
-> m [Decl SrcSpanInfo] -> m (Binds SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
forall (m :: * -> *).
MonadFail m =>
Maybe (ModuleName SrcSpanInfo)
-> [Fixity] -> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
appFixDecls Maybe (ModuleName SrcSpanInfo)
forall a. Maybe a
Nothing [Fixity]
fixs [Decl SrcSpanInfo]
decls  -- special behavior
        IPBinds SrcSpanInfo
l [IPBind SrcSpanInfo]
ips         -> ([IPBind SrcSpanInfo] -> Binds SrcSpanInfo)
-> m [IPBind SrcSpanInfo] -> m (Binds SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [IPBind SrcSpanInfo] -> Binds SrcSpanInfo
forall l. l -> [IPBind l] -> Binds l
IPBinds SrcSpanInfo
l) (m [IPBind SrcSpanInfo] -> m (Binds SrcSpanInfo))
-> m [IPBind SrcSpanInfo] -> m (Binds SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (IPBind SrcSpanInfo -> m (IPBind SrcSpanInfo))
-> [IPBind SrcSpanInfo] -> m [IPBind SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM IPBind SrcSpanInfo -> m (IPBind SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [IPBind SrcSpanInfo]
ips
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x


instance AppFixity IPBind where
    applyFixities :: [Fixity] -> IPBind SrcSpanInfo -> m (IPBind SrcSpanInfo)
applyFixities [Fixity]
fixs (IPBind SrcSpanInfo
l IPName SrcSpanInfo
n Exp SrcSpanInfo
e) = (Exp SrcSpanInfo -> IPBind SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (IPBind SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> IPName SrcSpanInfo -> Exp SrcSpanInfo -> IPBind SrcSpanInfo
forall l. l -> IPName l -> Exp l -> IPBind l
IPBind SrcSpanInfo
l IPName SrcSpanInfo
n) (m (Exp SrcSpanInfo) -> m (IPBind SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (IPBind SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Exp SrcSpanInfo
e

instance AppFixity FieldUpdate where
    applyFixities :: [Fixity] -> FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo)
applyFixities [Fixity]
fixs (FieldUpdate SrcSpanInfo
l QName SrcSpanInfo
n Exp SrcSpanInfo
e) = (Exp SrcSpanInfo -> FieldUpdate SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (FieldUpdate SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> QName SrcSpanInfo -> Exp SrcSpanInfo -> FieldUpdate SrcSpanInfo
forall l. l -> QName l -> Exp l -> FieldUpdate l
FieldUpdate SrcSpanInfo
l QName SrcSpanInfo
n) (m (Exp SrcSpanInfo) -> m (FieldUpdate SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (FieldUpdate SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Exp SrcSpanInfo
e
    applyFixities [Fixity]
_ FieldUpdate SrcSpanInfo
fup = FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return FieldUpdate SrcSpanInfo
fup

instance AppFixity Alt where
    applyFixities :: [Fixity] -> Alt SrcSpanInfo -> m (Alt SrcSpanInfo)
applyFixities [Fixity]
fixs (Alt SrcSpanInfo
l Pat SrcSpanInfo
p Rhs SrcSpanInfo
galts Maybe (Binds SrcSpanInfo)
bs) = (Pat SrcSpanInfo
 -> Rhs SrcSpanInfo -> Maybe (Binds SrcSpanInfo) -> Alt SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Rhs SrcSpanInfo)
-> m (Maybe (Binds SrcSpanInfo))
-> m (Alt SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> Pat SrcSpanInfo
-> Rhs SrcSpanInfo
-> Maybe (Binds SrcSpanInfo)
-> Alt SrcSpanInfo
forall l. l -> Pat l -> Rhs l -> Maybe (Binds l) -> Alt l
Alt SrcSpanInfo
l) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p) (Rhs SrcSpanInfo -> m (Rhs SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Rhs SrcSpanInfo
galts) ((Binds SrcSpanInfo -> m (Binds SrcSpanInfo))
-> Maybe (Binds SrcSpanInfo) -> m (Maybe (Binds SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Binds SrcSpanInfo)
bs)
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity QualStmt where
    applyFixities :: [Fixity] -> QualStmt SrcSpanInfo -> m (QualStmt SrcSpanInfo)
applyFixities [Fixity]
fixs QualStmt SrcSpanInfo
qstmt = case QualStmt SrcSpanInfo
qstmt of
        QualStmt     SrcSpanInfo
l Stmt SrcSpanInfo
s      -> (Stmt SrcSpanInfo -> QualStmt SrcSpanInfo)
-> m (Stmt SrcSpanInfo) -> m (QualStmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Stmt SrcSpanInfo -> QualStmt SrcSpanInfo
forall l. l -> Stmt l -> QualStmt l
QualStmt SrcSpanInfo
l) (m (Stmt SrcSpanInfo) -> m (QualStmt SrcSpanInfo))
-> m (Stmt SrcSpanInfo) -> m (QualStmt SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Stmt SrcSpanInfo
s
        ThenTrans    SrcSpanInfo
l Exp SrcSpanInfo
e      -> (Exp SrcSpanInfo -> QualStmt SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (QualStmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo
forall l. l -> Exp l -> QualStmt l
ThenTrans SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (QualStmt SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (QualStmt SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
        ThenBy       SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2  -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (QualStmt SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo
forall l. l -> Exp l -> Exp l -> QualStmt l
ThenBy SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
        GroupBy      SrcSpanInfo
l Exp SrcSpanInfo
e      -> (Exp SrcSpanInfo -> QualStmt SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (QualStmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo
forall l. l -> Exp l -> QualStmt l
GroupBy SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
        GroupUsing   SrcSpanInfo
l Exp SrcSpanInfo
e      -> (Exp SrcSpanInfo -> QualStmt SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (QualStmt SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo
forall l. l -> Exp l -> QualStmt l
GroupUsing SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
        GroupByUsing SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2  -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (QualStmt SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> QualStmt SrcSpanInfo
forall l. l -> Exp l -> Exp l -> QualStmt l
GroupByUsing SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity Bracket where
    applyFixities :: [Fixity] -> Bracket SrcSpanInfo -> m (Bracket SrcSpanInfo)
applyFixities [Fixity]
fixs Bracket SrcSpanInfo
br = case Bracket SrcSpanInfo
br of
        ExpBracket SrcSpanInfo
l Exp SrcSpanInfo
e    -> (Exp SrcSpanInfo -> Bracket SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Bracket SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Bracket SrcSpanInfo
forall l. l -> Exp l -> Bracket l
ExpBracket SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Bracket SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Bracket SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
        PatBracket SrcSpanInfo
l Pat SrcSpanInfo
p    -> (Pat SrcSpanInfo -> Bracket SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Bracket SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Pat SrcSpanInfo -> Bracket SrcSpanInfo
forall l. l -> Pat l -> Bracket l
PatBracket SrcSpanInfo
l) (m (Pat SrcSpanInfo) -> m (Bracket SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (Bracket SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
        DeclBracket SrcSpanInfo
l [Decl SrcSpanInfo]
ds  -> ([Decl SrcSpanInfo] -> Bracket SrcSpanInfo)
-> m [Decl SrcSpanInfo] -> m (Bracket SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Decl SrcSpanInfo] -> Bracket SrcSpanInfo
forall l. l -> [Decl l] -> Bracket l
DeclBracket SrcSpanInfo
l) (m [Decl SrcSpanInfo] -> m (Bracket SrcSpanInfo))
-> m [Decl SrcSpanInfo] -> m (Bracket SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Decl SrcSpanInfo -> m (Decl SrcSpanInfo))
-> [Decl SrcSpanInfo] -> m [Decl SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Decl SrcSpanInfo -> m (Decl SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Decl SrcSpanInfo]
ds
        Bracket SrcSpanInfo
_                 -> Bracket SrcSpanInfo -> m (Bracket SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Bracket SrcSpanInfo
br
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

instance AppFixity Splice where
    applyFixities :: [Fixity] -> Splice SrcSpanInfo -> m (Splice SrcSpanInfo)
applyFixities [Fixity]
fixs (ParenSplice SrcSpanInfo
l Exp SrcSpanInfo
e) = (Exp SrcSpanInfo -> Splice SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Splice SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Splice SrcSpanInfo
forall l. l -> Exp l -> Splice l
ParenSplice SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Splice SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Splice SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Exp SrcSpanInfo
e
    applyFixities [Fixity]
_ Splice SrcSpanInfo
s = Splice SrcSpanInfo -> m (Splice SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Splice SrcSpanInfo
s

instance AppFixity XAttr where
    applyFixities :: [Fixity] -> XAttr SrcSpanInfo -> m (XAttr SrcSpanInfo)
applyFixities [Fixity]
fixs (XAttr SrcSpanInfo
l XName SrcSpanInfo
n Exp SrcSpanInfo
e) = (Exp SrcSpanInfo -> XAttr SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (XAttr SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> XName SrcSpanInfo -> Exp SrcSpanInfo -> XAttr SrcSpanInfo
forall l. l -> XName l -> Exp l -> XAttr l
XAttr SrcSpanInfo
l XName SrcSpanInfo
n) (m (Exp SrcSpanInfo) -> m (XAttr SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (XAttr SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs Exp SrcSpanInfo
e


-- the boring boilerplate stuff for expressions too
-- Recursively fixes the "leaves" of the infix chains,
-- without yet touching the chain itself. We assume all chains are
-- left-associate to begin with.
leafFix :: Fail.MonadFail m => [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
leafFix :: [Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
leafFix [Fixity]
fixs Exp SrcSpanInfo
e' = case Exp SrcSpanInfo
e' of
    InfixApp SrcSpanInfo
l Exp SrcSpanInfo
e1 QOp SrcSpanInfo
op Exp SrcSpanInfo
e2       -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 ((Exp SrcSpanInfo
 -> QOp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> QOp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Exp SrcSpanInfo
-> QOp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> QOp l -> Exp l -> Exp l
InfixApp SrcSpanInfo
l) QOp SrcSpanInfo
op) ([Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
leafFix [Fixity]
fixs Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    App SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2               -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
App SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    NegApp SrcSpanInfo
l Exp SrcSpanInfo
e                -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l
NegApp SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
    Lambda SrcSpanInfo
l [Pat SrcSpanInfo]
pats Exp SrcSpanInfo
e           -> ([Pat SrcSpanInfo] -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m [Pat SrcSpanInfo]
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> [Pat SrcSpanInfo] -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> [Pat l] -> Exp l -> Exp l
Lambda SrcSpanInfo
l) ((Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Pat SrcSpanInfo]
pats) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
    Let SrcSpanInfo
l Binds SrcSpanInfo
bs Exp SrcSpanInfo
e                ->
        let extraFix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities ([Fixity]
fixs [Fixity] -> [Fixity] -> [Fixity]
forall a. [a] -> [a] -> [a]
++ Binds SrcSpanInfo -> [Fixity]
forall l. Binds l -> [Fixity]
getBindFixities Binds SrcSpanInfo
bs) ast SrcSpanInfo
x
         in (Binds SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Binds SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Binds SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Binds l -> Exp l -> Exp l
Let SrcSpanInfo
l) (Binds SrcSpanInfo -> m (Binds SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix Binds SrcSpanInfo
bs) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
extraFix Exp SrcSpanInfo
e
    If SrcSpanInfo
l Exp SrcSpanInfo
e Exp SrcSpanInfo
a Exp SrcSpanInfo
b                -> (Exp SrcSpanInfo
 -> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l -> Exp l
If SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
a) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
b)
    MultiIf SrcSpanInfo
l [GuardedRhs SrcSpanInfo]
alts            -> ([GuardedRhs SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [GuardedRhs SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [GuardedRhs SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> [GuardedRhs l] -> Exp l
MultiIf SrcSpanInfo
l) ((GuardedRhs SrcSpanInfo -> m (GuardedRhs SrcSpanInfo))
-> [GuardedRhs SrcSpanInfo] -> m [GuardedRhs SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM GuardedRhs SrcSpanInfo -> m (GuardedRhs SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [GuardedRhs SrcSpanInfo]
alts)
    Case SrcSpanInfo
l Exp SrcSpanInfo
e [Alt SrcSpanInfo]
alts             -> (Exp SrcSpanInfo -> [Alt SrcSpanInfo] -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m [Alt SrcSpanInfo]
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> [Alt SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> Exp l -> [Alt l] -> Exp l
Case SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e) (m [Alt SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Alt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Alt SrcSpanInfo -> m (Alt SrcSpanInfo))
-> [Alt SrcSpanInfo] -> m [Alt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Alt SrcSpanInfo -> m (Alt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Alt SrcSpanInfo]
alts
    Do SrcSpanInfo
l [Stmt SrcSpanInfo]
stmts                -> ([Stmt SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [Stmt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Stmt SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> [Stmt l] -> Exp l
Do SrcSpanInfo
l) (m [Stmt SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Stmt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo))
-> [Stmt SrcSpanInfo] -> m [Stmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Stmt SrcSpanInfo]
stmts
    MDo SrcSpanInfo
l [Stmt SrcSpanInfo]
stmts               -> ([Stmt SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [Stmt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Stmt SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> [Stmt l] -> Exp l
MDo SrcSpanInfo
l) (m [Stmt SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Stmt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo))
-> [Stmt SrcSpanInfo] -> m [Stmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Stmt SrcSpanInfo -> m (Stmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Stmt SrcSpanInfo]
stmts
    Tuple SrcSpanInfo
l Boxed
bx [Exp SrcSpanInfo]
exps           -> ([Exp SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Boxed -> [Exp SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> Boxed -> [Exp l] -> Exp l
Tuple SrcSpanInfo
l Boxed
bx) (m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> [Exp SrcSpanInfo] -> m [Exp SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Exp SrcSpanInfo]
exps
    List SrcSpanInfo
l [Exp SrcSpanInfo]
exps               -> ([Exp SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Exp SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> [Exp l] -> Exp l
List SrcSpanInfo
l) (m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> [Exp SrcSpanInfo] -> m [Exp SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix  [Exp SrcSpanInfo]
exps
    Paren SrcSpanInfo
l Exp SrcSpanInfo
e                 -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l
Paren SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
    LeftSection SrcSpanInfo
l Exp SrcSpanInfo
e QOp SrcSpanInfo
op        -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ((Exp SrcSpanInfo -> QOp SrcSpanInfo -> Exp SrcSpanInfo)
-> QOp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Exp SrcSpanInfo -> QOp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> QOp l -> Exp l
LeftSection SrcSpanInfo
l) QOp SrcSpanInfo
op) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
    RightSection SrcSpanInfo
l QOp SrcSpanInfo
op Exp SrcSpanInfo
e       -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> QOp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> QOp l -> Exp l -> Exp l
RightSection SrcSpanInfo
l QOp SrcSpanInfo
op) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
    RecConstr SrcSpanInfo
l QName SrcSpanInfo
n [FieldUpdate SrcSpanInfo]
fups        -> ([FieldUpdate SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [FieldUpdate SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> QName SrcSpanInfo
-> [FieldUpdate SrcSpanInfo]
-> Exp SrcSpanInfo
forall l. l -> QName l -> [FieldUpdate l] -> Exp l
RecConstr SrcSpanInfo
l QName SrcSpanInfo
n) (m [FieldUpdate SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [FieldUpdate SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo))
-> [FieldUpdate SrcSpanInfo] -> m [FieldUpdate SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [FieldUpdate SrcSpanInfo]
fups
    RecUpdate SrcSpanInfo
l Exp SrcSpanInfo
e [FieldUpdate SrcSpanInfo]
fups        -> (Exp SrcSpanInfo -> [FieldUpdate SrcSpanInfo] -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m [FieldUpdate SrcSpanInfo]
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> [FieldUpdate SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> Exp l -> [FieldUpdate l] -> Exp l
RecUpdate SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e) (m [FieldUpdate SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [FieldUpdate SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo))
-> [FieldUpdate SrcSpanInfo] -> m [FieldUpdate SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM FieldUpdate SrcSpanInfo -> m (FieldUpdate SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [FieldUpdate SrcSpanInfo]
fups
    EnumFrom SrcSpanInfo
l Exp SrcSpanInfo
e              -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l
EnumFrom SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
    EnumFromTo SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2        -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
EnumFromTo SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    EnumFromThen SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2      -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
EnumFromThen SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    EnumFromThenTo SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2 Exp SrcSpanInfo
e3 -> (Exp SrcSpanInfo
 -> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l -> Exp l
EnumFromThenTo SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e3)
    ListComp SrcSpanInfo
l Exp SrcSpanInfo
e [QualStmt SrcSpanInfo]
quals        -> (Exp SrcSpanInfo -> [QualStmt SrcSpanInfo] -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m [QualStmt SrcSpanInfo]
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> [QualStmt SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> Exp l -> [QualStmt l] -> Exp l
ListComp SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e) (m [QualStmt SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [QualStmt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (QualStmt SrcSpanInfo -> m (QualStmt SrcSpanInfo))
-> [QualStmt SrcSpanInfo] -> m [QualStmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM QualStmt SrcSpanInfo -> m (QualStmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [QualStmt SrcSpanInfo]
quals
    ParComp  SrcSpanInfo
l Exp SrcSpanInfo
e [[QualStmt SrcSpanInfo]]
qualss       -> (Exp SrcSpanInfo -> [[QualStmt SrcSpanInfo]] -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m [[QualStmt SrcSpanInfo]]
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> [[QualStmt SrcSpanInfo]] -> Exp SrcSpanInfo
forall l. l -> Exp l -> [[QualStmt l]] -> Exp l
ParComp SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e) (m [[QualStmt SrcSpanInfo]] -> m (Exp SrcSpanInfo))
-> m [[QualStmt SrcSpanInfo]] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ ([QualStmt SrcSpanInfo] -> m [QualStmt SrcSpanInfo])
-> [[QualStmt SrcSpanInfo]] -> m [[QualStmt SrcSpanInfo]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((QualStmt SrcSpanInfo -> m (QualStmt SrcSpanInfo))
-> [QualStmt SrcSpanInfo] -> m [QualStmt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM QualStmt SrcSpanInfo -> m (QualStmt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix) [[QualStmt SrcSpanInfo]]
qualss
    ExpTypeSig SrcSpanInfo
l Exp SrcSpanInfo
e Type SrcSpanInfo
t          -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ((Exp SrcSpanInfo -> Type SrcSpanInfo -> Exp SrcSpanInfo)
-> Type SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Exp SrcSpanInfo -> Type SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Type l -> Exp l
ExpTypeSig SrcSpanInfo
l) Type SrcSpanInfo
t) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
    BracketExp SrcSpanInfo
l Bracket SrcSpanInfo
b            -> (Bracket SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Bracket SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Bracket SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Bracket l -> Exp l
BracketExp SrcSpanInfo
l) (m (Bracket SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Bracket SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Bracket SrcSpanInfo -> m (Bracket SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Bracket SrcSpanInfo
b
    SpliceExp SrcSpanInfo
l Splice SrcSpanInfo
s             -> (Splice SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Splice SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Splice SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Splice l -> Exp l
SpliceExp SrcSpanInfo
l) (m (Splice SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Splice SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Splice SrcSpanInfo -> m (Splice SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Splice SrcSpanInfo
s
    XTag SrcSpanInfo
l XName SrcSpanInfo
n [XAttr SrcSpanInfo]
ats Maybe (Exp SrcSpanInfo)
mexp [Exp SrcSpanInfo]
cs      -> ([XAttr SrcSpanInfo]
 -> Maybe (Exp SrcSpanInfo) -> [Exp SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [XAttr SrcSpanInfo]
-> m (Maybe (Exp SrcSpanInfo))
-> m [Exp SrcSpanInfo]
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> XName SrcSpanInfo
-> [XAttr SrcSpanInfo]
-> Maybe (Exp SrcSpanInfo)
-> [Exp SrcSpanInfo]
-> Exp SrcSpanInfo
forall l.
l -> XName l -> [XAttr l] -> Maybe (Exp l) -> [Exp l] -> Exp l
XTag SrcSpanInfo
l XName SrcSpanInfo
n) ((XAttr SrcSpanInfo -> m (XAttr SrcSpanInfo))
-> [XAttr SrcSpanInfo] -> m [XAttr SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM XAttr SrcSpanInfo -> m (XAttr SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [XAttr SrcSpanInfo]
ats) ((Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> Maybe (Exp SrcSpanInfo) -> m (Maybe (Exp SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Exp SrcSpanInfo)
mexp) ((Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> [Exp SrcSpanInfo] -> m [Exp SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Exp SrcSpanInfo]
cs)
    XETag SrcSpanInfo
l XName SrcSpanInfo
n [XAttr SrcSpanInfo]
ats Maybe (Exp SrcSpanInfo)
mexp        -> ([XAttr SrcSpanInfo] -> Maybe (Exp SrcSpanInfo) -> Exp SrcSpanInfo)
-> m [XAttr SrcSpanInfo]
-> m (Maybe (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> XName SrcSpanInfo
-> [XAttr SrcSpanInfo]
-> Maybe (Exp SrcSpanInfo)
-> Exp SrcSpanInfo
forall l. l -> XName l -> [XAttr l] -> Maybe (Exp l) -> Exp l
XETag SrcSpanInfo
l XName SrcSpanInfo
n) ((XAttr SrcSpanInfo -> m (XAttr SrcSpanInfo))
-> [XAttr SrcSpanInfo] -> m [XAttr SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM XAttr SrcSpanInfo -> m (XAttr SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [XAttr SrcSpanInfo]
ats) ((Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> Maybe (Exp SrcSpanInfo) -> m (Maybe (Exp SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Exp SrcSpanInfo)
mexp)
    XExpTag SrcSpanInfo
l Exp SrcSpanInfo
e               -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l
XExpTag SrcSpanInfo
l) (m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo))
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e
    XChildTag SrcSpanInfo
l [Exp SrcSpanInfo]
cs            -> ([Exp SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Exp SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> [Exp l] -> Exp l
XChildTag SrcSpanInfo
l) (m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Exp SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Exp SrcSpanInfo -> m (Exp SrcSpanInfo))
-> [Exp SrcSpanInfo] -> m [Exp SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Exp SrcSpanInfo]
cs
    Proc SrcSpanInfo
l Pat SrcSpanInfo
p Exp SrcSpanInfo
e                -> (Pat SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Pat SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Pat l -> Exp l -> Exp l
Proc SrcSpanInfo
l) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
    LeftArrApp SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2        -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
LeftArrApp SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    RightArrApp SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2       -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
RightArrApp SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    LeftArrHighApp SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2    -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
LeftArrHighApp SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    RightArrHighApp SrcSpanInfo
l Exp SrcSpanInfo
e1 Exp SrcSpanInfo
e2   -> (Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> Exp l -> Exp l -> Exp l
RightArrHighApp SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e1) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e2)
    CorePragma SrcSpanInfo
l String
s Exp SrcSpanInfo
e          -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> String -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> String -> Exp l -> Exp l
CorePragma SrcSpanInfo
l String
s) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
    SCCPragma SrcSpanInfo
l String
s Exp SrcSpanInfo
e           -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> String -> Exp SrcSpanInfo -> Exp SrcSpanInfo
forall l. l -> String -> Exp l -> Exp l
SCCPragma SrcSpanInfo
l String
s) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
    GenPragma SrcSpanInfo
l String
s (Int, Int)
ab (Int, Int)
cd Exp SrcSpanInfo
e     -> (Exp SrcSpanInfo -> Exp SrcSpanInfo)
-> m (Exp SrcSpanInfo) -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> String
-> (Int, Int)
-> (Int, Int)
-> Exp SrcSpanInfo
-> Exp SrcSpanInfo
forall l. l -> String -> (Int, Int) -> (Int, Int) -> Exp l -> Exp l
GenPragma SrcSpanInfo
l String
s (Int, Int)
ab (Int, Int)
cd) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e)
    LCase SrcSpanInfo
l [Alt SrcSpanInfo]
alts              -> ([Alt SrcSpanInfo] -> Exp SrcSpanInfo)
-> m [Alt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Alt SrcSpanInfo] -> Exp SrcSpanInfo
forall l. l -> [Alt l] -> Exp l
LCase SrcSpanInfo
l) (m [Alt SrcSpanInfo] -> m (Exp SrcSpanInfo))
-> m [Alt SrcSpanInfo] -> m (Exp SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Alt SrcSpanInfo -> m (Alt SrcSpanInfo))
-> [Alt SrcSpanInfo] -> m [Alt SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Alt SrcSpanInfo -> m (Alt SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Alt SrcSpanInfo]
alts

    Exp SrcSpanInfo
_                         -> Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Exp SrcSpanInfo
e'
  where
    fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x

leafFixP :: Fail.MonadFail m => [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
leafFixP :: [Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
leafFixP [Fixity]
fixs Pat SrcSpanInfo
p' = case Pat SrcSpanInfo
p' of
        PInfixApp SrcSpanInfo
l Pat SrcSpanInfo
p1 QName SrcSpanInfo
op Pat SrcSpanInfo
p2    -> (Pat SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 ((Pat SrcSpanInfo
 -> QName SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> QName SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Pat SrcSpanInfo
-> QName SrcSpanInfo
-> Pat SrcSpanInfo
-> Pat SrcSpanInfo
forall l. l -> Pat l -> QName l -> Pat l -> Pat l
PInfixApp SrcSpanInfo
l) QName SrcSpanInfo
op) ([Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
leafFixP [Fixity]
fixs Pat SrcSpanInfo
p1) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p2)
        PApp SrcSpanInfo
l QName SrcSpanInfo
n [Pat SrcSpanInfo]
ps             -> ([Pat SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> QName SrcSpanInfo -> [Pat SrcSpanInfo] -> Pat SrcSpanInfo
forall l. l -> QName l -> [Pat l] -> Pat l
PApp SrcSpanInfo
l QName SrcSpanInfo
n) (m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo))
-> m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Pat SrcSpanInfo]
ps
        PTuple SrcSpanInfo
l Boxed
bx [Pat SrcSpanInfo]
ps          -> ([Pat SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Boxed -> [Pat SrcSpanInfo] -> Pat SrcSpanInfo
forall l. l -> Boxed -> [Pat l] -> Pat l
PTuple SrcSpanInfo
l Boxed
bx) (m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo))
-> m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Pat SrcSpanInfo]
ps
        PList SrcSpanInfo
l [Pat SrcSpanInfo]
ps              -> ([Pat SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [Pat SrcSpanInfo] -> Pat SrcSpanInfo
forall l. l -> [Pat l] -> Pat l
PList SrcSpanInfo
l) (m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo))
-> m [Pat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Pat SrcSpanInfo]
ps
        PParen SrcSpanInfo
l Pat SrcSpanInfo
p              -> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Pat l -> Pat l
PParen SrcSpanInfo
l) (m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
        PRec SrcSpanInfo
l QName SrcSpanInfo
n [PatField SrcSpanInfo]
pfs            -> ([PatField SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [PatField SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> QName SrcSpanInfo -> [PatField SrcSpanInfo] -> Pat SrcSpanInfo
forall l. l -> QName l -> [PatField l] -> Pat l
PRec SrcSpanInfo
l QName SrcSpanInfo
n) (m [PatField SrcSpanInfo] -> m (Pat SrcSpanInfo))
-> m [PatField SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (PatField SrcSpanInfo -> m (PatField SrcSpanInfo))
-> [PatField SrcSpanInfo] -> m [PatField SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PatField SrcSpanInfo -> m (PatField SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [PatField SrcSpanInfo]
pfs
        PAsPat SrcSpanInfo
l Name SrcSpanInfo
n Pat SrcSpanInfo
p            -> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo
-> Name SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Name l -> Pat l -> Pat l
PAsPat SrcSpanInfo
l Name SrcSpanInfo
n) (m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
        PIrrPat SrcSpanInfo
l Pat SrcSpanInfo
p             -> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Pat l -> Pat l
PIrrPat SrcSpanInfo
l) (m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
        PatTypeSig SrcSpanInfo
l Pat SrcSpanInfo
p Type SrcSpanInfo
t        -> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM ((Pat SrcSpanInfo -> Type SrcSpanInfo -> Pat SrcSpanInfo)
-> Type SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall a b c. (a -> b -> c) -> b -> a -> c
flip (SrcSpanInfo
-> Pat SrcSpanInfo -> Type SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Pat l -> Type l -> Pat l
PatTypeSig SrcSpanInfo
l) Type SrcSpanInfo
t) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p)
        PViewPat SrcSpanInfo
l Exp SrcSpanInfo
e Pat SrcSpanInfo
p          -> (Exp SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Exp SrcSpanInfo)
-> m (Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> Exp SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Exp l -> Pat l -> Pat l
PViewPat SrcSpanInfo
l) (Exp SrcSpanInfo -> m (Exp SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Exp SrcSpanInfo
e) (Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p)
        PRPat SrcSpanInfo
l [RPat SrcSpanInfo]
rps             -> ([RPat SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [RPat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [RPat SrcSpanInfo] -> Pat SrcSpanInfo
forall l. l -> [RPat l] -> Pat l
PRPat SrcSpanInfo
l) (m [RPat SrcSpanInfo] -> m (Pat SrcSpanInfo))
-> m [RPat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (RPat SrcSpanInfo -> m (RPat SrcSpanInfo))
-> [RPat SrcSpanInfo] -> m [RPat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [RPat SrcSpanInfo]
rps
        PXTag SrcSpanInfo
l XName SrcSpanInfo
n [PXAttr SrcSpanInfo]
ats Maybe (Pat SrcSpanInfo)
mp [Pat SrcSpanInfo]
ps     -> ([PXAttr SrcSpanInfo]
 -> Maybe (Pat SrcSpanInfo) -> [Pat SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [PXAttr SrcSpanInfo]
-> m (Maybe (Pat SrcSpanInfo))
-> m [Pat SrcSpanInfo]
-> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 a2 a3 r.
Monad m =>
(a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
liftM3 (SrcSpanInfo
-> XName SrcSpanInfo
-> [PXAttr SrcSpanInfo]
-> Maybe (Pat SrcSpanInfo)
-> [Pat SrcSpanInfo]
-> Pat SrcSpanInfo
forall l.
l -> XName l -> [PXAttr l] -> Maybe (Pat l) -> [Pat l] -> Pat l
PXTag SrcSpanInfo
l XName SrcSpanInfo
n) ((PXAttr SrcSpanInfo -> m (PXAttr SrcSpanInfo))
-> [PXAttr SrcSpanInfo] -> m [PXAttr SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PXAttr SrcSpanInfo -> m (PXAttr SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [PXAttr SrcSpanInfo]
ats) ((Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> Maybe (Pat SrcSpanInfo) -> m (Maybe (Pat SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Pat SrcSpanInfo)
mp) ((Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> [Pat SrcSpanInfo] -> m [Pat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [Pat SrcSpanInfo]
ps)
        PXETag SrcSpanInfo
l XName SrcSpanInfo
n [PXAttr SrcSpanInfo]
ats Maybe (Pat SrcSpanInfo)
mp       -> ([PXAttr SrcSpanInfo]
 -> Maybe (Pat SrcSpanInfo) -> Pat SrcSpanInfo)
-> m [PXAttr SrcSpanInfo]
-> m (Maybe (Pat SrcSpanInfo))
-> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (SrcSpanInfo
-> XName SrcSpanInfo
-> [PXAttr SrcSpanInfo]
-> Maybe (Pat SrcSpanInfo)
-> Pat SrcSpanInfo
forall l. l -> XName l -> [PXAttr l] -> Maybe (Pat l) -> Pat l
PXETag SrcSpanInfo
l XName SrcSpanInfo
n) ((PXAttr SrcSpanInfo -> m (PXAttr SrcSpanInfo))
-> [PXAttr SrcSpanInfo] -> m [PXAttr SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM PXAttr SrcSpanInfo -> m (PXAttr SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [PXAttr SrcSpanInfo]
ats) ((Pat SrcSpanInfo -> m (Pat SrcSpanInfo))
-> Maybe (Pat SrcSpanInfo) -> m (Maybe (Pat SrcSpanInfo))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Maybe (Pat SrcSpanInfo)
mp)
        PXPatTag SrcSpanInfo
l Pat SrcSpanInfo
p            -> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Pat l -> Pat l
PXPatTag SrcSpanInfo
l) (m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
        PXRPats SrcSpanInfo
l [RPat SrcSpanInfo]
rps           -> ([RPat SrcSpanInfo] -> Pat SrcSpanInfo)
-> m [RPat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> [RPat SrcSpanInfo] -> Pat SrcSpanInfo
forall l. l -> [RPat l] -> Pat l
PXRPats SrcSpanInfo
l) (m [RPat SrcSpanInfo] -> m (Pat SrcSpanInfo))
-> m [RPat SrcSpanInfo] -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ (RPat SrcSpanInfo -> m (RPat SrcSpanInfo))
-> [RPat SrcSpanInfo] -> m [RPat SrcSpanInfo]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM RPat SrcSpanInfo -> m (RPat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix [RPat SrcSpanInfo]
rps
        PBangPat SrcSpanInfo
l Pat SrcSpanInfo
p            -> (Pat SrcSpanInfo -> Pat SrcSpanInfo)
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (SrcSpanInfo -> Pat SrcSpanInfo -> Pat SrcSpanInfo
forall l. l -> Pat l -> Pat l
PBangPat SrcSpanInfo
l) (m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo))
-> m (Pat SrcSpanInfo) -> m (Pat SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix Pat SrcSpanInfo
p
        Pat SrcSpanInfo
_                       -> Pat SrcSpanInfo -> m (Pat SrcSpanInfo)
forall (m :: * -> *) a. Monad m => a -> m a
return Pat SrcSpanInfo
p'
      where fix :: ast SrcSpanInfo -> m (ast SrcSpanInfo)
fix ast SrcSpanInfo
x = [Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs ast SrcSpanInfo
x