{-# OPTIONS_GHC -fno-warn-orphans #-}

module Agda.TypeChecking.Serialise.Instances.Abstract where

import qualified Data.Map as Map
import qualified Data.Set as Set

import Agda.Syntax.Common
import qualified Agda.Syntax.Abstract as A
import Agda.Syntax.Info
import Agda.Syntax.Scope.Base
import Agda.Syntax.Fixity

import Agda.TypeChecking.Serialise.Base
import Agda.TypeChecking.Serialise.Instances.Common () --instance only

import Agda.Utils.Functor
import Agda.Utils.Lens
import Agda.Utils.Impossible

-- Don't serialize the tactic.
instance EmbPrj A.BindName where
  icod_ :: BindName -> S Int32
icod_ (A.BindName Name
a) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Name -> BindName
A.BindName Name
a
  value :: Int32 -> R BindName
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN Name -> BindName
A.BindName

instance EmbPrj Scope where
  icod_ :: Scope -> S Int32
icod_ (Scope ModuleName
a [ModuleName]
b ScopeNameSpaces
c Map QName ModuleName
d Maybe DataOrRecordModule
e) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' ModuleName
-> [ModuleName]
-> ScopeNameSpaces
-> Map QName ModuleName
-> Maybe DataOrRecordModule
-> Scope
Scope ModuleName
a [ModuleName]
b ScopeNameSpaces
c Map QName ModuleName
d Maybe DataOrRecordModule
e

  value :: Int32 -> R Scope
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN ModuleName
-> [ModuleName]
-> ScopeNameSpaces
-> Map QName ModuleName
-> Maybe DataOrRecordModule
-> Scope
Scope

instance EmbPrj DataOrRecordModule where
  icod_ :: DataOrRecordModule -> S Int32
icod_ DataOrRecordModule
IsDataModule   = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' DataOrRecordModule
IsDataModule
  icod_ DataOrRecordModule
IsRecordModule = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
0 DataOrRecordModule
IsRecordModule

  value :: Int32 -> R DataOrRecordModule
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase forall a b. (a -> b) -> a -> b
$ \case
    []  -> forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN DataOrRecordModule
IsDataModule
    [Int32
0] -> forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN DataOrRecordModule
IsRecordModule
    Node
_   -> forall a. R a
malformed

instance EmbPrj NameSpaceId where
  icod_ :: NameSpaceId -> S Int32
icod_ NameSpaceId
PublicNS        = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' NameSpaceId
PublicNS
  icod_ NameSpaceId
PrivateNS       = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 NameSpaceId
PrivateNS
  icod_ NameSpaceId
ImportedNS      = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
2 NameSpaceId
ImportedNS

  value :: Int32 -> R NameSpaceId
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase forall {a}. (Eq a, Num a) => [a] -> R NameSpaceId
valu where
    valu :: [a]
-> Arrows
     (Constant Int32 (Domains NameSpaceId)) (R (CoDomain NameSpaceId))
valu []  = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN NameSpaceId
PublicNS
    valu [a
1] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN NameSpaceId
PrivateNS
    valu [a
2] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN NameSpaceId
ImportedNS
    valu [a]
_   = forall a. R a
malformed

instance EmbPrj Access where
  icod_ :: Access -> S Int32
icod_ (PrivateAccess Origin
UserWritten) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
0 ()
  icod_ PrivateAccess{}             = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 ()
  icod_ Access
PublicAccess                = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Access
PublicAccess

  value :: Int32 -> R Access
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase forall {a}. (Eq a, Num a) => [a] -> R Access
valu where
    valu :: [a]
-> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access))
valu [a
0] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN forall a b. (a -> b) -> a -> b
$ Origin -> Access
PrivateAccess Origin
UserWritten
    valu [a
1] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN forall a b. (a -> b) -> a -> b
$ Origin -> Access
PrivateAccess Origin
Inserted
    valu []  = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Access
PublicAccess
    valu [a]
_   = forall a. R a
malformed

instance EmbPrj NameSpace where
  icod_ :: NameSpace -> S Int32
icod_ (NameSpace NamesInScope
a ModulesInScope
b InScopeSet
c) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
NameSpace NamesInScope
a ModulesInScope
b InScopeSet
c

  value :: Int32 -> R NameSpace
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace
NameSpace

instance EmbPrj WhyInScope where
  icod_ :: WhyInScope -> S Int32
icod_ WhyInScope
Defined       = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' WhyInScope
Defined
  icod_ (Opened QName
a WhyInScope
b)  = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
0 QName -> WhyInScope -> WhyInScope
Opened QName
a WhyInScope
b
  icod_ (Applied QName
a WhyInScope
b) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 QName -> WhyInScope -> WhyInScope
Applied QName
a WhyInScope
b

  value :: Int32 -> R WhyInScope
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R WhyInScope
valu where
    valu :: Node
-> Arrows
     (Constant Int32 (Domains WhyInScope)) (R (CoDomain WhyInScope))
valu []        = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN WhyInScope
Defined
    valu [Int32
0, Int32
a, Int32
b] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN QName -> WhyInScope -> WhyInScope
Opened Int32
a Int32
b
    valu [Int32
1, Int32
a, Int32
b] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN QName -> WhyInScope -> WhyInScope
Applied Int32
a Int32
b
    valu Node
_         = forall a. R a
malformed

-- Issue #1346: QNames are shared on their nameIds, so serializing will lose fixity information for
-- rebound fixities. We don't care about that in terms, but in the scope it's important to keep the
-- right fixity. Thus serialize the fixity separately.

data AbsNameWithFixity = AbsNameWithFixity Fixity A.QName KindOfName WhyInScope NameMetadata

toAbsName :: AbsNameWithFixity -> AbstractName
toAbsName :: AbsNameWithFixity -> AbstractName
toAbsName (AbsNameWithFixity Fixity
fx QName
a KindOfName
b WhyInScope
c NameMetadata
d) = QName -> KindOfName -> WhyInScope -> NameMetadata -> AbstractName
AbsName (forall i o. Lens' i o -> LensSet i o
set forall a. LensFixity a => Lens' Fixity a
lensFixity Fixity
fx QName
a) KindOfName
b WhyInScope
c NameMetadata
d

fromAbsName :: AbstractName -> AbsNameWithFixity
fromAbsName :: AbstractName -> AbsNameWithFixity
fromAbsName (AbsName QName
a KindOfName
b WhyInScope
c NameMetadata
d) = Fixity
-> QName
-> KindOfName
-> WhyInScope
-> NameMetadata
-> AbsNameWithFixity
AbsNameWithFixity (QName
a forall o i. o -> Lens' i o -> i
^. forall a. LensFixity a => Lens' Fixity a
lensFixity) QName
a KindOfName
b WhyInScope
c NameMetadata
d

instance EmbPrj AbsNameWithFixity where
  icod_ :: AbsNameWithFixity -> S Int32
icod_ (AbsNameWithFixity Fixity
a QName
b KindOfName
c WhyInScope
d NameMetadata
e) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Fixity
-> QName
-> KindOfName
-> WhyInScope
-> NameMetadata
-> AbsNameWithFixity
AbsNameWithFixity Fixity
a QName
b KindOfName
c WhyInScope
d NameMetadata
e
  value :: Int32 -> R AbsNameWithFixity
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN Fixity
-> QName
-> KindOfName
-> WhyInScope
-> NameMetadata
-> AbsNameWithFixity
AbsNameWithFixity

instance EmbPrj AbstractName where
  icod_ :: AbstractName -> S Int32
icod_ AbstractName
a = forall a. EmbPrj a => a -> S Int32
icod_ (AbstractName -> AbsNameWithFixity
fromAbsName AbstractName
a)
  value :: Int32 -> R AbstractName
value = AbsNameWithFixity -> AbstractName
toAbsName forall (m :: * -> *) b c a.
Functor m =>
(b -> c) -> (a -> m b) -> a -> m c
<.> forall a. EmbPrj a => Int32 -> R a
value

instance EmbPrj NameMetadata where
  icod_ :: NameMetadata -> S Int32
icod_ NameMetadata
NoMetadata                  = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' NameMetadata
NoMetadata
  icod_ (GeneralizedVarsMetadata Map QName Name
a) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Map QName Name -> NameMetadata
GeneralizedVarsMetadata Map QName Name
a

  value :: Int32 -> R NameMetadata
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R NameMetadata
valu where
    valu :: Node
-> Arrows
     (Constant Int32 (Domains NameMetadata)) (R (CoDomain NameMetadata))
valu []  = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN NameMetadata
NoMetadata
    valu [Int32
a] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Map QName Name -> NameMetadata
GeneralizedVarsMetadata Int32
a
    valu Node
_   = forall a. R a
malformed

instance EmbPrj A.Suffix where
  icod_ :: Suffix -> S Int32
icod_ Suffix
A.NoSuffix   = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Suffix
A.NoSuffix
  icod_ (A.Suffix Integer
a) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Integer -> Suffix
A.Suffix Integer
a

  value :: Int32 -> R Suffix
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R Suffix
valu where
    valu :: Node
-> Arrows (Constant Int32 (Domains Suffix)) (R (CoDomain Suffix))
valu []  = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Suffix
A.NoSuffix
    valu [Int32
a] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Integer -> Suffix
A.Suffix Int32
a
    valu Node
_   = forall a. R a
malformed

instance EmbPrj AbstractModule where
  icod_ :: AbstractModule -> S Int32
icod_ (AbsModule ModuleName
a WhyInScope
b) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' ModuleName -> WhyInScope -> AbstractModule
AbsModule ModuleName
a WhyInScope
b

  value :: Int32 -> R AbstractModule
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN ModuleName -> WhyInScope -> AbstractModule
AbsModule

instance EmbPrj KindOfName where
  -- -- Enums have a generic EmbPrj
  --
  -- icod_ DefName        = icodeN' DefName
  -- icod_ ConName        = icodeN 1 ConName
  -- icod_ FldName        = icodeN 2 FldName
  -- icod_ PatternSynName = icodeN 3 PatternSynName
  -- icod_ QuotableName   = icodeN 4 QuotableName
  -- icod_ MacroName      = icodeN 5 MacroName
  -- icod_ GeneralizeName = icodeN 6 GeneralizeName
  -- icod_ DisallowedGeneralizeName = icodeN 7 DisallowedGeneralizeName

  -- value = vcase valu where
  --   valu []  = valuN DefName
  --   valu [1] = valuN ConName
  --   valu [2] = valuN FldName
  --   valu [3] = valuN PatternSynName
  --   valu [4] = valuN QuotableName
  --   valu [5] = valuN MacroName
  --   valu [6] = valuN GeneralizeName
  --   valu [7] = valuN DisallowedGeneralizeName
  --   valu _   = malformed

instance EmbPrj BindingSource where
  icod_ :: BindingSource -> S Int32
icod_ BindingSource
LambdaBound   = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' BindingSource
LambdaBound
  icod_ BindingSource
PatternBound  = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 BindingSource
PatternBound
  icod_ BindingSource
LetBound      = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
2 BindingSource
LetBound
  icod_ BindingSource
WithBound     = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
3 BindingSource
WithBound

  value :: Int32 -> R BindingSource
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase forall {a}. (Eq a, Num a) => [a] -> R BindingSource
valu where
    valu :: [a]
-> Arrows
     (Constant Int32 (Domains BindingSource))
     (R (CoDomain BindingSource))
valu []  = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN BindingSource
LambdaBound
    valu [a
1] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN BindingSource
PatternBound
    valu [a
2] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN BindingSource
LetBound
    valu [a
3] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN BindingSource
WithBound
    valu [a]
_   = forall a. R a
malformed

instance EmbPrj LocalVar where
  icod_ :: LocalVar -> S Int32
icod_ (LocalVar Name
a BindingSource
b [AbstractName]
c)  = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Name -> BindingSource -> [AbstractName] -> LocalVar
LocalVar Name
a BindingSource
b [AbstractName]
c

  value :: Int32 -> R LocalVar
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN Name -> BindingSource -> [AbstractName] -> LocalVar
LocalVar

instance EmbPrj ConPatInfo where
  icod_ :: ConPatInfo -> S Int32
icod_ (ConPatInfo ConOrigin
a PatInfo
_ ConPatLazy
b) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' (\ConOrigin
a ConPatLazy
b -> ConOrigin -> PatInfo -> ConPatLazy -> ConPatInfo
ConPatInfo ConOrigin
a PatInfo
patNoRange ConPatLazy
b) ConOrigin
a ConPatLazy
b

  value :: Int32 -> R ConPatInfo
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN forall a b. (a -> b) -> a -> b
$ \ConOrigin
a ConPatLazy
b -> ConOrigin -> PatInfo -> ConPatLazy -> ConPatInfo
ConPatInfo ConOrigin
a PatInfo
patNoRange ConPatLazy
b

instance EmbPrj ConPatLazy

-- Only for pattern synonyms (where a is Void)
instance EmbPrj a => EmbPrj (A.Pattern' a) where
  icod_ :: Pattern' a -> S Int32
icod_ (A.VarP BindName
a)            = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
0 forall e. BindName -> Pattern' e
A.VarP BindName
a
  icod_ (A.ConP ConPatInfo
a AmbiguousQName
b NAPs a
c)        = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 forall e. ConPatInfo -> AmbiguousQName -> NAPs e -> Pattern' e
A.ConP ConPatInfo
a AmbiguousQName
b NAPs a
c
  icod_ (A.DefP PatInfo
p AmbiguousQName
a NAPs a
b)        = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
2 (forall e. PatInfo -> AmbiguousQName -> NAPs e -> Pattern' e
A.DefP PatInfo
p) AmbiguousQName
a NAPs a
b
  icod_ t :: Pattern' a
t@(A.WildP PatInfo
p)         = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
3 Pattern' a
t
  icod_ (A.AsP PatInfo
p BindName
a Pattern' a
b)         = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
4 (forall e. PatInfo -> BindName -> Pattern' e -> Pattern' e
A.AsP PatInfo
p) BindName
a Pattern' a
b
  icod_ (A.DotP PatInfo
p a
a)          = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
5 (forall e. PatInfo -> e -> Pattern' e
A.DotP PatInfo
p) a
a
  icod_ t :: Pattern' a
t@(A.AbsurdP PatInfo
_)       = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
6 Pattern' a
t
  icod_ (A.LitP PatInfo
i Literal
a)          = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
7 (forall e. PatInfo -> Literal -> Pattern' e
A.LitP PatInfo
i) Literal
a
  icod_ (A.ProjP PatInfo
p ProjOrigin
a AmbiguousQName
b)       = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
8 (forall e. PatInfo -> ProjOrigin -> AmbiguousQName -> Pattern' e
A.ProjP PatInfo
p) ProjOrigin
a AmbiguousQName
b
  icod_ (A.PatternSynP PatInfo
p AmbiguousQName
a NAPs a
b) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
9 (forall e. PatInfo -> AmbiguousQName -> NAPs e -> Pattern' e
A.PatternSynP PatInfo
p) AmbiguousQName
a NAPs a
b
  icod_ (A.RecP PatInfo
p [FieldAssignment' (Pattern' a)]
a)          = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
10 (forall e. PatInfo -> [FieldAssignment' (Pattern' e)] -> Pattern' e
A.RecP PatInfo
p) [FieldAssignment' (Pattern' a)]
a
  icod_ (A.EqualP PatInfo
_ [(a, a)]
a)        = forall a. HasCallStack => a
__IMPOSSIBLE__
  icod_ (A.WithP PatInfo
i Pattern' a
a)         = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
11 (forall e. PatInfo -> Pattern' e -> Pattern' e
A.WithP PatInfo
i) Pattern' a
a
  icod_ (A.AnnP PatInfo
i a
a Pattern' a
p)        = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
12 (forall e. PatInfo -> e -> Pattern' e -> Pattern' e
A.AnnP PatInfo
i) a
a Pattern' a
p

  value :: Int32 -> R (Pattern' a)
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase forall {e}. EmbPrj e => Node -> R (Pattern' e)
valu where
    valu :: Node -> R (Pattern' e)
valu [Int32
0, Int32
a]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN forall e. BindName -> Pattern' e
A.VarP Int32
a
    valu [Int32
1, Int32
a, Int32
b, Int32
c] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN forall e. ConPatInfo -> AmbiguousQName -> NAPs e -> Pattern' e
A.ConP Int32
a Int32
b Int32
c
    valu [Int32
2, Int32
a, Int32
b]    = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> AmbiguousQName -> NAPs e -> Pattern' e
A.DefP PatInfo
i) Int32
a Int32
b
    valu [Int32
3]          = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> Pattern' e
A.WildP PatInfo
i)
    valu [Int32
4, Int32
a, Int32
b]    = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> BindName -> Pattern' e -> Pattern' e
A.AsP PatInfo
i) Int32
a Int32
b
    valu [Int32
5, Int32
a]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> e -> Pattern' e
A.DotP PatInfo
i) Int32
a
    valu [Int32
6]          = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> Pattern' e
A.AbsurdP PatInfo
i)
    valu [Int32
7, Int32
a]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> Literal -> Pattern' e
A.LitP PatInfo
i) Int32
a
    valu [Int32
8, Int32
a, Int32
b]    = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> ProjOrigin -> AmbiguousQName -> Pattern' e
A.ProjP PatInfo
i) Int32
a Int32
b
    valu [Int32
9, Int32
a, Int32
b]    = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> AmbiguousQName -> NAPs e -> Pattern' e
A.PatternSynP PatInfo
i) Int32
a Int32
b
    valu [Int32
10, Int32
a]      = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> [FieldAssignment' (Pattern' e)] -> Pattern' e
A.RecP PatInfo
i) Int32
a
    valu [Int32
11, Int32
a]      = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> Pattern' e -> Pattern' e
A.WithP PatInfo
i) Int32
a
    valu [Int32
12, Int32
a, Int32
b]   = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN (forall e. PatInfo -> e -> Pattern' e -> Pattern' e
A.AnnP PatInfo
i) Int32
a Int32
b
    valu Node
_            = forall a. R a
malformed

    i :: PatInfo
i = PatInfo
patNoRange

instance EmbPrj ParenPreference where
  icod_ :: ParenPreference -> S Int32
icod_ ParenPreference
PreferParen     = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' ParenPreference
PreferParen
  icod_ ParenPreference
PreferParenless = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 ParenPreference
PreferParenless
  value :: Int32 -> R ParenPreference
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase forall {a}. (Eq a, Num a) => [a] -> R ParenPreference
valu where
    valu :: [a]
-> Arrows
     (Constant Int32 (Domains ParenPreference))
     (R (CoDomain ParenPreference))
valu []  = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN ParenPreference
PreferParen
    valu [a
1] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN ParenPreference
PreferParenless
    valu [a]
_   = forall a. R a
malformed

instance EmbPrj Precedence where
  icod_ :: Precedence -> S Int32
icod_ Precedence
TopCtx                 = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' Precedence
TopCtx
  icod_ Precedence
FunctionSpaceDomainCtx = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
1 Precedence
FunctionSpaceDomainCtx
  icod_ (LeftOperandCtx Fixity
a)     = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
2 Fixity -> Precedence
LeftOperandCtx Fixity
a
  icod_ (RightOperandCtx Fixity
a ParenPreference
b)  = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
3 Fixity -> ParenPreference -> Precedence
RightOperandCtx Fixity
a ParenPreference
b
  icod_ Precedence
FunctionCtx            = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
4 Precedence
FunctionCtx
  icod_ (ArgumentCtx ParenPreference
a)        = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
5 ParenPreference -> Precedence
ArgumentCtx ParenPreference
a
  icod_ Precedence
InsideOperandCtx       = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
6 Precedence
InsideOperandCtx
  icod_ Precedence
WithFunCtx             = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
7 Precedence
WithFunCtx
  icod_ Precedence
WithArgCtx             = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
8 Precedence
WithArgCtx
  icod_ Precedence
DotPatternCtx          = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
Int32 -> t -> Arrows (Domains t) (S Int32)
icodeN Int32
9 Precedence
DotPatternCtx

  value :: Int32 -> R Precedence
value = forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R Precedence
valu where
    valu :: Node
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
valu []        = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
TopCtx
    valu [Int32
1]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
FunctionSpaceDomainCtx
    valu [Int32
2, Int32
a]    = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Fixity -> Precedence
LeftOperandCtx Int32
a
    valu [Int32
3, Int32
a, Int32
b] = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Fixity -> ParenPreference -> Precedence
RightOperandCtx Int32
a Int32
b
    valu [Int32
4]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
FunctionCtx
    valu [Int32
5, Int32
a]    = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN ParenPreference -> Precedence
ArgumentCtx Int32
a
    valu [Int32
6]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
InsideOperandCtx
    valu [Int32
7]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
WithFunCtx
    valu [Int32
8]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
WithArgCtx
    valu [Int32
9]       = forall t.
(VALU t (IsBase t),
 Currying (Constant Int32 (Domains t)) (R (CoDomain t)),
 All EmbPrj (Domains t)) =>
t -> Arrows (Constant Int32 (Domains t)) (R (CoDomain t))
valuN Precedence
DotPatternCtx
    valu Node
_         = forall a. R a
malformed

instance EmbPrj ScopeInfo where
  icod_ :: ScopeInfo -> S Int32
icod_ (ScopeInfo ModuleName
a Map ModuleName Scope
b LocalVars
c LocalVars
d PrecedenceStack
e NameMap
f ModuleMap
g InScopeSet
h Fixities
i Polarities
j) = forall t.
(ICODE t (IsBase t), Currying (Domains t) (S Int32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Int32)
icodeN' (\ ModuleName
a Map ModuleName Scope
b LocalVars
c LocalVars
d PrecedenceStack
e -> ModuleName
-> Map ModuleName Scope
-> LocalVars
-> LocalVars
-> PrecedenceStack
-> NameMap
-> ModuleMap
-> InScopeSet
-> Fixities
-> Polarities
-> ScopeInfo
ScopeInfo ModuleName
a Map ModuleName Scope
b LocalVars
c LocalVars
d PrecedenceStack
e NameMap
f ModuleMap
g InScopeSet
h Fixities
i Polarities
j) ModuleName
a Map ModuleName Scope
b LocalVars
c LocalVars
d PrecedenceStack
e

  value :: Int32 -> R ScopeInfo
value = forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN (\ ModuleName
a Map ModuleName Scope
b LocalVars
c LocalVars
d PrecedenceStack
e -> ModuleName
-> Map ModuleName Scope
-> LocalVars
-> LocalVars
-> PrecedenceStack
-> NameMap
-> ModuleMap
-> InScopeSet
-> Fixities
-> Polarities
-> ScopeInfo
ScopeInfo ModuleName
a Map ModuleName Scope
b LocalVars
c LocalVars
d PrecedenceStack
e forall k a. Map k a
Map.empty forall k a. Map k a
Map.empty forall a. Set a
Set.empty forall k a. Map k a
Map.empty forall k a. Map k a
Map.empty)

instance EmbPrj NameOrModule