{-# LANGUAGE TypeFamilies #-}
module Agda.Syntax.Concrete.Pattern where
import Control.Applicative ( liftA2 )
import Control.Arrow ( first )
import Control.Monad.Identity
import Control.Monad.Writer
import Data.Foldable (Foldable, foldMap)
import Data.Traversable (Traversable, traverse)
import Data.Monoid
import Agda.Syntax.Common
import Agda.Syntax.Concrete
import Agda.Syntax.Position
import Agda.Utils.AffineHole
import Agda.Utils.Functor
import Agda.Utils.Impossible
import Agda.Utils.List
import Agda.Utils.Maybe
class IsEllipsis a where
isEllipsis :: a -> Bool
instance IsEllipsis Pattern where
isEllipsis :: Pattern -> Bool
isEllipsis = \case
EllipsisP{} -> Bool
True
RawAppP Range
_ [Pattern
p] -> Pattern -> Bool
forall a. IsEllipsis a => a -> Bool
isEllipsis Pattern
p
ParenP Range
_ Pattern
p -> Pattern -> Bool
forall a. IsEllipsis a => a -> Bool
isEllipsis Pattern
p
Pattern
_ -> Bool
False
class HasEllipsis a where
hasEllipsis :: a -> Bool
instance HasEllipsis Pattern where
hasEllipsis :: Pattern -> Bool
hasEllipsis Pattern
p =
case Pattern -> AffineHole Pattern Pattern
forall p. CPatternLike p => p -> AffineHole Pattern p
hasEllipsis' Pattern
p of
ZeroHoles Pattern
_ -> Bool
False
OneHole Pattern -> Pattern
_ Pattern
_ -> Bool
True
AffineHole Pattern Pattern
ManyHoles -> Bool
True
instance HasEllipsis LHS where
hasEllipsis :: LHS -> Bool
hasEllipsis (LHS Pattern
p [RewriteEqn]
_ [WithHiding WithExpr]
_ ExpandedEllipsis
_) = Pattern -> Bool
forall a. HasEllipsis a => a -> Bool
hasEllipsis Pattern
p
class IsWithP p where
isWithP :: p -> Maybe p
default isWithP :: (IsWithP q, Decoration f, f q ~ p) => p -> Maybe p
isWithP = (q -> Maybe q) -> f q -> Maybe (f q)
forall (t :: * -> *) (m :: * -> *) a b.
(Decoration t, Functor m) =>
(a -> m b) -> t a -> m (t b)
traverseF q -> Maybe q
forall p. IsWithP p => p -> Maybe p
isWithP
instance IsWithP Pattern where
isWithP :: Pattern -> Maybe Pattern
isWithP = \case
WithP Range
_ Pattern
p -> Pattern -> Maybe Pattern
forall a. a -> Maybe a
Just Pattern
p
RawAppP Range
_ [Pattern
p] -> Pattern -> Maybe Pattern
forall p. IsWithP p => p -> Maybe p
isWithP Pattern
p
ParenP Range
_ Pattern
p -> Pattern -> Maybe Pattern
forall p. IsWithP p => p -> Maybe p
isWithP Pattern
p
Pattern
_ -> Maybe Pattern
forall a. Maybe a
Nothing
instance IsWithP p => IsWithP (Arg p) where
instance IsWithP p => IsWithP (Named n p) where
data LHSPatternView
= LHSAppP [NamedArg Pattern]
| LHSWithP [Pattern]
lhsPatternView :: [NamedArg Pattern] -> Maybe (LHSPatternView, [NamedArg Pattern])
lhsPatternView :: [NamedArg Pattern] -> Maybe (LHSPatternView, [NamedArg Pattern])
lhsPatternView [] = Maybe (LHSPatternView, [NamedArg Pattern])
forall a. Maybe a
Nothing
lhsPatternView (NamedArg Pattern
p0 : [NamedArg Pattern]
ps) =
case NamedArg Pattern -> Pattern
forall a. NamedArg a -> a
namedArg NamedArg Pattern
p0 of
WithP Range
_i Pattern
p -> (LHSPatternView, [NamedArg Pattern])
-> Maybe (LHSPatternView, [NamedArg Pattern])
forall a. a -> Maybe a
Just ([Pattern] -> LHSPatternView
LHSWithP (Pattern
p Pattern -> [Pattern] -> [Pattern]
forall a. a -> [a] -> [a]
: (NamedArg Pattern -> Pattern) -> [NamedArg Pattern] -> [Pattern]
forall a b. (a -> b) -> [a] -> [b]
map NamedArg Pattern -> Pattern
forall a. NamedArg a -> a
namedArg [NamedArg Pattern]
ps1), [NamedArg Pattern]
ps2)
where
([NamedArg Pattern]
ps1, [NamedArg Pattern]
ps2) = (NamedArg Pattern -> Maybe (NamedArg Pattern))
-> [NamedArg Pattern] -> ([NamedArg Pattern], [NamedArg Pattern])
forall a b. (a -> Maybe b) -> [a] -> (Prefix b, [a])
spanJust NamedArg Pattern -> Maybe (NamedArg Pattern)
forall p. IsWithP p => p -> Maybe p
isWithP [NamedArg Pattern]
ps
Pattern
_ -> (LHSPatternView, [NamedArg Pattern])
-> Maybe (LHSPatternView, [NamedArg Pattern])
forall a. a -> Maybe a
Just ([NamedArg Pattern] -> LHSPatternView
LHSAppP (NamedArg Pattern
p0 NamedArg Pattern -> [NamedArg Pattern] -> [NamedArg Pattern]
forall a. a -> [a] -> [a]
: [NamedArg Pattern]
ps1), [NamedArg Pattern]
ps2)
where
([NamedArg Pattern]
ps1, [NamedArg Pattern]
ps2) = (NamedArg Pattern -> Bool)
-> [NamedArg Pattern] -> ([NamedArg Pattern], [NamedArg Pattern])
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (Maybe (NamedArg Pattern) -> Bool
forall a. Maybe a -> Bool
isNothing (Maybe (NamedArg Pattern) -> Bool)
-> (NamedArg Pattern -> Maybe (NamedArg Pattern))
-> NamedArg Pattern
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NamedArg Pattern -> Maybe (NamedArg Pattern)
forall p. IsWithP p => p -> Maybe p
isWithP) [NamedArg Pattern]
ps
lhsCoreApp :: LHSCore -> [NamedArg Pattern] -> LHSCore
lhsCoreApp :: LHSCore -> [NamedArg Pattern] -> LHSCore
lhsCoreApp LHSCore
core [NamedArg Pattern]
ps = LHSCore
core { lhsPats :: [NamedArg Pattern]
lhsPats = LHSCore -> [NamedArg Pattern]
lhsPats LHSCore
core [NamedArg Pattern] -> [NamedArg Pattern] -> [NamedArg Pattern]
forall a. [a] -> [a] -> [a]
++ [NamedArg Pattern]
ps }
lhsCoreWith :: LHSCore -> [Pattern] -> LHSCore
lhsCoreWith :: LHSCore -> [Pattern] -> LHSCore
lhsCoreWith (LHSWith LHSCore
core [Pattern]
wps []) [Pattern]
wps' = LHSCore -> [Pattern] -> [NamedArg Pattern] -> LHSCore
LHSWith LHSCore
core ([Pattern]
wps [Pattern] -> [Pattern] -> [Pattern]
forall a. [a] -> [a] -> [a]
++ [Pattern]
wps') []
lhsCoreWith LHSCore
core [Pattern]
wps' = LHSCore -> [Pattern] -> [NamedArg Pattern] -> LHSCore
LHSWith LHSCore
core [Pattern]
wps' []
lhsCoreAddSpine :: LHSCore -> [NamedArg Pattern] -> LHSCore
lhsCoreAddSpine :: LHSCore -> [NamedArg Pattern] -> LHSCore
lhsCoreAddSpine LHSCore
core [NamedArg Pattern]
ps0 =
case [NamedArg Pattern] -> Maybe (LHSPatternView, [NamedArg Pattern])
lhsPatternView [NamedArg Pattern]
ps0 of
Maybe (LHSPatternView, [NamedArg Pattern])
Nothing -> LHSCore
core
Just (LHSAppP [NamedArg Pattern]
ps , [NamedArg Pattern]
ps') -> LHSCore -> [NamedArg Pattern] -> LHSCore
lhsCoreApp LHSCore
core [NamedArg Pattern]
ps LHSCore -> [NamedArg Pattern] -> LHSCore
`lhsCoreAddSpine` [NamedArg Pattern]
ps'
Just (LHSWithP [Pattern]
wps, [NamedArg Pattern]
ps') -> LHSCore -> [Pattern] -> LHSCore
lhsCoreWith LHSCore
core [Pattern]
wps LHSCore -> [NamedArg Pattern] -> LHSCore
`lhsCoreAddSpine` [NamedArg Pattern]
ps'
mapLhsOriginalPattern :: (Pattern -> Pattern) -> LHS -> LHS
mapLhsOriginalPattern :: (Pattern -> Pattern) -> LHS -> LHS
mapLhsOriginalPattern Pattern -> Pattern
f lhs :: LHS
lhs@LHS{ lhsOriginalPattern :: LHS -> Pattern
lhsOriginalPattern = Pattern
p } =
LHS
lhs { lhsOriginalPattern :: Pattern
lhsOriginalPattern = Pattern -> Pattern
f Pattern
p }
mapLhsOriginalPatternM :: (Functor m, Applicative m) => (Pattern -> m Pattern) -> LHS -> m LHS
mapLhsOriginalPatternM :: (Pattern -> m Pattern) -> LHS -> m LHS
mapLhsOriginalPatternM Pattern -> m Pattern
f lhs :: LHS
lhs@LHS{ lhsOriginalPattern :: LHS -> Pattern
lhsOriginalPattern = Pattern
p } = Pattern -> m Pattern
f Pattern
p m Pattern -> (Pattern -> LHS) -> m LHS
forall (m :: * -> *) a b. Functor m => m a -> (a -> b) -> m b
<&> \ Pattern
p' ->
LHS
lhs { lhsOriginalPattern :: Pattern
lhsOriginalPattern = Pattern
p' }
hasCopatterns :: LHSCore -> Bool
hasCopatterns :: LHSCore -> Bool
hasCopatterns = \case
LHSHead{} -> Bool
False
LHSProj{} -> Bool
True
LHSWith LHSCore
h [Pattern]
_ [NamedArg Pattern]
_ -> LHSCore -> Bool
hasCopatterns LHSCore
h
class CPatternLike p where
foldrCPattern
:: Monoid m
=> (Pattern -> m -> m)
-> p -> m
default foldrCPattern
:: (Monoid m, Foldable f, CPatternLike q, f q ~ p)
=> (Pattern -> m -> m) -> p -> m
foldrCPattern = (q -> m) -> f q -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ((q -> m) -> f q -> m)
-> ((Pattern -> m -> m) -> q -> m)
-> (Pattern -> m -> m)
-> f q
-> m
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pattern -> m -> m) -> q -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern
traverseCPatternA :: (Applicative m, Functor m)
=> (Pattern -> m Pattern -> m Pattern)
-> p -> m p
default traverseCPatternA :: (Traversable f, CPatternLike q, f q ~ p, Applicative m, Functor m)
=> (Pattern -> m Pattern -> m Pattern)
-> p -> m p
traverseCPatternA = (q -> m q) -> f q -> m (f q)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((q -> m q) -> f q -> m (f q))
-> ((Pattern -> m Pattern -> m Pattern) -> q -> m q)
-> (Pattern -> m Pattern -> m Pattern)
-> f q
-> m (f q)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pattern -> m Pattern -> m Pattern) -> q -> m q
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA
traverseCPatternM
:: Monad m => (Pattern -> m Pattern)
-> (Pattern -> m Pattern)
-> p -> m p
default traverseCPatternM
:: (Traversable f, CPatternLike q, f q ~ p, Monad m)
=> (Pattern -> m Pattern)
-> (Pattern -> m Pattern)
-> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post = (q -> m q) -> f q -> m (f q)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse ((q -> m q) -> f q -> m (f q)) -> (q -> m q) -> f q -> m (f q)
forall a b. (a -> b) -> a -> b
$ (Pattern -> m Pattern) -> (Pattern -> m Pattern) -> q -> m q
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post
instance CPatternLike Pattern where
foldrCPattern :: (Pattern -> m -> m) -> Pattern -> m
foldrCPattern Pattern -> m -> m
f Pattern
p0 = Pattern -> m -> m
f Pattern
p0 (m -> m) -> m -> m
forall a b. (a -> b) -> a -> b
$
case Pattern
p0 of
AppP Pattern
p NamedArg Pattern
ps -> (Pattern -> m -> m) -> (Pattern, NamedArg Pattern) -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f (Pattern
p, NamedArg Pattern
ps)
RawAppP Range
_ [Pattern]
ps -> (Pattern -> m -> m) -> [Pattern] -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f [Pattern]
ps
OpAppP Range
_ QName
_ Set Name
_ [NamedArg Pattern]
ps -> (Pattern -> m -> m) -> [NamedArg Pattern] -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f [NamedArg Pattern]
ps
HiddenP Range
_ Named_ Pattern
ps -> (Pattern -> m -> m) -> Named_ Pattern -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f Named_ Pattern
ps
InstanceP Range
_ Named_ Pattern
ps -> (Pattern -> m -> m) -> Named_ Pattern -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f Named_ Pattern
ps
ParenP Range
_ Pattern
p -> (Pattern -> m -> m) -> Pattern -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f Pattern
p
AsP Range
_ Name
_ Pattern
p -> (Pattern -> m -> m) -> Pattern -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f Pattern
p
WithP Range
_ Pattern
p -> (Pattern -> m -> m) -> Pattern -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f Pattern
p
RecP Range
_ [FieldAssignment' Pattern]
ps -> (Pattern -> m -> m) -> [FieldAssignment' Pattern] -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f [FieldAssignment' Pattern]
ps
IdentP QName
_ -> m
forall a. Monoid a => a
mempty
WildP Range
_ -> m
forall a. Monoid a => a
mempty
DotP Range
_ WithExpr
_ -> m
forall a. Monoid a => a
mempty
AbsurdP Range
_ -> m
forall a. Monoid a => a
mempty
LitP Literal
_ -> m
forall a. Monoid a => a
mempty
QuoteP Range
_ -> m
forall a. Monoid a => a
mempty
EqualP Range
_ [(WithExpr, WithExpr)]
_ -> m
forall a. Monoid a => a
mempty
EllipsisP Range
_ -> m
forall a. Monoid a => a
mempty
traverseCPatternA :: (Pattern -> m Pattern -> m Pattern) -> Pattern -> m Pattern
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Pattern
p0 = Pattern -> m Pattern -> m Pattern
f Pattern
p0 (m Pattern -> m Pattern) -> m Pattern -> m Pattern
forall a b. (a -> b) -> a -> b
$ case Pattern
p0 of
AppP Pattern
p NamedArg Pattern
ps -> (Pattern -> NamedArg Pattern -> Pattern)
-> m Pattern -> m (NamedArg Pattern) -> m Pattern
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 Pattern -> NamedArg Pattern -> Pattern
AppP ((Pattern -> m Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Pattern
p) ((Pattern -> m Pattern -> m Pattern)
-> NamedArg Pattern -> m (NamedArg Pattern)
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f NamedArg Pattern
ps)
RawAppP Range
r [Pattern]
ps -> Range -> [Pattern] -> Pattern
RawAppP Range
r ([Pattern] -> Pattern) -> m [Pattern] -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern) -> [Pattern] -> m [Pattern]
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f [Pattern]
ps
OpAppP Range
r QName
x Set Name
xs [NamedArg Pattern]
ps -> Range -> QName -> Set Name -> [NamedArg Pattern] -> Pattern
OpAppP Range
r QName
x Set Name
xs ([NamedArg Pattern] -> Pattern)
-> m [NamedArg Pattern] -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern)
-> [NamedArg Pattern] -> m [NamedArg Pattern]
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f [NamedArg Pattern]
ps
HiddenP Range
r Named_ Pattern
p -> Range -> Named_ Pattern -> Pattern
HiddenP Range
r (Named_ Pattern -> Pattern) -> m (Named_ Pattern) -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern)
-> Named_ Pattern -> m (Named_ Pattern)
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Named_ Pattern
p
InstanceP Range
r Named_ Pattern
p -> Range -> Named_ Pattern -> Pattern
InstanceP Range
r (Named_ Pattern -> Pattern) -> m (Named_ Pattern) -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern)
-> Named_ Pattern -> m (Named_ Pattern)
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Named_ Pattern
p
ParenP Range
r Pattern
p -> Range -> Pattern -> Pattern
ParenP Range
r (Pattern -> Pattern) -> m Pattern -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Pattern
p
AsP Range
r Name
x Pattern
p -> Range -> Name -> Pattern -> Pattern
AsP Range
r Name
x (Pattern -> Pattern) -> m Pattern -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Pattern
p
WithP Range
r Pattern
p -> Range -> Pattern -> Pattern
WithP Range
r (Pattern -> Pattern) -> m Pattern -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f Pattern
p
RecP Range
r [FieldAssignment' Pattern]
ps -> Range -> [FieldAssignment' Pattern] -> Pattern
RecP Range
r ([FieldAssignment' Pattern] -> Pattern)
-> m [FieldAssignment' Pattern] -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern -> m Pattern)
-> [FieldAssignment' Pattern] -> m [FieldAssignment' Pattern]
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f [FieldAssignment' Pattern]
ps
IdentP QName
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
WildP Range
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
DotP Range
_ WithExpr
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
AbsurdP Range
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
LitP Literal
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
QuoteP Range
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
EqualP Range
_ [(WithExpr, WithExpr)]
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
EllipsisP Range
_ -> Pattern -> m Pattern
forall (f :: * -> *) a. Applicative f => a -> f a
pure Pattern
p0
traverseCPatternM :: (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Pattern -> m Pattern
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post = Pattern -> m Pattern
pre (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Pattern -> m Pattern
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Pattern -> m Pattern
recurse (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Pattern -> m Pattern
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> Pattern -> m Pattern
post
where
recurse :: Pattern -> m Pattern
recurse Pattern
p0 = case Pattern
p0 of
AppP Pattern
p NamedArg Pattern
ps -> (Pattern -> NamedArg Pattern -> Pattern)
-> (Pattern, NamedArg Pattern) -> Pattern
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Pattern -> NamedArg Pattern -> Pattern
AppP ((Pattern, NamedArg Pattern) -> Pattern)
-> m (Pattern, NamedArg Pattern) -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern)
-> (Pattern, NamedArg Pattern)
-> m (Pattern, NamedArg Pattern)
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post (Pattern
p, NamedArg Pattern
ps)
RawAppP Range
r [Pattern]
ps -> Range -> [Pattern] -> Pattern
RawAppP Range
r ([Pattern] -> Pattern) -> m [Pattern] -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> [Pattern] -> m [Pattern]
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post [Pattern]
ps
OpAppP Range
r QName
x Set Name
xs [NamedArg Pattern]
ps -> Range -> QName -> Set Name -> [NamedArg Pattern] -> Pattern
OpAppP Range
r QName
x Set Name
xs ([NamedArg Pattern] -> Pattern)
-> m [NamedArg Pattern] -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern)
-> [NamedArg Pattern]
-> m [NamedArg Pattern]
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post [NamedArg Pattern]
ps
HiddenP Range
r Named_ Pattern
p -> Range -> Named_ Pattern -> Pattern
HiddenP Range
r (Named_ Pattern -> Pattern) -> m (Named_ Pattern) -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Named_ Pattern -> m (Named_ Pattern)
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post Named_ Pattern
p
InstanceP Range
r Named_ Pattern
p -> Range -> Named_ Pattern -> Pattern
InstanceP Range
r (Named_ Pattern -> Pattern) -> m (Named_ Pattern) -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Named_ Pattern -> m (Named_ Pattern)
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post Named_ Pattern
p
ParenP Range
r Pattern
p -> Range -> Pattern -> Pattern
ParenP Range
r (Pattern -> Pattern) -> m Pattern -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post Pattern
p
AsP Range
r Name
x Pattern
p -> Range -> Name -> Pattern -> Pattern
AsP Range
r Name
x (Pattern -> Pattern) -> m Pattern -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post Pattern
p
WithP Range
r Pattern
p -> Range -> Pattern -> Pattern
WithP Range
r (Pattern -> Pattern) -> m Pattern -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> Pattern -> m Pattern
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post Pattern
p
RecP Range
r [FieldAssignment' Pattern]
ps -> Range -> [FieldAssignment' Pattern] -> Pattern
RecP Range
r ([FieldAssignment' Pattern] -> Pattern)
-> m [FieldAssignment' Pattern] -> m Pattern
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Pattern -> m Pattern)
-> (Pattern -> m Pattern)
-> [FieldAssignment' Pattern]
-> m [FieldAssignment' Pattern]
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post [FieldAssignment' Pattern]
ps
IdentP QName
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
WildP Range
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
DotP Range
_ WithExpr
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
AbsurdP Range
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
LitP Literal
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
QuoteP Range
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
EqualP Range
_ [(WithExpr, WithExpr)]
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
EllipsisP Range
_ -> Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern
p0
instance (CPatternLike a, CPatternLike b) => CPatternLike (a,b) where
foldrCPattern :: (Pattern -> m -> m) -> (a, b) -> m
foldrCPattern Pattern -> m -> m
f (a
p, b
p') =
(Pattern -> m -> m) -> a -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f a
p m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` (Pattern -> m -> m) -> b -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern Pattern -> m -> m
f b
p'
traverseCPatternA :: (Pattern -> m Pattern -> m Pattern) -> (a, b) -> m (a, b)
traverseCPatternA Pattern -> m Pattern -> m Pattern
f (a
p, b
p') =
(a -> b -> (a, b)) -> m a -> m b -> m (a, b)
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,)
((Pattern -> m Pattern -> m Pattern) -> a -> m a
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f a
p)
((Pattern -> m Pattern -> m Pattern) -> b -> m b
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA Pattern -> m Pattern -> m Pattern
f b
p')
traverseCPatternM :: (Pattern -> m Pattern)
-> (Pattern -> m Pattern) -> (a, b) -> m (a, b)
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post (a
p, b
p') =
(a -> b -> (a, b)) -> m a -> m b -> m (a, b)
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (,)
((Pattern -> m Pattern) -> (Pattern -> m Pattern) -> a -> m a
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post a
p)
((Pattern -> m Pattern) -> (Pattern -> m Pattern) -> b -> m b
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
post b
p')
instance CPatternLike p => CPatternLike (Arg p) where
instance CPatternLike p => CPatternLike (Named n p) where
instance CPatternLike p => CPatternLike [p] where
instance CPatternLike p => CPatternLike (Maybe p) where
instance CPatternLike p => CPatternLike (FieldAssignment' p) where
foldCPattern :: (CPatternLike p, Monoid m) => (Pattern -> m) -> p -> m
foldCPattern :: (Pattern -> m) -> p -> m
foldCPattern Pattern -> m
f = (Pattern -> m -> m) -> p -> m
forall p m.
(CPatternLike p, Monoid m) =>
(Pattern -> m -> m) -> p -> m
foldrCPattern ((Pattern -> m -> m) -> p -> m) -> (Pattern -> m -> m) -> p -> m
forall a b. (a -> b) -> a -> b
$ \ Pattern
p m
m -> Pattern -> m
f Pattern
p m -> m -> m
forall a. Monoid a => a -> a -> a
`mappend` m
m
preTraverseCPatternM
:: (CPatternLike p, Monad m)
=> (Pattern -> m Pattern)
-> p -> m p
preTraverseCPatternM :: (Pattern -> m Pattern) -> p -> m p
preTraverseCPatternM Pattern -> m Pattern
pre p
p = (Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
pre Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return p
p
postTraverseCPatternM
:: (CPatternLike p, Monad m)
=> (Pattern -> m Pattern)
-> p -> m p
postTraverseCPatternM :: (Pattern -> m Pattern) -> p -> m p
postTraverseCPatternM Pattern -> m Pattern
post p
p = (Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> (Pattern -> m Pattern) -> p -> m p
traverseCPatternM Pattern -> m Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return Pattern -> m Pattern
post p
p
mapCPattern :: CPatternLike p => (Pattern -> Pattern) -> p -> p
mapCPattern :: (Pattern -> Pattern) -> p -> p
mapCPattern Pattern -> Pattern
f = Identity p -> p
forall a. Identity a -> a
runIdentity (Identity p -> p) -> (p -> Identity p) -> p -> p
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pattern -> Identity Pattern) -> p -> Identity p
forall p (m :: * -> *).
(CPatternLike p, Monad m) =>
(Pattern -> m Pattern) -> p -> m p
postTraverseCPatternM (Pattern -> Identity Pattern
forall a. a -> Identity a
Identity (Pattern -> Identity Pattern)
-> (Pattern -> Pattern) -> Pattern -> Identity Pattern
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pattern -> Pattern
f)
patternQNames :: CPatternLike p => p -> [QName]
patternQNames :: p -> [QName]
patternQNames p
p = (Pattern -> Endo [QName]) -> p -> Endo [QName]
forall p m. (CPatternLike p, Monoid m) => (Pattern -> m) -> p -> m
foldCPattern Pattern -> Endo [QName]
f p
p Endo [QName] -> [QName] -> [QName]
forall a. Endo a -> a -> a
`appEndo` []
where
f :: Pattern -> Endo [QName]
f :: Pattern -> Endo [QName]
f = \case
IdentP QName
x -> ([QName] -> [QName]) -> Endo [QName]
forall a. (a -> a) -> Endo a
Endo (QName
x QName -> [QName] -> [QName]
forall a. a -> [a] -> [a]
:)
OpAppP Range
_ QName
x Set Name
_ [NamedArg Pattern]
_ -> ([QName] -> [QName]) -> Endo [QName]
forall a. (a -> a) -> Endo a
Endo (QName
x QName -> [QName] -> [QName]
forall a. a -> [a] -> [a]
:)
AsP Range
_ Name
x Pattern
_ -> Endo [QName]
forall a. Monoid a => a
mempty
AppP Pattern
_ NamedArg Pattern
_ -> Endo [QName]
forall a. Monoid a => a
mempty
WithP Range
_ Pattern
_ -> Endo [QName]
forall a. Monoid a => a
mempty
RawAppP Range
_ [Pattern]
_ -> Endo [QName]
forall a. Monoid a => a
mempty
HiddenP Range
_ Named_ Pattern
_ -> Endo [QName]
forall a. Monoid a => a
mempty
ParenP Range
_ Pattern
_ -> Endo [QName]
forall a. Monoid a => a
mempty
WildP Range
_ -> Endo [QName]
forall a. Monoid a => a
mempty
AbsurdP Range
_ -> Endo [QName]
forall a. Monoid a => a
mempty
DotP Range
_ WithExpr
_ -> Endo [QName]
forall a. Monoid a => a
mempty
LitP Literal
_ -> Endo [QName]
forall a. Monoid a => a
mempty
QuoteP Range
_ -> Endo [QName]
forall a. Monoid a => a
mempty
InstanceP Range
_ Named_ Pattern
_ -> Endo [QName]
forall a. Monoid a => a
mempty
RecP Range
_ [FieldAssignment' Pattern]
_ -> Endo [QName]
forall a. Monoid a => a
mempty
EqualP Range
_ [(WithExpr, WithExpr)]
_ -> Endo [QName]
forall a. Monoid a => a
mempty
EllipsisP Range
_ -> Endo [QName]
forall a. Monoid a => a
mempty
patternNames :: Pattern -> [Name]
patternNames :: Pattern -> [Name]
patternNames = (QName -> Name) -> [QName] -> [Name]
forall a b. (a -> b) -> [a] -> [b]
map QName -> Name
unqualify ([QName] -> [Name]) -> (Pattern -> [QName]) -> Pattern -> [Name]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pattern -> [QName]
forall p. CPatternLike p => p -> [QName]
patternQNames
hasWithPatterns :: CPatternLike p => p -> Bool
hasWithPatterns :: p -> Bool
hasWithPatterns = Any -> Bool
getAny (Any -> Bool) -> (p -> Any) -> p -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pattern -> Any) -> p -> Any
forall p m. (CPatternLike p, Monoid m) => (Pattern -> m) -> p -> m
foldCPattern (Bool -> Any
Any (Bool -> Any) -> (Pattern -> Bool) -> Pattern -> Any
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pattern -> Bool
isWithPattern)
isWithPattern :: Pattern -> Bool
isWithPattern :: Pattern -> Bool
isWithPattern = \case
WithP{} -> Bool
True
Pattern
_ -> Bool
False
numberOfWithPatterns :: CPatternLike p => p -> Int
numberOfWithPatterns :: p -> Int
numberOfWithPatterns = Sum Int -> Int
forall a. Sum a -> a
getSum (Sum Int -> Int) -> (p -> Sum Int) -> p -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Pattern -> Sum Int) -> p -> Sum Int
forall p m. (CPatternLike p, Monoid m) => (Pattern -> m) -> p -> m
foldCPattern (Int -> Sum Int
forall a. a -> Sum a
Sum (Int -> Sum Int) -> (Pattern -> Int) -> Pattern -> Sum Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pattern -> Int
forall p. Num p => Pattern -> p
f)
where f :: Pattern -> p
f Pattern
p = if Pattern -> Bool
isWithPattern Pattern
p then p
1 else p
0
hasEllipsis' :: CPatternLike p => p -> AffineHole Pattern p
hasEllipsis' :: p -> AffineHole Pattern p
hasEllipsis' = (Pattern
-> AffineHole Pattern Pattern -> AffineHole Pattern Pattern)
-> p -> AffineHole Pattern p
forall p (m :: * -> *).
(CPatternLike p, Applicative m, Functor m) =>
(Pattern -> m Pattern -> m Pattern) -> p -> m p
traverseCPatternA ((Pattern
-> AffineHole Pattern Pattern -> AffineHole Pattern Pattern)
-> p -> AffineHole Pattern p)
-> (Pattern
-> AffineHole Pattern Pattern -> AffineHole Pattern Pattern)
-> p
-> AffineHole Pattern p
forall a b. (a -> b) -> a -> b
$ \ Pattern
p AffineHole Pattern Pattern
mp ->
case Pattern
p of
EllipsisP{} -> (Pattern -> Pattern) -> Pattern -> AffineHole Pattern Pattern
forall r a. (r -> a) -> r -> AffineHole r a
OneHole Pattern -> Pattern
forall a. a -> a
id Pattern
p
Pattern
_ -> AffineHole Pattern Pattern
mp
reintroduceEllipsis :: ExpandedEllipsis -> Pattern -> Pattern
reintroduceEllipsis :: ExpandedEllipsis -> Pattern -> Pattern
reintroduceEllipsis ExpandedEllipsis
NoEllipsis Pattern
p = Pattern
p
reintroduceEllipsis (ExpandedEllipsis Range
r Int
k) Pattern
p =
let core :: Pattern
core = Range -> Pattern
EllipsisP Range
r
wargs :: [NamedArg Pattern]
wargs = ([NamedArg Pattern], [NamedArg Pattern]) -> [NamedArg Pattern]
forall a b. (a, b) -> b
snd (([NamedArg Pattern], [NamedArg Pattern]) -> [NamedArg Pattern])
-> ([NamedArg Pattern], [NamedArg Pattern]) -> [NamedArg Pattern]
forall a b. (a -> b) -> a -> b
$ Int
-> [NamedArg Pattern] -> ([NamedArg Pattern], [NamedArg Pattern])
forall p. IsWithP p => Int -> [p] -> ([p], [p])
splitEllipsis Int
k ([NamedArg Pattern] -> ([NamedArg Pattern], [NamedArg Pattern]))
-> [NamedArg Pattern] -> ([NamedArg Pattern], [NamedArg Pattern])
forall a b. (a -> b) -> a -> b
$ Pattern -> [NamedArg Pattern]
patternAppView Pattern
p
in (Pattern -> NamedArg Pattern -> Pattern)
-> Pattern -> [NamedArg Pattern] -> Pattern
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl Pattern -> NamedArg Pattern -> Pattern
AppP Pattern
core [NamedArg Pattern]
wargs
splitEllipsis :: (IsWithP p) => Int -> [p] -> ([p],[p])
splitEllipsis :: Int -> [p] -> ([p], [p])
splitEllipsis Int
k [] = ([] , [])
splitEllipsis Int
k (p
p:[p]
ps)
| Maybe p -> Bool
forall a. Maybe a -> Bool
isJust (p -> Maybe p
forall p. IsWithP p => p -> Maybe p
isWithP p
p) = if
| Int
k Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 -> ([] , p
pp -> [p] -> [p]
forall a. a -> [a] -> [a]
:[p]
ps)
| Bool
otherwise -> ([p] -> [p]) -> ([p], [p]) -> ([p], [p])
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first (p
pp -> [p] -> [p]
forall a. a -> [a] -> [a]
:) (([p], [p]) -> ([p], [p])) -> ([p], [p]) -> ([p], [p])
forall a b. (a -> b) -> a -> b
$ Int -> [p] -> ([p], [p])
forall p. IsWithP p => Int -> [p] -> ([p], [p])
splitEllipsis (Int
kInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1) [p]
ps
| Bool
otherwise = ([p] -> [p]) -> ([p], [p]) -> ([p], [p])
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (b, d) (c, d)
first (p
pp -> [p] -> [p]
forall a. a -> [a] -> [a]
:) (([p], [p]) -> ([p], [p])) -> ([p], [p]) -> ([p], [p])
forall a b. (a -> b) -> a -> b
$ Int -> [p] -> ([p], [p])
forall p. IsWithP p => Int -> [p] -> ([p], [p])
splitEllipsis Int
k [p]
ps
patternAppView :: Pattern -> [NamedArg Pattern]
patternAppView :: Pattern -> [NamedArg Pattern]
patternAppView Pattern
p = case Pattern
p of
AppP Pattern
p NamedArg Pattern
arg -> Pattern -> [NamedArg Pattern]
patternAppView Pattern
p [NamedArg Pattern] -> [NamedArg Pattern] -> [NamedArg Pattern]
forall a. [a] -> [a] -> [a]
++ [NamedArg Pattern
arg]
OpAppP Range
_ QName
x Set Name
_ [NamedArg Pattern]
ps -> Pattern -> NamedArg Pattern
forall a. a -> NamedArg a
defaultNamedArg (QName -> Pattern
IdentP QName
x) NamedArg Pattern -> [NamedArg Pattern] -> [NamedArg Pattern]
forall a. a -> [a] -> [a]
: [NamedArg Pattern]
ps
ParenP Range
_ Pattern
p -> Pattern -> [NamedArg Pattern]
patternAppView Pattern
p
RawAppP Range
_ [Pattern]
_ -> [NamedArg Pattern]
forall a. HasCallStack => a
__IMPOSSIBLE__
Pattern
_ -> [ Pattern -> NamedArg Pattern
forall a. a -> NamedArg a
defaultNamedArg Pattern
p ]