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

-- Only instances exported
module Mikan.TypeChecking.Serialise.Instances () where

import Mikan.Syntax.Position
import Mikan.Syntax.TopLevelModuleName
import Mikan.TypeChecking.Monad.Base
import Mikan.TypeChecking.Serialise.Base
import Mikan.TypeChecking.Serialise.Instances.Common (SerialisedRange(..))
import Mikan.TypeChecking.Serialise.Instances.Errors ()
import Mikan.TypeChecking.Serialise.Instances.General ()
import Mikan.TypeChecking.Serialise.Instances.Highlighting ()
import Mikan.TypeChecking.Serialise.Instances.Abstract ()
import Mikan.Utils.Hash
import Mikan.Utils.Monad

type RangedImportedModules =
  [(SerialisedRange, TopLevelModuleName, Hash)]

fromImportedModules ::
  [(TopLevelModuleName, Hash)] -> RangedImportedModules
fromImportedModules :: [(TopLevelModuleName, Hash)] -> RangedImportedModules
fromImportedModules [(TopLevelModuleName, Hash)]
ms = [(Range -> SerialisedRange
SerialisedRange (Range -> SerialisedRange) -> Range -> SerialisedRange
forall a b. (a -> b) -> a -> b
$ TopLevelModuleName -> Range
forall a. HasRange a => a -> Range
getRange TopLevelModuleName
x, TopLevelModuleName
x, Hash
hash) | (TopLevelModuleName
x, Hash
hash) <- [(TopLevelModuleName, Hash)]
ms]

toImportedModules ::
  RangedImportedModules -> [(TopLevelModuleName, Hash)]
toImportedModules :: RangedImportedModules -> [(TopLevelModuleName, Hash)]
toImportedModules RangedImportedModules
ms = [(Range -> TopLevelModuleName -> TopLevelModuleName
forall a. SetRange a => Range -> a -> a
setRange (SerialisedRange -> Range
underlyingRange SerialisedRange
r) TopLevelModuleName
x, Hash
hash) | (SerialisedRange
r, TopLevelModuleName
x, Hash
hash) <- RangedImportedModules
ms]

instance EmbPrj Interface where
  icod_ :: Interface -> S Word32
icod_ (Interface Hash
a Text
b FileType
c [(TopLevelModuleName, Hash)]
d ModuleName
e TopLevelModuleName
f Map ModuleName Scope
g ScopeInfo
h Signature
i RemoteMetaStore
j DisplayForms
k UserWarnings
l Maybe ShortText
m BuiltinThings' (PrimitiveId, QName)
n Map ShortText ForeignCodeStack
o HighlightingInfo
p [OptionsPragma]
q [OptionsPragma]
r PragmaOptions
s PatternSynDefns
t Set (TCWarning' EncodedDiagnostic)
u Set QName
v Map OpaqueId OpaqueBlock
w Map QName OpaqueId
x) =
      (Hash
 -> Text
 -> FileType
 -> RangedImportedModules
 -> ModuleName
 -> TopLevelModuleName
 -> Map ModuleName Scope
 -> ScopeInfo
 -> Signature
 -> RemoteMetaStore
 -> DisplayForms
 -> UserWarnings
 -> Maybe ShortText
 -> BuiltinThings' (PrimitiveId, QName)
 -> Map ShortText ForeignCodeStack
 -> HighlightingInfo
 -> [OptionsPragma]
 -> [OptionsPragma]
 -> PragmaOptions
 -> PatternSynDefns
 -> Set (TCWarning' EncodedDiagnostic)
 -> Set QName
 -> Map OpaqueId OpaqueBlock
 -> Map QName OpaqueId
 -> Interface)
-> Arrows
     (Domains
        (Hash
         -> Text
         -> FileType
         -> RangedImportedModules
         -> ModuleName
         -> TopLevelModuleName
         -> Map ModuleName Scope
         -> ScopeInfo
         -> Signature
         -> RemoteMetaStore
         -> DisplayForms
         -> UserWarnings
         -> Maybe ShortText
         -> BuiltinThings' (PrimitiveId, QName)
         -> Map ShortText ForeignCodeStack
         -> HighlightingInfo
         -> [OptionsPragma]
         -> [OptionsPragma]
         -> PragmaOptions
         -> PatternSynDefns
         -> Set (TCWarning' EncodedDiagnostic)
         -> Set QName
         -> Map OpaqueId OpaqueBlock
         -> Map QName OpaqueId
         -> Interface))
     (S Word32)
forall t.
(ICODE t (Arity t), StrictCurrying (Domains t) (S Word32),
 All EmbPrj (Domains t)) =>
t -> Arrows (Domains t) (S Word32)
icodeN' Hash
-> Text
-> FileType
-> RangedImportedModules
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
interface Hash
a Text
b FileType
c ([(TopLevelModuleName, Hash)] -> RangedImportedModules
fromImportedModules [(TopLevelModuleName, Hash)]
d) ModuleName
e TopLevelModuleName
f Map ModuleName Scope
g ScopeInfo
h Signature
i RemoteMetaStore
j DisplayForms
k UserWarnings
l Maybe ShortText
m BuiltinThings' (PrimitiveId, QName)
n Map ShortText ForeignCodeStack
o HighlightingInfo
p [OptionsPragma]
q [OptionsPragma]
r PragmaOptions
s PatternSynDefns
t Set (TCWarning' EncodedDiagnostic)
u Set QName
v Map OpaqueId OpaqueBlock
w Map QName OpaqueId
x
    where interface :: Hash
-> Text
-> FileType
-> RangedImportedModules
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
interface Hash
a Text
b FileType
c = Hash
-> Text
-> FileType
-> [(TopLevelModuleName, Hash)]
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
Interface Hash
a Text
b FileType
c ([(TopLevelModuleName, Hash)]
 -> ModuleName
 -> TopLevelModuleName
 -> Map ModuleName Scope
 -> ScopeInfo
 -> Signature
 -> RemoteMetaStore
 -> DisplayForms
 -> UserWarnings
 -> Maybe ShortText
 -> BuiltinThings' (PrimitiveId, QName)
 -> Map ShortText ForeignCodeStack
 -> HighlightingInfo
 -> [OptionsPragma]
 -> [OptionsPragma]
 -> PragmaOptions
 -> PatternSynDefns
 -> Set (TCWarning' EncodedDiagnostic)
 -> Set QName
 -> Map OpaqueId OpaqueBlock
 -> Map QName OpaqueId
 -> Interface)
-> (RangedImportedModules -> [(TopLevelModuleName, Hash)])
-> RangedImportedModules
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RangedImportedModules -> [(TopLevelModuleName, Hash)]
toImportedModules

  value :: Word32 -> R Interface
value = (Hash
 -> Text
 -> FileType
 -> RangedImportedModules
 -> ModuleName
 -> TopLevelModuleName
 -> Map ModuleName Scope
 -> ScopeInfo
 -> Signature
 -> RemoteMetaStore
 -> DisplayForms
 -> UserWarnings
 -> Maybe ShortText
 -> BuiltinThings' (PrimitiveId, QName)
 -> Map ShortText ForeignCodeStack
 -> HighlightingInfo
 -> [OptionsPragma]
 -> [OptionsPragma]
 -> PragmaOptions
 -> PatternSynDefns
 -> Set (TCWarning' EncodedDiagnostic)
 -> Set QName
 -> Map OpaqueId OpaqueBlock
 -> Map QName OpaqueId
 -> Interface)
-> Word32
-> R (CoDomain
        (Hash
         -> Text
         -> FileType
         -> RangedImportedModules
         -> ModuleName
         -> TopLevelModuleName
         -> Map ModuleName Scope
         -> ScopeInfo
         -> Signature
         -> RemoteMetaStore
         -> DisplayForms
         -> UserWarnings
         -> Maybe ShortText
         -> BuiltinThings' (PrimitiveId, QName)
         -> Map ShortText ForeignCodeStack
         -> HighlightingInfo
         -> [OptionsPragma]
         -> [OptionsPragma]
         -> PragmaOptions
         -> PatternSynDefns
         -> Set (TCWarning' EncodedDiagnostic)
         -> Set QName
         -> Map OpaqueId OpaqueBlock
         -> Map QName OpaqueId
         -> Interface))
forall t.
(VALU t (Arity t), All EmbPrj (CoDomain t : Domains t)) =>
t -> Word32 -> R (CoDomain t)
valueN Hash
-> Text
-> FileType
-> RangedImportedModules
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
interface
    where interface :: Hash
-> Text
-> FileType
-> RangedImportedModules
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
interface Hash
a Text
b FileType
c = Hash
-> Text
-> FileType
-> [(TopLevelModuleName, Hash)]
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
Interface Hash
a Text
b FileType
c ([(TopLevelModuleName, Hash)]
 -> ModuleName
 -> TopLevelModuleName
 -> Map ModuleName Scope
 -> ScopeInfo
 -> Signature
 -> RemoteMetaStore
 -> DisplayForms
 -> UserWarnings
 -> Maybe ShortText
 -> BuiltinThings' (PrimitiveId, QName)
 -> Map ShortText ForeignCodeStack
 -> HighlightingInfo
 -> [OptionsPragma]
 -> [OptionsPragma]
 -> PragmaOptions
 -> PatternSynDefns
 -> Set (TCWarning' EncodedDiagnostic)
 -> Set QName
 -> Map OpaqueId OpaqueBlock
 -> Map QName OpaqueId
 -> Interface)
-> (RangedImportedModules -> [(TopLevelModuleName, Hash)])
-> RangedImportedModules
-> ModuleName
-> TopLevelModuleName
-> Map ModuleName Scope
-> ScopeInfo
-> Signature
-> RemoteMetaStore
-> DisplayForms
-> UserWarnings
-> Maybe ShortText
-> BuiltinThings' (PrimitiveId, QName)
-> Map ShortText ForeignCodeStack
-> HighlightingInfo
-> [OptionsPragma]
-> [OptionsPragma]
-> PragmaOptions
-> PatternSynDefns
-> Set (TCWarning' EncodedDiagnostic)
-> Set QName
-> Map OpaqueId OpaqueBlock
-> Map QName OpaqueId
-> Interface
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RangedImportedModules -> [(TopLevelModuleName, Hash)]
toImportedModules

instance EmbPrj UserWarningInfo where
  icod_ :: UserWarningInfo -> S Word32
icod_ (UserWarningInfo ShortText
a Name
b) = (ShortText, Name) -> S Word32
forall a. EmbPrj a => a -> S Word32
icod_ (ShortText
a, Name
b)

  value :: Word32 -> R UserWarningInfo
value Word32
op = (ShortText -> Name -> UserWarningInfo)
-> (ShortText, Name) -> UserWarningInfo
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ShortText -> Name -> UserWarningInfo
UserWarningInfo ((ShortText, Name) -> UserWarningInfo)
-> ReaderT Decode IO (ShortText, Name) -> R UserWarningInfo
forall (m :: * -> *) a b. Monad m => (a -> b) -> m a -> m b
<$!> Word32 -> ReaderT Decode IO (ShortText, Name)
forall a. EmbPrj a => Word32 -> R a
value Word32
op