{-# LANGUAGE CPP #-}
{-# LANGUAGE ApplicativeDo #-}  -- see exprToPattern

{-| The concrete syntax is a raw representation of the program text
    without any desugaring at all.  This is what the parser produces.
    The idea is that if we figure out how to keep the concrete syntax
    around, it can be printed exactly as the user wrote it.
-}
module Agda.Syntax.Concrete
  ( -- * Expressions
    Expr(..)
  , OpApp(..), fromOrdinary
  , OpAppArgs, OpAppArgs'
  , module Agda.Syntax.Concrete.Name
  , AppView(..), appView, unAppView
  , rawApp, rawAppP
  , isSingleIdentifierP, removeParenP
  , isPattern, isAbsurdP, isBinderP
  , exprToPatternWithHoles
  , returnExpr
    -- * Bindings
  , Binder'(..)
  , Binder
  , mkBinder_
  , mkBinder
  , LamBinding
  , LamBinding'(..)
  , dropTypeAndModality
  , TypedBinding
  , TypedBinding'(..)
  , RecordAssignment
  , RecordAssignments
  , FieldAssignment, FieldAssignment'(..), nameFieldA, exprFieldA
  , ModuleAssignment(..)
  , BoundName(..), mkBoundName_, mkBoundName
  , TacticAttribute
  , Telescope, Telescope1
  , lamBindingsToTelescope
  , makePi
  , mkLam, mkLet, mkTLet
    -- * Declarations
  , RecordDirective(..)
  , isRecordDirective
  , RecordDirectives
  , Declaration(..)
  , ModuleApplication(..)
  , TypeSignature
  , TypeSignatureOrInstanceBlock
  , ImportDirective, Using, ImportedName
  , Renaming, RenamingDirective, HidingDirective
  , AsName'(..), AsName
  , OpenShortHand(..), RewriteEqn, WithExpr
  , LHS(..), Pattern(..), LHSCore(..)
  , observeHiding
  , observeRelevance
  , observeModifiers
  , LamClause(..)
  , RHS, RHS'(..), WhereClause, WhereClause'(..), ExprWhere(..)
  , DoStmt(..)
  , Pragma(..)
  , Module(..)
  , ThingWithFixity(..)
  , HoleContent, HoleContent'(..)
  , spanAllowedBeforeModule
  )
  where

import Prelude hiding (null)

import Control.DeepSeq

import qualified Data.DList as DL
import Data.Functor.Identity
import Data.Set         ( Set  )
import Data.Text        ( Text )
-- import Data.Traversable ( forM )

import GHC.Generics     ( Generic )

import Agda.Syntax.Position
import Agda.Syntax.Common
import Agda.Syntax.Fixity
import Agda.Syntax.Literal

import Agda.Syntax.Concrete.Name
import qualified Agda.Syntax.Abstract.Name as A

import Agda.TypeChecking.Positivity.Occurrence

import Agda.Utils.Applicative ( forA )
import Agda.Utils.Either      ( maybeLeft )
import Agda.Utils.Lens
import Agda.Utils.List1       ( List1, pattern (:|) )
import qualified Agda.Utils.List1 as List1
import Agda.Utils.List2       ( List2, pattern List2 )
import Agda.Utils.Null

import Agda.Utils.Impossible

data OpApp e
  = SyntaxBindingLambda Range (List1 LamBinding) e
    -- ^ An abstraction inside a special syntax declaration
    --   (see Issue 358 why we introduce this).
  | Ordinary e
  deriving (forall a b. a -> OpApp b -> OpApp a
forall a b. (a -> b) -> OpApp a -> OpApp b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> OpApp b -> OpApp a
$c<$ :: forall a b. a -> OpApp b -> OpApp a
fmap :: forall a b. (a -> b) -> OpApp a -> OpApp b
$cfmap :: forall a b. (a -> b) -> OpApp a -> OpApp b
Functor, forall a. Eq a => a -> OpApp a -> Bool
forall a. Num a => OpApp a -> a
forall a. Ord a => OpApp a -> a
forall m. Monoid m => OpApp m -> m
forall a. OpApp a -> Bool
forall a. OpApp a -> Int
forall a. OpApp a -> [a]
forall a. (a -> a -> a) -> OpApp a -> a
forall m a. Monoid m => (a -> m) -> OpApp a -> m
forall b a. (b -> a -> b) -> b -> OpApp a -> b
forall a b. (a -> b -> b) -> b -> OpApp a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => OpApp a -> a
$cproduct :: forall a. Num a => OpApp a -> a
sum :: forall a. Num a => OpApp a -> a
$csum :: forall a. Num a => OpApp a -> a
minimum :: forall a. Ord a => OpApp a -> a
$cminimum :: forall a. Ord a => OpApp a -> a
maximum :: forall a. Ord a => OpApp a -> a
$cmaximum :: forall a. Ord a => OpApp a -> a
elem :: forall a. Eq a => a -> OpApp a -> Bool
$celem :: forall a. Eq a => a -> OpApp a -> Bool
length :: forall a. OpApp a -> Int
$clength :: forall a. OpApp a -> Int
null :: forall a. OpApp a -> Bool
$cnull :: forall a. OpApp a -> Bool
toList :: forall a. OpApp a -> [a]
$ctoList :: forall a. OpApp a -> [a]
foldl1 :: forall a. (a -> a -> a) -> OpApp a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> OpApp a -> a
foldr1 :: forall a. (a -> a -> a) -> OpApp a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> OpApp a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> OpApp a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> OpApp a -> b
foldl :: forall b a. (b -> a -> b) -> b -> OpApp a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> OpApp a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> OpApp a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> OpApp a -> b
foldr :: forall a b. (a -> b -> b) -> b -> OpApp a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> OpApp a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> OpApp a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> OpApp a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> OpApp a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> OpApp a -> m
fold :: forall m. Monoid m => OpApp m -> m
$cfold :: forall m. Monoid m => OpApp m -> m
Foldable, Functor OpApp
Foldable OpApp
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => OpApp (m a) -> m (OpApp a)
forall (f :: * -> *) a. Applicative f => OpApp (f a) -> f (OpApp a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> OpApp a -> m (OpApp b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> OpApp a -> f (OpApp b)
sequence :: forall (m :: * -> *) a. Monad m => OpApp (m a) -> m (OpApp a)
$csequence :: forall (m :: * -> *) a. Monad m => OpApp (m a) -> m (OpApp a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> OpApp a -> m (OpApp b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> OpApp a -> m (OpApp b)
sequenceA :: forall (f :: * -> *) a. Applicative f => OpApp (f a) -> f (OpApp a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => OpApp (f a) -> f (OpApp a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> OpApp a -> f (OpApp b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> OpApp a -> f (OpApp b)
Traversable, OpApp e -> OpApp e -> Bool
forall e. Eq e => OpApp e -> OpApp e -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpApp e -> OpApp e -> Bool
$c/= :: forall e. Eq e => OpApp e -> OpApp e -> Bool
== :: OpApp e -> OpApp e -> Bool
$c== :: forall e. Eq e => OpApp e -> OpApp e -> Bool
Eq)

fromOrdinary :: e -> OpApp e -> e
fromOrdinary :: forall e. e -> OpApp e -> e
fromOrdinary e
d (Ordinary e
e) = e
e
fromOrdinary e
d OpApp e
_            = e
d

data FieldAssignment' a = FieldAssignment { forall a. FieldAssignment' a -> Name
_nameFieldA :: Name, forall a. FieldAssignment' a -> a
_exprFieldA :: a }
  deriving (forall a b. a -> FieldAssignment' b -> FieldAssignment' a
forall a b. (a -> b) -> FieldAssignment' a -> FieldAssignment' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> FieldAssignment' b -> FieldAssignment' a
$c<$ :: forall a b. a -> FieldAssignment' b -> FieldAssignment' a
fmap :: forall a b. (a -> b) -> FieldAssignment' a -> FieldAssignment' b
$cfmap :: forall a b. (a -> b) -> FieldAssignment' a -> FieldAssignment' b
Functor, forall a. Eq a => a -> FieldAssignment' a -> Bool
forall a. Num a => FieldAssignment' a -> a
forall a. Ord a => FieldAssignment' a -> a
forall m. Monoid m => FieldAssignment' m -> m
forall a. FieldAssignment' a -> Bool
forall a. FieldAssignment' a -> Int
forall a. FieldAssignment' a -> [a]
forall a. (a -> a -> a) -> FieldAssignment' a -> a
forall m a. Monoid m => (a -> m) -> FieldAssignment' a -> m
forall b a. (b -> a -> b) -> b -> FieldAssignment' a -> b
forall a b. (a -> b -> b) -> b -> FieldAssignment' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => FieldAssignment' a -> a
$cproduct :: forall a. Num a => FieldAssignment' a -> a
sum :: forall a. Num a => FieldAssignment' a -> a
$csum :: forall a. Num a => FieldAssignment' a -> a
minimum :: forall a. Ord a => FieldAssignment' a -> a
$cminimum :: forall a. Ord a => FieldAssignment' a -> a
maximum :: forall a. Ord a => FieldAssignment' a -> a
$cmaximum :: forall a. Ord a => FieldAssignment' a -> a
elem :: forall a. Eq a => a -> FieldAssignment' a -> Bool
$celem :: forall a. Eq a => a -> FieldAssignment' a -> Bool
length :: forall a. FieldAssignment' a -> Int
$clength :: forall a. FieldAssignment' a -> Int
null :: forall a. FieldAssignment' a -> Bool
$cnull :: forall a. FieldAssignment' a -> Bool
toList :: forall a. FieldAssignment' a -> [a]
$ctoList :: forall a. FieldAssignment' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> FieldAssignment' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> FieldAssignment' a -> a
foldr1 :: forall a. (a -> a -> a) -> FieldAssignment' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> FieldAssignment' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> FieldAssignment' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> FieldAssignment' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> FieldAssignment' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> FieldAssignment' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> FieldAssignment' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> FieldAssignment' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> FieldAssignment' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> FieldAssignment' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> FieldAssignment' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> FieldAssignment' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> FieldAssignment' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> FieldAssignment' a -> m
fold :: forall m. Monoid m => FieldAssignment' m -> m
$cfold :: forall m. Monoid m => FieldAssignment' m -> m
Foldable, Functor FieldAssignment'
Foldable FieldAssignment'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
FieldAssignment' (m a) -> m (FieldAssignment' a)
forall (f :: * -> *) a.
Applicative f =>
FieldAssignment' (f a) -> f (FieldAssignment' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FieldAssignment' a -> m (FieldAssignment' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FieldAssignment' a -> f (FieldAssignment' b)
sequence :: forall (m :: * -> *) a.
Monad m =>
FieldAssignment' (m a) -> m (FieldAssignment' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
FieldAssignment' (m a) -> m (FieldAssignment' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FieldAssignment' a -> m (FieldAssignment' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FieldAssignment' a -> m (FieldAssignment' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
FieldAssignment' (f a) -> f (FieldAssignment' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
FieldAssignment' (f a) -> f (FieldAssignment' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FieldAssignment' a -> f (FieldAssignment' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FieldAssignment' a -> f (FieldAssignment' b)
Traversable, Int -> FieldAssignment' a -> ShowS
forall a. Show a => Int -> FieldAssignment' a -> ShowS
forall a. Show a => [FieldAssignment' a] -> ShowS
forall a. Show a => FieldAssignment' a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldAssignment' a] -> ShowS
$cshowList :: forall a. Show a => [FieldAssignment' a] -> ShowS
show :: FieldAssignment' a -> String
$cshow :: forall a. Show a => FieldAssignment' a -> String
showsPrec :: Int -> FieldAssignment' a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> FieldAssignment' a -> ShowS
Show, FieldAssignment' a -> FieldAssignment' a -> Bool
forall a. Eq a => FieldAssignment' a -> FieldAssignment' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldAssignment' a -> FieldAssignment' a -> Bool
$c/= :: forall a. Eq a => FieldAssignment' a -> FieldAssignment' a -> Bool
== :: FieldAssignment' a -> FieldAssignment' a -> Bool
$c== :: forall a. Eq a => FieldAssignment' a -> FieldAssignment' a -> Bool
Eq)

type FieldAssignment = FieldAssignment' Expr

data ModuleAssignment  = ModuleAssignment
                           { ModuleAssignment -> QName
_qnameModA     :: QName
                           , ModuleAssignment -> [Expr]
_exprModA      :: [Expr]
                           , ModuleAssignment -> ImportDirective
_importDirModA :: ImportDirective
                           }
  deriving ModuleAssignment -> ModuleAssignment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModuleAssignment -> ModuleAssignment -> Bool
$c/= :: ModuleAssignment -> ModuleAssignment -> Bool
== :: ModuleAssignment -> ModuleAssignment -> Bool
$c== :: ModuleAssignment -> ModuleAssignment -> Bool
Eq

type RecordAssignment  = Either FieldAssignment ModuleAssignment
type RecordAssignments = [RecordAssignment]

nameFieldA :: Lens' Name (FieldAssignment' a)
nameFieldA :: forall a. Lens' Name (FieldAssignment' a)
nameFieldA Name -> f Name
f FieldAssignment' a
r = Name -> f Name
f (forall a. FieldAssignment' a -> Name
_nameFieldA FieldAssignment' a
r) forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \Name
x -> FieldAssignment' a
r { _nameFieldA :: Name
_nameFieldA = Name
x }

exprFieldA :: Lens' a (FieldAssignment' a)
exprFieldA :: forall a. Lens' a (FieldAssignment' a)
exprFieldA a -> f a
f FieldAssignment' a
r = a -> f a
f (forall a. FieldAssignment' a -> a
_exprFieldA FieldAssignment' a
r) forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \a
x -> FieldAssignment' a
r { _exprFieldA :: a
_exprFieldA = a
x }

-- UNUSED Liang-Ting Chen 2019-07-16
--qnameModA :: Lens' QName ModuleAssignment
--qnameModA f r = f (_qnameModA r) <&> \x -> r { _qnameModA = x }
--
--exprModA :: Lens' [Expr] ModuleAssignment
--exprModA f r = f (_exprModA r) <&> \x -> r { _exprModA = x }
--
--importDirModA :: Lens' ImportDirective ModuleAssignment
--importDirModA f r = f (_importDirModA r) <&> \x -> r { _importDirModA = x }

-- | Concrete expressions. Should represent exactly what the user wrote.
data Expr
  = Ident QName                                -- ^ ex: @x@
  | Lit Range Literal                          -- ^ ex: @1@ or @\"foo\"@
  | QuestionMark Range (Maybe Nat)             -- ^ ex: @?@ or @{! ... !}@
  | Underscore Range (Maybe String)            -- ^ ex: @_@ or @_A_5@
  | RawApp Range (List2 Expr)                  -- ^ before parsing operators
  | App Range Expr (NamedArg Expr)             -- ^ ex: @e e@, @e {e}@, or @e {x = e}@
  | OpApp Range QName (Set A.Name) OpAppArgs   -- ^ ex: @e + e@
                                               -- The 'QName' is possibly ambiguous,
                                               -- but it must correspond to one of the names in the set.
  | WithApp Range Expr [Expr]                  -- ^ ex: @e | e1 | .. | en@
  | HiddenArg Range (Named_ Expr)              -- ^ ex: @{e}@ or @{x=e}@
  | InstanceArg Range (Named_ Expr)            -- ^ ex: @{{e}}@ or @{{x=e}}@
  | Lam Range (List1 LamBinding) Expr          -- ^ ex: @\\x {y} -> e@ or @\\(x:A){y:B} -> e@
  | AbsurdLam Range Hiding                     -- ^ ex: @\\ ()@
  | ExtendedLam Range Erased
      (List1 LamClause)                        -- ^ ex: @\\ { p11 .. p1a -> e1 ; .. ; pn1 .. pnz -> en }@
  | Fun Range (Arg Expr) Expr                  -- ^ ex: @e -> e@ or @.e -> e@ (NYI: @{e} -> e@)
  | Pi Telescope1 Expr                         -- ^ ex: @(xs:e) -> e@ or @{xs:e} -> e@
  | Rec Range RecordAssignments                -- ^ ex: @record {x = a; y = b}@, or @record { x = a; M1; M2 }@
  | RecUpdate Range Expr [FieldAssignment]     -- ^ ex: @record e {x = a; y = b}@
  | Let Range (List1 Declaration) (Maybe Expr) -- ^ ex: @let Ds in e@, missing body when parsing do-notation let
  | Paren Range Expr                           -- ^ ex: @(e)@
  | IdiomBrackets Range [Expr]                 -- ^ ex: @(| e1 | e2 | .. | en |)@ or @(|)@
  | DoBlock Range (List1 DoStmt)               -- ^ ex: @do x <- m1; m2@
  | Absurd Range                               -- ^ ex: @()@ or @{}@, only in patterns
  | As Range Name Expr                         -- ^ ex: @x\@p@, only in patterns
  | Dot Range Expr                             -- ^ ex: @.p@, only in patterns
  | DoubleDot Range Expr                       -- ^ ex: @..A@, used for parsing @..A -> B@
  | Quote Range                                -- ^ ex: @quote@, should be applied to a name
  | QuoteTerm Range                            -- ^ ex: @quoteTerm@, should be applied to a term
  | Tactic Range Expr                          -- ^ ex: @\@(tactic t)@, used to declare tactic arguments
  | Unquote Range                              -- ^ ex: @unquote@, should be applied to a term of type @Term@
  | DontCare Expr                              -- ^ to print irrelevant things
  | Equal Range Expr Expr                      -- ^ ex: @a = b@, used internally in the parser
  | Ellipsis Range                             -- ^ @...@, used internally to parse patterns.
  | Generalized Expr
  deriving Expr -> Expr -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Expr -> Expr -> Bool
$c/= :: Expr -> Expr -> Bool
== :: Expr -> Expr -> Bool
$c== :: Expr -> Expr -> Bool
Eq

type OpAppArgs = OpAppArgs' Expr
type OpAppArgs' e = [NamedArg (MaybePlaceholder (OpApp e))]

-- | Concrete patterns. No literals in patterns at the moment.
data Pattern
  = IdentP QName                           -- ^ @c@ or @x@
  | QuoteP Range                           -- ^ @quote@
  | AppP Pattern (NamedArg Pattern)        -- ^ @p p'@ or @p {x = p'}@
  | RawAppP Range (List2 Pattern)          -- ^ @p1..pn@ before parsing operators
  | OpAppP Range QName (Set A.Name)
           [NamedArg Pattern]              -- ^ eg: @p => p'@ for operator @_=>_@
                                           -- The 'QName' is possibly
                                           -- ambiguous, but it must
                                           -- correspond to one of
                                           -- the names in the set.
  | HiddenP Range (Named_ Pattern)         -- ^ @{p}@ or @{x = p}@
  | InstanceP Range (Named_ Pattern)       -- ^ @{{p}}@ or @{{x = p}}@
  | ParenP Range Pattern                   -- ^ @(p)@
  | WildP Range                            -- ^ @_@
  | AbsurdP Range                          -- ^ @()@
  | AsP Range Name Pattern                 -- ^ @x\@p@ unused
  | DotP Range Expr                        -- ^ @.e@
  | LitP Range Literal                     -- ^ @0@, @1@, etc.
  | RecP Range [FieldAssignment' Pattern]  -- ^ @record {x = p; y = q}@
  | EqualP Range [(Expr,Expr)]             -- ^ @i = i1@ i.e. cubical face lattice generator
  | EllipsisP Range (Maybe Pattern)        -- ^ @...@, only as left-most pattern.
                                           --   Second arg is @Nothing@ before expansion, and
                                           --   @Just p@ after expanding ellipsis to @p@.
  | WithP Range Pattern                    -- ^ @| p@, for with-patterns.
  deriving Pattern -> Pattern -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pattern -> Pattern -> Bool
$c/= :: Pattern -> Pattern -> Bool
== :: Pattern -> Pattern -> Bool
$c== :: Pattern -> Pattern -> Bool
Eq

data DoStmt
  = DoBind Range Pattern Expr [LamClause]   -- ^ @p ← e where cs@
  | DoThen Expr
  | DoLet Range (List1 Declaration)
  deriving DoStmt -> DoStmt -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DoStmt -> DoStmt -> Bool
$c/= :: DoStmt -> DoStmt -> Bool
== :: DoStmt -> DoStmt -> Bool
$c== :: DoStmt -> DoStmt -> Bool
Eq

-- | A Binder @x\@p@, the pattern is optional
data Binder' a = Binder
  { forall a. Binder' a -> Maybe Pattern
binderPattern :: Maybe Pattern
  , forall a. Binder' a -> a
binderName    :: a
  } deriving (Binder' a -> Binder' a -> Bool
forall a. Eq a => Binder' a -> Binder' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Binder' a -> Binder' a -> Bool
$c/= :: forall a. Eq a => Binder' a -> Binder' a -> Bool
== :: Binder' a -> Binder' a -> Bool
$c== :: forall a. Eq a => Binder' a -> Binder' a -> Bool
Eq, forall a b. a -> Binder' b -> Binder' a
forall a b. (a -> b) -> Binder' a -> Binder' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Binder' b -> Binder' a
$c<$ :: forall a b. a -> Binder' b -> Binder' a
fmap :: forall a b. (a -> b) -> Binder' a -> Binder' b
$cfmap :: forall a b. (a -> b) -> Binder' a -> Binder' b
Functor, forall a. Eq a => a -> Binder' a -> Bool
forall a. Num a => Binder' a -> a
forall a. Ord a => Binder' a -> a
forall m. Monoid m => Binder' m -> m
forall a. Binder' a -> Bool
forall a. Binder' a -> Int
forall a. Binder' a -> [a]
forall a. (a -> a -> a) -> Binder' a -> a
forall m a. Monoid m => (a -> m) -> Binder' a -> m
forall b a. (b -> a -> b) -> b -> Binder' a -> b
forall a b. (a -> b -> b) -> b -> Binder' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => Binder' a -> a
$cproduct :: forall a. Num a => Binder' a -> a
sum :: forall a. Num a => Binder' a -> a
$csum :: forall a. Num a => Binder' a -> a
minimum :: forall a. Ord a => Binder' a -> a
$cminimum :: forall a. Ord a => Binder' a -> a
maximum :: forall a. Ord a => Binder' a -> a
$cmaximum :: forall a. Ord a => Binder' a -> a
elem :: forall a. Eq a => a -> Binder' a -> Bool
$celem :: forall a. Eq a => a -> Binder' a -> Bool
length :: forall a. Binder' a -> Int
$clength :: forall a. Binder' a -> Int
null :: forall a. Binder' a -> Bool
$cnull :: forall a. Binder' a -> Bool
toList :: forall a. Binder' a -> [a]
$ctoList :: forall a. Binder' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Binder' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Binder' a -> a
foldr1 :: forall a. (a -> a -> a) -> Binder' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Binder' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Binder' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Binder' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Binder' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Binder' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Binder' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Binder' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Binder' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Binder' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Binder' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Binder' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Binder' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Binder' a -> m
fold :: forall m. Monoid m => Binder' m -> m
$cfold :: forall m. Monoid m => Binder' m -> m
Foldable, Functor Binder'
Foldable Binder'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => Binder' (m a) -> m (Binder' a)
forall (f :: * -> *) a.
Applicative f =>
Binder' (f a) -> f (Binder' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Binder' a -> m (Binder' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Binder' a -> f (Binder' b)
sequence :: forall (m :: * -> *) a. Monad m => Binder' (m a) -> m (Binder' a)
$csequence :: forall (m :: * -> *) a. Monad m => Binder' (m a) -> m (Binder' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Binder' a -> m (Binder' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Binder' a -> m (Binder' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Binder' (f a) -> f (Binder' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Binder' (f a) -> f (Binder' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Binder' a -> f (Binder' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Binder' a -> f (Binder' b)
Traversable)

type Binder = Binder' BoundName

mkBinder_ :: Name -> Binder
mkBinder_ :: Name -> Binder
mkBinder_ = forall a. a -> Binder' a
mkBinder forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> BoundName
mkBoundName_

mkBinder :: a -> Binder' a
mkBinder :: forall a. a -> Binder' a
mkBinder = forall a. Maybe Pattern -> a -> Binder' a
Binder forall a. Maybe a
Nothing

-- | A lambda binding is either domain free or typed.

type LamBinding = LamBinding' TypedBinding
data LamBinding' a
  = DomainFree (NamedArg Binder)
    -- ^ . @x@ or @{x}@ or @.x@ or @.{x}@ or @{.x}@ or @x\@p@ or @(p)@
  | DomainFull a
    -- ^ . @(xs : e)@ or @{xs : e}@
  deriving (forall a b. a -> LamBinding' b -> LamBinding' a
forall a b. (a -> b) -> LamBinding' a -> LamBinding' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> LamBinding' b -> LamBinding' a
$c<$ :: forall a b. a -> LamBinding' b -> LamBinding' a
fmap :: forall a b. (a -> b) -> LamBinding' a -> LamBinding' b
$cfmap :: forall a b. (a -> b) -> LamBinding' a -> LamBinding' b
Functor, forall a. Eq a => a -> LamBinding' a -> Bool
forall a. Num a => LamBinding' a -> a
forall a. Ord a => LamBinding' a -> a
forall m. Monoid m => LamBinding' m -> m
forall a. LamBinding' a -> Bool
forall a. LamBinding' a -> Int
forall a. LamBinding' a -> [a]
forall a. (a -> a -> a) -> LamBinding' a -> a
forall m a. Monoid m => (a -> m) -> LamBinding' a -> m
forall b a. (b -> a -> b) -> b -> LamBinding' a -> b
forall a b. (a -> b -> b) -> b -> LamBinding' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => LamBinding' a -> a
$cproduct :: forall a. Num a => LamBinding' a -> a
sum :: forall a. Num a => LamBinding' a -> a
$csum :: forall a. Num a => LamBinding' a -> a
minimum :: forall a. Ord a => LamBinding' a -> a
$cminimum :: forall a. Ord a => LamBinding' a -> a
maximum :: forall a. Ord a => LamBinding' a -> a
$cmaximum :: forall a. Ord a => LamBinding' a -> a
elem :: forall a. Eq a => a -> LamBinding' a -> Bool
$celem :: forall a. Eq a => a -> LamBinding' a -> Bool
length :: forall a. LamBinding' a -> Int
$clength :: forall a. LamBinding' a -> Int
null :: forall a. LamBinding' a -> Bool
$cnull :: forall a. LamBinding' a -> Bool
toList :: forall a. LamBinding' a -> [a]
$ctoList :: forall a. LamBinding' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> LamBinding' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> LamBinding' a -> a
foldr1 :: forall a. (a -> a -> a) -> LamBinding' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> LamBinding' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> LamBinding' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> LamBinding' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> LamBinding' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> LamBinding' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> LamBinding' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> LamBinding' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> LamBinding' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> LamBinding' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> LamBinding' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> LamBinding' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> LamBinding' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> LamBinding' a -> m
fold :: forall m. Monoid m => LamBinding' m -> m
$cfold :: forall m. Monoid m => LamBinding' m -> m
Foldable, Functor LamBinding'
Foldable LamBinding'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
LamBinding' (m a) -> m (LamBinding' a)
forall (f :: * -> *) a.
Applicative f =>
LamBinding' (f a) -> f (LamBinding' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LamBinding' a -> m (LamBinding' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LamBinding' a -> f (LamBinding' b)
sequence :: forall (m :: * -> *) a.
Monad m =>
LamBinding' (m a) -> m (LamBinding' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
LamBinding' (m a) -> m (LamBinding' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LamBinding' a -> m (LamBinding' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> LamBinding' a -> m (LamBinding' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
LamBinding' (f a) -> f (LamBinding' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
LamBinding' (f a) -> f (LamBinding' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LamBinding' a -> f (LamBinding' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> LamBinding' a -> f (LamBinding' b)
Traversable, LamBinding' a -> LamBinding' a -> Bool
forall a. Eq a => LamBinding' a -> LamBinding' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LamBinding' a -> LamBinding' a -> Bool
$c/= :: forall a. Eq a => LamBinding' a -> LamBinding' a -> Bool
== :: LamBinding' a -> LamBinding' a -> Bool
$c== :: forall a. Eq a => LamBinding' a -> LamBinding' a -> Bool
Eq)

-- | Drop type annotations and lets from bindings.
dropTypeAndModality :: LamBinding -> [LamBinding]
dropTypeAndModality :: LamBinding -> [LamBinding]
dropTypeAndModality (DomainFull (TBind Range
_ List1 (NamedArg Binder)
xs Expr
_)) =
  forall a b. (a -> b) -> [a] -> [b]
map (forall a. NamedArg Binder -> LamBinding' a
DomainFree forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. LensModality a => Modality -> a -> a
setModality Modality
defaultModality) forall a b. (a -> b) -> a -> b
$ forall l. IsList l => l -> [Item l]
List1.toList List1 (NamedArg Binder)
xs
dropTypeAndModality (DomainFull TLet{}) = []
dropTypeAndModality (DomainFree NamedArg Binder
x) = [forall a. NamedArg Binder -> LamBinding' a
DomainFree forall a b. (a -> b) -> a -> b
$ forall a. LensModality a => Modality -> a -> a
setModality Modality
defaultModality NamedArg Binder
x]

data BoundName = BName
  { BoundName -> Name
boundName       :: Name
  , BoundName -> Fixity'
bnameFixity     :: Fixity'
  , BoundName -> Maybe Expr
bnameTactic     :: TacticAttribute -- From @tactic attribute
  , BoundName -> Bool
bnameIsFinite   :: Bool
  }
  deriving BoundName -> BoundName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BoundName -> BoundName -> Bool
$c/= :: BoundName -> BoundName -> Bool
== :: BoundName -> BoundName -> Bool
$c== :: BoundName -> BoundName -> Bool
Eq

type TacticAttribute = Maybe Expr

mkBoundName_ :: Name -> BoundName
mkBoundName_ :: Name -> BoundName
mkBoundName_ Name
x = Name -> Fixity' -> BoundName
mkBoundName Name
x Fixity'
noFixity'

mkBoundName :: Name -> Fixity' -> BoundName
mkBoundName :: Name -> Fixity' -> BoundName
mkBoundName Name
x Fixity'
f = Name -> Fixity' -> Maybe Expr -> Bool -> BoundName
BName Name
x Fixity'
f forall a. Maybe a
Nothing Bool
False

-- | A typed binding.

type TypedBinding = TypedBinding' Expr

data TypedBinding' e
  = TBind Range (List1 (NamedArg Binder)) e
    -- ^ Binding @(x1\@p1 ... xn\@pn : A)@.
  | TLet  Range (List1 Declaration)
    -- ^ Let binding @(let Ds)@ or @(open M args)@.
  deriving (forall a b. a -> TypedBinding' b -> TypedBinding' a
forall a b. (a -> b) -> TypedBinding' a -> TypedBinding' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> TypedBinding' b -> TypedBinding' a
$c<$ :: forall a b. a -> TypedBinding' b -> TypedBinding' a
fmap :: forall a b. (a -> b) -> TypedBinding' a -> TypedBinding' b
$cfmap :: forall a b. (a -> b) -> TypedBinding' a -> TypedBinding' b
Functor, forall a. Eq a => a -> TypedBinding' a -> Bool
forall a. Num a => TypedBinding' a -> a
forall a. Ord a => TypedBinding' a -> a
forall m. Monoid m => TypedBinding' m -> m
forall a. TypedBinding' a -> Bool
forall a. TypedBinding' a -> Int
forall a. TypedBinding' a -> [a]
forall a. (a -> a -> a) -> TypedBinding' a -> a
forall m a. Monoid m => (a -> m) -> TypedBinding' a -> m
forall b a. (b -> a -> b) -> b -> TypedBinding' a -> b
forall a b. (a -> b -> b) -> b -> TypedBinding' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => TypedBinding' a -> a
$cproduct :: forall a. Num a => TypedBinding' a -> a
sum :: forall a. Num a => TypedBinding' a -> a
$csum :: forall a. Num a => TypedBinding' a -> a
minimum :: forall a. Ord a => TypedBinding' a -> a
$cminimum :: forall a. Ord a => TypedBinding' a -> a
maximum :: forall a. Ord a => TypedBinding' a -> a
$cmaximum :: forall a. Ord a => TypedBinding' a -> a
elem :: forall a. Eq a => a -> TypedBinding' a -> Bool
$celem :: forall a. Eq a => a -> TypedBinding' a -> Bool
length :: forall a. TypedBinding' a -> Int
$clength :: forall a. TypedBinding' a -> Int
null :: forall a. TypedBinding' a -> Bool
$cnull :: forall a. TypedBinding' a -> Bool
toList :: forall a. TypedBinding' a -> [a]
$ctoList :: forall a. TypedBinding' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> TypedBinding' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> TypedBinding' a -> a
foldr1 :: forall a. (a -> a -> a) -> TypedBinding' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> TypedBinding' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> TypedBinding' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> TypedBinding' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> TypedBinding' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> TypedBinding' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> TypedBinding' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> TypedBinding' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> TypedBinding' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> TypedBinding' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> TypedBinding' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> TypedBinding' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> TypedBinding' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> TypedBinding' a -> m
fold :: forall m. Monoid m => TypedBinding' m -> m
$cfold :: forall m. Monoid m => TypedBinding' m -> m
Foldable, Functor TypedBinding'
Foldable TypedBinding'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
TypedBinding' (m a) -> m (TypedBinding' a)
forall (f :: * -> *) a.
Applicative f =>
TypedBinding' (f a) -> f (TypedBinding' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TypedBinding' a -> m (TypedBinding' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TypedBinding' a -> f (TypedBinding' b)
sequence :: forall (m :: * -> *) a.
Monad m =>
TypedBinding' (m a) -> m (TypedBinding' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
TypedBinding' (m a) -> m (TypedBinding' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TypedBinding' a -> m (TypedBinding' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> TypedBinding' a -> m (TypedBinding' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
TypedBinding' (f a) -> f (TypedBinding' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
TypedBinding' (f a) -> f (TypedBinding' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TypedBinding' a -> f (TypedBinding' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> TypedBinding' a -> f (TypedBinding' b)
Traversable, TypedBinding' e -> TypedBinding' e -> Bool
forall e. Eq e => TypedBinding' e -> TypedBinding' e -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypedBinding' e -> TypedBinding' e -> Bool
$c/= :: forall e. Eq e => TypedBinding' e -> TypedBinding' e -> Bool
== :: TypedBinding' e -> TypedBinding' e -> Bool
$c== :: forall e. Eq e => TypedBinding' e -> TypedBinding' e -> Bool
Eq)

-- | A telescope is a sequence of typed bindings. Bound variables are in scope
--   in later types.
type Telescope1 = List1 TypedBinding
type Telescope  = [TypedBinding]

-- | We can try to get a @Telescope@ from a @[LamBinding]@.
--   If we have a type annotation already, we're happy.
--   Otherwise we manufacture a binder with an underscore for the type.
lamBindingsToTelescope :: Range -> [LamBinding] -> Telescope
lamBindingsToTelescope :: Range -> [LamBinding] -> Telescope
lamBindingsToTelescope Range
r = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a -> b) -> a -> b
$ \case
  DomainFull TypedBinding
ty -> TypedBinding
ty
  DomainFree NamedArg Binder
nm -> forall e. Range -> List1 (NamedArg Binder) -> e -> TypedBinding' e
TBind Range
r (forall a. a -> NonEmpty a
List1.singleton NamedArg Binder
nm) forall a b. (a -> b) -> a -> b
$ Range -> Maybe String -> Expr
Underscore Range
r forall a. Maybe a
Nothing

-- | Smart constructor for @Pi@: check whether the @Telescope@ is empty

makePi :: Telescope -> Expr -> Expr
makePi :: Telescope -> Expr -> Expr
makePi []     = forall a. a -> a
id
makePi (TypedBinding
b:Telescope
bs) = Telescope1 -> Expr -> Expr
Pi (TypedBinding
b forall a. a -> [a] -> NonEmpty a
:| Telescope
bs)

-- | Smart constructor for @Lam@: check for non-zero bindings.

mkLam :: Range -> [LamBinding] -> Expr -> Expr
mkLam :: Range -> [LamBinding] -> Expr -> Expr
mkLam Range
r []     Expr
e = Expr
e
mkLam Range
r (LamBinding
x:[LamBinding]
xs) Expr
e = Range -> List1 LamBinding -> Expr -> Expr
Lam Range
r (LamBinding
x forall a. a -> [a] -> NonEmpty a
:| [LamBinding]
xs) Expr
e

-- | Smart constructor for @Let@: check for non-zero let bindings.

mkLet :: Range -> [Declaration] -> Expr -> Expr
mkLet :: Range -> [Declaration] -> Expr -> Expr
mkLet Range
r []     Expr
e = Expr
e
mkLet Range
r (Declaration
d:[Declaration]
ds) Expr
e = Range -> List1 Declaration -> Maybe Expr -> Expr
Let Range
r (Declaration
d forall a. a -> [a] -> NonEmpty a
:| [Declaration]
ds) (forall a. a -> Maybe a
Just Expr
e)

-- | Smart constructor for @TLet@: check for non-zero let bindings.

mkTLet :: Range -> [Declaration] -> Maybe (TypedBinding' e)
mkTLet :: forall e. Range -> [Declaration] -> Maybe (TypedBinding' e)
mkTLet Range
r []     = forall a. Maybe a
Nothing
mkTLet Range
r (Declaration
d:[Declaration]
ds) = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall e. Range -> List1 Declaration -> TypedBinding' e
TLet Range
r (Declaration
d forall a. a -> [a] -> NonEmpty a
:| [Declaration]
ds)

{-| Left hand sides can be written in infix style. For example:

    > n + suc m = suc (n + m)
    > (f ∘ g) x = f (g x)

   We use fixity information to see which name is actually defined.
-}
data LHS = LHS  -- ^ Original pattern (including with-patterns), rewrite equations and with-expressions.
  { LHS -> Pattern
lhsOriginalPattern :: Pattern
    -- ^ e.g. @f ps | wps@
  , LHS -> [RewriteEqn]
lhsRewriteEqn      :: [RewriteEqn]
    -- ^ @(rewrite e | with p <- e in eq)@ (many)
  , LHS -> [WithExpr]
lhsWithExpr        :: [WithExpr]
    -- ^ @with e1 in eq | {e2} | ...@ (many)
  }
  deriving LHS -> LHS -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LHS -> LHS -> Bool
$c/= :: LHS -> LHS -> Bool
== :: LHS -> LHS -> Bool
$c== :: LHS -> LHS -> Bool
Eq

type RewriteEqn = RewriteEqn' () Name Pattern Expr
type WithExpr   = Named Name (Arg Expr)

-- | Processed (operator-parsed) intermediate form of the core @f ps@ of 'LHS'.
--   Corresponds to 'lhsOriginalPattern'.
data LHSCore
  = LHSHead  { LHSCore -> QName
lhsDefName      :: QName               -- ^ @f@
             , LHSCore -> [NamedArg Pattern]
lhsPats         :: [NamedArg Pattern]  -- ^ @ps@
             }
  | LHSProj  { LHSCore -> QName
lhsDestructor   :: QName               -- ^ Record projection.
             , LHSCore -> [NamedArg Pattern]
lhsPatsLeft     :: [NamedArg Pattern]  -- ^ Patterns for record indices (currently none).
             , LHSCore -> NamedArg LHSCore
lhsFocus        :: NamedArg LHSCore    -- ^ Main argument.
             , lhsPats         :: [NamedArg Pattern]  -- ^ More application patterns.
             }
  | LHSWith  { LHSCore -> LHSCore
lhsHead         :: LHSCore
             , LHSCore -> [Pattern]
lhsWithPatterns :: [Pattern]          -- ^ Non-empty; at least one @(| p)@.
             , lhsPats         :: [NamedArg Pattern] -- ^ More application patterns.
             }
  | LHSEllipsis
             { LHSCore -> Range
lhsEllipsisRange :: Range
             , LHSCore -> LHSCore
lhsEllipsisPat   :: LHSCore           -- ^ Pattern that was expanded from an ellipsis @...@.
             }
  deriving LHSCore -> LHSCore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LHSCore -> LHSCore -> Bool
$c/= :: LHSCore -> LHSCore -> Bool
== :: LHSCore -> LHSCore -> Bool
$c== :: LHSCore -> LHSCore -> Bool
Eq

type RHS = RHS' Expr
data RHS' e
  = AbsurdRHS -- ^ No right hand side because of absurd match.
  | RHS e
  deriving (forall a b. a -> RHS' b -> RHS' a
forall a b. (a -> b) -> RHS' a -> RHS' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> RHS' b -> RHS' a
$c<$ :: forall a b. a -> RHS' b -> RHS' a
fmap :: forall a b. (a -> b) -> RHS' a -> RHS' b
$cfmap :: forall a b. (a -> b) -> RHS' a -> RHS' b
Functor, forall a. Eq a => a -> RHS' a -> Bool
forall a. Num a => RHS' a -> a
forall a. Ord a => RHS' a -> a
forall m. Monoid m => RHS' m -> m
forall a. RHS' a -> Bool
forall a. RHS' a -> Int
forall a. RHS' a -> [a]
forall a. (a -> a -> a) -> RHS' a -> a
forall m a. Monoid m => (a -> m) -> RHS' a -> m
forall b a. (b -> a -> b) -> b -> RHS' a -> b
forall a b. (a -> b -> b) -> b -> RHS' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => RHS' a -> a
$cproduct :: forall a. Num a => RHS' a -> a
sum :: forall a. Num a => RHS' a -> a
$csum :: forall a. Num a => RHS' a -> a
minimum :: forall a. Ord a => RHS' a -> a
$cminimum :: forall a. Ord a => RHS' a -> a
maximum :: forall a. Ord a => RHS' a -> a
$cmaximum :: forall a. Ord a => RHS' a -> a
elem :: forall a. Eq a => a -> RHS' a -> Bool
$celem :: forall a. Eq a => a -> RHS' a -> Bool
length :: forall a. RHS' a -> Int
$clength :: forall a. RHS' a -> Int
null :: forall a. RHS' a -> Bool
$cnull :: forall a. RHS' a -> Bool
toList :: forall a. RHS' a -> [a]
$ctoList :: forall a. RHS' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> RHS' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> RHS' a -> a
foldr1 :: forall a. (a -> a -> a) -> RHS' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> RHS' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> RHS' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> RHS' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> RHS' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> RHS' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> RHS' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> RHS' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> RHS' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> RHS' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> RHS' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> RHS' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> RHS' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> RHS' a -> m
fold :: forall m. Monoid m => RHS' m -> m
$cfold :: forall m. Monoid m => RHS' m -> m
Foldable, Functor RHS'
Foldable RHS'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => RHS' (m a) -> m (RHS' a)
forall (f :: * -> *) a. Applicative f => RHS' (f a) -> f (RHS' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> RHS' a -> m (RHS' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> RHS' a -> f (RHS' b)
sequence :: forall (m :: * -> *) a. Monad m => RHS' (m a) -> m (RHS' a)
$csequence :: forall (m :: * -> *) a. Monad m => RHS' (m a) -> m (RHS' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> RHS' a -> m (RHS' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> RHS' a -> m (RHS' b)
sequenceA :: forall (f :: * -> *) a. Applicative f => RHS' (f a) -> f (RHS' a)
$csequenceA :: forall (f :: * -> *) a. Applicative f => RHS' (f a) -> f (RHS' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> RHS' a -> f (RHS' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> RHS' a -> f (RHS' b)
Traversable, RHS' e -> RHS' e -> Bool
forall e. Eq e => RHS' e -> RHS' e -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RHS' e -> RHS' e -> Bool
$c/= :: forall e. Eq e => RHS' e -> RHS' e -> Bool
== :: RHS' e -> RHS' e -> Bool
$c== :: forall e. Eq e => RHS' e -> RHS' e -> Bool
Eq)

-- | @where@ block following a clause.
type WhereClause = WhereClause' [Declaration]

-- The generalization @WhereClause'@ is for the sake of Concrete.Generic.
data WhereClause' decls
  = NoWhere
      -- ^ No @where@ clauses.
  | AnyWhere Range decls
      -- ^ Ordinary @where@.  'Range' of the @where@ keyword.
      --   List of declarations can be empty.
  | SomeWhere Range Name Access decls
      -- ^ Named where: @module M where ds@.
      --   'Range' of the keywords @module@ and @where@.
      --   The 'Access' flag applies to the 'Name' (not the module contents!)
      --   and is propagated from the parent function.
      --   List of declarations can be empty.
  deriving (WhereClause' decls -> WhereClause' decls -> Bool
forall decls.
Eq decls =>
WhereClause' decls -> WhereClause' decls -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WhereClause' decls -> WhereClause' decls -> Bool
$c/= :: forall decls.
Eq decls =>
WhereClause' decls -> WhereClause' decls -> Bool
== :: WhereClause' decls -> WhereClause' decls -> Bool
$c== :: forall decls.
Eq decls =>
WhereClause' decls -> WhereClause' decls -> Bool
Eq, forall a b. a -> WhereClause' b -> WhereClause' a
forall a b. (a -> b) -> WhereClause' a -> WhereClause' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> WhereClause' b -> WhereClause' a
$c<$ :: forall a b. a -> WhereClause' b -> WhereClause' a
fmap :: forall a b. (a -> b) -> WhereClause' a -> WhereClause' b
$cfmap :: forall a b. (a -> b) -> WhereClause' a -> WhereClause' b
Functor, forall a. Eq a => a -> WhereClause' a -> Bool
forall a. Num a => WhereClause' a -> a
forall a. Ord a => WhereClause' a -> a
forall m. Monoid m => WhereClause' m -> m
forall a. WhereClause' a -> Bool
forall a. WhereClause' a -> Int
forall a. WhereClause' a -> [a]
forall a. (a -> a -> a) -> WhereClause' a -> a
forall m a. Monoid m => (a -> m) -> WhereClause' a -> m
forall b a. (b -> a -> b) -> b -> WhereClause' a -> b
forall a b. (a -> b -> b) -> b -> WhereClause' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => WhereClause' a -> a
$cproduct :: forall a. Num a => WhereClause' a -> a
sum :: forall a. Num a => WhereClause' a -> a
$csum :: forall a. Num a => WhereClause' a -> a
minimum :: forall a. Ord a => WhereClause' a -> a
$cminimum :: forall a. Ord a => WhereClause' a -> a
maximum :: forall a. Ord a => WhereClause' a -> a
$cmaximum :: forall a. Ord a => WhereClause' a -> a
elem :: forall a. Eq a => a -> WhereClause' a -> Bool
$celem :: forall a. Eq a => a -> WhereClause' a -> Bool
length :: forall a. WhereClause' a -> Int
$clength :: forall a. WhereClause' a -> Int
null :: forall a. WhereClause' a -> Bool
$cnull :: forall a. WhereClause' a -> Bool
toList :: forall a. WhereClause' a -> [a]
$ctoList :: forall a. WhereClause' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> WhereClause' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> WhereClause' a -> a
foldr1 :: forall a. (a -> a -> a) -> WhereClause' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> WhereClause' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> WhereClause' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> WhereClause' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> WhereClause' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> WhereClause' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> WhereClause' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> WhereClause' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> WhereClause' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> WhereClause' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> WhereClause' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> WhereClause' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> WhereClause' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> WhereClause' a -> m
fold :: forall m. Monoid m => WhereClause' m -> m
$cfold :: forall m. Monoid m => WhereClause' m -> m
Foldable, Functor WhereClause'
Foldable WhereClause'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
WhereClause' (m a) -> m (WhereClause' a)
forall (f :: * -> *) a.
Applicative f =>
WhereClause' (f a) -> f (WhereClause' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WhereClause' a -> m (WhereClause' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WhereClause' a -> f (WhereClause' b)
sequence :: forall (m :: * -> *) a.
Monad m =>
WhereClause' (m a) -> m (WhereClause' a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
WhereClause' (m a) -> m (WhereClause' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WhereClause' a -> m (WhereClause' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> WhereClause' a -> m (WhereClause' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
WhereClause' (f a) -> f (WhereClause' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
WhereClause' (f a) -> f (WhereClause' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WhereClause' a -> f (WhereClause' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> WhereClause' a -> f (WhereClause' b)
Traversable)

data LamClause = LamClause
  { LamClause -> [Pattern]
lamLHS      :: [Pattern]   -- ^ Possibly empty sequence.
  , LamClause -> RHS
lamRHS      :: RHS
  , LamClause -> Bool
lamCatchAll :: Bool
  }
  deriving LamClause -> LamClause -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LamClause -> LamClause -> Bool
$c/= :: LamClause -> LamClause -> Bool
== :: LamClause -> LamClause -> Bool
$c== :: LamClause -> LamClause -> Bool
Eq

-- | An expression followed by a where clause.
--   Currently only used to give better a better error message in interaction.
data ExprWhere = ExprWhere Expr WhereClause

-- | The things you are allowed to say when you shuffle names between name
--   spaces (i.e. in @import@, @namespace@, or @open@ declarations).
type ImportDirective = ImportDirective' Name Name
type Using           = Using'           Name Name
type Renaming        = Renaming'        Name Name
type RenamingDirective = RenamingDirective' Name Name
type HidingDirective   = HidingDirective'   Name Name  -- 'Hiding' is already taken

-- | An imported name can be a module or a defined name.
type ImportedName = ImportedName' Name Name

-- | The content of the @as@-clause of the import statement.
data AsName' a = AsName
  { forall a. AsName' a -> a
asName  :: a
    -- ^ The \"as\" name.
  , forall a. AsName' a -> Range
asRange :: Range
    -- ^ The range of the \"as\" keyword.  Retained for highlighting purposes.
  }
  deriving (Int -> AsName' a -> ShowS
forall a. Show a => Int -> AsName' a -> ShowS
forall a. Show a => [AsName' a] -> ShowS
forall a. Show a => AsName' a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AsName' a] -> ShowS
$cshowList :: forall a. Show a => [AsName' a] -> ShowS
show :: AsName' a -> String
$cshow :: forall a. Show a => AsName' a -> String
showsPrec :: Int -> AsName' a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> AsName' a -> ShowS
Show, forall a b. a -> AsName' b -> AsName' a
forall a b. (a -> b) -> AsName' a -> AsName' b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> AsName' b -> AsName' a
$c<$ :: forall a b. a -> AsName' b -> AsName' a
fmap :: forall a b. (a -> b) -> AsName' a -> AsName' b
$cfmap :: forall a b. (a -> b) -> AsName' a -> AsName' b
Functor, forall a. Eq a => a -> AsName' a -> Bool
forall a. Num a => AsName' a -> a
forall a. Ord a => AsName' a -> a
forall m. Monoid m => AsName' m -> m
forall a. AsName' a -> Bool
forall a. AsName' a -> Int
forall a. AsName' a -> [a]
forall a. (a -> a -> a) -> AsName' a -> a
forall m a. Monoid m => (a -> m) -> AsName' a -> m
forall b a. (b -> a -> b) -> b -> AsName' a -> b
forall a b. (a -> b -> b) -> b -> AsName' a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => AsName' a -> a
$cproduct :: forall a. Num a => AsName' a -> a
sum :: forall a. Num a => AsName' a -> a
$csum :: forall a. Num a => AsName' a -> a
minimum :: forall a. Ord a => AsName' a -> a
$cminimum :: forall a. Ord a => AsName' a -> a
maximum :: forall a. Ord a => AsName' a -> a
$cmaximum :: forall a. Ord a => AsName' a -> a
elem :: forall a. Eq a => a -> AsName' a -> Bool
$celem :: forall a. Eq a => a -> AsName' a -> Bool
length :: forall a. AsName' a -> Int
$clength :: forall a. AsName' a -> Int
null :: forall a. AsName' a -> Bool
$cnull :: forall a. AsName' a -> Bool
toList :: forall a. AsName' a -> [a]
$ctoList :: forall a. AsName' a -> [a]
foldl1 :: forall a. (a -> a -> a) -> AsName' a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> AsName' a -> a
foldr1 :: forall a. (a -> a -> a) -> AsName' a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> AsName' a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> AsName' a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> AsName' a -> b
foldl :: forall b a. (b -> a -> b) -> b -> AsName' a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> AsName' a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> AsName' a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> AsName' a -> b
foldr :: forall a b. (a -> b -> b) -> b -> AsName' a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> AsName' a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> AsName' a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> AsName' a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> AsName' a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> AsName' a -> m
fold :: forall m. Monoid m => AsName' m -> m
$cfold :: forall m. Monoid m => AsName' m -> m
Foldable, Functor AsName'
Foldable AsName'
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => AsName' (m a) -> m (AsName' a)
forall (f :: * -> *) a.
Applicative f =>
AsName' (f a) -> f (AsName' a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AsName' a -> m (AsName' b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AsName' a -> f (AsName' b)
sequence :: forall (m :: * -> *) a. Monad m => AsName' (m a) -> m (AsName' a)
$csequence :: forall (m :: * -> *) a. Monad m => AsName' (m a) -> m (AsName' a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AsName' a -> m (AsName' b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AsName' a -> m (AsName' b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
AsName' (f a) -> f (AsName' a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
AsName' (f a) -> f (AsName' a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AsName' a -> f (AsName' b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AsName' a -> f (AsName' b)
Traversable, AsName' a -> AsName' a -> Bool
forall a. Eq a => AsName' a -> AsName' a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AsName' a -> AsName' a -> Bool
$c/= :: forall a. Eq a => AsName' a -> AsName' a -> Bool
== :: AsName' a -> AsName' a -> Bool
$c== :: forall a. Eq a => AsName' a -> AsName' a -> Bool
Eq)

-- | From the parser, we get an expression for the @as@-'Name', which
--   we have to parse into a 'Name'.
type AsName = AsName' (Either Expr Name)

{--------------------------------------------------------------------------
    Declarations
 --------------------------------------------------------------------------}

-- | Just type signatures.
type TypeSignature = Declaration

-- | Just field signatures
type FieldSignature = Declaration

-- | Just type signatures or instance blocks.
type TypeSignatureOrInstanceBlock = Declaration

-- | Isolated record directives parsed as Declarations
data RecordDirective
   = Induction (Ranged Induction)
       -- ^ Range of keyword @[co]inductive@.
   | Constructor Name IsInstance
   | Eta         (Ranged HasEta0)
       -- ^ Range of @[no-]eta-equality@ keyword.
   | PatternOrCopattern Range
       -- ^ If declaration @pattern@ is present, give its range.
   deriving (RecordDirective -> RecordDirective -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecordDirective -> RecordDirective -> Bool
$c/= :: RecordDirective -> RecordDirective -> Bool
== :: RecordDirective -> RecordDirective -> Bool
$c== :: RecordDirective -> RecordDirective -> Bool
Eq, Int -> RecordDirective -> ShowS
[RecordDirective] -> ShowS
RecordDirective -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecordDirective] -> ShowS
$cshowList :: [RecordDirective] -> ShowS
show :: RecordDirective -> String
$cshow :: RecordDirective -> String
showsPrec :: Int -> RecordDirective -> ShowS
$cshowsPrec :: Int -> RecordDirective -> ShowS
Show)

type RecordDirectives = RecordDirectives' (Name, IsInstance)

{-| The representation type of a declaration. The comments indicate
    which type in the intended family the constructor targets.
-}

data Declaration
  = TypeSig ArgInfo TacticAttribute Name Expr
      -- ^ Axioms and functions can be irrelevant. (Hiding should be NotHidden)
  | FieldSig IsInstance TacticAttribute Name (Arg Expr)
  | Generalize Range [TypeSignature] -- ^ Variables to be generalized, can be hidden and/or irrelevant.
  | Field Range [FieldSignature]
  | FunClause LHS RHS WhereClause Bool
  | DataSig     Range Name [LamBinding] Expr -- ^ lone data signature in mutual block
  | Data        Range Name [LamBinding] Expr [TypeSignatureOrInstanceBlock]
  | DataDef     Range Name [LamBinding] [TypeSignatureOrInstanceBlock]
  | RecordSig   Range Name [LamBinding] Expr -- ^ lone record signature in mutual block
  | RecordDef   Range Name RecordDirectives [LamBinding] [Declaration]
  | Record      Range Name RecordDirectives [LamBinding] Expr [Declaration]
  | RecordDirective RecordDirective -- ^ Should not survive beyond the parser
  | Infix Fixity (List1 Name)
  | Syntax      Name Notation -- ^ notation declaration for a name
  | PatternSyn  Range Name [Arg Name] Pattern
  | Mutual      Range [Declaration]  -- @Range@ of the whole @mutual@ block.
  | InterleavedMutual Range [Declaration]
  | Abstract    Range [Declaration]
  | Private     Range Origin [Declaration]
    -- ^ In "Agda.Syntax.Concrete.Definitions" we generate private blocks
    --   temporarily, which should be treated different that user-declared
    --   private blocks.  Thus the 'Origin'.
  | InstanceB   Range [Declaration]
    -- ^ The 'Range' here (exceptionally) only refers to the range of the
    --   @instance@ keyword.  The range of the whole block @InstanceB r ds@
    --   is @fuseRange r ds@.
  | LoneConstructor Range [Declaration]
  | Macro       Range [Declaration]
  | Postulate   Range [TypeSignatureOrInstanceBlock]
  | Primitive   Range [TypeSignature]
  | Open        Range QName ImportDirective
  | Import      Range QName (Maybe AsName) !OpenShortHand ImportDirective
  | ModuleMacro Range  Name ModuleApplication !OpenShortHand ImportDirective
  | Module      Range QName Telescope [Declaration]
  | UnquoteDecl Range [Name] Expr
      -- ^ @unquoteDecl xs = e@
  | UnquoteDef  Range [Name] Expr
      -- ^ @unquoteDef xs = e@
  | UnquoteData Range Name [Name] Expr
      -- ^ @unquoteDecl data d constructor xs = e@
  | Pragma      Pragma
  deriving Declaration -> Declaration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Declaration -> Declaration -> Bool
$c/= :: Declaration -> Declaration -> Bool
== :: Declaration -> Declaration -> Bool
$c== :: Declaration -> Declaration -> Bool
Eq

-- | Extract a record directive
isRecordDirective :: Declaration -> Maybe RecordDirective
isRecordDirective :: Declaration -> Maybe RecordDirective
isRecordDirective (RecordDirective RecordDirective
r) = forall a. a -> Maybe a
Just RecordDirective
r
isRecordDirective (InstanceB Range
r [RecordDirective (Constructor Name
n IsInstance
p)]) = forall a. a -> Maybe a
Just (Name -> IsInstance -> RecordDirective
Constructor Name
n (Range -> IsInstance
InstanceDef Range
r))
isRecordDirective Declaration
_ = forall a. Maybe a
Nothing

data ModuleApplication
  = SectionApp Range Telescope Expr
    -- ^ @tel. M args@
  | RecordModuleInstance Range QName
    -- ^ @M {{...}}@
  deriving ModuleApplication -> ModuleApplication -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModuleApplication -> ModuleApplication -> Bool
$c/= :: ModuleApplication -> ModuleApplication -> Bool
== :: ModuleApplication -> ModuleApplication -> Bool
$c== :: ModuleApplication -> ModuleApplication -> Bool
Eq

data OpenShortHand = DoOpen | DontOpen
  deriving (OpenShortHand -> OpenShortHand -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OpenShortHand -> OpenShortHand -> Bool
$c/= :: OpenShortHand -> OpenShortHand -> Bool
== :: OpenShortHand -> OpenShortHand -> Bool
$c== :: OpenShortHand -> OpenShortHand -> Bool
Eq, Int -> OpenShortHand -> ShowS
[OpenShortHand] -> ShowS
OpenShortHand -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OpenShortHand] -> ShowS
$cshowList :: [OpenShortHand] -> ShowS
show :: OpenShortHand -> String
$cshow :: OpenShortHand -> String
showsPrec :: Int -> OpenShortHand -> ShowS
$cshowsPrec :: Int -> OpenShortHand -> ShowS
Show, forall x. Rep OpenShortHand x -> OpenShortHand
forall x. OpenShortHand -> Rep OpenShortHand x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OpenShortHand x -> OpenShortHand
$cfrom :: forall x. OpenShortHand -> Rep OpenShortHand x
Generic)

-- Pragmas ----------------------------------------------------------------

data Pragma
  = OptionsPragma             Range [String]
  | BuiltinPragma             Range RString QName
  | RewritePragma             Range Range [QName]        -- ^ Second Range is for REWRITE keyword.
  | ForeignPragma             Range RString String       -- ^ first string is backend name
  | CompilePragma             Range RString QName String -- ^ first string is backend name
  | StaticPragma              Range QName
  | InlinePragma              Range Bool QName  -- ^ INLINE or NOINLINE

  | ImpossiblePragma          Range [String]
    -- ^ Throws an internal error in the scope checker.
    --   The 'String's are words to be displayed with the error.
  | EtaPragma                 Range QName
    -- ^ For coinductive records, use pragma instead of regular
    --   @eta-equality@ definition (as it is might make Agda loop).
  | WarningOnUsage            Range QName Text
    -- ^ Applies to the named function
  | WarningOnImport           Range Text
    -- ^ Applies to the current module
  | InjectivePragma           Range QName
    -- ^ Mark a definition as injective for the pattern matching unifier.
  | DisplayPragma             Range Pattern Expr
    -- ^ Display lhs as rhs (modifies the printer).

  -- Attached (more or less) pragmas handled in the nicifier (Concrete.Definitions):
  | CatchallPragma            Range
    -- ^ Applies to the following function clause.
  | TerminationCheckPragma    Range (TerminationCheck Name)
    -- ^ Applies to the following function (and all that are mutually recursive with it)
    --   or to the functions in the following mutual block.
  | NoCoverageCheckPragma     Range
    -- ^ Applies to the following function (and all that are mutually recursive with it)
    --   or to the functions in the following mutual block.
  | NoPositivityCheckPragma   Range
    -- ^ Applies to the following data/record type or mutual block.
  | PolarityPragma            Range Name [Occurrence]
  | NoUniverseCheckPragma     Range
    -- ^ Applies to the following data/record type.
  | NotProjectionLikePragma   Range QName
    -- ^ Applies to the stated function
  deriving Pragma -> Pragma -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pragma -> Pragma -> Bool
$c/= :: Pragma -> Pragma -> Bool
== :: Pragma -> Pragma -> Bool
$c== :: Pragma -> Pragma -> Bool
Eq

---------------------------------------------------------------------------

-- | Modules: Top-level pragmas plus other top-level declarations.

data Module = Mod
  { Module -> [Pragma]
modPragmas :: [Pragma]
  , Module -> [Declaration]
modDecls   :: [Declaration]
  }

-- | Splits off allowed (= import) declarations before the first
--   non-allowed declaration.
--   After successful parsing, the first non-allowed declaration
--   should be a module declaration.
spanAllowedBeforeModule :: [Declaration] -> ([Declaration], [Declaration])
spanAllowedBeforeModule :: [Declaration] -> ([Declaration], [Declaration])
spanAllowedBeforeModule = forall a. (a -> Bool) -> [a] -> ([a], [a])
span Declaration -> Bool
isAllowedBeforeModule
  where
    isAllowedBeforeModule :: Declaration -> Bool
isAllowedBeforeModule (Pragma OptionsPragma{}) = Bool
True
    isAllowedBeforeModule (Pragma BuiltinPragma{}) = Bool
True
    isAllowedBeforeModule (Private Range
_ Origin
_ [Declaration]
ds) = forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Declaration -> Bool
isAllowedBeforeModule [Declaration]
ds
    isAllowedBeforeModule Import{}       = Bool
True
    isAllowedBeforeModule ModuleMacro{}  = Bool
True
    isAllowedBeforeModule Open{}         = Bool
True
    isAllowedBeforeModule Declaration
_              = Bool
False

{--------------------------------------------------------------------------
    Things we parse but are not part of the Agda file syntax
 --------------------------------------------------------------------------}

-- | Extended content of an interaction hole.
data HoleContent' qn nm p e
  = HoleContentExpr    e                       -- ^ @e@
  | HoleContentRewrite [RewriteEqn' qn nm p e] -- ^ @(rewrite | invert) e0 | ... | en@
  deriving (forall a b. a -> HoleContent' qn nm p b -> HoleContent' qn nm p a
forall a b.
(a -> b) -> HoleContent' qn nm p a -> HoleContent' qn nm p b
forall qn nm p a b.
a -> HoleContent' qn nm p b -> HoleContent' qn nm p a
forall qn nm p a b.
(a -> b) -> HoleContent' qn nm p a -> HoleContent' qn nm p b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> HoleContent' qn nm p b -> HoleContent' qn nm p a
$c<$ :: forall qn nm p a b.
a -> HoleContent' qn nm p b -> HoleContent' qn nm p a
fmap :: forall a b.
(a -> b) -> HoleContent' qn nm p a -> HoleContent' qn nm p b
$cfmap :: forall qn nm p a b.
(a -> b) -> HoleContent' qn nm p a -> HoleContent' qn nm p b
Functor, forall a. HoleContent' qn nm p a -> Bool
forall m a. Monoid m => (a -> m) -> HoleContent' qn nm p a -> m
forall a b. (a -> b -> b) -> b -> HoleContent' qn nm p a -> b
forall qn nm p a. Eq a => a -> HoleContent' qn nm p a -> Bool
forall qn nm p a. Num a => HoleContent' qn nm p a -> a
forall qn nm p a. Ord a => HoleContent' qn nm p a -> a
forall qn nm p m. Monoid m => HoleContent' qn nm p m -> m
forall qn nm p a. HoleContent' qn nm p a -> Bool
forall qn nm p a. HoleContent' qn nm p a -> Int
forall qn nm p a. HoleContent' qn nm p a -> [a]
forall qn nm p a. (a -> a -> a) -> HoleContent' qn nm p a -> a
forall qn nm p m a.
Monoid m =>
(a -> m) -> HoleContent' qn nm p a -> m
forall qn nm p b a.
(b -> a -> b) -> b -> HoleContent' qn nm p a -> b
forall qn nm p a b.
(a -> b -> b) -> b -> HoleContent' qn nm p a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => HoleContent' qn nm p a -> a
$cproduct :: forall qn nm p a. Num a => HoleContent' qn nm p a -> a
sum :: forall a. Num a => HoleContent' qn nm p a -> a
$csum :: forall qn nm p a. Num a => HoleContent' qn nm p a -> a
minimum :: forall a. Ord a => HoleContent' qn nm p a -> a
$cminimum :: forall qn nm p a. Ord a => HoleContent' qn nm p a -> a
maximum :: forall a. Ord a => HoleContent' qn nm p a -> a
$cmaximum :: forall qn nm p a. Ord a => HoleContent' qn nm p a -> a
elem :: forall a. Eq a => a -> HoleContent' qn nm p a -> Bool
$celem :: forall qn nm p a. Eq a => a -> HoleContent' qn nm p a -> Bool
length :: forall a. HoleContent' qn nm p a -> Int
$clength :: forall qn nm p a. HoleContent' qn nm p a -> Int
null :: forall a. HoleContent' qn nm p a -> Bool
$cnull :: forall qn nm p a. HoleContent' qn nm p a -> Bool
toList :: forall a. HoleContent' qn nm p a -> [a]
$ctoList :: forall qn nm p a. HoleContent' qn nm p a -> [a]
foldl1 :: forall a. (a -> a -> a) -> HoleContent' qn nm p a -> a
$cfoldl1 :: forall qn nm p a. (a -> a -> a) -> HoleContent' qn nm p a -> a
foldr1 :: forall a. (a -> a -> a) -> HoleContent' qn nm p a -> a
$cfoldr1 :: forall qn nm p a. (a -> a -> a) -> HoleContent' qn nm p a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> HoleContent' qn nm p a -> b
$cfoldl' :: forall qn nm p b a.
(b -> a -> b) -> b -> HoleContent' qn nm p a -> b
foldl :: forall b a. (b -> a -> b) -> b -> HoleContent' qn nm p a -> b
$cfoldl :: forall qn nm p b a.
(b -> a -> b) -> b -> HoleContent' qn nm p a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> HoleContent' qn nm p a -> b
$cfoldr' :: forall qn nm p a b.
(a -> b -> b) -> b -> HoleContent' qn nm p a -> b
foldr :: forall a b. (a -> b -> b) -> b -> HoleContent' qn nm p a -> b
$cfoldr :: forall qn nm p a b.
(a -> b -> b) -> b -> HoleContent' qn nm p a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> HoleContent' qn nm p a -> m
$cfoldMap' :: forall qn nm p m a.
Monoid m =>
(a -> m) -> HoleContent' qn nm p a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> HoleContent' qn nm p a -> m
$cfoldMap :: forall qn nm p m a.
Monoid m =>
(a -> m) -> HoleContent' qn nm p a -> m
fold :: forall m. Monoid m => HoleContent' qn nm p m -> m
$cfold :: forall qn nm p m. Monoid m => HoleContent' qn nm p m -> m
Foldable, forall qn nm p. Functor (HoleContent' qn nm p)
forall qn nm p. Foldable (HoleContent' qn nm p)
forall qn nm p (m :: * -> *) a.
Monad m =>
HoleContent' qn nm p (m a) -> m (HoleContent' qn nm p a)
forall qn nm p (f :: * -> *) a.
Applicative f =>
HoleContent' qn nm p (f a) -> f (HoleContent' qn nm p a)
forall qn nm p (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HoleContent' qn nm p a -> m (HoleContent' qn nm p b)
forall qn nm p (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HoleContent' qn nm p a -> f (HoleContent' qn nm p b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HoleContent' qn nm p a -> f (HoleContent' qn nm p b)
sequence :: forall (m :: * -> *) a.
Monad m =>
HoleContent' qn nm p (m a) -> m (HoleContent' qn nm p a)
$csequence :: forall qn nm p (m :: * -> *) a.
Monad m =>
HoleContent' qn nm p (m a) -> m (HoleContent' qn nm p a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HoleContent' qn nm p a -> m (HoleContent' qn nm p b)
$cmapM :: forall qn nm p (m :: * -> *) a b.
Monad m =>
(a -> m b) -> HoleContent' qn nm p a -> m (HoleContent' qn nm p b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
HoleContent' qn nm p (f a) -> f (HoleContent' qn nm p a)
$csequenceA :: forall qn nm p (f :: * -> *) a.
Applicative f =>
HoleContent' qn nm p (f a) -> f (HoleContent' qn nm p a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HoleContent' qn nm p a -> f (HoleContent' qn nm p b)
$ctraverse :: forall qn nm p (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> HoleContent' qn nm p a -> f (HoleContent' qn nm p b)
Traversable)

type HoleContent = HoleContent' () Name Pattern Expr

---------------------------------------------------------------------------
-- * Smart constructors
---------------------------------------------------------------------------

rawApp :: List1 Expr -> Expr
rawApp :: List1 Expr -> Expr
rawApp es :: List1 Expr
es@(Expr
e1 :| Expr
e2 : [Expr]
rest) = Range -> List2 Expr -> Expr
RawApp (forall a. HasRange a => a -> Range
getRange List1 Expr
es) forall a b. (a -> b) -> a -> b
$ forall a. a -> a -> [a] -> List2 a
List2 Expr
e1 Expr
e2 [Expr]
rest
rawApp (Expr
e :| []) = Expr
e

rawAppP :: List1 Pattern -> Pattern
rawAppP :: List1 Pattern -> Pattern
rawAppP ps :: List1 Pattern
ps@(Pattern
p1 :| Pattern
p2 : [Pattern]
rest) = Range -> List2 Pattern -> Pattern
RawAppP (forall a. HasRange a => a -> Range
getRange List1 Pattern
ps) forall a b. (a -> b) -> a -> b
$ forall a. a -> a -> [a] -> List2 a
List2 Pattern
p1 Pattern
p2 [Pattern]
rest
rawAppP (Pattern
p :| []) = Pattern
p

{--------------------------------------------------------------------------
    Views
 --------------------------------------------------------------------------}

-- | The 'Expr' is not an application.
data AppView = AppView Expr [NamedArg Expr]

appView :: Expr -> AppView
appView :: Expr -> AppView
appView Expr
e = [NamedArg Expr] -> AppView
f (forall a. DList a -> [a]
DL.toList DList (NamedArg Expr)
ess)
  where
    ([NamedArg Expr] -> AppView
f, DList (NamedArg Expr)
ess) = Expr -> ([NamedArg Expr] -> AppView, DList (NamedArg Expr))
appView' Expr
e

    appView' :: Expr -> ([NamedArg Expr] -> AppView, DList (NamedArg Expr))
appView' = \case
      App Range
r Expr
e1 NamedArg Expr
e2      -> forall {a} {a}. (a, DList a) -> a -> (a, DList a)
vApp (Expr -> ([NamedArg Expr] -> AppView, DList (NamedArg Expr))
appView' Expr
e1) NamedArg Expr
e2
      RawApp Range
_ (List2 Expr
e1 Expr
e2 [Expr]
es)
                       -> (Expr -> [NamedArg Expr] -> AppView
AppView Expr
e1, forall a. [a] -> DList a
DL.fromList (forall a b. (a -> b) -> [a] -> [b]
map Expr -> NamedArg Expr
arg (Expr
e2 forall a. a -> [a] -> [a]
: [Expr]
es)))
      Expr
e                -> (Expr -> [NamedArg Expr] -> AppView
AppView Expr
e, forall a. Monoid a => a
mempty)

    vApp :: (a, DList a) -> a -> (a, DList a)
vApp (a
f, DList a
es) a
arg = (a
f, DList a
es forall a. DList a -> a -> DList a
`DL.snoc` a
arg)

    arg :: Expr -> NamedArg Expr
arg (HiddenArg   Range
_ Named_ Expr
e) = forall a. LensHiding a => a -> a
hide         forall a b. (a -> b) -> a -> b
$ forall a. a -> Arg a
defaultArg Named_ Expr
e
    arg (InstanceArg Range
_ Named_ Expr
e) = forall a. LensHiding a => a -> a
makeInstance forall a b. (a -> b) -> a -> b
$ forall a. a -> Arg a
defaultArg Named_ Expr
e
    arg Expr
e                 = forall a. a -> Arg a
defaultArg (forall a name. a -> Named name a
unnamed Expr
e)

unAppView :: AppView -> Expr
unAppView :: AppView -> Expr
unAppView (AppView Expr
e [NamedArg Expr]
nargs) = List1 Expr -> Expr
rawApp (Expr
e forall a. a -> [a] -> NonEmpty a
:| forall a b. (a -> b) -> [a] -> [b]
map NamedArg Expr -> Expr
unNamedArg [NamedArg Expr]
nargs)

  where
    unNamedArg :: NamedArg Expr -> Expr
unNamedArg NamedArg Expr
narg = (forall a b. (a -> b) -> a -> b
$ forall e. Arg e -> e
unArg NamedArg Expr
narg) forall a b. (a -> b) -> a -> b
$ case forall a. LensHiding a => a -> Hiding
getHiding NamedArg Expr
narg of
      Hiding
Hidden     -> Range -> Named_ Expr -> Expr
HiddenArg (forall a. HasRange a => a -> Range
getRange NamedArg Expr
narg)
      Hiding
NotHidden  -> forall name a. Named name a -> a
namedThing
      Instance{} -> Range -> Named_ Expr -> Expr
InstanceArg (forall a. HasRange a => a -> Range
getRange NamedArg Expr
narg)

isSingleIdentifierP :: Pattern -> Maybe Name
isSingleIdentifierP :: Pattern -> Maybe Name
isSingleIdentifierP = \case
  IdentP (QName Name
x) -> forall a. a -> Maybe a
Just Name
x
  WildP Range
r          -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Range -> Name
noName Range
r
  ParenP Range
_ Pattern
p       -> Pattern -> Maybe Name
isSingleIdentifierP Pattern
p
  Pattern
_                -> forall a. Maybe a
Nothing

removeParenP :: Pattern -> Pattern
removeParenP :: Pattern -> Pattern
removeParenP = \case
    ParenP Range
_ Pattern
p -> Pattern -> Pattern
removeParenP Pattern
p
    Pattern
p -> Pattern
p

-- | Observe the hiding status of an expression
observeHiding :: Expr -> WithHiding Expr
observeHiding :: Expr -> WithHiding Expr
observeHiding = \case
  HiddenArg Range
_   (Named Maybe (WithOrigin (Ranged String))
Nothing Expr
e) -> forall a. Hiding -> a -> WithHiding a
WithHiding Hiding
Hidden Expr
e
  InstanceArg Range
_ (Named Maybe (WithOrigin (Ranged String))
Nothing Expr
e) -> forall a. Hiding -> a -> WithHiding a
WithHiding (Overlappable -> Hiding
Instance Overlappable
NoOverlap) Expr
e
  Expr
e                               -> forall a. Hiding -> a -> WithHiding a
WithHiding Hiding
NotHidden Expr
e

-- | Observe the relevance status of an expression
observeRelevance :: Expr -> (Relevance, Expr)
observeRelevance :: Expr -> (Relevance, Expr)
observeRelevance = \case
  Dot Range
_ Expr
e       -> (Relevance
Irrelevant, Expr
e)
  DoubleDot Range
_ Expr
e -> (Relevance
NonStrict, Expr
e)
  Expr
e             -> (Relevance
Relevant, Expr
e)

-- | Observe various modifiers applied to an expression
observeModifiers :: Expr -> Arg Expr
observeModifiers :: Expr -> Arg Expr
observeModifiers Expr
e =
  let (Relevance
rel, WithHiding Hiding
hid Expr
e') = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Expr -> WithHiding Expr
observeHiding (Expr -> (Relevance, Expr)
observeRelevance Expr
e) in
  forall a. LensRelevance a => Relevance -> a -> a
setRelevance Relevance
rel forall a b. (a -> b) -> a -> b
$ forall a. LensHiding a => Hiding -> a -> a
setHiding Hiding
hid forall a b. (a -> b) -> a -> b
$ forall a. a -> Arg a
defaultArg Expr
e'

returnExpr :: Expr -> Maybe Expr
returnExpr :: Expr -> Maybe Expr
returnExpr (Pi Telescope1
_ Expr
e)        = Expr -> Maybe Expr
returnExpr Expr
e
returnExpr (Fun Range
_ Arg Expr
_  Expr
e)    = Expr -> Maybe Expr
returnExpr Expr
e
returnExpr (Let Range
_ List1 Declaration
_ Maybe Expr
e)     = Expr -> Maybe Expr
returnExpr forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe Expr
e
returnExpr (Paren Range
_ Expr
e)     = Expr -> Maybe Expr
returnExpr Expr
e
returnExpr (Generalized Expr
e) = Expr -> Maybe Expr
returnExpr Expr
e
returnExpr Expr
e               = forall (f :: * -> *) a. Applicative f => a -> f a
pure Expr
e

-- | Turn an expression into a pattern. Fails if the expression is not a
--   valid pattern.

isPattern :: Expr -> Maybe Pattern
isPattern :: Expr -> Maybe Pattern
isPattern = forall (m :: * -> *).
Applicative m =>
(Expr -> m Pattern) -> Expr -> m Pattern
exprToPattern (forall a b. a -> b -> a
const forall a. Maybe a
Nothing)

-- | Turn an expression into a pattern, turning non-pattern subexpressions into 'WildP'.

exprToPatternWithHoles :: Expr -> Pattern
exprToPatternWithHoles :: Expr -> Pattern
exprToPatternWithHoles = forall a. Identity a -> a
runIdentity forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *).
Applicative m =>
(Expr -> m Pattern) -> Expr -> m Pattern
exprToPattern (forall a. a -> Identity a
Identity forall b c a. (b -> c) -> (a -> b) -> a -> c
. Range -> Pattern
WildP forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. HasRange a => a -> Range
getRange)

-- | Generic expression to pattern conversion.

exprToPattern :: Applicative m
  => (Expr -> m Pattern)  -- ^ Default result for non-pattern things.
  -> Expr                 -- ^ The expression to translate.
  -> m Pattern            -- ^ The translated pattern (maybe).
exprToPattern :: forall (m :: * -> *).
Applicative m =>
(Expr -> m Pattern) -> Expr -> m Pattern
exprToPattern Expr -> m Pattern
fallback = Expr -> m Pattern
loop
  where
  loop :: Expr -> m Pattern
loop = \case
    Ident       QName
x        -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ QName -> Pattern
IdentP QName
x
    App         Range
_ Expr
e1 NamedArg Expr
e2  -> Pattern -> NamedArg Pattern -> Pattern
AppP forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> m Pattern
loop Expr
e1 forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Expr -> m Pattern
loop) NamedArg Expr
e2
    Paren       Range
r Expr
e      -> Range -> Pattern -> Pattern
ParenP Range
r forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> m Pattern
loop Expr
e
    Underscore  Range
r Maybe String
_      -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> Pattern
WildP Range
r
    Absurd      Range
r        -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> Pattern
AbsurdP Range
r
    As          Range
r Name
x Expr
e    -> Range -> (Pattern -> Pattern) -> Pattern -> Pattern
pushUnderBracesP Range
r (Range -> Name -> Pattern -> Pattern
AsP Range
r Name
x) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> m Pattern
loop Expr
e
    Dot         Range
r Expr
e      -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> (Expr -> Pattern) -> Expr -> Pattern
pushUnderBracesE Range
r (Range -> Expr -> Pattern
DotP Range
r) Expr
e
    -- Wen, 2020-08-27: We disallow Float patterns, since equality for floating
    -- point numbers is not stable across architectures and with different
    -- compiler flags.
    e :: Expr
e@(Lit Range
_ LitFloat{}) -> Expr -> m Pattern
fallback Expr
e
    Lit         Range
r Literal
l      -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> Literal -> Pattern
LitP Range
r Literal
l
    HiddenArg   Range
r Named_ Expr
e      -> Range -> Named_ Pattern -> Pattern
HiddenP   Range
r forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Expr -> m Pattern
loop Named_ Expr
e
    InstanceArg Range
r Named_ Expr
e      -> Range -> Named_ Pattern -> Pattern
InstanceP Range
r forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Expr -> m Pattern
loop Named_ Expr
e
    RawApp      Range
r List2 Expr
es     -> Range -> List2 Pattern -> Pattern
RawAppP   Range
r forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Expr -> m Pattern
loop List2 Expr
es
    Quote       Range
r        -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> Pattern
QuoteP Range
r
    Equal       Range
r Expr
e1 Expr
e2  -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> [(Expr, Expr)] -> Pattern
EqualP Range
r [(Expr
e1, Expr
e2)]
    Ellipsis    Range
r        -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Range -> Maybe Pattern -> Pattern
EllipsisP Range
r forall a. Maybe a
Nothing
    e :: Expr
e@(Rec Range
r RecordAssignments
es)
        -- We cannot translate record expressions with module parts.
      | Just [FieldAssignment]
fs <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM forall a b. Either a b -> Maybe a
maybeLeft RecordAssignments
es -> Range -> [FieldAssignment' Pattern] -> Pattern
RecP Range
r forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse Expr -> m Pattern
loop) [FieldAssignment]
fs
      | Bool
otherwise -> Expr -> m Pattern
fallback Expr
e
    -- WithApp has already lost the range information of the bars '|'
    WithApp     Range
r Expr
e [Expr]
es   -> do -- ApplicativeDo
      Pattern
p  <- Expr -> m Pattern
loop Expr
e
      [NamedArg Pattern]
ps <- forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
t a -> (a -> f b) -> f (t b)
forA [Expr]
es forall a b. (a -> b) -> a -> b
$ \ Expr
e -> do -- ApplicativeDo
        Pattern
p <- Expr -> m Pattern
loop Expr
e
        pure $ forall a. a -> NamedArg a
defaultNamedArg forall a b. (a -> b) -> a -> b
$ Range -> Pattern -> Pattern
WithP (forall a. HasRange a => a -> Range
getRange Expr
e) Pattern
p   -- TODO #2822: Range!
      pure $ forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl Pattern -> NamedArg Pattern -> Pattern
AppP Pattern
p [NamedArg Pattern]
ps
    Expr
e -> Expr -> m Pattern
fallback Expr
e

  pushUnderBracesP :: Range -> (Pattern -> Pattern) -> (Pattern -> Pattern)
  pushUnderBracesP :: Range -> (Pattern -> Pattern) -> Pattern -> Pattern
pushUnderBracesP Range
r Pattern -> Pattern
f = \case
    HiddenP   Range
_ Named_ Pattern
p   -> Range -> Named_ Pattern -> Pattern
HiddenP   Range
r forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pattern -> Pattern
f Named_ Pattern
p
    InstanceP Range
_ Named_ Pattern
p   -> Range -> Named_ Pattern -> Pattern
InstanceP Range
r forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Pattern -> Pattern
f Named_ Pattern
p
    Pattern
p               -> Pattern -> Pattern
f Pattern
p

  pushUnderBracesE :: Range -> (Expr -> Pattern) -> (Expr -> Pattern)
  pushUnderBracesE :: Range -> (Expr -> Pattern) -> Expr -> Pattern
pushUnderBracesE Range
r Expr -> Pattern
f = \case
    HiddenArg   Range
_ Named_ Expr
p -> Range -> Named_ Pattern -> Pattern
HiddenP   Range
r forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Expr -> Pattern
f Named_ Expr
p
    InstanceArg Range
_ Named_ Expr
p -> Range -> Named_ Pattern -> Pattern
InstanceP Range
r forall a b. (a -> b) -> a -> b
$ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Expr -> Pattern
f Named_ Expr
p
    Expr
p               -> Expr -> Pattern
f Expr
p

isAbsurdP :: Pattern -> Maybe (Range, Hiding)
isAbsurdP :: Pattern -> Maybe (Range, Hiding)
isAbsurdP = \case
  AbsurdP Range
r      -> forall (f :: * -> *) a. Applicative f => a -> f a
pure (Range
r, Hiding
NotHidden)
  AsP Range
_ Name
_      Pattern
p -> Pattern -> Maybe (Range, Hiding)
isAbsurdP Pattern
p
  ParenP Range
_     Pattern
p -> Pattern -> Maybe (Range, Hiding)
isAbsurdP Pattern
p
  HiddenP   Range
_ Named_ Pattern
np -> (Hiding
Hidden forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$)              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Pattern -> Maybe (Range, Hiding)
isAbsurdP (forall name a. Named name a -> a
namedThing Named_ Pattern
np)
  InstanceP Range
_ Named_ Pattern
np -> (Overlappable -> Hiding
Instance Overlappable
YesOverlap forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Pattern -> Maybe (Range, Hiding)
isAbsurdP (forall name a. Named name a -> a
namedThing Named_ Pattern
np)
  Pattern
_ -> forall a. Maybe a
Nothing

isBinderP :: Pattern -> Maybe Binder
isBinderP :: Pattern -> Maybe Binder
isBinderP = \case
  IdentP QName
qn  -> Name -> Binder
mkBinder_ forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> QName -> Maybe Name
isUnqualified QName
qn
  WildP Range
r    -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ Name -> Binder
mkBinder_ forall a b. (a -> b) -> a -> b
$ forall a. SetRange a => Range -> a -> a
setRange Range
r Name
simpleHole
  AsP Range
r Name
n Pattern
p  -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. Maybe Pattern -> a -> Binder' a
Binder (forall a. a -> Maybe a
Just Pattern
p) forall a b. (a -> b) -> a -> b
$ Name -> BoundName
mkBoundName_ Name
n
  ParenP Range
r Pattern
p -> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. Maybe Pattern -> a -> Binder' a
Binder (forall a. a -> Maybe a
Just Pattern
p) forall a b. (a -> b) -> a -> b
$ Name -> BoundName
mkBoundName_ forall a b. (a -> b) -> a -> b
$ forall a. SetRange a => Range -> a -> a
setRange Range
r Name
simpleHole
  Pattern
_ -> forall a. Maybe a
Nothing

{--------------------------------------------------------------------------
    Instances
 --------------------------------------------------------------------------}

-- Null
------------------------------------------------------------------------

-- | A 'WhereClause' is 'null' when the @where@ keyword is absent.
--   An empty list of declarations does not count as 'null' here.

instance Null (WhereClause' a) where
  empty :: WhereClause' a
empty = forall a. WhereClause' a
NoWhere
  null :: WhereClause' a -> Bool
null WhereClause' a
NoWhere = Bool
True
  null AnyWhere{} = Bool
False
  null SomeWhere{} = Bool
False

-- Lenses
------------------------------------------------------------------------

instance LensHiding LamBinding where
  getHiding :: LamBinding -> Hiding
getHiding   (DomainFree NamedArg Binder
x) = forall a. LensHiding a => a -> Hiding
getHiding NamedArg Binder
x
  getHiding   (DomainFull TypedBinding
a) = forall a. LensHiding a => a -> Hiding
getHiding TypedBinding
a
  mapHiding :: (Hiding -> Hiding) -> LamBinding -> LamBinding
mapHiding Hiding -> Hiding
f (DomainFree NamedArg Binder
x) = forall a. NamedArg Binder -> LamBinding' a
DomainFree forall a b. (a -> b) -> a -> b
$ forall a. LensHiding a => (Hiding -> Hiding) -> a -> a
mapHiding Hiding -> Hiding
f NamedArg Binder
x
  mapHiding Hiding -> Hiding
f (DomainFull TypedBinding
a) = forall a. a -> LamBinding' a
DomainFull forall a b. (a -> b) -> a -> b
$ forall a. LensHiding a => (Hiding -> Hiding) -> a -> a
mapHiding Hiding -> Hiding
f TypedBinding
a

instance LensHiding TypedBinding where
  getHiding :: TypedBinding -> Hiding
getHiding (TBind Range
_ (NamedArg Binder
x :| [NamedArg Binder]
_) Expr
_) = forall a. LensHiding a => a -> Hiding
getHiding NamedArg Binder
x   -- Slightly dubious
  getHiding TLet{}              = forall a. Monoid a => a
mempty
  mapHiding :: (Hiding -> Hiding) -> TypedBinding -> TypedBinding
mapHiding Hiding -> Hiding
f (TBind Range
r List1 (NamedArg Binder)
xs Expr
e) = forall e. Range -> List1 (NamedArg Binder) -> e -> TypedBinding' e
TBind Range
r (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. LensHiding a => (Hiding -> Hiding) -> a -> a
mapHiding Hiding -> Hiding
f) List1 (NamedArg Binder)
xs) Expr
e
  mapHiding Hiding -> Hiding
f b :: TypedBinding
b@TLet{}       = TypedBinding
b

instance LensRelevance TypedBinding where
  getRelevance :: TypedBinding -> Relevance
getRelevance (TBind Range
_ (NamedArg Binder
x :|[NamedArg Binder]
_) Expr
_) = forall a. LensRelevance a => a -> Relevance
getRelevance NamedArg Binder
x   -- Slightly dubious
  getRelevance TLet{}              = Relevance
unitRelevance
  mapRelevance :: (Relevance -> Relevance) -> TypedBinding -> TypedBinding
mapRelevance Relevance -> Relevance
f (TBind Range
r List1 (NamedArg Binder)
xs Expr
e) = forall e. Range -> List1 (NamedArg Binder) -> e -> TypedBinding' e
TBind Range
r (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. LensRelevance a => (Relevance -> Relevance) -> a -> a
mapRelevance Relevance -> Relevance
f) List1 (NamedArg Binder)
xs) Expr
e
  mapRelevance Relevance -> Relevance
f b :: TypedBinding
b@TLet{}       = TypedBinding
b

-- HasRange instances
------------------------------------------------------------------------

instance HasRange e => HasRange (OpApp e) where
  getRange :: OpApp e -> Range
getRange = \case
    Ordinary e
e -> forall a. HasRange a => a -> Range
getRange e
e
    SyntaxBindingLambda Range
r List1 LamBinding
_ e
_ -> Range
r

instance HasRange Expr where
  getRange :: Expr -> Range
getRange = \case
      Ident QName
x            -> forall a. HasRange a => a -> Range
getRange QName
x
      Lit Range
r Literal
_            -> Range
r
      QuestionMark Range
r Maybe Int
_   -> Range
r
      Underscore Range
r Maybe String
_     -> Range
r
      App Range
r Expr
_ NamedArg Expr
_          -> Range
r
      RawApp Range
r List2 Expr
_         -> Range
r
      OpApp Range
r QName
_ Set Name
_ OpAppArgs
_      -> Range
r
      WithApp Range
r Expr
_ [Expr]
_      -> Range
r
      Lam Range
r List1 LamBinding
_ Expr
_          -> Range
r
      AbsurdLam Range
r Hiding
_      -> Range
r
      ExtendedLam Range
r Erased
_ List1 LamClause
_  -> Range
r
      Fun Range
r Arg Expr
_ Expr
_          -> Range
r
      Pi Telescope1
b Expr
e             -> forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Telescope1
b Expr
e
      Let Range
r List1 Declaration
_ Maybe Expr
_          -> Range
r
      Paren Range
r Expr
_          -> Range
r
      IdiomBrackets Range
r [Expr]
_  -> Range
r
      DoBlock Range
r List1 DoStmt
_        -> Range
r
      As Range
r Name
_ Expr
_           -> Range
r
      Dot Range
r Expr
_            -> Range
r
      DoubleDot Range
r Expr
_      -> Range
r
      Absurd Range
r           -> Range
r
      HiddenArg Range
r Named_ Expr
_      -> Range
r
      InstanceArg Range
r Named_ Expr
_    -> Range
r
      Rec Range
r RecordAssignments
_            -> Range
r
      RecUpdate Range
r Expr
_ [FieldAssignment]
_    -> Range
r
      Quote Range
r            -> Range
r
      QuoteTerm Range
r        -> Range
r
      Unquote Range
r          -> Range
r
      Tactic Range
r Expr
_         -> Range
r
      DontCare{}         -> forall a. Range' a
noRange
      Equal Range
r Expr
_ Expr
_        -> Range
r
      Ellipsis Range
r         -> Range
r
      Generalized Expr
e      -> forall a. HasRange a => a -> Range
getRange Expr
e

-- instance HasRange Telescope where
--     getRange (TeleBind bs) = getRange bs
--     getRange (TeleFun x y) = fuseRange x y

instance HasRange Binder where
  getRange :: Binder -> Range
getRange (Binder Maybe Pattern
a BoundName
b) = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Maybe Pattern
a BoundName
b

instance HasRange TypedBinding where
  getRange :: TypedBinding -> Range
getRange (TBind Range
r List1 (NamedArg Binder)
_ Expr
_) = Range
r
  getRange (TLet Range
r List1 Declaration
_)    = Range
r

instance HasRange LamBinding where
  getRange :: LamBinding -> Range
getRange (DomainFree NamedArg Binder
x) = forall a. HasRange a => a -> Range
getRange NamedArg Binder
x
  getRange (DomainFull TypedBinding
b) = forall a. HasRange a => a -> Range
getRange TypedBinding
b

instance HasRange BoundName where
  getRange :: BoundName -> Range
getRange = forall a. HasRange a => a -> Range
getRange forall b c a. (b -> c) -> (a -> b) -> a -> c
. BoundName -> Name
boundName

instance HasRange WhereClause where
  getRange :: WhereClause -> Range
getRange  WhereClause
NoWhere             = forall a. Range' a
noRange
  getRange (AnyWhere Range
r [Declaration]
ds)      = forall a. HasRange a => a -> Range
getRange (Range
r, [Declaration]
ds)
  getRange (SomeWhere Range
r Name
x Access
_ [Declaration]
ds) = forall a. HasRange a => a -> Range
getRange (Range
r, Name
x, [Declaration]
ds)

instance HasRange ModuleApplication where
  getRange :: ModuleApplication -> Range
getRange (SectionApp Range
r Telescope
_ Expr
_) = Range
r
  getRange (RecordModuleInstance Range
r QName
_) = Range
r

instance HasRange a => HasRange (FieldAssignment' a) where
  getRange :: FieldAssignment' a -> Range
getRange (FieldAssignment Name
a a
b) = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Name
a a
b

instance HasRange ModuleAssignment where
  getRange :: ModuleAssignment -> Range
getRange (ModuleAssignment QName
a [Expr]
b ImportDirective
c) = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange QName
a [Expr]
b forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` ImportDirective
c

instance HasRange RecordDirective where
  getRange :: RecordDirective -> Range
getRange (Induction Ranged Induction
a)          = forall a. HasRange a => a -> Range
getRange Ranged Induction
a
  getRange (Eta Ranged HasEta0
a    )            = forall a. HasRange a => a -> Range
getRange Ranged HasEta0
a
  getRange (Constructor Name
a IsInstance
b)      = forall a. HasRange a => a -> Range
getRange (Name
a, IsInstance
b)
  getRange (PatternOrCopattern Range
r) = Range
r

instance HasRange Declaration where
  getRange :: Declaration -> Range
getRange (TypeSig ArgInfo
_ Maybe Expr
_ Name
x Expr
t)       = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Name
x Expr
t
  getRange (FieldSig IsInstance
_ Maybe Expr
_ Name
x Arg Expr
t)      = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Name
x Arg Expr
t
  getRange (Field Range
r [Declaration]
_)             = Range
r
  getRange (FunClause LHS
lhs RHS
rhs WhereClause
wh Bool
_) = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange LHS
lhs RHS
rhs forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` WhereClause
wh
  getRange (DataSig Range
r Name
_ [LamBinding]
_ Expr
_)       = Range
r
  getRange (Data Range
r Name
_ [LamBinding]
_ Expr
_ [Declaration]
_)        = Range
r
  getRange (DataDef Range
r Name
_ [LamBinding]
_ [Declaration]
_)       = Range
r
  getRange (RecordSig Range
r Name
_ [LamBinding]
_ Expr
_)     = Range
r
  getRange (RecordDef Range
r Name
_ RecordDirectives
_ [LamBinding]
_ [Declaration]
_)   = Range
r
  getRange (Record Range
r Name
_ RecordDirectives
_ [LamBinding]
_ Expr
_ [Declaration]
_)    = Range
r
  getRange (RecordDirective RecordDirective
r)     = forall a. HasRange a => a -> Range
getRange RecordDirective
r
  getRange (Mutual Range
r [Declaration]
_)            = Range
r
  getRange (InterleavedMutual Range
r [Declaration]
_) = Range
r
  getRange (LoneConstructor Range
r [Declaration]
_)   = Range
r
  getRange (Abstract Range
r [Declaration]
_)          = Range
r
  getRange (Generalize Range
r [Declaration]
_)        = Range
r
  getRange (Open Range
r QName
_ ImportDirective
_)            = Range
r
  getRange (ModuleMacro Range
r Name
_ ModuleApplication
_ OpenShortHand
_ ImportDirective
_) = Range
r
  getRange (Import Range
r QName
_ Maybe AsName
_ OpenShortHand
_ ImportDirective
_)      = Range
r
  getRange (InstanceB Range
r [Declaration]
_)         = Range
r
  getRange (Macro Range
r [Declaration]
_)             = Range
r
  getRange (Private Range
r Origin
_ [Declaration]
_)         = Range
r
  getRange (Postulate Range
r [Declaration]
_)         = Range
r
  getRange (Primitive Range
r [Declaration]
_)         = Range
r
  getRange (Module Range
r QName
_ Telescope
_ [Declaration]
_)        = Range
r
  getRange (Infix Fixity
f List1 Name
_)             = forall a. HasRange a => a -> Range
getRange Fixity
f
  getRange (Syntax Name
n Notation
_)            = forall a. HasRange a => a -> Range
getRange Name
n
  getRange (PatternSyn Range
r Name
_ [Arg Name]
_ Pattern
_)    = Range
r
  getRange (UnquoteDecl Range
r [Name]
_ Expr
_)     = Range
r
  getRange (UnquoteDef Range
r [Name]
_ Expr
_)      = Range
r
  getRange (UnquoteData Range
r Name
_ [Name]
_ Expr
_)   = Range
r
  getRange (Pragma Pragma
p)              = forall a. HasRange a => a -> Range
getRange Pragma
p

instance HasRange LHS where
  getRange :: LHS -> Range
getRange (LHS Pattern
p [RewriteEqn]
eqns [WithExpr]
ws) = Pattern
p forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` [RewriteEqn]
eqns forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` [WithExpr]
ws

instance HasRange LHSCore where
  getRange :: LHSCore -> Range
getRange (LHSHead QName
f [NamedArg Pattern]
ps)              = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange QName
f [NamedArg Pattern]
ps
  getRange (LHSProj QName
d [NamedArg Pattern]
ps1 NamedArg LHSCore
lhscore [NamedArg Pattern]
ps2) = QName
d forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` [NamedArg Pattern]
ps1 forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` NamedArg LHSCore
lhscore forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` [NamedArg Pattern]
ps2
  getRange (LHSWith LHSCore
f [Pattern]
wps [NamedArg Pattern]
ps)          = LHSCore
f forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` [Pattern]
wps forall u t. (HasRange u, HasRange t) => u -> t -> Range
`fuseRange` [NamedArg Pattern]
ps
  getRange (LHSEllipsis Range
r LHSCore
p)           = Range
r

instance HasRange RHS where
  getRange :: RHS -> Range
getRange RHS
AbsurdRHS = forall a. Range' a
noRange
  getRange (RHS Expr
e)   = forall a. HasRange a => a -> Range
getRange Expr
e

instance HasRange LamClause where
  getRange :: LamClause -> Range
getRange (LamClause [Pattern]
lhs RHS
rhs Bool
_) = forall a. HasRange a => a -> Range
getRange ([Pattern]
lhs, RHS
rhs)

instance HasRange DoStmt where
  getRange :: DoStmt -> Range
getRange (DoBind Range
r Pattern
_ Expr
_ [LamClause]
_) = Range
r
  getRange (DoThen Expr
e)       = forall a. HasRange a => a -> Range
getRange Expr
e
  getRange (DoLet Range
r List1 Declaration
_)      = Range
r

instance HasRange Pragma where
  getRange :: Pragma -> Range
getRange (OptionsPragma Range
r [String]
_)               = Range
r
  getRange (BuiltinPragma Range
r Ranged String
_ QName
_)             = Range
r
  getRange (RewritePragma Range
r Range
_ [QName]
_)             = Range
r
  getRange (CompilePragma Range
r Ranged String
_ QName
_ String
_)           = Range
r
  getRange (ForeignPragma Range
r Ranged String
_ String
_)             = Range
r
  getRange (StaticPragma Range
r QName
_)                = Range
r
  getRange (InjectivePragma Range
r QName
_)             = Range
r
  getRange (InlinePragma Range
r Bool
_ QName
_)              = Range
r
  getRange (ImpossiblePragma Range
r [String]
_)            = Range
r
  getRange (EtaPragma Range
r QName
_)                   = Range
r
  getRange (TerminationCheckPragma Range
r TerminationCheck Name
_)      = Range
r
  getRange (NoCoverageCheckPragma Range
r)         = Range
r
  getRange (WarningOnUsage Range
r QName
_ Text
_)            = Range
r
  getRange (WarningOnImport Range
r Text
_)             = Range
r
  getRange (CatchallPragma Range
r)                = Range
r
  getRange (DisplayPragma Range
r Pattern
_ Expr
_)             = Range
r
  getRange (NoPositivityCheckPragma Range
r)       = Range
r
  getRange (PolarityPragma Range
r Name
_ [Occurrence]
_)            = Range
r
  getRange (NoUniverseCheckPragma Range
r)         = Range
r
  getRange (NotProjectionLikePragma Range
r QName
_)     = Range
r

instance HasRange AsName where
  getRange :: AsName -> Range
getRange AsName
a = forall a. HasRange a => a -> Range
getRange (forall a. AsName' a -> Range
asRange AsName
a, forall a. AsName' a -> a
asName AsName
a)

instance HasRange Pattern where
  getRange :: Pattern -> Range
getRange (IdentP QName
x)         = forall a. HasRange a => a -> Range
getRange QName
x
  getRange (AppP Pattern
p NamedArg Pattern
q)         = forall u t. (HasRange u, HasRange t) => u -> t -> Range
fuseRange Pattern
p NamedArg Pattern
q
  getRange (OpAppP Range
r QName
_ Set Name
_ [NamedArg Pattern]
_)   = Range
r
  getRange (RawAppP Range
r List2 Pattern
_)      = Range
r
  getRange (ParenP Range
r Pattern
_)       = Range
r
  getRange (WildP Range
r)          = Range
r
  getRange (AsP Range
r Name
_ Pattern
_)        = Range
r
  getRange (AbsurdP Range
r)        = Range
r
  getRange (LitP Range
r Literal
_)         = Range
r
  getRange (QuoteP Range
r)         = Range
r
  getRange (HiddenP Range
r Named_ Pattern
_)      = Range
r
  getRange (InstanceP Range
r Named_ Pattern
_)    = Range
r
  getRange (DotP Range
r Expr
_)         = Range
r
  getRange (RecP Range
r [FieldAssignment' Pattern]
_)         = Range
r
  getRange (EqualP Range
r [(Expr, Expr)]
_)       = Range
r
  getRange (EllipsisP Range
r Maybe Pattern
_)    = Range
r
  getRange (WithP Range
r Pattern
_)        = Range
r

-- SetRange instances
------------------------------------------------------------------------

instance SetRange Pattern where
  setRange :: Range -> Pattern -> Pattern
setRange Range
r (IdentP QName
x)         = QName -> Pattern
IdentP (forall a. SetRange a => Range -> a -> a
setRange Range
r QName
x)
  setRange Range
r (AppP Pattern
p NamedArg Pattern
q)         = Pattern -> NamedArg Pattern -> Pattern
AppP (forall a. SetRange a => Range -> a -> a
setRange Range
r Pattern
p) (forall a. SetRange a => Range -> a -> a
setRange Range
r NamedArg Pattern
q)
  setRange Range
r (OpAppP Range
_ QName
x Set Name
ns [NamedArg Pattern]
ps) = Range -> QName -> Set Name -> [NamedArg Pattern] -> Pattern
OpAppP Range
r QName
x Set Name
ns [NamedArg Pattern]
ps
  setRange Range
r (RawAppP Range
_ List2 Pattern
ps)     = Range -> List2 Pattern -> Pattern
RawAppP Range
r List2 Pattern
ps
  setRange Range
r (ParenP Range
_ Pattern
p)       = Range -> Pattern -> Pattern
ParenP Range
r Pattern
p
  setRange Range
r (WildP Range
_)          = Range -> Pattern
WildP Range
r
  setRange Range
r (AsP Range
_ Name
x Pattern
p)        = Range -> Name -> Pattern -> Pattern
AsP Range
r (forall a. SetRange a => Range -> a -> a
setRange Range
r Name
x) Pattern
p
  setRange Range
r (AbsurdP Range
_)        = Range -> Pattern
AbsurdP Range
r
  setRange Range
r (LitP Range
_ Literal
l)         = Range -> Literal -> Pattern
LitP Range
r Literal
l
  setRange Range
r (QuoteP Range
_)         = Range -> Pattern
QuoteP Range
r
  setRange Range
r (HiddenP Range
_ Named_ Pattern
p)      = Range -> Named_ Pattern -> Pattern
HiddenP Range
r Named_ Pattern
p
  setRange Range
r (InstanceP Range
_ Named_ Pattern
p)    = Range -> Named_ Pattern -> Pattern
InstanceP Range
r Named_ Pattern
p
  setRange Range
r (DotP Range
_ Expr
e)         = Range -> Expr -> Pattern
DotP Range
r Expr
e
  setRange Range
r (RecP Range
_ [FieldAssignment' Pattern]
fs)        = Range -> [FieldAssignment' Pattern] -> Pattern
RecP Range
r [FieldAssignment' Pattern]
fs
  setRange Range
r (EqualP Range
_ [(Expr, Expr)]
es)      = Range -> [(Expr, Expr)] -> Pattern
EqualP Range
r [(Expr, Expr)]
es
  setRange Range
r (EllipsisP Range
_ Maybe Pattern
mp)   = Range -> Maybe Pattern -> Pattern
EllipsisP Range
r Maybe Pattern
mp
  setRange Range
r (WithP Range
_ Pattern
p)        = Range -> Pattern -> Pattern
WithP Range
r Pattern
p

instance SetRange TypedBinding where
  setRange :: Range -> TypedBinding -> TypedBinding
setRange Range
r (TBind Range
_ List1 (NamedArg Binder)
xs Expr
e) = forall e. Range -> List1 (NamedArg Binder) -> e -> TypedBinding' e
TBind Range
r List1 (NamedArg Binder)
xs Expr
e
  setRange Range
r (TLet Range
_ List1 Declaration
ds)    = forall e. Range -> List1 Declaration -> TypedBinding' e
TLet Range
r List1 Declaration
ds

-- KillRange instances
------------------------------------------------------------------------

instance KillRange a => KillRange (FieldAssignment' a) where
  killRange :: KillRangeT (FieldAssignment' a)
killRange (FieldAssignment Name
a a
b) = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 forall a. Name -> a -> FieldAssignment' a
FieldAssignment Name
a a
b

instance KillRange ModuleAssignment where
  killRange :: KillRangeT ModuleAssignment
killRange (ModuleAssignment QName
a [Expr]
b ImportDirective
c) = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 QName -> [Expr] -> ImportDirective -> ModuleAssignment
ModuleAssignment QName
a [Expr]
b ImportDirective
c

instance KillRange AsName where
  killRange :: KillRangeT AsName
killRange (AsName Either Expr Name
n Range
_) = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a. a -> Range -> AsName' a
AsName forall a. Range' a
noRange) Either Expr Name
n

instance KillRange Binder where
  killRange :: KillRangeT Binder
killRange (Binder Maybe Pattern
a BoundName
b) = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 forall a. Maybe Pattern -> a -> Binder' a
Binder Maybe Pattern
a BoundName
b

instance KillRange BoundName where
  killRange :: KillRangeT BoundName
killRange (BName Name
n Fixity'
f Maybe Expr
t Bool
b) = forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 Name -> Fixity' -> Maybe Expr -> Bool -> BoundName
BName Name
n Fixity'
f Maybe Expr
t Bool
b

instance KillRange RecordDirective where
  killRange :: KillRangeT RecordDirective
killRange (Induction Ranged Induction
a)          = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Ranged Induction -> RecordDirective
Induction Ranged Induction
a
  killRange (Eta Ranged HasEta0
a    )            = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Ranged HasEta0 -> RecordDirective
Eta Ranged HasEta0
a
  killRange (Constructor Name
a IsInstance
b)      = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Name -> IsInstance -> RecordDirective
Constructor Name
a IsInstance
b
  killRange (PatternOrCopattern Range
_) = Range -> RecordDirective
PatternOrCopattern forall a. Range' a
noRange

instance KillRange Declaration where
  killRange :: KillRangeT Declaration
killRange (TypeSig ArgInfo
i Maybe Expr
t Name
n Expr
e)       = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (ArgInfo -> Maybe Expr -> Name -> Expr -> Declaration
TypeSig ArgInfo
i) Maybe Expr
t Name
n Expr
e
  killRange (FieldSig IsInstance
i Maybe Expr
t Name
n Arg Expr
e)      = forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 IsInstance -> Maybe Expr -> Name -> Arg Expr -> Declaration
FieldSig IsInstance
i Maybe Expr
t Name
n Arg Expr
e
  killRange (Generalize Range
r [Declaration]
ds )      = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Generalize forall a. Range' a
noRange) [Declaration]
ds
  killRange (Field Range
r [Declaration]
fs)            = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Field forall a. Range' a
noRange) [Declaration]
fs
  killRange (FunClause LHS
l RHS
r WhereClause
w Bool
ca)    = forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 LHS -> RHS -> WhereClause -> Bool -> Declaration
FunClause LHS
l RHS
r WhereClause
w Bool
ca
  killRange (DataSig Range
_ Name
n [LamBinding]
l Expr
e)       = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> Name -> [LamBinding] -> Expr -> Declaration
DataSig forall a. Range' a
noRange) Name
n [LamBinding]
l Expr
e
  killRange (Data Range
_ Name
n [LamBinding]
l Expr
e [Declaration]
c)        = forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 (Range
-> Name -> [LamBinding] -> Expr -> [Declaration] -> Declaration
Data forall a. Range' a
noRange) Name
n [LamBinding]
l Expr
e [Declaration]
c
  killRange (DataDef Range
_ Name
n [LamBinding]
l [Declaration]
c)       = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> Name -> [LamBinding] -> [Declaration] -> Declaration
DataDef forall a. Range' a
noRange) Name
n [LamBinding]
l [Declaration]
c
  killRange (RecordSig Range
_ Name
n [LamBinding]
l Expr
e)     = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> Name -> [LamBinding] -> Expr -> Declaration
RecordSig forall a. Range' a
noRange) Name
n [LamBinding]
l Expr
e
  killRange (RecordDef Range
_ Name
n RecordDirectives
dir [LamBinding]
k [Declaration]
d) = forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 (Range
-> Name
-> RecordDirectives
-> [LamBinding]
-> [Declaration]
-> Declaration
RecordDef forall a. Range' a
noRange) Name
n RecordDirectives
dir [LamBinding]
k [Declaration]
d
  killRange (RecordDirective RecordDirective
a)     = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 RecordDirective -> Declaration
RecordDirective RecordDirective
a
  killRange (Record Range
_ Name
n RecordDirectives
dir [LamBinding]
k Expr
e [Declaration]
d)  = forall a b c d e f.
(KillRange a, KillRange b, KillRange c, KillRange d,
 KillRange e) =>
(a -> b -> c -> d -> e -> f) -> a -> b -> c -> d -> e -> f
killRange5 (Range
-> Name
-> RecordDirectives
-> [LamBinding]
-> Expr
-> [Declaration]
-> Declaration
Record forall a. Range' a
noRange) Name
n RecordDirectives
dir [LamBinding]
k Expr
e [Declaration]
d
  killRange (Infix Fixity
f List1 Name
n)             = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Fixity -> List1 Name -> Declaration
Infix Fixity
f List1 Name
n
  killRange (Syntax Name
n Notation
no)           = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (\Name
n -> Name -> Notation -> Declaration
Syntax Name
n Notation
no) Name
n
  killRange (PatternSyn Range
_ Name
n [Arg Name]
ns Pattern
p)   = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> Name -> [Arg Name] -> Pattern -> Declaration
PatternSyn forall a. Range' a
noRange) Name
n [Arg Name]
ns Pattern
p
  killRange (Mutual Range
_ [Declaration]
d)            = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Mutual forall a. Range' a
noRange) [Declaration]
d
  killRange (InterleavedMutual Range
_ [Declaration]
d) = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
InterleavedMutual forall a. Range' a
noRange) [Declaration]
d
  killRange (LoneConstructor Range
_ [Declaration]
d)   = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
LoneConstructor forall a. Range' a
noRange) [Declaration]
d
  killRange (Abstract Range
_ [Declaration]
d)          = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Abstract forall a. Range' a
noRange) [Declaration]
d
  killRange (Private Range
_ Origin
o [Declaration]
d)         = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Origin -> [Declaration] -> Declaration
Private forall a. Range' a
noRange) Origin
o [Declaration]
d
  killRange (InstanceB Range
_ [Declaration]
d)         = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
InstanceB forall a. Range' a
noRange) [Declaration]
d
  killRange (Macro Range
_ [Declaration]
d)             = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Macro forall a. Range' a
noRange) [Declaration]
d
  killRange (Postulate Range
_ [Declaration]
t)         = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Postulate forall a. Range' a
noRange) [Declaration]
t
  killRange (Primitive Range
_ [Declaration]
t)         = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Declaration] -> Declaration
Primitive forall a. Range' a
noRange) [Declaration]
t
  killRange (Open Range
_ QName
q ImportDirective
i)            = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> QName -> ImportDirective -> Declaration
Open forall a. Range' a
noRange) QName
q ImportDirective
i
  killRange (Import Range
_ QName
q Maybe AsName
a OpenShortHand
o ImportDirective
i)      = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (\QName
q Maybe AsName
a -> Range
-> QName
-> Maybe AsName
-> OpenShortHand
-> ImportDirective
-> Declaration
Import forall a. Range' a
noRange QName
q Maybe AsName
a OpenShortHand
o) QName
q Maybe AsName
a ImportDirective
i
  killRange (ModuleMacro Range
_ Name
n ModuleApplication
m OpenShortHand
o ImportDirective
i) = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (\Name
n ModuleApplication
m -> Range
-> Name
-> ModuleApplication
-> OpenShortHand
-> ImportDirective
-> Declaration
ModuleMacro forall a. Range' a
noRange Name
n ModuleApplication
m OpenShortHand
o) Name
n ModuleApplication
m ImportDirective
i
  killRange (Module Range
_ QName
q Telescope
t [Declaration]
d)        = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> QName -> Telescope -> [Declaration] -> Declaration
Module forall a. Range' a
noRange) QName
q Telescope
t [Declaration]
d
  killRange (UnquoteDecl Range
_ [Name]
x Expr
t)     = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> [Name] -> Expr -> Declaration
UnquoteDecl forall a. Range' a
noRange) [Name]
x Expr
t
  killRange (UnquoteDef Range
_ [Name]
x Expr
t)      = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> [Name] -> Expr -> Declaration
UnquoteDef forall a. Range' a
noRange) [Name]
x Expr
t
  killRange (UnquoteData Range
_ Name
xs [Name]
cs Expr
t) = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> Name -> [Name] -> Expr -> Declaration
UnquoteData forall a. Range' a
noRange) Name
xs [Name]
cs Expr
t
  killRange (Pragma Pragma
p)              = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Pragma -> Declaration
Pragma Pragma
p

instance KillRange Expr where
  killRange :: Expr -> Expr
killRange (Ident QName
q)             = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 QName -> Expr
Ident QName
q
  killRange (Lit Range
_ Literal
l)             = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Literal -> Expr
Lit forall a. Range' a
noRange) Literal
l
  killRange (QuestionMark Range
_ Maybe Int
n)    = Range -> Maybe Int -> Expr
QuestionMark forall a. Range' a
noRange Maybe Int
n
  killRange (Underscore Range
_ Maybe String
n)      = Range -> Maybe String -> Expr
Underscore forall a. Range' a
noRange Maybe String
n
  killRange (RawApp Range
_ List2 Expr
e)          = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> List2 Expr -> Expr
RawApp forall a. Range' a
noRange) List2 Expr
e
  killRange (App Range
_ Expr
e NamedArg Expr
a)           = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Expr -> NamedArg Expr -> Expr
App forall a. Range' a
noRange) Expr
e NamedArg Expr
a
  killRange (OpApp Range
_ QName
n Set Name
ns OpAppArgs
o)      = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> QName -> Set Name -> OpAppArgs -> Expr
OpApp forall a. Range' a
noRange) QName
n Set Name
ns OpAppArgs
o
  killRange (WithApp Range
_ Expr
e [Expr]
es)      = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Expr -> [Expr] -> Expr
WithApp forall a. Range' a
noRange) Expr
e [Expr]
es
  killRange (HiddenArg Range
_ Named_ Expr
n)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Named_ Expr -> Expr
HiddenArg forall a. Range' a
noRange) Named_ Expr
n
  killRange (InstanceArg Range
_ Named_ Expr
n)     = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Named_ Expr -> Expr
InstanceArg forall a. Range' a
noRange) Named_ Expr
n
  killRange (Lam Range
_ List1 LamBinding
l Expr
e)           = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> List1 LamBinding -> Expr -> Expr
Lam forall a. Range' a
noRange) List1 LamBinding
l Expr
e
  killRange (AbsurdLam Range
_ Hiding
h)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Hiding -> Expr
AbsurdLam forall a. Range' a
noRange) Hiding
h
  killRange (ExtendedLam Range
_ Erased
e List1 LamClause
lrw) = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Erased -> List1 LamClause -> Expr
ExtendedLam forall a. Range' a
noRange) Erased
e List1 LamClause
lrw
  killRange (Fun Range
_ Arg Expr
e1 Expr
e2)         = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Arg Expr -> Expr -> Expr
Fun forall a. Range' a
noRange) Arg Expr
e1 Expr
e2
  killRange (Pi Telescope1
t Expr
e)              = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Telescope1 -> Expr -> Expr
Pi Telescope1
t Expr
e
  killRange (Rec Range
_ RecordAssignments
ne)            = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> RecordAssignments -> Expr
Rec forall a. Range' a
noRange) RecordAssignments
ne
  killRange (RecUpdate Range
_ Expr
e [FieldAssignment]
ne)    = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Expr -> [FieldAssignment] -> Expr
RecUpdate forall a. Range' a
noRange) Expr
e [FieldAssignment]
ne
  killRange (Let Range
_ List1 Declaration
d Maybe Expr
e)           = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> List1 Declaration -> Maybe Expr -> Expr
Let forall a. Range' a
noRange) List1 Declaration
d Maybe Expr
e
  killRange (Paren Range
_ Expr
e)           = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Expr -> Expr
Paren forall a. Range' a
noRange) Expr
e
  killRange (IdiomBrackets Range
_ [Expr]
es)  = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [Expr] -> Expr
IdiomBrackets forall a. Range' a
noRange) [Expr]
es
  killRange (DoBlock Range
_ List1 DoStmt
ss)        = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> List1 DoStmt -> Expr
DoBlock forall a. Range' a
noRange) List1 DoStmt
ss
  killRange (Absurd Range
_)            = Range -> Expr
Absurd forall a. Range' a
noRange
  killRange (As Range
_ Name
n Expr
e)            = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Name -> Expr -> Expr
As forall a. Range' a
noRange) Name
n Expr
e
  killRange (Dot Range
_ Expr
e)             = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Expr -> Expr
Dot forall a. Range' a
noRange) Expr
e
  killRange (DoubleDot Range
_ Expr
e)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Expr -> Expr
DoubleDot forall a. Range' a
noRange) Expr
e
  killRange (Quote Range
_)             = Range -> Expr
Quote forall a. Range' a
noRange
  killRange (QuoteTerm Range
_)         = Range -> Expr
QuoteTerm forall a. Range' a
noRange
  killRange (Unquote Range
_)           = Range -> Expr
Unquote forall a. Range' a
noRange
  killRange (Tactic Range
_ Expr
t)          = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Expr -> Expr
Tactic forall a. Range' a
noRange) Expr
t
  killRange (DontCare Expr
e)          = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Expr -> Expr
DontCare Expr
e
  killRange (Equal Range
_ Expr
x Expr
y)         = Range -> Expr -> Expr -> Expr
Equal forall a. Range' a
noRange Expr
x Expr
y
  killRange (Ellipsis Range
_)          = Range -> Expr
Ellipsis forall a. Range' a
noRange
  killRange (Generalized Expr
e)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Expr -> Expr
Generalized Expr
e

instance KillRange LamBinding where
  killRange :: LamBinding -> LamBinding
killRange (DomainFree NamedArg Binder
b) = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 forall a. NamedArg Binder -> LamBinding' a
DomainFree NamedArg Binder
b
  killRange (DomainFull TypedBinding
t) = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 forall a. a -> LamBinding' a
DomainFull TypedBinding
t

instance KillRange LHS where
  killRange :: KillRangeT LHS
killRange (LHS Pattern
p [RewriteEqn]
r [WithExpr]
w)  = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 Pattern -> [RewriteEqn] -> [WithExpr] -> LHS
LHS Pattern
p [RewriteEqn]
r [WithExpr]
w

instance KillRange LamClause where
  killRange :: KillRangeT LamClause
killRange (LamClause [Pattern]
a RHS
b Bool
c) = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 [Pattern] -> RHS -> Bool -> LamClause
LamClause [Pattern]
a RHS
b Bool
c

instance KillRange DoStmt where
  killRange :: KillRangeT DoStmt
killRange (DoBind Range
r Pattern
p Expr
e [LamClause]
w) = forall a b c d e.
(KillRange a, KillRange b, KillRange c, KillRange d) =>
(a -> b -> c -> d -> e) -> a -> b -> c -> d -> e
killRange4 Range -> Pattern -> Expr -> [LamClause] -> DoStmt
DoBind Range
r Pattern
p Expr
e [LamClause]
w
  killRange (DoThen Expr
e)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 Expr -> DoStmt
DoThen Expr
e
  killRange (DoLet Range
r List1 Declaration
ds)     = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Range -> List1 Declaration -> DoStmt
DoLet Range
r List1 Declaration
ds

instance KillRange ModuleApplication where
  killRange :: KillRangeT ModuleApplication
killRange (SectionApp Range
_ Telescope
t Expr
e)    = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Telescope -> Expr -> ModuleApplication
SectionApp forall a. Range' a
noRange) Telescope
t Expr
e
  killRange (RecordModuleInstance Range
_ QName
q) = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> QName -> ModuleApplication
RecordModuleInstance forall a. Range' a
noRange) QName
q

instance KillRange e => KillRange (OpApp e) where
  killRange :: KillRangeT (OpApp e)
killRange (SyntaxBindingLambda Range
_ List1 LamBinding
l e
e) = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (forall e. Range -> List1 LamBinding -> e -> OpApp e
SyntaxBindingLambda forall a. Range' a
noRange) List1 LamBinding
l e
e
  killRange (Ordinary e
e)                = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 forall e. e -> OpApp e
Ordinary e
e

instance KillRange Pattern where
  killRange :: Pattern -> Pattern
killRange (IdentP QName
q)        = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 QName -> Pattern
IdentP QName
q
  killRange (AppP Pattern
p NamedArg Pattern
ps)       = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 Pattern -> NamedArg Pattern -> Pattern
AppP Pattern
p NamedArg Pattern
ps
  killRange (RawAppP Range
_ List2 Pattern
p)     = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> List2 Pattern -> Pattern
RawAppP forall a. Range' a
noRange) List2 Pattern
p
  killRange (OpAppP Range
_ QName
n Set Name
ns [NamedArg Pattern]
p) = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (Range -> QName -> Set Name -> [NamedArg Pattern] -> Pattern
OpAppP forall a. Range' a
noRange) QName
n Set Name
ns [NamedArg Pattern]
p
  killRange (HiddenP Range
_ Named_ Pattern
n)     = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Named_ Pattern -> Pattern
HiddenP forall a. Range' a
noRange) Named_ Pattern
n
  killRange (InstanceP Range
_ Named_ Pattern
n)   = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Named_ Pattern -> Pattern
InstanceP forall a. Range' a
noRange) Named_ Pattern
n
  killRange (ParenP Range
_ Pattern
p)      = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Pattern -> Pattern
ParenP forall a. Range' a
noRange) Pattern
p
  killRange (WildP Range
_)         = Range -> Pattern
WildP forall a. Range' a
noRange
  killRange (AbsurdP Range
_)       = Range -> Pattern
AbsurdP forall a. Range' a
noRange
  killRange (AsP Range
_ Name
n Pattern
p)       = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Name -> Pattern -> Pattern
AsP forall a. Range' a
noRange) Name
n Pattern
p
  killRange (DotP Range
_ Expr
e)        = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Expr -> Pattern
DotP forall a. Range' a
noRange) Expr
e
  killRange (LitP Range
_ Literal
l)        = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Literal -> Pattern
LitP forall a. Range' a
noRange) Literal
l
  killRange (QuoteP Range
_)        = Range -> Pattern
QuoteP forall a. Range' a
noRange
  killRange (RecP Range
_ [FieldAssignment' Pattern]
fs)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [FieldAssignment' Pattern] -> Pattern
RecP forall a. Range' a
noRange) [FieldAssignment' Pattern]
fs
  killRange (EqualP Range
_ [(Expr, Expr)]
es)     = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> [(Expr, Expr)] -> Pattern
EqualP forall a. Range' a
noRange) [(Expr, Expr)]
es
  killRange (EllipsisP Range
_ Maybe Pattern
mp)  = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Maybe Pattern -> Pattern
EllipsisP forall a. Range' a
noRange) Maybe Pattern
mp
  killRange (WithP Range
_ Pattern
p)       = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Pattern -> Pattern
WithP forall a. Range' a
noRange) Pattern
p

instance KillRange Pragma where
  killRange :: KillRangeT Pragma
killRange (OptionsPragma Range
_ [String]
s)               = Range -> [String] -> Pragma
OptionsPragma forall a. Range' a
noRange [String]
s
  killRange (BuiltinPragma Range
_ Ranged String
s QName
e)             = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Ranged String -> QName -> Pragma
BuiltinPragma forall a. Range' a
noRange Ranged String
s) QName
e
  killRange (RewritePragma Range
_ Range
_ [QName]
qs)            = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Range -> [QName] -> Pragma
RewritePragma forall a. Range' a
noRange forall a. Range' a
noRange) [QName]
qs
  killRange (StaticPragma Range
_ QName
q)                = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> QName -> Pragma
StaticPragma forall a. Range' a
noRange) QName
q
  killRange (InjectivePragma Range
_ QName
q)             = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> QName -> Pragma
InjectivePragma forall a. Range' a
noRange) QName
q
  killRange (InlinePragma Range
_ Bool
b QName
q)              = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> Bool -> QName -> Pragma
InlinePragma forall a. Range' a
noRange Bool
b) QName
q
  killRange (CompilePragma Range
_ Ranged String
b QName
q String
s)           = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (\ QName
q -> Range -> Ranged String -> QName -> String -> Pragma
CompilePragma forall a. Range' a
noRange Ranged String
b QName
q String
s) QName
q
  killRange (ForeignPragma Range
_ Ranged String
b String
s)             = Range -> Ranged String -> String -> Pragma
ForeignPragma forall a. Range' a
noRange Ranged String
b String
s
  killRange (ImpossiblePragma Range
_ [String]
strs)         = Range -> [String] -> Pragma
ImpossiblePragma forall a. Range' a
noRange [String]
strs
  killRange (TerminationCheckPragma Range
_ TerminationCheck Name
t)      = Range -> TerminationCheck Name -> Pragma
TerminationCheckPragma forall a. Range' a
noRange (forall a. KillRange a => KillRangeT a
killRange TerminationCheck Name
t)
  killRange (NoCoverageCheckPragma Range
_)         = Range -> Pragma
NoCoverageCheckPragma forall a. Range' a
noRange
  killRange (WarningOnUsage Range
_ QName
nm Text
str)         = Range -> QName -> Text -> Pragma
WarningOnUsage forall a. Range' a
noRange (forall a. KillRange a => KillRangeT a
killRange QName
nm) Text
str
  killRange (WarningOnImport Range
_ Text
str)           = Range -> Text -> Pragma
WarningOnImport forall a. Range' a
noRange Text
str
  killRange (CatchallPragma Range
_)                = Range -> Pragma
CatchallPragma forall a. Range' a
noRange
  killRange (DisplayPragma Range
_ Pattern
lhs Expr
rhs)         = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (Range -> Pattern -> Expr -> Pragma
DisplayPragma forall a. Range' a
noRange) Pattern
lhs Expr
rhs
  killRange (EtaPragma Range
_ QName
q)                   = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (Range -> QName -> Pragma
EtaPragma forall a. Range' a
noRange) QName
q
  killRange (NoPositivityCheckPragma Range
_)       = Range -> Pragma
NoPositivityCheckPragma forall a. Range' a
noRange
  killRange (PolarityPragma Range
_ Name
q [Occurrence]
occs)         = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (\Name
q -> Range -> Name -> [Occurrence] -> Pragma
PolarityPragma forall a. Range' a
noRange Name
q [Occurrence]
occs) Name
q
  killRange (NoUniverseCheckPragma Range
_)         = Range -> Pragma
NoUniverseCheckPragma forall a. Range' a
noRange
  killRange (NotProjectionLikePragma Range
_ QName
q)     = Range -> QName -> Pragma
NotProjectionLikePragma forall a. Range' a
noRange QName
q

instance KillRange RHS where
  killRange :: KillRangeT RHS
killRange RHS
AbsurdRHS = forall e. RHS' e
AbsurdRHS
  killRange (RHS Expr
e)   = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 forall e. e -> RHS' e
RHS Expr
e

instance KillRange TypedBinding where
  killRange :: TypedBinding -> TypedBinding
killRange (TBind Range
_ List1 (NamedArg Binder)
b Expr
e) = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 (forall e. Range -> List1 (NamedArg Binder) -> e -> TypedBinding' e
TBind forall a. Range' a
noRange) List1 (NamedArg Binder)
b Expr
e
  killRange (TLet Range
r List1 Declaration
ds)   = forall a b c.
(KillRange a, KillRange b) =>
(a -> b -> c) -> a -> b -> c
killRange2 forall e. Range -> List1 Declaration -> TypedBinding' e
TLet Range
r List1 Declaration
ds

instance KillRange WhereClause where
  killRange :: KillRangeT WhereClause
killRange WhereClause
NoWhere             = forall a. WhereClause' a
NoWhere
  killRange (AnyWhere Range
r [Declaration]
d)      = forall a b. KillRange a => (a -> b) -> a -> b
killRange1 (forall decls. Range -> decls -> WhereClause' decls
AnyWhere forall a. Range' a
noRange) [Declaration]
d
  killRange (SomeWhere Range
r Name
n Access
a [Declaration]
d) = forall a b c d.
(KillRange a, KillRange b, KillRange c) =>
(a -> b -> c -> d) -> a -> b -> c -> d
killRange3 (forall decls.
Range -> Name -> Access -> decls -> WhereClause' decls
SomeWhere forall a. Range' a
noRange) Name
n Access
a [Declaration]
d

------------------------------------------------------------------------
-- NFData instances

-- | Ranges are not forced.

instance NFData Expr where
  rnf :: Expr -> ()
rnf (Ident QName
a)           = forall a. NFData a => a -> ()
rnf QName
a
  rnf (Lit Range
_ Literal
a)           = forall a. NFData a => a -> ()
rnf Literal
a
  rnf (QuestionMark Range
_ Maybe Int
a)  = forall a. NFData a => a -> ()
rnf Maybe Int
a
  rnf (Underscore Range
_ Maybe String
a)    = forall a. NFData a => a -> ()
rnf Maybe String
a
  rnf (RawApp Range
_ List2 Expr
a)        = forall a. NFData a => a -> ()
rnf List2 Expr
a
  rnf (App Range
_ Expr
a NamedArg Expr
b)         = forall a. NFData a => a -> ()
rnf Expr
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf NamedArg Expr
b
  rnf (OpApp Range
_ QName
a Set Name
b OpAppArgs
c)     = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Set Name
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf OpAppArgs
c
  rnf (WithApp Range
_ Expr
a [Expr]
b)     = forall a. NFData a => a -> ()
rnf Expr
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Expr]
b
  rnf (HiddenArg Range
_ Named_ Expr
a)     = forall a. NFData a => a -> ()
rnf Named_ Expr
a
  rnf (InstanceArg Range
_ Named_ Expr
a)   = forall a. NFData a => a -> ()
rnf Named_ Expr
a
  rnf (Lam Range
_ List1 LamBinding
a Expr
b)         = forall a. NFData a => a -> ()
rnf List1 LamBinding
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (AbsurdLam Range
_ Hiding
a)     = forall a. NFData a => a -> ()
rnf Hiding
a
  rnf (ExtendedLam Range
_ Erased
a List1 LamClause
b) = forall a. NFData a => a -> ()
rnf Erased
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf List1 LamClause
b
  rnf (Fun Range
_ Arg Expr
a Expr
b)         = forall a. NFData a => a -> ()
rnf Arg Expr
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (Pi Telescope1
a Expr
b)            = forall a. NFData a => a -> ()
rnf Telescope1
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (Rec Range
_ RecordAssignments
a)           = forall a. NFData a => a -> ()
rnf RecordAssignments
a
  rnf (RecUpdate Range
_ Expr
a [FieldAssignment]
b)   = forall a. NFData a => a -> ()
rnf Expr
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [FieldAssignment]
b
  rnf (Let Range
_ List1 Declaration
a Maybe Expr
b)         = forall a. NFData a => a -> ()
rnf List1 Declaration
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Maybe Expr
b
  rnf (Paren Range
_ Expr
a)         = forall a. NFData a => a -> ()
rnf Expr
a
  rnf (IdiomBrackets Range
_ [Expr]
a) = forall a. NFData a => a -> ()
rnf [Expr]
a
  rnf (DoBlock Range
_ List1 DoStmt
a)       = forall a. NFData a => a -> ()
rnf List1 DoStmt
a
  rnf (Absurd Range
_)          = ()
  rnf (As Range
_ Name
a Expr
b)          = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (Dot Range
_ Expr
a)           = forall a. NFData a => a -> ()
rnf Expr
a
  rnf (DoubleDot Range
_ Expr
a)     = forall a. NFData a => a -> ()
rnf Expr
a
  rnf (Quote Range
_)           = ()
  rnf (QuoteTerm Range
_)       = ()
  rnf (Tactic Range
_ Expr
a)        = forall a. NFData a => a -> ()
rnf Expr
a
  rnf (Unquote Range
_)         = ()
  rnf (DontCare Expr
a)        = forall a. NFData a => a -> ()
rnf Expr
a
  rnf (Equal Range
_ Expr
a Expr
b)       = forall a. NFData a => a -> ()
rnf Expr
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (Ellipsis Range
_)        = ()
  rnf (Generalized Expr
e)     = forall a. NFData a => a -> ()
rnf Expr
e

-- | Ranges are not forced.

instance NFData Pattern where
  rnf :: Pattern -> ()
rnf (IdentP QName
a)       = forall a. NFData a => a -> ()
rnf QName
a
  rnf (QuoteP Range
_)       = ()
  rnf (AppP Pattern
a NamedArg Pattern
b)       = forall a. NFData a => a -> ()
rnf Pattern
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf NamedArg Pattern
b
  rnf (RawAppP Range
_ List2 Pattern
a)    = forall a. NFData a => a -> ()
rnf List2 Pattern
a
  rnf (OpAppP Range
_ QName
a Set Name
b [NamedArg Pattern]
c) = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Set Name
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [NamedArg Pattern]
c
  rnf (HiddenP Range
_ Named_ Pattern
a)    = forall a. NFData a => a -> ()
rnf Named_ Pattern
a
  rnf (InstanceP Range
_ Named_ Pattern
a)  = forall a. NFData a => a -> ()
rnf Named_ Pattern
a
  rnf (ParenP Range
_ Pattern
a)     = forall a. NFData a => a -> ()
rnf Pattern
a
  rnf (WildP Range
_)        = ()
  rnf (AbsurdP Range
_)      = ()
  rnf (AsP Range
_ Name
a Pattern
b)      = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Pattern
b
  rnf (DotP Range
_ Expr
a)       = forall a. NFData a => a -> ()
rnf Expr
a
  rnf (LitP Range
_ Literal
a)       = forall a. NFData a => a -> ()
rnf Literal
a
  rnf (RecP Range
_ [FieldAssignment' Pattern]
a)       = forall a. NFData a => a -> ()
rnf [FieldAssignment' Pattern]
a
  rnf (EqualP Range
_ [(Expr, Expr)]
es)    = forall a. NFData a => a -> ()
rnf [(Expr, Expr)]
es
  rnf (EllipsisP Range
_ Maybe Pattern
mp) = forall a. NFData a => a -> ()
rnf Maybe Pattern
mp
  rnf (WithP Range
_ Pattern
a)      = forall a. NFData a => a -> ()
rnf Pattern
a

-- | Ranges are not forced.

instance NFData RecordDirective where
  rnf :: RecordDirective -> ()
rnf (Induction Ranged Induction
a)          = forall a. NFData a => a -> ()
rnf Ranged Induction
a
  rnf (Eta Ranged HasEta0
a    )            = forall a. NFData a => a -> ()
rnf Ranged HasEta0
a
  rnf (Constructor Name
a IsInstance
b)      = forall a. NFData a => a -> ()
rnf (Name
a, IsInstance
b)
  rnf (PatternOrCopattern Range
_) = ()

instance NFData Declaration where
  rnf :: Declaration -> ()
rnf (TypeSig ArgInfo
a Maybe Expr
b Name
c Expr
d)       = forall a. NFData a => a -> ()
rnf ArgInfo
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Maybe Expr
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Name
c seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
d
  rnf (FieldSig IsInstance
a Maybe Expr
b Name
c Arg Expr
d)      = forall a. NFData a => a -> ()
rnf IsInstance
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Maybe Expr
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Name
c seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Arg Expr
d
  rnf (Generalize Range
_ [Declaration]
a)        = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Field Range
_ [Declaration]
fs)            = forall a. NFData a => a -> ()
rnf [Declaration]
fs
  rnf (FunClause LHS
a RHS
b WhereClause
c Bool
d)     = forall a. NFData a => a -> ()
rnf LHS
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf RHS
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf WhereClause
c seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Bool
d
  rnf (DataSig Range
_ Name
a [LamBinding]
b Expr
c)       = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [LamBinding]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
c
  rnf (Data Range
_ Name
a [LamBinding]
b Expr
c [Declaration]
d)        = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [LamBinding]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
c seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Declaration]
d
  rnf (DataDef Range
_ Name
a [LamBinding]
b [Declaration]
c)       = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [LamBinding]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Declaration]
c
  rnf (RecordSig Range
_ Name
a [LamBinding]
b Expr
c)     = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [LamBinding]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
c
  rnf (RecordDef Range
_ Name
a RecordDirectives
b [LamBinding]
c [Declaration]
d)   = forall a. NFData a => a -> ()
rnf (Name
a, RecordDirectives
b, [LamBinding]
c, [Declaration]
d)
  rnf (Record Range
_ Name
a RecordDirectives
b [LamBinding]
c Expr
d [Declaration]
e)    = forall a. NFData a => a -> ()
rnf (Name
a, RecordDirectives
b, [LamBinding]
c, Expr
d, [Declaration]
e)
  rnf (RecordDirective RecordDirective
a)     = forall a. NFData a => a -> ()
rnf RecordDirective
a
  rnf (Infix Fixity
a List1 Name
b)             = forall a. NFData a => a -> ()
rnf Fixity
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf List1 Name
b
  rnf (Syntax Name
a Notation
b)            = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Notation
b
  rnf (PatternSyn Range
_ Name
a [Arg Name]
b Pattern
c)    = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Arg Name]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Pattern
c
  rnf (Mutual Range
_ [Declaration]
a)            = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (InterleavedMutual Range
_ [Declaration]
a) = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (LoneConstructor Range
_ [Declaration]
a)   = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Abstract Range
_ [Declaration]
a)          = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Private Range
_ Origin
_ [Declaration]
a)         = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (InstanceB Range
_ [Declaration]
a)         = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Macro Range
_ [Declaration]
a)             = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Postulate Range
_ [Declaration]
a)         = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Primitive Range
_ [Declaration]
a)         = forall a. NFData a => a -> ()
rnf [Declaration]
a
  rnf (Open Range
_ QName
a ImportDirective
b)            = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ImportDirective
b
  rnf (Import Range
_ QName
a Maybe AsName
b OpenShortHand
_ ImportDirective
c)      = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Maybe AsName
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ImportDirective
c
  rnf (ModuleMacro Range
_ Name
a ModuleApplication
b OpenShortHand
_ ImportDirective
c) = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ModuleApplication
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ImportDirective
c
  rnf (Module Range
_ QName
a Telescope
b [Declaration]
c)        = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Telescope
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Declaration]
c
  rnf (UnquoteDecl Range
_ [Name]
a Expr
b)     = forall a. NFData a => a -> ()
rnf [Name]
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (UnquoteDef Range
_ [Name]
a Expr
b)      = forall a. NFData a => a -> ()
rnf [Name]
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (UnquoteData Range
_ Name
a [Name]
b Expr
c)   = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Name]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
c
  rnf (Pragma Pragma
a)              = forall a. NFData a => a -> ()
rnf Pragma
a

instance NFData OpenShortHand

-- | Ranges are not forced.

instance NFData Pragma where
  rnf :: Pragma -> ()
rnf (OptionsPragma Range
_ [String]
a)               = forall a. NFData a => a -> ()
rnf [String]
a
  rnf (BuiltinPragma Range
_ Ranged String
a QName
b)             = forall a. NFData a => a -> ()
rnf Ranged String
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf QName
b
  rnf (RewritePragma Range
_ Range
_ [QName]
a)             = forall a. NFData a => a -> ()
rnf [QName]
a
  rnf (CompilePragma Range
_ Ranged String
a QName
b String
c)           = forall a. NFData a => a -> ()
rnf Ranged String
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf QName
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf String
c
  rnf (ForeignPragma Range
_ Ranged String
b String
s)             = forall a. NFData a => a -> ()
rnf Ranged String
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf String
s
  rnf (StaticPragma Range
_ QName
a)                = forall a. NFData a => a -> ()
rnf QName
a
  rnf (InjectivePragma Range
_ QName
a)             = forall a. NFData a => a -> ()
rnf QName
a
  rnf (InlinePragma Range
_ Bool
_ QName
a)              = forall a. NFData a => a -> ()
rnf QName
a
  rnf (ImpossiblePragma Range
_ [String]
a)            = forall a. NFData a => a -> ()
rnf [String]
a
  rnf (EtaPragma Range
_ QName
a)                   = forall a. NFData a => a -> ()
rnf QName
a
  rnf (TerminationCheckPragma Range
_ TerminationCheck Name
a)      = forall a. NFData a => a -> ()
rnf TerminationCheck Name
a
  rnf (NoCoverageCheckPragma Range
_)         = ()
  rnf (WarningOnUsage Range
_ QName
a Text
b)            = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Text
b
  rnf (WarningOnImport Range
_ Text
a)             = forall a. NFData a => a -> ()
rnf Text
a
  rnf (CatchallPragma Range
_)                = ()
  rnf (DisplayPragma Range
_ Pattern
a Expr
b)             = forall a. NFData a => a -> ()
rnf Pattern
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (NoPositivityCheckPragma Range
_)       = ()
  rnf (PolarityPragma Range
_ Name
a [Occurrence]
b)            = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Occurrence]
b
  rnf (NoUniverseCheckPragma Range
_)         = ()
  rnf (NotProjectionLikePragma Range
_ QName
q)     = forall a. NFData a => a -> ()
rnf QName
q

-- | Ranges are not forced.

instance NFData AsName where
  rnf :: AsName -> ()
rnf (AsName Either Expr Name
a Range
_) = forall a. NFData a => a -> ()
rnf Either Expr Name
a

-- | Ranges are not forced.

instance NFData a => NFData (TypedBinding' a) where
  rnf :: TypedBinding' a -> ()
rnf (TBind Range
_ List1 (NamedArg Binder)
a a
b) = forall a. NFData a => a -> ()
rnf List1 (NamedArg Binder)
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf a
b
  rnf (TLet Range
_ List1 Declaration
a)    = forall a. NFData a => a -> ()
rnf List1 Declaration
a

-- | Ranges are not forced.

instance NFData ModuleApplication where
  rnf :: ModuleApplication -> ()
rnf (SectionApp Range
_ Telescope
a Expr
b)    = forall a. NFData a => a -> ()
rnf Telescope
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Expr
b
  rnf (RecordModuleInstance Range
_ QName
a) = forall a. NFData a => a -> ()
rnf QName
a

-- | Ranges are not forced.

instance NFData a => NFData (OpApp a) where
  rnf :: OpApp a -> ()
rnf (SyntaxBindingLambda Range
_ List1 LamBinding
a a
b) = forall a. NFData a => a -> ()
rnf List1 LamBinding
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf a
b
  rnf (Ordinary a
a)                = forall a. NFData a => a -> ()
rnf a
a

-- | Ranges are not forced.

instance NFData LHS where
  rnf :: LHS -> ()
rnf (LHS Pattern
a [RewriteEqn]
b [WithExpr]
c) = forall a. NFData a => a -> ()
rnf Pattern
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [RewriteEqn]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [WithExpr]
c

instance NFData a => NFData (FieldAssignment' a) where
  rnf :: FieldAssignment' a -> ()
rnf (FieldAssignment Name
a a
b) = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf a
b

instance NFData ModuleAssignment where
  rnf :: ModuleAssignment -> ()
rnf (ModuleAssignment QName
a [Expr]
b ImportDirective
c) = forall a. NFData a => a -> ()
rnf QName
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf [Expr]
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf ImportDirective
c

instance NFData a => NFData (WhereClause' a) where
  rnf :: WhereClause' a -> ()
rnf WhereClause' a
NoWhere             = ()
  rnf (AnyWhere Range
_ a
a)      = forall a. NFData a => a -> ()
rnf a
a
  rnf (SomeWhere Range
_ Name
a Access
b a
c) = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Access
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf a
c

instance NFData LamClause where
  rnf :: LamClause -> ()
rnf (LamClause [Pattern]
a RHS
b Bool
c) = forall a. NFData a => a -> ()
rnf ([Pattern]
a, RHS
b, Bool
c)

instance NFData a => NFData (LamBinding' a) where
  rnf :: LamBinding' a -> ()
rnf (DomainFree NamedArg Binder
a) = forall a. NFData a => a -> ()
rnf NamedArg Binder
a
  rnf (DomainFull a
a) = forall a. NFData a => a -> ()
rnf a
a

instance NFData Binder where
  rnf :: Binder -> ()
rnf (Binder Maybe Pattern
a BoundName
b) = forall a. NFData a => a -> ()
rnf Maybe Pattern
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf BoundName
b

instance NFData BoundName where
  rnf :: BoundName -> ()
rnf (BName Name
a Fixity'
b Maybe Expr
c Bool
d) = forall a. NFData a => a -> ()
rnf Name
a seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Fixity'
b seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Maybe Expr
c seq :: forall a b. a -> b -> b
`seq` forall a. NFData a => a -> ()
rnf Bool
d

instance NFData a => NFData (RHS' a) where
  rnf :: RHS' a -> ()
rnf RHS' a
AbsurdRHS = ()
  rnf (RHS a
a)   = forall a. NFData a => a -> ()
rnf a
a

instance NFData DoStmt where
  rnf :: DoStmt -> ()
rnf (DoBind Range
_ Pattern
p Expr
e [LamClause]
w) = forall a. NFData a => a -> ()
rnf (Pattern
p, Expr
e, [LamClause]
w)
  rnf (DoThen Expr
e)       = forall a. NFData a => a -> ()
rnf Expr
e
  rnf (DoLet Range
_ List1 Declaration
ds)     = forall a. NFData a => a -> ()
rnf List1 Declaration
ds