{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleInstances, DeriveFunctor #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Language.Haskell.Exts.Annotated.Parser
-- Copyright   :  (c) Niklas Broberg 2004-2009
--                (c) Michael Sloan 2013
-- License     :  BSD-style (see the file LICENSE.txt)
--
-- Maintainer  :  Niklas Broberg, d00nibro@chalmers.se
-- Stability   :  stable
-- Portability :  portable
--
-- Annotated parser for Haskell with extensions.
--
-----------------------------------------------------------------------------
module Language.Haskell.Exts.Parser
    (
    -- * General parsing
      Parseable(parse, parseWithMode, parseWithComments)
    , ParseMode(..), defaultParseMode, ParseResult(..), fromParseResult
    -- * Parsing of specific AST elements
    -- ** Modules
    , parseModule, parseModuleWithMode, parseModuleWithComments
    -- ** Expressions
    , parseExp, parseExpWithMode, parseExpWithComments
    -- ** Statements
    , parseStmt, parseStmtWithMode, parseStmtWithComments
    -- ** Patterns
    , parsePat, parsePatWithMode, parsePatWithComments
    -- ** Declarations
    , parseDecl, parseDeclWithMode, parseDeclWithComments
    -- ** Types
    , parseType, parseTypeWithMode, parseTypeWithComments
    -- ** Imports
    , parseImportDecl, parseImportDeclWithMode, parseImportDeclWithComments
    -- * Non-greedy parsers
    , NonGreedy(..)
    , ListOf(..), unListOf
    -- ** Module head parsers
    , getTopPragmas
    , PragmasAndModuleName(..)
    , PragmasAndModuleHead(..)
    , ModuleHeadAndImports(..)
    ) where

import Data.Data hiding (Fixity)
import Language.Haskell.Exts.Fixity
import Language.Haskell.Exts.Syntax
import Language.Haskell.Exts.Comments
import Language.Haskell.Exts.InternalParser
import Language.Haskell.Exts.ParseMonad
import Language.Haskell.Exts.SrcLoc

instance Parseable (Decl   SrcSpanInfo) where parser :: Maybe [Fixity] -> P (Decl SrcSpanInfo)
parser = P (Decl SrcSpanInfo) -> Maybe [Fixity] -> P (Decl SrcSpanInfo)
forall (a :: * -> *).
AppFixity a =>
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser P (Decl SrcSpanInfo)
mparseDecl
instance Parseable (Exp    SrcSpanInfo) where parser :: Maybe [Fixity] -> P (Exp SrcSpanInfo)
parser = P (Exp SrcSpanInfo) -> Maybe [Fixity] -> P (Exp SrcSpanInfo)
forall (a :: * -> *).
AppFixity a =>
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser P (Exp SrcSpanInfo)
mparseExp
instance Parseable (Module SrcSpanInfo) where parser :: Maybe [Fixity] -> P (Module SrcSpanInfo)
parser = P (Module SrcSpanInfo) -> Maybe [Fixity] -> P (Module SrcSpanInfo)
forall (a :: * -> *).
AppFixity a =>
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser P (Module SrcSpanInfo)
mparseModule
instance Parseable (Pat    SrcSpanInfo) where parser :: Maybe [Fixity] -> P (Pat SrcSpanInfo)
parser = P (Pat SrcSpanInfo) -> Maybe [Fixity] -> P (Pat SrcSpanInfo)
forall (a :: * -> *).
AppFixity a =>
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser P (Pat SrcSpanInfo)
mparsePat
instance Parseable (Stmt   SrcSpanInfo) where parser :: Maybe [Fixity] -> P (Stmt SrcSpanInfo)
parser = P (Stmt SrcSpanInfo) -> Maybe [Fixity] -> P (Stmt SrcSpanInfo)
forall (a :: * -> *).
AppFixity a =>
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser P (Stmt SrcSpanInfo)
mparseStmt
instance Parseable (Type   SrcSpanInfo) where parser :: Maybe [Fixity] -> P (Type SrcSpanInfo)
parser = P (Type SrcSpanInfo) -> Maybe [Fixity] -> P (Type SrcSpanInfo)
forall (a :: * -> *).
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParserNoFixity P (Type SrcSpanInfo)
mparseType
instance Parseable (ImportDecl SrcSpanInfo) where parser :: Maybe [Fixity] -> P (ImportDecl SrcSpanInfo)
parser = P (ImportDecl SrcSpanInfo)
-> Maybe [Fixity] -> P (ImportDecl SrcSpanInfo)
forall (a :: * -> *).
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParserNoFixity P (ImportDecl SrcSpanInfo)
mparseImportDecl

normalParser :: AppFixity a => P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser :: forall (a :: * -> *).
AppFixity a =>
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParser P (a SrcSpanInfo)
p Maybe [Fixity]
Nothing = P (a SrcSpanInfo)
p
normalParser P (a SrcSpanInfo)
p (Just [Fixity]
fixs) = P (a SrcSpanInfo)
p P (a SrcSpanInfo)
-> (a SrcSpanInfo -> P (a SrcSpanInfo)) -> P (a SrcSpanInfo)
forall a b. P a -> (a -> P b) -> P b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a SrcSpanInfo
ast -> [Fixity] -> a SrcSpanInfo -> P (a SrcSpanInfo)
forall (m :: * -> *).
MonadFail m =>
[Fixity] -> a SrcSpanInfo -> m (a SrcSpanInfo)
forall (ast :: * -> *) (m :: * -> *).
(AppFixity ast, MonadFail m) =>
[Fixity] -> ast SrcSpanInfo -> m (ast SrcSpanInfo)
applyFixities [Fixity]
fixs a SrcSpanInfo
ast P (a SrcSpanInfo) -> SrcLoc -> P (a SrcSpanInfo)
forall a. P a -> SrcLoc -> P a
`atSrcLoc` SrcLoc
noLoc

normalParserNoFixity :: P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParserNoFixity :: forall (a :: * -> *).
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParserNoFixity P (a SrcSpanInfo)
p Maybe [Fixity]
_ = P (a SrcSpanInfo)
p

-- Type-specific functions

-- | Parse of a string, which should contain a complete Haskell module, using 'defaultParseMode'.
parseModule :: String -> ParseResult (Module SrcSpanInfo)
parseModule :: String -> ParseResult (Module SrcSpanInfo)
parseModule = String -> ParseResult (Module SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode'.
parseModuleWithMode :: ParseMode -> String -> ParseResult (Module SrcSpanInfo)
parseModuleWithMode :: ParseMode -> String -> ParseResult (Module SrcSpanInfo)
parseModuleWithMode = ParseMode -> String -> ParseResult (Module SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parseModuleWithComments :: ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment])
parseModuleWithComments :: ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment])
parseModuleWithComments = ParseMode -> String -> ParseResult (Module SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- | Parse of a string containing a Haskell expression, using 'defaultParseMode'.
parseExp :: String -> ParseResult (Exp SrcSpanInfo)
parseExp :: String -> ParseResult (Exp SrcSpanInfo)
parseExp = String -> ParseResult (Exp SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a Haskell expression, using an explicit 'ParseMode'.
parseExpWithMode :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo)
parseExpWithMode :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo)
parseExpWithMode = ParseMode -> String -> ParseResult (Exp SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parseExpWithComments :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment])
parseExpWithComments :: ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment])
parseExpWithComments = ParseMode -> String -> ParseResult (Exp SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- | Parse of a string containing a Haskell pattern, using 'defaultParseMode'.
parsePat :: String -> ParseResult (Pat SrcSpanInfo)
parsePat :: String -> ParseResult (Pat SrcSpanInfo)
parsePat = String -> ParseResult (Pat SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a Haskell pattern, using an explicit 'ParseMode'.
parsePatWithMode :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo)
parsePatWithMode :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo)
parsePatWithMode = ParseMode -> String -> ParseResult (Pat SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parsePatWithComments :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment])
parsePatWithComments :: ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment])
parsePatWithComments = ParseMode -> String -> ParseResult (Pat SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- | Parse of a string containing a Haskell top-level declaration, using 'defaultParseMode'.
parseDecl :: String -> ParseResult (Decl SrcSpanInfo)
parseDecl :: String -> ParseResult (Decl SrcSpanInfo)
parseDecl = String -> ParseResult (Decl SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a Haskell top-level declaration, using an explicit 'ParseMode'.
parseDeclWithMode :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo)
parseDeclWithMode :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo)
parseDeclWithMode = ParseMode -> String -> ParseResult (Decl SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment])
parseDeclWithComments :: ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment])
parseDeclWithComments = ParseMode -> String -> ParseResult (Decl SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- | Parse of a string containing a Haskell type, using 'defaultParseMode'.
parseType :: String -> ParseResult (Type SrcSpanInfo)
parseType :: String -> ParseResult (Type SrcSpanInfo)
parseType = String -> ParseResult (Type SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a Haskell type, using an explicit 'ParseMode'.
parseTypeWithMode :: ParseMode -> String -> ParseResult (Type SrcSpanInfo)
parseTypeWithMode :: ParseMode -> String -> ParseResult (Type SrcSpanInfo)
parseTypeWithMode = ParseMode -> String -> ParseResult (Type SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parseTypeWithComments :: ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment])
parseTypeWithComments :: ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment])
parseTypeWithComments = ParseMode -> String -> ParseResult (Type SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- | Parse of a string containing a Haskell statement, using 'defaultParseMode'.
parseStmt :: String -> ParseResult (Stmt SrcSpanInfo)
parseStmt :: String -> ParseResult (Stmt SrcSpanInfo)
parseStmt = String -> ParseResult (Stmt SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a Haskell type, using an explicit 'ParseMode'.
parseStmtWithMode :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo)
parseStmtWithMode :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo)
parseStmtWithMode = ParseMode -> String -> ParseResult (Stmt SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parseStmtWithComments :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment])
parseStmtWithComments :: ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment])
parseStmtWithComments = ParseMode -> String -> ParseResult (Stmt SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- | Parse of a string containing a Haskell statement, using 'defaultParseMode'.
parseImportDecl :: String -> ParseResult (ImportDecl SrcSpanInfo)
parseImportDecl :: String -> ParseResult (ImportDecl SrcSpanInfo)
parseImportDecl = String -> ParseResult (ImportDecl SrcSpanInfo)
forall ast. Parseable ast => String -> ParseResult ast
parse

-- | Parse of a string containing a Haskell type, using an explicit 'ParseMode'.
parseImportDeclWithMode :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo)
parseImportDeclWithMode :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo)
parseImportDeclWithMode = ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo)
forall ast. Parseable ast => ParseMode -> String -> ParseResult ast
parseWithMode

-- | Parse of a string containing a complete Haskell module, using an explicit 'ParseMode', retaining comments.
parseImportDeclWithComments :: ParseMode -> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment])
parseImportDeclWithComments :: ParseMode
-> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment])
parseImportDeclWithComments = ParseMode
-> String -> ParseResult (ImportDecl SrcSpanInfo, [Comment])
forall ast.
Parseable ast =>
ParseMode -> String -> ParseResult (ast, [Comment])
parseWithComments

-- Non-greedy parsers (should use ng- prefixed parses exported by InternalParser)

-- | Non-greedy parse of a string starting with a series of top-level option pragmas.
getTopPragmas :: String -> ParseResult [ModulePragma SrcSpanInfo]
getTopPragmas :: String -> ParseResult [ModulePragma SrcSpanInfo]
getTopPragmas = (NonGreedy (ListOf (ModulePragma SrcSpanInfo))
 -> [ModulePragma SrcSpanInfo])
-> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))
-> ParseResult [ModulePragma SrcSpanInfo]
forall a b. (a -> b) -> ParseResult a -> ParseResult b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ListOf (ModulePragma SrcSpanInfo) -> [ModulePragma SrcSpanInfo]
forall a. ListOf a -> [a]
unListOf (ListOf (ModulePragma SrcSpanInfo) -> [ModulePragma SrcSpanInfo])
-> (NonGreedy (ListOf (ModulePragma SrcSpanInfo))
    -> ListOf (ModulePragma SrcSpanInfo))
-> NonGreedy (ListOf (ModulePragma SrcSpanInfo))
-> [ModulePragma SrcSpanInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonGreedy (ListOf (ModulePragma SrcSpanInfo))
-> ListOf (ModulePragma SrcSpanInfo)
forall a. NonGreedy a -> a
unNonGreedy) (ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))
 -> ParseResult [ModulePragma SrcSpanInfo])
-> (String
    -> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo))))
-> String
-> ParseResult [ModulePragma SrcSpanInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String
-> ParseResult (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))
forall ast. Parseable ast => String -> ParseResult ast
parse

instance Parseable (NonGreedy (ListOf (ModulePragma SrcSpanInfo))) where
  parser :: Maybe [Fixity] -> P (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))
parser = P ([ModulePragma SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> Maybe [Fixity]
-> P (NonGreedy (ListOf (ModulePragma SrcSpanInfo)))
forall (a :: * -> *).
P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> Maybe [Fixity] -> P (NonGreedy (ListOf (a SrcSpanInfo)))
nglistParserNoFixity P ([ModulePragma SrcSpanInfo], [SrcSpan], SrcSpanInfo)
ngparseModulePragmas

nglistParserNoFixity :: P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo) -> Maybe [Fixity] -> P (NonGreedy (ListOf (a SrcSpanInfo)))
nglistParserNoFixity :: forall (a :: * -> *).
P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> Maybe [Fixity] -> P (NonGreedy (ListOf (a SrcSpanInfo)))
nglistParserNoFixity P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
f = (([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
 -> NonGreedy (ListOf (a SrcSpanInfo)))
-> P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> P (NonGreedy (ListOf (a SrcSpanInfo)))
forall a b. (a -> b) -> P a -> P b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ListOf (a SrcSpanInfo) -> NonGreedy (ListOf (a SrcSpanInfo))
forall a. a -> NonGreedy a
NonGreedy (ListOf (a SrcSpanInfo) -> NonGreedy (ListOf (a SrcSpanInfo)))
-> (([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
    -> ListOf (a SrcSpanInfo))
-> ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> NonGreedy (ListOf (a SrcSpanInfo))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo) -> ListOf (a SrcSpanInfo)
forall a. ([a], [SrcSpan], SrcSpanInfo) -> ListOf a
toListOf) (P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
 -> P (NonGreedy (ListOf (a SrcSpanInfo))))
-> (Maybe [Fixity] -> P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo))
-> Maybe [Fixity]
-> P (NonGreedy (ListOf (a SrcSpanInfo)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> Maybe [Fixity] -> P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
forall (a :: * -> *).
P (a SrcSpanInfo) -> Maybe [Fixity] -> P (a SrcSpanInfo)
normalParserNoFixity P ([a SrcSpanInfo], [SrcSpan], SrcSpanInfo)
f

-- | Type intended to be used with 'Parseable', with instances that implement a
--   non-greedy parse of the module name, including top-level pragmas.  This
--   means that a parse error that comes after the module header won't be
--   returned. If the 'Maybe' value is 'Nothing', then this means that there was
--   no module header.
data PragmasAndModuleName l = PragmasAndModuleName l
    [ModulePragma l]
    (Maybe (ModuleName l))
  deriving (PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
(PragmasAndModuleName l -> PragmasAndModuleName l -> Bool)
-> (PragmasAndModuleName l -> PragmasAndModuleName l -> Bool)
-> Eq (PragmasAndModuleName l)
forall l.
Eq l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall l.
Eq l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
== :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
$c/= :: forall l.
Eq l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
/= :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
Eq,Eq (PragmasAndModuleName l)
Eq (PragmasAndModuleName l) =>
(PragmasAndModuleName l -> PragmasAndModuleName l -> Ordering)
-> (PragmasAndModuleName l -> PragmasAndModuleName l -> Bool)
-> (PragmasAndModuleName l -> PragmasAndModuleName l -> Bool)
-> (PragmasAndModuleName l -> PragmasAndModuleName l -> Bool)
-> (PragmasAndModuleName l -> PragmasAndModuleName l -> Bool)
-> (PragmasAndModuleName l
    -> PragmasAndModuleName l -> PragmasAndModuleName l)
-> (PragmasAndModuleName l
    -> PragmasAndModuleName l -> PragmasAndModuleName l)
-> Ord (PragmasAndModuleName l)
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
PragmasAndModuleName l -> PragmasAndModuleName l -> Ordering
PragmasAndModuleName l
-> PragmasAndModuleName l -> PragmasAndModuleName l
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
forall l. Ord l => Eq (PragmasAndModuleName l)
forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Ordering
forall l.
Ord l =>
PragmasAndModuleName l
-> PragmasAndModuleName l -> PragmasAndModuleName l
$ccompare :: forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Ordering
compare :: PragmasAndModuleName l -> PragmasAndModuleName l -> Ordering
$c< :: forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
< :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
$c<= :: forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
<= :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
$c> :: forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
> :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
$c>= :: forall l.
Ord l =>
PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
>= :: PragmasAndModuleName l -> PragmasAndModuleName l -> Bool
$cmax :: forall l.
Ord l =>
PragmasAndModuleName l
-> PragmasAndModuleName l -> PragmasAndModuleName l
max :: PragmasAndModuleName l
-> PragmasAndModuleName l -> PragmasAndModuleName l
$cmin :: forall l.
Ord l =>
PragmasAndModuleName l
-> PragmasAndModuleName l -> PragmasAndModuleName l
min :: PragmasAndModuleName l
-> PragmasAndModuleName l -> PragmasAndModuleName l
Ord,Int -> PragmasAndModuleName l -> ShowS
[PragmasAndModuleName l] -> ShowS
PragmasAndModuleName l -> String
(Int -> PragmasAndModuleName l -> ShowS)
-> (PragmasAndModuleName l -> String)
-> ([PragmasAndModuleName l] -> ShowS)
-> Show (PragmasAndModuleName l)
forall l. Show l => Int -> PragmasAndModuleName l -> ShowS
forall l. Show l => [PragmasAndModuleName l] -> ShowS
forall l. Show l => PragmasAndModuleName l -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall l. Show l => Int -> PragmasAndModuleName l -> ShowS
showsPrec :: Int -> PragmasAndModuleName l -> ShowS
$cshow :: forall l. Show l => PragmasAndModuleName l -> String
show :: PragmasAndModuleName l -> String
$cshowList :: forall l. Show l => [PragmasAndModuleName l] -> ShowS
showList :: [PragmasAndModuleName l] -> ShowS
Show,Typeable,Typeable (PragmasAndModuleName l)
Typeable (PragmasAndModuleName l) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> PragmasAndModuleName l
 -> c (PragmasAndModuleName l))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleName l))
-> (PragmasAndModuleName l -> Constr)
-> (PragmasAndModuleName l -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c (PragmasAndModuleName l)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (PragmasAndModuleName l)))
-> ((forall b. Data b => b -> b)
    -> PragmasAndModuleName l -> PragmasAndModuleName l)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> PragmasAndModuleName l
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> PragmasAndModuleName l
    -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> PragmasAndModuleName l -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PragmasAndModuleName l -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> PragmasAndModuleName l -> m (PragmasAndModuleName l))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PragmasAndModuleName l -> m (PragmasAndModuleName l))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PragmasAndModuleName l -> m (PragmasAndModuleName l))
-> Data (PragmasAndModuleName l)
PragmasAndModuleName l -> Constr
PragmasAndModuleName l -> DataType
(forall b. Data b => b -> b)
-> PragmasAndModuleName l -> PragmasAndModuleName l
forall l. Data l => Typeable (PragmasAndModuleName l)
forall l. Data l => PragmasAndModuleName l -> Constr
forall l. Data l => PragmasAndModuleName l -> DataType
forall l.
Data l =>
(forall b. Data b => b -> b)
-> PragmasAndModuleName l -> PragmasAndModuleName l
forall l u.
Data l =>
Int -> (forall d. Data d => d -> u) -> PragmasAndModuleName l -> u
forall l u.
Data l =>
(forall d. Data d => d -> u) -> PragmasAndModuleName l -> [u]
forall l r r'.
Data l =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
forall l r r'.
Data l =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
forall l (m :: * -> *).
(Data l, Monad m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
forall l (c :: * -> *).
Data l =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleName l)
forall l (c :: * -> *).
Data l =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleName l
-> c (PragmasAndModuleName l)
forall l (t :: * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleName l))
forall l (t :: * -> * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleName l))
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) -> PragmasAndModuleName l -> u
forall u.
(forall d. Data d => d -> u) -> PragmasAndModuleName l -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleName l)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleName l
-> c (PragmasAndModuleName l)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleName l))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleName l))
$cgfoldl :: forall l (c :: * -> *).
Data l =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleName l
-> c (PragmasAndModuleName l)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleName l
-> c (PragmasAndModuleName l)
$cgunfold :: forall l (c :: * -> *).
Data l =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleName l)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleName l)
$ctoConstr :: forall l. Data l => PragmasAndModuleName l -> Constr
toConstr :: PragmasAndModuleName l -> Constr
$cdataTypeOf :: forall l. Data l => PragmasAndModuleName l -> DataType
dataTypeOf :: PragmasAndModuleName l -> DataType
$cdataCast1 :: forall l (t :: * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleName l))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleName l))
$cdataCast2 :: forall l (t :: * -> * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleName l))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleName l))
$cgmapT :: forall l.
Data l =>
(forall b. Data b => b -> b)
-> PragmasAndModuleName l -> PragmasAndModuleName l
gmapT :: (forall b. Data b => b -> b)
-> PragmasAndModuleName l -> PragmasAndModuleName l
$cgmapQl :: forall l r r'.
Data l =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
$cgmapQr :: forall l r r'.
Data l =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleName l
-> r
$cgmapQ :: forall l u.
Data l =>
(forall d. Data d => d -> u) -> PragmasAndModuleName l -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> PragmasAndModuleName l -> [u]
$cgmapQi :: forall l u.
Data l =>
Int -> (forall d. Data d => d -> u) -> PragmasAndModuleName l -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PragmasAndModuleName l -> u
$cgmapM :: forall l (m :: * -> *).
(Data l, Monad m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
$cgmapMp :: forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
$cgmapMo :: forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleName l -> m (PragmasAndModuleName l)
Data)

instance Parseable (NonGreedy (PragmasAndModuleName SrcSpanInfo)) where
    parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleName SrcSpanInfo))
parser Maybe [Fixity]
_ = do
        (([ModulePragma SrcSpanInfo]
pragmas, [SrcSpan]
pss, SrcSpanInfo
pl), Maybe (ModuleName SrcSpanInfo)
mn) <- P (([ModulePragma SrcSpanInfo], [SrcSpan], SrcSpanInfo),
   Maybe (ModuleName SrcSpanInfo))
ngparsePragmasAndModuleName
        let l :: SrcSpanInfo
l = SrcSpanInfo -> Maybe SrcSpanInfo -> SrcSpanInfo
combSpanMaybe (SrcSpanInfo
pl SrcSpanInfo -> [SrcSpan] -> SrcSpanInfo
<** [SrcSpan]
pss) ((ModuleName SrcSpanInfo -> SrcSpanInfo)
-> Maybe (ModuleName SrcSpanInfo) -> Maybe SrcSpanInfo
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ModuleName SrcSpanInfo -> SrcSpanInfo
forall l. ModuleName l -> l
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Maybe (ModuleName SrcSpanInfo)
mn)
        NonGreedy (PragmasAndModuleName SrcSpanInfo)
-> P (NonGreedy (PragmasAndModuleName SrcSpanInfo))
forall a. a -> P a
forall (m :: * -> *) a. Monad m => a -> m a
return (NonGreedy (PragmasAndModuleName SrcSpanInfo)
 -> P (NonGreedy (PragmasAndModuleName SrcSpanInfo)))
-> NonGreedy (PragmasAndModuleName SrcSpanInfo)
-> P (NonGreedy (PragmasAndModuleName SrcSpanInfo))
forall a b. (a -> b) -> a -> b
$ PragmasAndModuleName SrcSpanInfo
-> NonGreedy (PragmasAndModuleName SrcSpanInfo)
forall a. a -> NonGreedy a
NonGreedy (PragmasAndModuleName SrcSpanInfo
 -> NonGreedy (PragmasAndModuleName SrcSpanInfo))
-> PragmasAndModuleName SrcSpanInfo
-> NonGreedy (PragmasAndModuleName SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> [ModulePragma SrcSpanInfo]
-> Maybe (ModuleName SrcSpanInfo)
-> PragmasAndModuleName SrcSpanInfo
forall l.
l
-> [ModulePragma l]
-> Maybe (ModuleName l)
-> PragmasAndModuleName l
PragmasAndModuleName SrcSpanInfo
l [ModulePragma SrcSpanInfo]
pragmas Maybe (ModuleName SrcSpanInfo)
mn

--   Type intended to be used with 'Parseable', with instances that
--   implement a non-greedy parse of the module name, including
--   top-level pragmas.  This means that a parse error that comes
--   after the module header won't be returned. If the 'Maybe' value
--   is 'Nothing', this means that there was no module head.
--
--   Note that the 'ParseMode' matters for this due to the 'MagicHash'
--   changing the lexing of identifiers to include \"#\".
data PragmasAndModuleHead l = PragmasAndModuleHead l
    [ModulePragma l]
    (Maybe (ModuleHead l))
  deriving (PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
(PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool)
-> (PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool)
-> Eq (PragmasAndModuleHead l)
forall l.
Eq l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall l.
Eq l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
== :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
$c/= :: forall l.
Eq l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
/= :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
Eq,Eq (PragmasAndModuleHead l)
Eq (PragmasAndModuleHead l) =>
(PragmasAndModuleHead l -> PragmasAndModuleHead l -> Ordering)
-> (PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool)
-> (PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool)
-> (PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool)
-> (PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool)
-> (PragmasAndModuleHead l
    -> PragmasAndModuleHead l -> PragmasAndModuleHead l)
-> (PragmasAndModuleHead l
    -> PragmasAndModuleHead l -> PragmasAndModuleHead l)
-> Ord (PragmasAndModuleHead l)
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Ordering
PragmasAndModuleHead l
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
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
forall l. Ord l => Eq (PragmasAndModuleHead l)
forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Ordering
forall l.
Ord l =>
PragmasAndModuleHead l
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
$ccompare :: forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Ordering
compare :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Ordering
$c< :: forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
< :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
$c<= :: forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
<= :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
$c> :: forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
> :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
$c>= :: forall l.
Ord l =>
PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
>= :: PragmasAndModuleHead l -> PragmasAndModuleHead l -> Bool
$cmax :: forall l.
Ord l =>
PragmasAndModuleHead l
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
max :: PragmasAndModuleHead l
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
$cmin :: forall l.
Ord l =>
PragmasAndModuleHead l
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
min :: PragmasAndModuleHead l
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
Ord,Int -> PragmasAndModuleHead l -> ShowS
[PragmasAndModuleHead l] -> ShowS
PragmasAndModuleHead l -> String
(Int -> PragmasAndModuleHead l -> ShowS)
-> (PragmasAndModuleHead l -> String)
-> ([PragmasAndModuleHead l] -> ShowS)
-> Show (PragmasAndModuleHead l)
forall l. Show l => Int -> PragmasAndModuleHead l -> ShowS
forall l. Show l => [PragmasAndModuleHead l] -> ShowS
forall l. Show l => PragmasAndModuleHead l -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall l. Show l => Int -> PragmasAndModuleHead l -> ShowS
showsPrec :: Int -> PragmasAndModuleHead l -> ShowS
$cshow :: forall l. Show l => PragmasAndModuleHead l -> String
show :: PragmasAndModuleHead l -> String
$cshowList :: forall l. Show l => [PragmasAndModuleHead l] -> ShowS
showList :: [PragmasAndModuleHead l] -> ShowS
Show,Typeable,Typeable (PragmasAndModuleHead l)
Typeable (PragmasAndModuleHead l) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> PragmasAndModuleHead l
 -> c (PragmasAndModuleHead l))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleHead l))
-> (PragmasAndModuleHead l -> Constr)
-> (PragmasAndModuleHead l -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c (PragmasAndModuleHead l)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (PragmasAndModuleHead l)))
-> ((forall b. Data b => b -> b)
    -> PragmasAndModuleHead l -> PragmasAndModuleHead l)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> PragmasAndModuleHead l
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> PragmasAndModuleHead l
    -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> PragmasAndModuleHead l -> m (PragmasAndModuleHead l))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PragmasAndModuleHead l -> m (PragmasAndModuleHead l))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> PragmasAndModuleHead l -> m (PragmasAndModuleHead l))
-> Data (PragmasAndModuleHead l)
PragmasAndModuleHead l -> Constr
PragmasAndModuleHead l -> DataType
(forall b. Data b => b -> b)
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
forall l. Data l => Typeable (PragmasAndModuleHead l)
forall l. Data l => PragmasAndModuleHead l -> Constr
forall l. Data l => PragmasAndModuleHead l -> DataType
forall l.
Data l =>
(forall b. Data b => b -> b)
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
forall l u.
Data l =>
Int -> (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> u
forall l u.
Data l =>
(forall d. Data d => d -> u) -> PragmasAndModuleHead l -> [u]
forall l r r'.
Data l =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
forall l r r'.
Data l =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
forall l (m :: * -> *).
(Data l, Monad m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
forall l (c :: * -> *).
Data l =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleHead l)
forall l (c :: * -> *).
Data l =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleHead l
-> c (PragmasAndModuleHead l)
forall l (t :: * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleHead l))
forall l (t :: * -> * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleHead l))
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) -> PragmasAndModuleHead l -> u
forall u.
(forall d. Data d => d -> u) -> PragmasAndModuleHead l -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleHead l)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleHead l
-> c (PragmasAndModuleHead l)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleHead l))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleHead l))
$cgfoldl :: forall l (c :: * -> *).
Data l =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleHead l
-> c (PragmasAndModuleHead l)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> PragmasAndModuleHead l
-> c (PragmasAndModuleHead l)
$cgunfold :: forall l (c :: * -> *).
Data l =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleHead l)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (PragmasAndModuleHead l)
$ctoConstr :: forall l. Data l => PragmasAndModuleHead l -> Constr
toConstr :: PragmasAndModuleHead l -> Constr
$cdataTypeOf :: forall l. Data l => PragmasAndModuleHead l -> DataType
dataTypeOf :: PragmasAndModuleHead l -> DataType
$cdataCast1 :: forall l (t :: * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleHead l))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (PragmasAndModuleHead l))
$cdataCast2 :: forall l (t :: * -> * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleHead l))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (PragmasAndModuleHead l))
$cgmapT :: forall l.
Data l =>
(forall b. Data b => b -> b)
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
gmapT :: (forall b. Data b => b -> b)
-> PragmasAndModuleHead l -> PragmasAndModuleHead l
$cgmapQl :: forall l r r'.
Data l =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
$cgmapQr :: forall l r r'.
Data l =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> PragmasAndModuleHead l
-> r
$cgmapQ :: forall l u.
Data l =>
(forall d. Data d => d -> u) -> PragmasAndModuleHead l -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> PragmasAndModuleHead l -> [u]
$cgmapQi :: forall l u.
Data l =>
Int -> (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> PragmasAndModuleHead l -> u
$cgmapM :: forall l (m :: * -> *).
(Data l, Monad m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
$cgmapMp :: forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
$cgmapMo :: forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> PragmasAndModuleHead l -> m (PragmasAndModuleHead l)
Data)

instance Parseable (NonGreedy (PragmasAndModuleHead SrcSpanInfo)) where
    parser :: Maybe [Fixity] -> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo))
parser Maybe [Fixity]
_ = do
        (([ModulePragma SrcSpanInfo]
pragmas, [SrcSpan]
pss, SrcSpanInfo
pl), Maybe (ModuleHead SrcSpanInfo)
mh) <- P (([ModulePragma SrcSpanInfo], [SrcSpan], SrcSpanInfo),
   Maybe (ModuleHead SrcSpanInfo))
ngparsePragmasAndModuleHead
        let l :: SrcSpanInfo
l = SrcSpanInfo -> Maybe SrcSpanInfo -> SrcSpanInfo
combSpanMaybe (SrcSpanInfo
pl SrcSpanInfo -> [SrcSpan] -> SrcSpanInfo
<** [SrcSpan]
pss) ((ModuleHead SrcSpanInfo -> SrcSpanInfo)
-> Maybe (ModuleHead SrcSpanInfo) -> Maybe SrcSpanInfo
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ModuleHead SrcSpanInfo -> SrcSpanInfo
forall l. ModuleHead l -> l
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Maybe (ModuleHead SrcSpanInfo)
mh)
        NonGreedy (PragmasAndModuleHead SrcSpanInfo)
-> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo))
forall a. a -> P a
forall (m :: * -> *) a. Monad m => a -> m a
return (NonGreedy (PragmasAndModuleHead SrcSpanInfo)
 -> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo)))
-> NonGreedy (PragmasAndModuleHead SrcSpanInfo)
-> P (NonGreedy (PragmasAndModuleHead SrcSpanInfo))
forall a b. (a -> b) -> a -> b
$ PragmasAndModuleHead SrcSpanInfo
-> NonGreedy (PragmasAndModuleHead SrcSpanInfo)
forall a. a -> NonGreedy a
NonGreedy (PragmasAndModuleHead SrcSpanInfo
 -> NonGreedy (PragmasAndModuleHead SrcSpanInfo))
-> PragmasAndModuleHead SrcSpanInfo
-> NonGreedy (PragmasAndModuleHead SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> [ModulePragma SrcSpanInfo]
-> Maybe (ModuleHead SrcSpanInfo)
-> PragmasAndModuleHead SrcSpanInfo
forall l.
l
-> [ModulePragma l]
-> Maybe (ModuleHead l)
-> PragmasAndModuleHead l
PragmasAndModuleHead SrcSpanInfo
l [ModulePragma SrcSpanInfo]
pragmas Maybe (ModuleHead SrcSpanInfo)
mh

--   Type intended to be used with 'Parseable', with instances that
--   implement a non-greedy parse of the module head, including
--   top-level pragmas, module name, export list, and import
--   list. This means that if a parse error that comes after the
--   imports won't be returned.  If the 'Maybe' value is 'Nothing',
--   this means that there was no module head.
--
--   Note that the 'ParseMode' matters for this due to the 'MagicHash'
--   changing the lexing of identifiers to include \"#\".
data ModuleHeadAndImports l = ModuleHeadAndImports l
    [ModulePragma l]
    (Maybe (ModuleHead l))
    [ImportDecl l]
  deriving (ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
(ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool)
-> (ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool)
-> Eq (ModuleHeadAndImports l)
forall l.
Eq l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall l.
Eq l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
== :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
$c/= :: forall l.
Eq l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
/= :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
Eq,Eq (ModuleHeadAndImports l)
Eq (ModuleHeadAndImports l) =>
(ModuleHeadAndImports l -> ModuleHeadAndImports l -> Ordering)
-> (ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool)
-> (ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool)
-> (ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool)
-> (ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool)
-> (ModuleHeadAndImports l
    -> ModuleHeadAndImports l -> ModuleHeadAndImports l)
-> (ModuleHeadAndImports l
    -> ModuleHeadAndImports l -> ModuleHeadAndImports l)
-> Ord (ModuleHeadAndImports l)
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Ordering
ModuleHeadAndImports l
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
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
forall l. Ord l => Eq (ModuleHeadAndImports l)
forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Ordering
forall l.
Ord l =>
ModuleHeadAndImports l
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
$ccompare :: forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Ordering
compare :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Ordering
$c< :: forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
< :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
$c<= :: forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
<= :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
$c> :: forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
> :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
$c>= :: forall l.
Ord l =>
ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
>= :: ModuleHeadAndImports l -> ModuleHeadAndImports l -> Bool
$cmax :: forall l.
Ord l =>
ModuleHeadAndImports l
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
max :: ModuleHeadAndImports l
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
$cmin :: forall l.
Ord l =>
ModuleHeadAndImports l
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
min :: ModuleHeadAndImports l
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
Ord,Int -> ModuleHeadAndImports l -> ShowS
[ModuleHeadAndImports l] -> ShowS
ModuleHeadAndImports l -> String
(Int -> ModuleHeadAndImports l -> ShowS)
-> (ModuleHeadAndImports l -> String)
-> ([ModuleHeadAndImports l] -> ShowS)
-> Show (ModuleHeadAndImports l)
forall l. Show l => Int -> ModuleHeadAndImports l -> ShowS
forall l. Show l => [ModuleHeadAndImports l] -> ShowS
forall l. Show l => ModuleHeadAndImports l -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall l. Show l => Int -> ModuleHeadAndImports l -> ShowS
showsPrec :: Int -> ModuleHeadAndImports l -> ShowS
$cshow :: forall l. Show l => ModuleHeadAndImports l -> String
show :: ModuleHeadAndImports l -> String
$cshowList :: forall l. Show l => [ModuleHeadAndImports l] -> ShowS
showList :: [ModuleHeadAndImports l] -> ShowS
Show,Typeable,Typeable (ModuleHeadAndImports l)
Typeable (ModuleHeadAndImports l) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> ModuleHeadAndImports l
 -> c (ModuleHeadAndImports l))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (ModuleHeadAndImports l))
-> (ModuleHeadAndImports l -> Constr)
-> (ModuleHeadAndImports l -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c (ModuleHeadAndImports l)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (ModuleHeadAndImports l)))
-> ((forall b. Data b => b -> b)
    -> ModuleHeadAndImports l -> ModuleHeadAndImports l)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> ModuleHeadAndImports l
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> ModuleHeadAndImports l
    -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> ModuleHeadAndImports l -> m (ModuleHeadAndImports l))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ModuleHeadAndImports l -> m (ModuleHeadAndImports l))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> ModuleHeadAndImports l -> m (ModuleHeadAndImports l))
-> Data (ModuleHeadAndImports l)
ModuleHeadAndImports l -> Constr
ModuleHeadAndImports l -> DataType
(forall b. Data b => b -> b)
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
forall l. Data l => Typeable (ModuleHeadAndImports l)
forall l. Data l => ModuleHeadAndImports l -> Constr
forall l. Data l => ModuleHeadAndImports l -> DataType
forall l.
Data l =>
(forall b. Data b => b -> b)
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
forall l u.
Data l =>
Int -> (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> u
forall l u.
Data l =>
(forall d. Data d => d -> u) -> ModuleHeadAndImports l -> [u]
forall l r r'.
Data l =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
forall l r r'.
Data l =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
forall l (m :: * -> *).
(Data l, Monad m) =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
forall l (c :: * -> *).
Data l =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ModuleHeadAndImports l)
forall l (c :: * -> *).
Data l =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ModuleHeadAndImports l
-> c (ModuleHeadAndImports l)
forall l (t :: * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ModuleHeadAndImports l))
forall l (t :: * -> * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ModuleHeadAndImports l))
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) -> ModuleHeadAndImports l -> u
forall u.
(forall d. Data d => d -> u) -> ModuleHeadAndImports l -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ModuleHeadAndImports l)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ModuleHeadAndImports l
-> c (ModuleHeadAndImports l)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ModuleHeadAndImports l))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ModuleHeadAndImports l))
$cgfoldl :: forall l (c :: * -> *).
Data l =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ModuleHeadAndImports l
-> c (ModuleHeadAndImports l)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ModuleHeadAndImports l
-> c (ModuleHeadAndImports l)
$cgunfold :: forall l (c :: * -> *).
Data l =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ModuleHeadAndImports l)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ModuleHeadAndImports l)
$ctoConstr :: forall l. Data l => ModuleHeadAndImports l -> Constr
toConstr :: ModuleHeadAndImports l -> Constr
$cdataTypeOf :: forall l. Data l => ModuleHeadAndImports l -> DataType
dataTypeOf :: ModuleHeadAndImports l -> DataType
$cdataCast1 :: forall l (t :: * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ModuleHeadAndImports l))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ModuleHeadAndImports l))
$cdataCast2 :: forall l (t :: * -> * -> *) (c :: * -> *).
(Data l, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ModuleHeadAndImports l))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (ModuleHeadAndImports l))
$cgmapT :: forall l.
Data l =>
(forall b. Data b => b -> b)
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
gmapT :: (forall b. Data b => b -> b)
-> ModuleHeadAndImports l -> ModuleHeadAndImports l
$cgmapQl :: forall l r r'.
Data l =>
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
$cgmapQr :: forall l r r'.
Data l =>
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ModuleHeadAndImports l
-> r
$cgmapQ :: forall l u.
Data l =>
(forall d. Data d => d -> u) -> ModuleHeadAndImports l -> [u]
gmapQ :: forall u.
(forall d. Data d => d -> u) -> ModuleHeadAndImports l -> [u]
$cgmapQi :: forall l u.
Data l =>
Int -> (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> u
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ModuleHeadAndImports l -> u
$cgmapM :: forall l (m :: * -> *).
(Data l, Monad m) =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
$cgmapMp :: forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
$cgmapMo :: forall l (m :: * -> *).
(Data l, MonadPlus m) =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ModuleHeadAndImports l -> m (ModuleHeadAndImports l)
Data)

instance Parseable (NonGreedy (ModuleHeadAndImports SrcSpanInfo)) where
    parser :: Maybe [Fixity] -> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo))
parser Maybe [Fixity]
_ = do
        (([ModulePragma SrcSpanInfo]
pragmas, [SrcSpan]
pss, SrcSpanInfo
pl), Maybe (ModuleHead SrcSpanInfo)
mh, Maybe ([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo)
mimps) <- P (([ModulePragma SrcSpanInfo], [SrcSpan], SrcSpanInfo),
   Maybe (ModuleHead SrcSpanInfo),
   Maybe ([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo))
ngparseModuleHeadAndImports
        let l :: SrcSpanInfo
l = (SrcSpanInfo
pl SrcSpanInfo -> [SrcSpan] -> SrcSpanInfo
<** [SrcSpan]
pss) SrcSpanInfo -> Maybe SrcSpanInfo -> SrcSpanInfo
`combSpanMaybe`
                ((ModuleHead SrcSpanInfo -> SrcSpanInfo)
-> Maybe (ModuleHead SrcSpanInfo) -> Maybe SrcSpanInfo
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ModuleHead SrcSpanInfo -> SrcSpanInfo
forall l. ModuleHead l -> l
forall (ast :: * -> *) l. Annotated ast => ast l -> l
ann Maybe (ModuleHead SrcSpanInfo)
mh) SrcSpanInfo -> Maybe SrcSpanInfo -> SrcSpanInfo
`combSpanMaybe`
                ((([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo) -> SrcSpanInfo)
-> Maybe ([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> Maybe SrcSpanInfo
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\([ImportDecl SrcSpanInfo]
_, [SrcSpan]
iss, SrcSpanInfo
il) -> SrcSpanInfo
il SrcSpanInfo -> [SrcSpan] -> SrcSpanInfo
<** [SrcSpan]
iss) Maybe ([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo)
mimps)
            imps :: [ImportDecl SrcSpanInfo]
imps = [ImportDecl SrcSpanInfo]
-> (([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo)
    -> [ImportDecl SrcSpanInfo])
-> Maybe ([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo)
-> [ImportDecl SrcSpanInfo]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\([ImportDecl SrcSpanInfo]
x, [SrcSpan]
_, SrcSpanInfo
_) -> [ImportDecl SrcSpanInfo]
x) Maybe ([ImportDecl SrcSpanInfo], [SrcSpan], SrcSpanInfo)
mimps
        NonGreedy (ModuleHeadAndImports SrcSpanInfo)
-> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo))
forall a. a -> P a
forall (m :: * -> *) a. Monad m => a -> m a
return (NonGreedy (ModuleHeadAndImports SrcSpanInfo)
 -> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo)))
-> NonGreedy (ModuleHeadAndImports SrcSpanInfo)
-> P (NonGreedy (ModuleHeadAndImports SrcSpanInfo))
forall a b. (a -> b) -> a -> b
$ ModuleHeadAndImports SrcSpanInfo
-> NonGreedy (ModuleHeadAndImports SrcSpanInfo)
forall a. a -> NonGreedy a
NonGreedy (ModuleHeadAndImports SrcSpanInfo
 -> NonGreedy (ModuleHeadAndImports SrcSpanInfo))
-> ModuleHeadAndImports SrcSpanInfo
-> NonGreedy (ModuleHeadAndImports SrcSpanInfo)
forall a b. (a -> b) -> a -> b
$ SrcSpanInfo
-> [ModulePragma SrcSpanInfo]
-> Maybe (ModuleHead SrcSpanInfo)
-> [ImportDecl SrcSpanInfo]
-> ModuleHeadAndImports SrcSpanInfo
forall l.
l
-> [ModulePragma l]
-> Maybe (ModuleHead l)
-> [ImportDecl l]
-> ModuleHeadAndImports l
ModuleHeadAndImports SrcSpanInfo
l [ModulePragma SrcSpanInfo]
pragmas Maybe (ModuleHead SrcSpanInfo)
mh [ImportDecl SrcSpanInfo]
imps

-- | Instances of 'Parseable' for @NonGreedy a@ will only consume the input
--   until @a@ is fully parsed.  This means that parse errors that come later
--   in the input will be ignored.  It's also more efficient, as it's fully lazy
--   in the remainder of the input:
--
--   >>> parse (unlines ("module A where" : "main =" : repeat "blah")) :: ParseResult PragmasAndModuleHead
--   ParseOk (NonGreedy {unNonGreedy = PragmasAndModuleHead [] (ModuleName "A",Nothing,Nothing)})
--
--   (this example uses the simplified AST)
newtype NonGreedy a = NonGreedy { forall a. NonGreedy a -> a
unNonGreedy :: a }
  deriving (NonGreedy a -> NonGreedy a -> Bool
(NonGreedy a -> NonGreedy a -> Bool)
-> (NonGreedy a -> NonGreedy a -> Bool) -> Eq (NonGreedy a)
forall a. Eq a => NonGreedy a -> NonGreedy a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => NonGreedy a -> NonGreedy a -> Bool
== :: NonGreedy a -> NonGreedy a -> Bool
$c/= :: forall a. Eq a => NonGreedy a -> NonGreedy a -> Bool
/= :: NonGreedy a -> NonGreedy a -> Bool
Eq,Eq (NonGreedy a)
Eq (NonGreedy a) =>
(NonGreedy a -> NonGreedy a -> Ordering)
-> (NonGreedy a -> NonGreedy a -> Bool)
-> (NonGreedy a -> NonGreedy a -> Bool)
-> (NonGreedy a -> NonGreedy a -> Bool)
-> (NonGreedy a -> NonGreedy a -> Bool)
-> (NonGreedy a -> NonGreedy a -> NonGreedy a)
-> (NonGreedy a -> NonGreedy a -> NonGreedy a)
-> Ord (NonGreedy a)
NonGreedy a -> NonGreedy a -> Bool
NonGreedy a -> NonGreedy a -> Ordering
NonGreedy a -> NonGreedy a -> NonGreedy a
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
forall a. Ord a => Eq (NonGreedy a)
forall a. Ord a => NonGreedy a -> NonGreedy a -> Bool
forall a. Ord a => NonGreedy a -> NonGreedy a -> Ordering
forall a. Ord a => NonGreedy a -> NonGreedy a -> NonGreedy a
$ccompare :: forall a. Ord a => NonGreedy a -> NonGreedy a -> Ordering
compare :: NonGreedy a -> NonGreedy a -> Ordering
$c< :: forall a. Ord a => NonGreedy a -> NonGreedy a -> Bool
< :: NonGreedy a -> NonGreedy a -> Bool
$c<= :: forall a. Ord a => NonGreedy a -> NonGreedy a -> Bool
<= :: NonGreedy a -> NonGreedy a -> Bool
$c> :: forall a. Ord a => NonGreedy a -> NonGreedy a -> Bool
> :: NonGreedy a -> NonGreedy a -> Bool
$c>= :: forall a. Ord a => NonGreedy a -> NonGreedy a -> Bool
>= :: NonGreedy a -> NonGreedy a -> Bool
$cmax :: forall a. Ord a => NonGreedy a -> NonGreedy a -> NonGreedy a
max :: NonGreedy a -> NonGreedy a -> NonGreedy a
$cmin :: forall a. Ord a => NonGreedy a -> NonGreedy a -> NonGreedy a
min :: NonGreedy a -> NonGreedy a -> NonGreedy a
Ord,Int -> NonGreedy a -> ShowS
[NonGreedy a] -> ShowS
NonGreedy a -> String
(Int -> NonGreedy a -> ShowS)
-> (NonGreedy a -> String)
-> ([NonGreedy a] -> ShowS)
-> Show (NonGreedy a)
forall a. Show a => Int -> NonGreedy a -> ShowS
forall a. Show a => [NonGreedy a] -> ShowS
forall a. Show a => NonGreedy a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> NonGreedy a -> ShowS
showsPrec :: Int -> NonGreedy a -> ShowS
$cshow :: forall a. Show a => NonGreedy a -> String
show :: NonGreedy a -> String
$cshowList :: forall a. Show a => [NonGreedy a] -> ShowS
showList :: [NonGreedy a] -> ShowS
Show,Typeable,Typeable (NonGreedy a)
Typeable (NonGreedy a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> NonGreedy a -> c (NonGreedy a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (NonGreedy a))
-> (NonGreedy a -> Constr)
-> (NonGreedy a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (NonGreedy a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (NonGreedy a)))
-> ((forall b. Data b => b -> b) -> NonGreedy a -> NonGreedy a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r)
-> (forall u. (forall d. Data d => d -> u) -> NonGreedy a -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> NonGreedy a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a))
-> Data (NonGreedy a)
NonGreedy a -> Constr
NonGreedy a -> DataType
(forall b. Data b => b -> b) -> NonGreedy a -> NonGreedy a
forall a. Data a => Typeable (NonGreedy a)
forall a. Data a => NonGreedy a -> Constr
forall a. Data a => NonGreedy a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> NonGreedy a -> NonGreedy a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> NonGreedy a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> NonGreedy a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonGreedy a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonGreedy a -> c (NonGreedy a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (NonGreedy a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonGreedy a))
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) -> NonGreedy a -> u
forall u. (forall d. Data d => d -> u) -> NonGreedy a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonGreedy a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonGreedy a -> c (NonGreedy a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (NonGreedy a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonGreedy a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonGreedy a -> c (NonGreedy a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> NonGreedy a -> c (NonGreedy a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonGreedy a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (NonGreedy a)
$ctoConstr :: forall a. Data a => NonGreedy a -> Constr
toConstr :: NonGreedy a -> Constr
$cdataTypeOf :: forall a. Data a => NonGreedy a -> DataType
dataTypeOf :: NonGreedy a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (NonGreedy a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (NonGreedy a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonGreedy a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (NonGreedy a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> NonGreedy a -> NonGreedy a
gmapT :: (forall b. Data b => b -> b) -> NonGreedy a -> NonGreedy a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> NonGreedy a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> NonGreedy a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> NonGreedy a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> NonGreedy a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> NonGreedy a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> NonGreedy a -> m (NonGreedy a)
Data)

instance Functor NonGreedy where
    fmap :: forall a b. (a -> b) -> NonGreedy a -> NonGreedy b
fmap a -> b
f (NonGreedy a
x) = b -> NonGreedy b
forall a. a -> NonGreedy a
NonGreedy (a -> b
f a
x)

-- | @ListOf a@ stores lists of the AST type @a@, along with a 'SrcSpanInfo',
--   in order to provide 'Parseable' instances for lists.  These instances are
--   provided when the type is used as a list in the syntax, and the same
--   delimiters are used in all of its usages. Some exceptions are made:
data ListOf a = ListOf SrcSpanInfo [a]
  deriving (ListOf a -> ListOf a -> Bool
(ListOf a -> ListOf a -> Bool)
-> (ListOf a -> ListOf a -> Bool) -> Eq (ListOf a)
forall a. Eq a => ListOf a -> ListOf a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => ListOf a -> ListOf a -> Bool
== :: ListOf a -> ListOf a -> Bool
$c/= :: forall a. Eq a => ListOf a -> ListOf a -> Bool
/= :: ListOf a -> ListOf a -> Bool
Eq,Eq (ListOf a)
Eq (ListOf a) =>
(ListOf a -> ListOf a -> Ordering)
-> (ListOf a -> ListOf a -> Bool)
-> (ListOf a -> ListOf a -> Bool)
-> (ListOf a -> ListOf a -> Bool)
-> (ListOf a -> ListOf a -> Bool)
-> (ListOf a -> ListOf a -> ListOf a)
-> (ListOf a -> ListOf a -> ListOf a)
-> Ord (ListOf a)
ListOf a -> ListOf a -> Bool
ListOf a -> ListOf a -> Ordering
ListOf a -> ListOf a -> ListOf a
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
forall a. Ord a => Eq (ListOf a)
forall a. Ord a => ListOf a -> ListOf a -> Bool
forall a. Ord a => ListOf a -> ListOf a -> Ordering
forall a. Ord a => ListOf a -> ListOf a -> ListOf a
$ccompare :: forall a. Ord a => ListOf a -> ListOf a -> Ordering
compare :: ListOf a -> ListOf a -> Ordering
$c< :: forall a. Ord a => ListOf a -> ListOf a -> Bool
< :: ListOf a -> ListOf a -> Bool
$c<= :: forall a. Ord a => ListOf a -> ListOf a -> Bool
<= :: ListOf a -> ListOf a -> Bool
$c> :: forall a. Ord a => ListOf a -> ListOf a -> Bool
> :: ListOf a -> ListOf a -> Bool
$c>= :: forall a. Ord a => ListOf a -> ListOf a -> Bool
>= :: ListOf a -> ListOf a -> Bool
$cmax :: forall a. Ord a => ListOf a -> ListOf a -> ListOf a
max :: ListOf a -> ListOf a -> ListOf a
$cmin :: forall a. Ord a => ListOf a -> ListOf a -> ListOf a
min :: ListOf a -> ListOf a -> ListOf a
Ord,Int -> ListOf a -> ShowS
[ListOf a] -> ShowS
ListOf a -> String
(Int -> ListOf a -> ShowS)
-> (ListOf a -> String) -> ([ListOf a] -> ShowS) -> Show (ListOf a)
forall a. Show a => Int -> ListOf a -> ShowS
forall a. Show a => [ListOf a] -> ShowS
forall a. Show a => ListOf a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> ListOf a -> ShowS
showsPrec :: Int -> ListOf a -> ShowS
$cshow :: forall a. Show a => ListOf a -> String
show :: ListOf a -> String
$cshowList :: forall a. Show a => [ListOf a] -> ShowS
showList :: [ListOf a] -> ShowS
Show,Typeable,Typeable (ListOf a)
Typeable (ListOf a) =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> ListOf a -> c (ListOf a))
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c (ListOf a))
-> (ListOf a -> Constr)
-> (ListOf a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c (ListOf a)))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c (ListOf a)))
-> ((forall b. Data b => b -> b) -> ListOf a -> ListOf a)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ListOf a -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ListOf a -> r)
-> (forall u. (forall d. Data d => d -> u) -> ListOf a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> ListOf a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a))
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a))
-> Data (ListOf a)
ListOf a -> Constr
ListOf a -> DataType
(forall b. Data b => b -> b) -> ListOf a -> ListOf a
forall a. Data a => Typeable (ListOf a)
forall a. Data a => ListOf a -> Constr
forall a. Data a => ListOf a -> DataType
forall a.
Data a =>
(forall b. Data b => b -> b) -> ListOf a -> ListOf a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ListOf a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> ListOf a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListOf a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListOf a -> c (ListOf a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ListOf a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListOf a))
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) -> ListOf a -> u
forall u. (forall d. Data d => d -> u) -> ListOf a -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListOf a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListOf a -> c (ListOf a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ListOf a))
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListOf a))
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListOf a -> c (ListOf a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ListOf a -> c (ListOf a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListOf a)
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (ListOf a)
$ctoConstr :: forall a. Data a => ListOf a -> Constr
toConstr :: ListOf a -> Constr
$cdataTypeOf :: forall a. Data a => ListOf a -> DataType
dataTypeOf :: ListOf a -> DataType
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (ListOf a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (ListOf a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListOf a))
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ListOf a))
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> ListOf a -> ListOf a
gmapT :: (forall b. Data b => b -> b) -> ListOf a -> ListOf a
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ListOf a -> r
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> ListOf a -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> ListOf a -> [u]
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> ListOf a -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ListOf a -> u
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ListOf a -> m (ListOf a)
Data,(forall a b. (a -> b) -> ListOf a -> ListOf b)
-> (forall a b. a -> ListOf b -> ListOf a) -> Functor ListOf
forall a b. a -> ListOf b -> ListOf a
forall a b. (a -> b) -> ListOf a -> ListOf b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> ListOf a -> ListOf b
fmap :: forall a b. (a -> b) -> ListOf a -> ListOf b
$c<$ :: forall a b. a -> ListOf b -> ListOf a
<$ :: forall a b. a -> ListOf b -> ListOf a
Functor)

unListOf :: ListOf a -> [a]
unListOf :: forall a. ListOf a -> [a]
unListOf (ListOf SrcSpanInfo
_ [a]
xs) = [a]
xs

-- It's safe to forget about the previous SrcSpanInfo 'srcInfoPoints',
-- as long as they are created with (presently) are all created with
-- 'noInfoSpan' ('nIS'), '(<^^>)', or '(<++>)', all of which have
-- empty 'srcInfoPoints'. Ideally, the parsers would return better
-- types, but this works.
toListOf :: ([a], [SrcSpan], SrcSpanInfo) -> ListOf a
toListOf :: forall a. ([a], [SrcSpan], SrcSpanInfo) -> ListOf a
toListOf ([a]
xs, [SrcSpan]
ss, SrcSpanInfo
l) = SrcSpanInfo -> [a] -> ListOf a
forall a. SrcSpanInfo -> [a] -> ListOf a
ListOf (SrcSpan -> [SrcSpan] -> SrcSpanInfo
infoSpan (SrcSpanInfo -> SrcSpan
srcInfoSpan SrcSpanInfo
l) [SrcSpan]
ss) [a]
xs