{-# 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) = (Name -> BindName) -> Name -> S Int32
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 = (Name -> BindName) -> Int32 -> R (CoDomain (Name -> BindName))
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) = (ModuleName
 -> [ModuleName]
 -> ScopeNameSpaces
 -> Map QName ModuleName
 -> Maybe DataOrRecordModule
 -> Scope)
-> ModuleName
-> [ModuleName]
-> ScopeNameSpaces
-> Map QName ModuleName
-> Maybe DataOrRecordModule
-> S Int32
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 = (ModuleName
 -> [ModuleName]
 -> ScopeNameSpaces
 -> Map QName ModuleName
 -> Maybe DataOrRecordModule
 -> Scope)
-> Int32
-> R (CoDomain
        (ModuleName
         -> [ModuleName]
         -> ScopeNameSpaces
         -> Map QName ModuleName
         -> Maybe DataOrRecordModule
         -> Scope))
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   = DataOrRecordModule -> Arrows (Domains DataOrRecordModule) (S Int32)
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 = Int32
-> DataOrRecordModule
-> Arrows (Domains DataOrRecordModule) (S Int32)
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 = (Node -> R DataOrRecordModule) -> Int32 -> R DataOrRecordModule
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase ((Node -> R DataOrRecordModule) -> Int32 -> R DataOrRecordModule)
-> (Node -> R DataOrRecordModule) -> Int32 -> R DataOrRecordModule
forall a b. (a -> b) -> a -> b
$ \case
    []  -> DataOrRecordModule
-> Arrows
     (Constant Int32 (Domains DataOrRecordModule))
     (R (CoDomain DataOrRecordModule))
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] -> DataOrRecordModule
-> Arrows
     (Constant Int32 (Domains DataOrRecordModule))
     (R (CoDomain DataOrRecordModule))
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
_   -> R DataOrRecordModule
forall a. R a
malformed

instance EmbPrj NameSpaceId where
  icod_ :: NameSpaceId -> S Int32
icod_ NameSpaceId
PublicNS        = NameSpaceId -> Arrows (Domains NameSpaceId) (S Int32)
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       = Int32 -> NameSpaceId -> Arrows (Domains NameSpaceId) (S Int32)
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      = Int32 -> NameSpaceId -> Arrows (Domains NameSpaceId) (S Int32)
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 = (Node -> R NameSpaceId) -> Int32 -> R NameSpaceId
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R NameSpaceId
forall a. (Eq a, Num a) => [a] -> R NameSpaceId
valu where
    valu :: [a] -> R NameSpaceId
valu []  = NameSpaceId
-> Arrows
     (Constant Int32 (Domains NameSpaceId)) (R (CoDomain NameSpaceId))
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] = NameSpaceId
-> Arrows
     (Constant Int32 (Domains NameSpaceId)) (R (CoDomain NameSpaceId))
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] = NameSpaceId
-> Arrows
     (Constant Int32 (Domains NameSpaceId)) (R (CoDomain NameSpaceId))
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]
_   = R NameSpaceId
forall a. R a
malformed

instance EmbPrj Access where
  icod_ :: Access -> S Int32
icod_ (PrivateAccess Origin
UserWritten) = Int32 -> () -> Arrows (Domains ()) (S Int32)
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{}             = Int32 -> () -> Arrows (Domains ()) (S Int32)
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                = Access -> Arrows (Domains Access) (S Int32)
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 = (Node -> R Access) -> Int32 -> R Access
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R Access
forall a. (Eq a, Num a) => [a] -> R Access
valu where
    valu :: [a] -> R Access
valu [a
0] = Access
-> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access))
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
 -> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access)))
-> Access
-> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access))
forall a b. (a -> b) -> a -> b
$ Origin -> Access
PrivateAccess Origin
UserWritten
    valu [a
1] = Access
-> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access))
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
 -> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access)))
-> Access
-> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access))
forall a b. (a -> b) -> a -> b
$ Origin -> Access
PrivateAccess Origin
Inserted
    valu []  = Access
-> Arrows (Constant Int32 (Domains Access)) (R (CoDomain Access))
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]
_   = R Access
forall a. R a
malformed

instance EmbPrj NameSpace where
  icod_ :: NameSpace -> S Int32
icod_ (NameSpace NamesInScope
a ModulesInScope
b InScopeSet
c) = (NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace)
-> NamesInScope -> ModulesInScope -> InScopeSet -> S Int32
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 = (NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace)
-> Int32
-> R (CoDomain
        (NamesInScope -> ModulesInScope -> InScopeSet -> NameSpace))
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       = WhyInScope -> Arrows (Domains WhyInScope) (S Int32)
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)  = Int32
-> (QName -> WhyInScope -> WhyInScope)
-> QName
-> WhyInScope
-> S Int32
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) = Int32
-> (QName -> WhyInScope -> WhyInScope)
-> QName
-> WhyInScope
-> S Int32
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 = (Node -> R WhyInScope) -> Int32 -> R WhyInScope
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R WhyInScope
valu where
    valu :: Node -> R WhyInScope
valu []        = WhyInScope
-> Arrows
     (Constant Int32 (Domains WhyInScope)) (R (CoDomain WhyInScope))
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] = (QName -> WhyInScope -> WhyInScope)
-> Int32 -> Int32 -> R WhyInScope
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] = (QName -> WhyInScope -> WhyInScope)
-> Int32 -> Int32 -> R WhyInScope
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
_         = R WhyInScope
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 (Lens' Fixity QName -> LensSet Fixity QName
forall i o. Lens' i o -> LensSet i o
set forall a. LensFixity a => Lens' Fixity a
Lens' Fixity QName
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 QName -> Lens' Fixity QName -> Fixity
forall o i. o -> Lens' i o -> i
^. forall a. LensFixity a => Lens' Fixity a
Lens' Fixity QName
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) = (Fixity
 -> QName
 -> KindOfName
 -> WhyInScope
 -> NameMetadata
 -> AbsNameWithFixity)
-> Fixity
-> QName
-> KindOfName
-> WhyInScope
-> NameMetadata
-> S Int32
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 = (Fixity
 -> QName
 -> KindOfName
 -> WhyInScope
 -> NameMetadata
 -> AbsNameWithFixity)
-> Int32
-> R (CoDomain
        (Fixity
         -> QName
         -> KindOfName
         -> WhyInScope
         -> NameMetadata
         -> AbsNameWithFixity))
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 = AbsNameWithFixity -> S Int32
forall a. EmbPrj a => a -> S Int32
icod_ (AbstractName -> AbsNameWithFixity
fromAbsName AbstractName
a)
  value :: Int32 -> R AbstractName
value = AbsNameWithFixity -> AbstractName
toAbsName (AbsNameWithFixity -> AbstractName)
-> (Int32 -> R AbsNameWithFixity) -> Int32 -> R AbstractName
forall (m :: * -> *) b c a.
Functor m =>
(b -> c) -> (a -> m b) -> a -> m c
<.> Int32 -> R AbsNameWithFixity
forall a. EmbPrj a => Int32 -> R a
value

instance EmbPrj NameMetadata where
  icod_ :: NameMetadata -> S Int32
icod_ NameMetadata
NoMetadata                  = NameMetadata -> Arrows (Domains NameMetadata) (S Int32)
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) = (Map QName Name -> NameMetadata) -> Map QName Name -> S Int32
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 = (Node -> R NameMetadata) -> Int32 -> R NameMetadata
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R NameMetadata
valu where
    valu :: Node -> R NameMetadata
valu []  = NameMetadata
-> Arrows
     (Constant Int32 (Domains NameMetadata)) (R (CoDomain NameMetadata))
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] = (Map QName Name -> NameMetadata) -> Int32 -> R NameMetadata
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
_   = R NameMetadata
forall a. R a
malformed

instance EmbPrj A.Suffix where
  icod_ :: Suffix -> S Int32
icod_ Suffix
A.NoSuffix   = Suffix -> Arrows (Domains Suffix) (S Int32)
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) = (Integer -> Suffix) -> Integer -> S Int32
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 = (Node -> R Suffix) -> Int32 -> R Suffix
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R Suffix
valu where
    valu :: Node -> R Suffix
valu []  = Suffix
-> Arrows (Constant Int32 (Domains Suffix)) (R (CoDomain Suffix))
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] = (Integer -> Suffix) -> Int32 -> R Suffix
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
_   = R Suffix
forall a. R a
malformed

instance EmbPrj AbstractModule where
  icod_ :: AbstractModule -> S Int32
icod_ (AbsModule ModuleName
a WhyInScope
b) = (ModuleName -> WhyInScope -> AbstractModule)
-> ModuleName -> WhyInScope -> S Int32
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 = (ModuleName -> WhyInScope -> AbstractModule)
-> Int32
-> R (CoDomain (ModuleName -> WhyInScope -> AbstractModule))
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   = BindingSource -> Arrows (Domains BindingSource) (S Int32)
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  = Int32 -> BindingSource -> Arrows (Domains BindingSource) (S Int32)
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      = Int32 -> BindingSource -> Arrows (Domains BindingSource) (S Int32)
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     = Int32 -> BindingSource -> Arrows (Domains BindingSource) (S Int32)
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 = (Node -> R BindingSource) -> Int32 -> R BindingSource
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R BindingSource
forall a. (Eq a, Num a) => [a] -> R BindingSource
valu where
    valu :: [a] -> R BindingSource
valu []  = BindingSource
-> Arrows
     (Constant Int32 (Domains BindingSource))
     (R (CoDomain BindingSource))
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] = BindingSource
-> Arrows
     (Constant Int32 (Domains BindingSource))
     (R (CoDomain BindingSource))
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] = BindingSource
-> Arrows
     (Constant Int32 (Domains BindingSource))
     (R (CoDomain BindingSource))
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] = BindingSource
-> Arrows
     (Constant Int32 (Domains BindingSource))
     (R (CoDomain BindingSource))
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]
_   = R BindingSource
forall a. R a
malformed

instance EmbPrj LocalVar where
  icod_ :: LocalVar -> S Int32
icod_ (LocalVar Name
a BindingSource
b [AbstractName]
c)  = (Name -> BindingSource -> [AbstractName] -> LocalVar)
-> Name -> BindingSource -> [AbstractName] -> S Int32
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 = (Name -> BindingSource -> [AbstractName] -> LocalVar)
-> Int32
-> R (CoDomain
        (Name -> BindingSource -> [AbstractName] -> LocalVar))
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) = (ConOrigin -> ConPatLazy -> ConPatInfo)
-> ConOrigin -> ConPatLazy -> S Int32
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 = (ConOrigin -> ConPatLazy -> ConPatInfo)
-> Int32 -> R (CoDomain (ConOrigin -> ConPatLazy -> ConPatInfo))
forall t.
(VALU t (IsBase t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Int32 -> R (CoDomain t)
valueN ((ConOrigin -> ConPatLazy -> ConPatInfo)
 -> Int32 -> R (CoDomain (ConOrigin -> ConPatLazy -> ConPatInfo)))
-> (ConOrigin -> ConPatLazy -> ConPatInfo)
-> Int32
-> R (CoDomain (ConOrigin -> ConPatLazy -> ConPatInfo))
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)            = Int32 -> (BindName -> Pattern' Any) -> BindName -> S Int32
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 BindName -> Pattern' Any
forall e. BindName -> Pattern' e
A.VarP BindName
a
  icod_ (A.ConP ConPatInfo
a AmbiguousQName
b NAPs a
c)        = Int32
-> (ConPatInfo -> AmbiguousQName -> NAPs a -> Pattern' a)
-> ConPatInfo
-> AmbiguousQName
-> NAPs a
-> S Int32
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 ConPatInfo -> AmbiguousQName -> NAPs a -> Pattern' a
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)        = Int32
-> (AmbiguousQName -> NAPs a -> Pattern' a)
-> AmbiguousQName
-> NAPs a
-> S Int32
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 (PatInfo -> AmbiguousQName -> NAPs a -> Pattern' a
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)         = Int32 -> Pattern' a -> Arrows (Domains (Pattern' a)) (S Int32)
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)         = Int32
-> (BindName -> Pattern' a -> Pattern' a)
-> BindName
-> Pattern' a
-> S Int32
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 (PatInfo -> BindName -> Pattern' a -> Pattern' a
forall e. PatInfo -> BindName -> Pattern' e -> Pattern' e
A.AsP PatInfo
p) BindName
a Pattern' a
b
  icod_ (A.DotP PatInfo
p a
a)          = Int32 -> (a -> Pattern' a) -> a -> S Int32
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 (PatInfo -> a -> Pattern' a
forall e. PatInfo -> e -> Pattern' e
A.DotP PatInfo
p) a
a
  icod_ t :: Pattern' a
t@(A.AbsurdP PatInfo
_)       = Int32 -> Pattern' a -> Arrows (Domains (Pattern' a)) (S Int32)
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)          = Int32 -> (Literal -> Pattern' Any) -> Literal -> S Int32
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 (PatInfo -> Literal -> Pattern' Any
forall e. PatInfo -> Literal -> Pattern' e
A.LitP PatInfo
i) Literal
a
  icod_ (A.ProjP PatInfo
p ProjOrigin
a AmbiguousQName
b)       = Int32
-> (ProjOrigin -> AmbiguousQName -> Pattern' Any)
-> ProjOrigin
-> AmbiguousQName
-> S Int32
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 (PatInfo -> ProjOrigin -> AmbiguousQName -> Pattern' Any
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) = Int32
-> (AmbiguousQName -> NAPs a -> Pattern' a)
-> AmbiguousQName
-> NAPs a
-> S Int32
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 (PatInfo -> AmbiguousQName -> NAPs a -> Pattern' a
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)          = Int32
-> ([FieldAssignment' (Pattern' a)] -> Pattern' a)
-> [FieldAssignment' (Pattern' a)]
-> S Int32
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 (PatInfo -> [FieldAssignment' (Pattern' a)] -> Pattern' a
forall e. PatInfo -> [FieldAssignment' (Pattern' e)] -> Pattern' e
A.RecP PatInfo
p) [FieldAssignment' (Pattern' a)]
a
  icod_ (A.EqualP PatInfo
_ [(a, a)]
a)        = S Int32
forall a. HasCallStack => a
__IMPOSSIBLE__
  icod_ (A.WithP PatInfo
i Pattern' a
a)         = Int32 -> (Pattern' a -> Pattern' a) -> Pattern' a -> S Int32
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 (PatInfo -> Pattern' a -> Pattern' a
forall e. PatInfo -> Pattern' e -> Pattern' e
A.WithP PatInfo
i) Pattern' a
a
  icod_ (A.AnnP PatInfo
i a
a Pattern' a
p)        = Int32
-> (a -> Pattern' a -> Pattern' a) -> a -> Pattern' a -> S Int32
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 (PatInfo -> a -> Pattern' a -> Pattern' a
forall e. PatInfo -> e -> Pattern' e -> Pattern' e
A.AnnP PatInfo
i) a
a Pattern' a
p

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

    i :: PatInfo
i = PatInfo
patNoRange

instance EmbPrj ParenPreference where
  icod_ :: ParenPreference -> S Int32
icod_ ParenPreference
PreferParen     = ParenPreference -> Arrows (Domains ParenPreference) (S Int32)
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 = Int32
-> ParenPreference -> Arrows (Domains ParenPreference) (S Int32)
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 = (Node -> R ParenPreference) -> Int32 -> R ParenPreference
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R ParenPreference
forall a. (Eq a, Num a) => [a] -> R ParenPreference
valu where
    valu :: [a] -> R ParenPreference
valu []  = ParenPreference
-> Arrows
     (Constant Int32 (Domains ParenPreference))
     (R (CoDomain ParenPreference))
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] = ParenPreference
-> Arrows
     (Constant Int32 (Domains ParenPreference))
     (R (CoDomain ParenPreference))
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]
_   = R ParenPreference
forall a. R a
malformed

instance EmbPrj Precedence where
  icod_ :: Precedence -> S Int32
icod_ Precedence
TopCtx                 = Precedence -> Arrows (Domains Precedence) (S Int32)
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 = Int32 -> Precedence -> Arrows (Domains Precedence) (S Int32)
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)     = Int32 -> (Fixity -> Precedence) -> Fixity -> S Int32
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)  = Int32
-> (Fixity -> ParenPreference -> Precedence)
-> Fixity
-> ParenPreference
-> S Int32
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            = Int32 -> Precedence -> Arrows (Domains Precedence) (S Int32)
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)        = Int32
-> (ParenPreference -> Precedence) -> ParenPreference -> S Int32
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       = Int32 -> Precedence -> Arrows (Domains Precedence) (S Int32)
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             = Int32 -> Precedence -> Arrows (Domains Precedence) (S Int32)
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             = Int32 -> Precedence -> Arrows (Domains Precedence) (S Int32)
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          = Int32 -> Precedence -> Arrows (Domains Precedence) (S Int32)
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 = (Node -> R Precedence) -> Int32 -> R Precedence
forall a. EmbPrj a => (Node -> R a) -> Int32 -> R a
vcase Node -> R Precedence
valu where
    valu :: Node -> R Precedence
valu []        = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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]       = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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]    = (Fixity -> Precedence) -> Int32 -> R Precedence
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] = (Fixity -> ParenPreference -> Precedence)
-> Int32 -> Int32 -> R Precedence
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]       = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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]    = (ParenPreference -> Precedence) -> Int32 -> R Precedence
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]       = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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]       = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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]       = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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]       = Precedence
-> Arrows
     (Constant Int32 (Domains Precedence)) (R (CoDomain Precedence))
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
_         = R Precedence
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) = (ModuleName
 -> Map ModuleName Scope
 -> LocalVars
 -> LocalVars
 -> PrecedenceStack
 -> ScopeInfo)
-> ModuleName
-> Map ModuleName Scope
-> LocalVars
-> LocalVars
-> PrecedenceStack
-> S Int32
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 = (ModuleName
 -> Map ModuleName Scope
 -> LocalVars
 -> LocalVars
 -> PrecedenceStack
 -> ScopeInfo)
-> Int32
-> R (CoDomain
        (ModuleName
         -> Map ModuleName Scope
         -> LocalVars
         -> LocalVars
         -> PrecedenceStack
         -> ScopeInfo))
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 NameMap
forall k a. Map k a
Map.empty ModuleMap
forall k a. Map k a
Map.empty InScopeSet
forall a. Set a
Set.empty Fixities
forall k a. Map k a
Map.empty Polarities
forall k a. Map k a
Map.empty)

instance EmbPrj NameOrModule