{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ViewPatterns #-}
module Unison.UnisonFile
(
UnisonFile (..),
pattern UnisonFile,
emptyUnisonFile,
allWatches,
dataDeclarations,
declsToTypeLookup,
dependencies,
effectDeclarations,
typecheckingTerm,
watchesOfKind,
definitionLocation,
termBindings,
leftBiasedMerge,
TypecheckedUnisonFile (..),
allTerms,
dataDeclarations',
discardTypes,
effectDeclarations',
hashConstructors,
constructorsForDecls,
hashTerms,
indexByReference,
lookupDecl,
nonEmpty,
termSignatureExternalLabeledDependencies,
topLevelComponents,
typecheckedToTypeLookup,
typecheckedUnisonFile,
Unison.UnisonFile.rewrite,
prepareRewrite,
termNamespaceBindings,
typeNamespaceBindings,
)
where
import Control.Lens
import Data.Map qualified as Map
import Data.Set qualified as Set
import Data.Vector qualified as Vector
import Unison.ABT qualified as ABT
import Unison.Builtin.Decls qualified as DD
import Unison.ConstructorReference (GConstructorReference (..))
import Unison.ConstructorType qualified as CT
import Unison.DataDeclaration (DataDeclaration, EffectDeclaration (..))
import Unison.DataDeclaration qualified as DD
import Unison.DataDeclaration qualified as DataDeclaration
import Unison.Hash qualified as Hash
import Unison.Hashing.V2.Convert qualified as Hashing
import Unison.LabeledDependency (LabeledDependency)
import Unison.LabeledDependency qualified as LD
import Unison.Prelude
import Unison.Reference (Reference, TermReference, TypeReference)
import Unison.Reference qualified as Reference
import Unison.Referent qualified as Referent
import Unison.Term (Term)
import Unison.Term qualified as Term
import Unison.Type (Type)
import Unison.Type qualified as Type
import Unison.Typechecker.TypeLookup qualified as TL
import Unison.UnisonFile.Type (TypecheckedUnisonFile (..), UnisonFile (..), pattern TypecheckedUnisonFile, pattern UnisonFile)
import Unison.Util.Defns (Defns (..), DefnsF)
import Unison.Util.List qualified as List
import Unison.Var (Var)
import Unison.Var qualified as Var
import Unison.WatchKind (WatchKind, pattern TestWatch)
import Unison.WatchKind qualified as WatchKind
emptyUnisonFile :: UnisonFile v a
emptyUnisonFile :: forall v a. UnisonFile v a
emptyUnisonFile =
UnisonFileId
{ $sel:dataDeclarationsId:UnisonFileId :: Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId = Map v (TypeReferenceId, DataDeclaration v a)
forall k a. Map k a
Map.empty,
$sel:effectDeclarationsId:UnisonFileId :: Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId = Map v (TypeReferenceId, EffectDeclaration v a)
forall k a. Map k a
Map.empty,
$sel:terms:UnisonFileId :: Map v (a, Term v a)
terms = Map v (a, Term v a)
forall k a. Map k a
Map.empty,
$sel:watches:UnisonFileId :: Map WatchKind [(v, a, Term v a)]
watches = Map WatchKind [(v, a, Term v a)]
forall k a. Map k a
Map.empty
}
leftBiasedMerge :: forall v a. (Ord v) => UnisonFile v a -> UnisonFile v a -> UnisonFile v a
leftBiasedMerge :: forall v a.
Ord v =>
UnisonFile v a -> UnisonFile v a -> UnisonFile v a
leftBiasedMerge UnisonFile v a
lhs UnisonFile v a
rhs =
let mergedTerms :: Map v (a, Term v a)
mergedTerms = (Map v (a, Term v a) -> v -> (a, Term v a) -> Map v (a, Term v a))
-> Map v (a, Term v a)
-> Map v (a, Term v a)
-> Map v (a, Term v a)
forall a k b. (a -> k -> b -> a) -> a -> Map k b -> a
Map.foldlWithKey' (Set v
-> Map v (a, Term v a) -> v -> (a, Term v a) -> Map v (a, Term v a)
forall x. Set v -> Map v x -> v -> x -> Map v x
addNotIn Set v
lhsTermNames) UnisonFile v a
lhs.terms UnisonFile v a
rhs.terms
mergedWatches :: Map WatchKind [(v, a, Term v a)]
mergedWatches = (Map WatchKind [(v, a, Term v a)]
-> WatchKind
-> [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)])
-> Map WatchKind [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
forall a k b. (a -> k -> b -> a) -> a -> Map k b -> a
Map.foldlWithKey' Map WatchKind [(v, a, Term v a)]
-> WatchKind
-> [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
addWatch (UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches UnisonFile v a
lhs) (UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches UnisonFile v a
rhs)
mergedDataDecls :: Map v (TypeReferenceId, DataDeclaration v a)
mergedDataDecls = (Map v (TypeReferenceId, DataDeclaration v a)
-> v
-> (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a))
-> Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a)
forall a k b. (a -> k -> b -> a) -> a -> Map k b -> a
Map.foldlWithKey' (Set v
-> Map v (TypeReferenceId, DataDeclaration v a)
-> v
-> (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a)
forall x. Set v -> Map v x -> v -> x -> Map v x
addNotIn Set v
lhsTypeNames) (UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId UnisonFile v a
lhs) (UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId UnisonFile v a
rhs)
mergedEffectDecls :: Map v (TypeReferenceId, EffectDeclaration v a)
mergedEffectDecls = (Map v (TypeReferenceId, EffectDeclaration v a)
-> v
-> (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a))
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall a k b. (a -> k -> b -> a) -> a -> Map k b -> a
Map.foldlWithKey' (Set v
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> v
-> (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall x. Set v -> Map v x -> v -> x -> Map v x
addNotIn Set v
lhsTypeNames) (UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId UnisonFile v a
lhs) (UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId UnisonFile v a
rhs)
in UnisonFileId
{ $sel:dataDeclarationsId:UnisonFileId :: Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId = Map v (TypeReferenceId, DataDeclaration v a)
mergedDataDecls,
$sel:effectDeclarationsId:UnisonFileId :: Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId = Map v (TypeReferenceId, EffectDeclaration v a)
mergedEffectDecls,
$sel:terms:UnisonFileId :: Map v (a, Term v a)
terms = Map v (a, Term v a)
mergedTerms,
$sel:watches:UnisonFileId :: Map WatchKind [(v, a, Term v a)]
watches = Map WatchKind [(v, a, Term v a)]
mergedWatches
}
where
lhsTermNames :: Set v
lhsTermNames =
Map v (a, Term v a) -> Set v
forall k a. Map k a -> Set k
Map.keysSet UnisonFile v a
lhs.terms
Set v -> Set v -> Set v
forall a. Semigroup a => a -> a -> a
<> ([(v, a, Term v a)] -> Set v)
-> Map WatchKind [(v, a, Term v a)] -> Set v
forall m a. Monoid m => (a -> m) -> Map WatchKind a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\[(v, a, Term v a)]
x -> [v] -> Set v
forall a. Ord a => [a] -> Set a
Set.fromList [v
v | (v
v, a
_, Term v a
_) <- [(v, a, Term v a)]
x]) (UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches UnisonFile v a
lhs)
lhsTypeNames :: Set v
lhsTypeNames =
Map v (TypeReferenceId, DataDeclaration v a) -> Set v
forall k a. Map k a -> Set k
Map.keysSet (UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId UnisonFile v a
lhs)
Set v -> Set v -> Set v
forall a. Semigroup a => a -> a -> a
<> Map v (TypeReferenceId, EffectDeclaration v a) -> Set v
forall k a. Map k a -> Set k
Map.keysSet (UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId UnisonFile v a
lhs)
addNotIn :: forall x. Set v -> Map v x -> v -> x -> Map v x
addNotIn :: forall x. Set v -> Map v x -> v -> x -> Map v x
addNotIn Set v
namesToAvoid Map v x
b v
k x
v = case v -> Set v -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member v
k Set v
namesToAvoid of
Bool
True -> Map v x
b
Bool
False -> v -> x -> Map v x -> Map v x
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert v
k x
v Map v x
b
addWatch :: Map WatchKind [(v, a, Term v a)] -> WatchKind -> [(v, a, Term v a)] -> Map WatchKind [(v, a, Term v a)]
addWatch :: Map WatchKind [(v, a, Term v a)]
-> WatchKind
-> [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
addWatch Map WatchKind [(v, a, Term v a)]
b WatchKind
k [(v, a, Term v a)]
v = case ((v, a, Term v a) -> Bool)
-> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(v
x, a
_, Term v a
_) -> Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ v -> Set v -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member v
x Set v
lhsTermNames) [(v, a, Term v a)]
v of
[] -> Map WatchKind [(v, a, Term v a)]
b
[(v, a, Term v a)]
v -> ([(v, a, Term v a)] -> [(v, a, Term v a)] -> [(v, a, Term v a)])
-> WatchKind
-> [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
Map.insertWith [(v, a, Term v a)] -> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a. [a] -> [a] -> [a]
(++) WatchKind
k [(v, a, Term v a)]
v Map WatchKind [(v, a, Term v a)]
b
dataDeclarations :: UnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations :: forall v a.
UnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations = ((TypeReferenceId, DataDeclaration v a)
-> (Reference, DataDeclaration v a))
-> Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (Reference, DataDeclaration v a)
forall a b. (a -> b) -> Map v a -> Map v b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((TypeReferenceId -> Reference)
-> (TypeReferenceId, DataDeclaration v a)
-> (Reference, DataDeclaration v a)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first TypeReferenceId -> Reference
forall h t. Id' h -> Reference' t h
Reference.DerivedId) (Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (Reference, DataDeclaration v a))
-> (UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a))
-> UnisonFile v a
-> Map v (Reference, DataDeclaration v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId
effectDeclarations :: UnisonFile v a -> Map v (Reference, EffectDeclaration v a)
effectDeclarations :: forall v a.
UnisonFile v a -> Map v (Reference, EffectDeclaration v a)
effectDeclarations = ((TypeReferenceId, EffectDeclaration v a)
-> (Reference, EffectDeclaration v a))
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (Reference, EffectDeclaration v a)
forall a b. (a -> b) -> Map v a -> Map v b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((TypeReferenceId -> Reference)
-> (TypeReferenceId, EffectDeclaration v a)
-> (Reference, EffectDeclaration v a)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first TypeReferenceId -> Reference
forall h t. Id' h -> Reference' t h
Reference.DerivedId) (Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (Reference, EffectDeclaration v a))
-> (UnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a))
-> UnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
UnisonFile v a -> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId
watchesOfKind :: WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
watchesOfKind :: forall v a. WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
watchesOfKind WatchKind
kind UnisonFile v a
uf = [(v, a, Term v a)]
-> WatchKind
-> Map WatchKind [(v, a, Term v a)]
-> [(v, a, Term v a)]
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault [] WatchKind
kind (UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches UnisonFile v a
uf)
watchesOfOtherKinds :: WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
watchesOfOtherKinds :: forall v a. WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
watchesOfOtherKinds WatchKind
kind UnisonFile v a
uf =
[[(v, a, Term v a)]] -> [(v, a, Term v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join [[(v, a, Term v a)]
ws | (WatchKind
k, [(v, a, Term v a)]
ws) <- Map WatchKind [(v, a, Term v a)]
-> [(WatchKind, [(v, a, Term v a)])]
forall k a. Map k a -> [(k, a)]
Map.toList (UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches UnisonFile v a
uf), WatchKind
k WatchKind -> WatchKind -> Bool
forall a. Eq a => a -> a -> Bool
/= WatchKind
kind]
allWatches :: UnisonFile v a -> [(v, a, Term v a)]
allWatches :: forall v a. UnisonFile v a -> [(v, a, Term v a)]
allWatches = [[(v, a, Term v a)]] -> [(v, a, Term v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join ([[(v, a, Term v a)]] -> [(v, a, Term v a)])
-> (UnisonFile v a -> [[(v, a, Term v a)]])
-> UnisonFile v a
-> [(v, a, Term v a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map WatchKind [(v, a, Term v a)] -> [[(v, a, Term v a)]]
forall k a. Map k a -> [a]
Map.elems (Map WatchKind [(v, a, Term v a)] -> [[(v, a, Term v a)]])
-> (UnisonFile v a -> Map WatchKind [(v, a, Term v a)])
-> UnisonFile v a
-> [[(v, a, Term v a)]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches
definitionLocation :: (Var v) => v -> UnisonFile v a -> Maybe a
definitionLocation :: forall v a. Var v => v -> UnisonFile v a -> Maybe a
definitionLocation v
v UnisonFile v a
uf =
UnisonFile v a
uf.terms Map v (a, Term v a)
-> Getting (First a) (Map v (a, Term v a)) a -> Maybe a
forall s a. s -> Getting (First a) s a -> Maybe a
^? Index (Map v (a, Term v a))
-> Traversal' (Map v (a, Term v a)) (IxValue (Map v (a, Term v a)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix v
Index (Map v (a, Term v a))
v ((IxValue (Map v (a, Term v a))
-> Const (First a) (IxValue (Map v (a, Term v a))))
-> Map v (a, Term v a) -> Const (First a) (Map v (a, Term v a)))
-> ((a -> Const (First a) a)
-> IxValue (Map v (a, Term v a))
-> Const (First a) (IxValue (Map v (a, Term v a))))
-> Getting (First a) (Map v (a, Term v a)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Const (First a) a)
-> IxValue (Map v (a, Term v a))
-> Const (First a) (IxValue (Map v (a, Term v a)))
forall s t a b. Field1 s t a b => Lens s t a b
Lens
(IxValue (Map v (a, Term v a))) (IxValue (Map v (a, Term v a))) a a
_1
Maybe a -> Maybe a -> Maybe a
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
forall v a. UnisonFile v a -> Map WatchKind [(v, a, Term v a)]
watches UnisonFile v a
uf Map WatchKind [(v, a, Term v a)]
-> Getting (First a) (Map WatchKind [(v, a, Term v a)]) a
-> Maybe a
forall s a. s -> Getting (First a) s a -> Maybe a
^? ([(v, a, Term v a)] -> Const (First a) [(v, a, Term v a)])
-> Map WatchKind [(v, a, Term v a)]
-> Const (First a) (Map WatchKind [(v, a, Term v a)])
forall (f :: * -> *) a. Foldable f => IndexedFold Int (f a) a
IndexedFold
Int (Map WatchKind [(v, a, Term v a)]) [(v, a, Term v a)]
folded (([(v, a, Term v a)] -> Const (First a) [(v, a, Term v a)])
-> Map WatchKind [(v, a, Term v a)]
-> Const (First a) (Map WatchKind [(v, a, Term v a)]))
-> ((a -> Const (First a) a)
-> [(v, a, Term v a)] -> Const (First a) [(v, a, Term v a)])
-> Getting (First a) (Map WatchKind [(v, a, Term v a)]) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> [(v, a, Term v a)] -> Const (First a) [(v, a, Term v a)]
forall (f :: * -> *) a. Foldable f => IndexedFold Int (f a) a
IndexedFold Int [(v, a, Term v a)] (v, a, Term v a)
folded (((v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> [(v, a, Term v a)] -> Const (First a) [(v, a, Term v a)])
-> ((a -> Const (First a) a)
-> (v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> (a -> Const (First a) a)
-> [(v, a, Term v a)]
-> Const (First a) [(v, a, Term v a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (First ()) (v, a, Term v a) ()
-> ((v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> (v, a, Term v a)
-> Const (First a) (v, a, Term v a)
forall i (p :: * -> * -> *) (f :: * -> *) a.
(Indexable i p, Applicative f) =>
Getting (First i) a i -> p a (f a) -> a -> f a
filteredBy ((v -> Const (First ()) v)
-> (v, a, Term v a) -> Const (First ()) (v, a, Term v a)
forall s t a b. Field1 s t a b => Lens s t a b
Lens (v, a, Term v a) (v, a, Term v a) v v
_1 ((v -> Const (First ()) v)
-> (v, a, Term v a) -> Const (First ()) (v, a, Term v a))
-> ((() -> Const (First ()) ()) -> v -> Const (First ()) v)
-> Getting (First ()) (v, a, Term v a) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. v -> Prism' v ()
forall a. Eq a => a -> Prism' a ()
only v
v) (((v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> (v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> ((a -> Const (First a) a)
-> (v, a, Term v a) -> Const (First a) (v, a, Term v a))
-> (a -> Const (First a) a)
-> (v, a, Term v a)
-> Const (First a) (v, a, Term v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Const (First a) a)
-> (v, a, Term v a) -> Const (First a) (v, a, Term v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens (v, a, Term v a) (v, a, Term v a) a a
_2
Maybe a -> Maybe a -> Maybe a
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> UnisonFile v a -> Map v (Reference, DataDeclaration v a)
forall v a.
UnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations UnisonFile v a
uf Map v (Reference, DataDeclaration v a)
-> Getting (First a) (Map v (Reference, DataDeclaration v a)) a
-> Maybe a
forall s a. s -> Getting (First a) s a -> Maybe a
^? Index (Map v (Reference, DataDeclaration v a))
-> Traversal'
(Map v (Reference, DataDeclaration v a))
(IxValue (Map v (Reference, DataDeclaration v a)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix v
Index (Map v (Reference, DataDeclaration v a))
v (((Reference, DataDeclaration v a)
-> Const (First a) (Reference, DataDeclaration v a))
-> Map v (Reference, DataDeclaration v a)
-> Const (First a) (Map v (Reference, DataDeclaration v a)))
-> ((a -> Const (First a) a)
-> (Reference, DataDeclaration v a)
-> Const (First a) (Reference, DataDeclaration v a))
-> Getting (First a) (Map v (Reference, DataDeclaration v a)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DataDeclaration v a -> Const (First a) (DataDeclaration v a))
-> (Reference, DataDeclaration v a)
-> Const (First a) (Reference, DataDeclaration v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(Reference, DataDeclaration v a)
(Reference, DataDeclaration v a)
(DataDeclaration v a)
(DataDeclaration v a)
_2 ((DataDeclaration v a -> Const (First a) (DataDeclaration v a))
-> (Reference, DataDeclaration v a)
-> Const (First a) (Reference, DataDeclaration v a))
-> ((a -> Const (First a) a)
-> DataDeclaration v a -> Const (First a) (DataDeclaration v a))
-> (a -> Const (First a) a)
-> (Reference, DataDeclaration v a)
-> Const (First a) (Reference, DataDeclaration v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DataDeclaration v a -> a)
-> (a -> Const (First a) a)
-> DataDeclaration v a
-> Const (First a) (DataDeclaration v a)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to DataDeclaration v a -> a
forall v a. DataDeclaration v a -> a
DD.annotation
Maybe a -> Maybe a -> Maybe a
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> UnisonFile v a -> Map v (Reference, EffectDeclaration v a)
forall v a.
UnisonFile v a -> Map v (Reference, EffectDeclaration v a)
effectDeclarations UnisonFile v a
uf Map v (Reference, EffectDeclaration v a)
-> Getting (First a) (Map v (Reference, EffectDeclaration v a)) a
-> Maybe a
forall s a. s -> Getting (First a) s a -> Maybe a
^? Index (Map v (Reference, EffectDeclaration v a))
-> Traversal'
(Map v (Reference, EffectDeclaration v a))
(IxValue (Map v (Reference, EffectDeclaration v a)))
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix v
Index (Map v (Reference, EffectDeclaration v a))
v (((Reference, EffectDeclaration v a)
-> Const (First a) (Reference, EffectDeclaration v a))
-> Map v (Reference, EffectDeclaration v a)
-> Const (First a) (Map v (Reference, EffectDeclaration v a)))
-> ((a -> Const (First a) a)
-> (Reference, EffectDeclaration v a)
-> Const (First a) (Reference, EffectDeclaration v a))
-> Getting (First a) (Map v (Reference, EffectDeclaration v a)) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EffectDeclaration v a -> Const (First a) (EffectDeclaration v a))
-> (Reference, EffectDeclaration v a)
-> Const (First a) (Reference, EffectDeclaration v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(Reference, EffectDeclaration v a)
(Reference, EffectDeclaration v a)
(EffectDeclaration v a)
(EffectDeclaration v a)
_2 ((EffectDeclaration v a -> Const (First a) (EffectDeclaration v a))
-> (Reference, EffectDeclaration v a)
-> Const (First a) (Reference, EffectDeclaration v a))
-> ((a -> Const (First a) a)
-> EffectDeclaration v a
-> Const (First a) (EffectDeclaration v a))
-> (a -> Const (First a) a)
-> (Reference, EffectDeclaration v a)
-> Const (First a) (Reference, EffectDeclaration v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EffectDeclaration v a -> a)
-> (a -> Const (First a) a)
-> EffectDeclaration v a
-> Const (First a) (EffectDeclaration v a)
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to (DataDeclaration v a -> a
forall v a. DataDeclaration v a -> a
DD.annotation (DataDeclaration v a -> a)
-> (EffectDeclaration v a -> DataDeclaration v a)
-> EffectDeclaration v a
-> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EffectDeclaration v a -> DataDeclaration v a
forall v a. EffectDeclaration v a -> DataDeclaration v a
DD.toDataDecl)
typecheckingTerm :: (Var v, Monoid a) => UnisonFile v a -> Term v a
typecheckingTerm :: forall v a. (Var v, Monoid a) => UnisonFile v a -> Term v a
typecheckingTerm UnisonFile v a
uf =
Bool -> [(v, a, Term v a)] -> Term v a -> Term v a
forall v a vt.
(Ord v, Monoid a) =>
Bool -> [(v, a, Term' vt v a)] -> Term' vt v a -> Term' vt v a
Term.letRec' Bool
True [(v, a, Term v a)]
bindings (Term v a -> Term v a) -> Term v a -> Term v a
forall a b. (a -> b) -> a -> b
$
a -> Term v a
forall v a vt at ap. Var v => a -> Term2 vt at ap v a
DD.unitTerm a
forall a. Monoid a => a
mempty
where
bindings :: [(v, a, Term v a)]
bindings =
UnisonFile v a -> [(v, a, Term v a)]
forall v a. UnisonFile v a -> [(v, a, Term v a)]
termBindings UnisonFile v a
uf [(v, a, Term v a)] -> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a. Semigroup a => a -> a -> a
<> [(v, a, Term v a)]
testWatches [(v, a, Term v a)] -> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a. Semigroup a => a -> a -> a
<> WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
forall v a. WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
watchesOfOtherKinds WatchKind
forall a. (Eq a, IsString a) => a
TestWatch UnisonFile v a
uf
f :: Term (F vt at ap) v at -> Term (F vt at ap) v at
f Term (F vt at ap) v at
w = let wa :: at
wa = Term (F vt at ap) v at -> at
forall (f :: * -> *) v a. Term f v a -> a
ABT.annotation Term (F vt at ap) v at
w in at
-> Term (F vt at ap) v at -> Type vt at -> Term (F vt at ap) v at
forall v a vt at ap.
Ord v =>
a -> Term2 vt at ap v a -> Type vt at -> Term2 vt at ap v a
Term.ann at
wa Term (F vt at ap) v at
w (at -> Type vt at
forall v a. Ord v => a -> Type v a
DD.testResultListType at
wa)
testWatches :: [(v, a, Term v a)]
testWatches = ((v, a, Term v a) -> (v, a, Term v a))
-> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a b. (a -> b) -> [a] -> [b]
map ((Term v a -> Term v a) -> (v, a, Term v a) -> (v, a, Term v a)
forall b c a. (b -> c) -> (v, a, b) -> (v, a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second Term v a -> Term v a
forall {v} {vt} {at} {ap}.
(Ord v, Ord vt) =>
Term (F vt at ap) v at -> Term (F vt at ap) v at
f) ([(v, a, Term v a)] -> [(v, a, Term v a)])
-> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a b. (a -> b) -> a -> b
$ WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
forall v a. WatchKind -> UnisonFile v a -> [(v, a, Term v a)]
watchesOfKind WatchKind
forall a. (Eq a, IsString a) => a
TestWatch UnisonFile v a
uf
termBindings :: UnisonFile v a -> [(v, a, Term v a)]
termBindings :: forall v a. UnisonFile v a -> [(v, a, Term v a)]
termBindings UnisonFile v a
uf =
(v -> (a, Term v a) -> [(v, a, Term v a)] -> [(v, a, Term v a)])
-> [(v, a, Term v a)] -> Map v (a, Term v a) -> [(v, a, Term v a)]
forall k a b. (k -> a -> b -> b) -> b -> Map k a -> b
Map.foldrWithKey (\v
k (a
a, Term v a
t) [(v, a, Term v a)]
b -> (v
k, a
a, Term v a
t) (v, a, Term v a) -> [(v, a, Term v a)] -> [(v, a, Term v a)]
forall a. a -> [a] -> [a]
: [(v, a, Term v a)]
b) [] UnisonFile v a
uf.terms
dataDeclarations' :: TypecheckedUnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations' :: forall v a.
TypecheckedUnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations' = ((TypeReferenceId, DataDeclaration v a)
-> (Reference, DataDeclaration v a))
-> Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (Reference, DataDeclaration v a)
forall a b. (a -> b) -> Map v a -> Map v b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((TypeReferenceId -> Reference)
-> (TypeReferenceId, DataDeclaration v a)
-> (Reference, DataDeclaration v a)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first TypeReferenceId -> Reference
forall h t. Id' h -> Reference' t h
Reference.DerivedId) (Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (Reference, DataDeclaration v a))
-> (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a))
-> TypecheckedUnisonFile v a
-> Map v (Reference, DataDeclaration v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId'
effectDeclarations' :: TypecheckedUnisonFile v a -> Map v (Reference, EffectDeclaration v a)
effectDeclarations' :: forall v a.
TypecheckedUnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
effectDeclarations' = ((TypeReferenceId, EffectDeclaration v a)
-> (Reference, EffectDeclaration v a))
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (Reference, EffectDeclaration v a)
forall a b. (a -> b) -> Map v a -> Map v b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((TypeReferenceId -> Reference)
-> (TypeReferenceId, EffectDeclaration v a)
-> (Reference, EffectDeclaration v a)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first TypeReferenceId -> Reference
forall h t. Id' h -> Reference' t h
Reference.DerivedId) (Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (Reference, EffectDeclaration v a))
-> (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a))
-> TypecheckedUnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId'
hashTerms :: TypecheckedUnisonFile v a -> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
hashTerms :: forall v a.
TypecheckedUnisonFile v a
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
hashTerms = ((a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
-> (a, Reference, Maybe WatchKind, Term v a, Type v a))
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
forall a b. (a -> b) -> Map v a -> Map v b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ASetter
(a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
(a, Reference, Maybe WatchKind, Term v a, Type v a)
TypeReferenceId
Reference
-> (TypeReferenceId -> Reference)
-> (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
-> (a, Reference, Maybe WatchKind, Term v a, Type v a)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
(a, Reference, Maybe WatchKind, Term v a, Type v a)
TypeReferenceId
Reference
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
(a, Reference, Maybe WatchKind, Term v a, Type v a)
TypeReferenceId
Reference
_2 TypeReferenceId -> Reference
forall h t. Id' h -> Reference' t h
Reference.DerivedId) (Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a))
-> (TypecheckedUnisonFile v a
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a))
-> TypecheckedUnisonFile v a
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TypecheckedUnisonFile v a
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
hashTermsId
mapTerms :: (Term v a -> Term v a) -> UnisonFile v a -> UnisonFile v a
mapTerms :: forall v a.
(Term v a -> Term v a) -> UnisonFile v a -> UnisonFile v a
mapTerms Term v a -> Term v a
f (UnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects Map v (a, Term v a)
terms Map WatchKind [(v, a, Term v a)]
watches) =
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (a, Term v a)
-> Map WatchKind [(v, a, Term v a)]
-> UnisonFile v a
forall v a.
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (a, Term v a)
-> Map WatchKind [(v, a, Term v a)]
-> UnisonFile v a
UnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects Map v (a, Term v a)
terms' Map WatchKind [(v, a, Term v a)]
watches'
where
terms' :: Map v (a, Term v a)
terms' = ASetter
(Map v (a, Term v a)) (Map v (a, Term v a)) (Term v a) (Term v a)
-> (Term v a -> Term v a)
-> Map v (a, Term v a)
-> Map v (a, Term v a)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (((a, Term v a) -> Identity (a, Term v a))
-> Map v (a, Term v a) -> Identity (Map v (a, Term v a))
Setter
(Map v (a, Term v a))
(Map v (a, Term v a))
(a, Term v a)
(a, Term v a)
forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped (((a, Term v a) -> Identity (a, Term v a))
-> Map v (a, Term v a) -> Identity (Map v (a, Term v a)))
-> ((Term v a -> Identity (Term v a))
-> (a, Term v a) -> Identity (a, Term v a))
-> ASetter
(Map v (a, Term v a)) (Map v (a, Term v a)) (Term v a) (Term v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Term v a -> Identity (Term v a))
-> (a, Term v a) -> Identity (a, Term v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens (a, Term v a) (a, Term v a) (Term v a) (Term v a)
_2) Term v a -> Term v a
f Map v (a, Term v a)
terms
watches' :: Map WatchKind [(v, a, Term v a)]
watches' = ASetter
(Map WatchKind [(v, a, Term v a)])
(Map WatchKind [(v, a, Term v a)])
(Term v a)
(Term v a)
-> (Term v a -> Term v a)
-> Map WatchKind [(v, a, Term v a)]
-> Map WatchKind [(v, a, Term v a)]
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over (([(v, a, Term v a)] -> Identity [(v, a, Term v a)])
-> Map WatchKind [(v, a, Term v a)]
-> Identity (Map WatchKind [(v, a, Term v a)])
Setter
(Map WatchKind [(v, a, Term v a)])
(Map WatchKind [(v, a, Term v a)])
[(v, a, Term v a)]
[(v, a, Term v a)]
forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped (([(v, a, Term v a)] -> Identity [(v, a, Term v a)])
-> Map WatchKind [(v, a, Term v a)]
-> Identity (Map WatchKind [(v, a, Term v a)]))
-> ((Term v a -> Identity (Term v a))
-> [(v, a, Term v a)] -> Identity [(v, a, Term v a)])
-> ASetter
(Map WatchKind [(v, a, Term v a)])
(Map WatchKind [(v, a, Term v a)])
(Term v a)
(Term v a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((v, a, Term v a) -> Identity (v, a, Term v a))
-> [(v, a, Term v a)] -> Identity [(v, a, Term v a)]
Setter
[(v, a, Term v a)]
[(v, a, Term v a)]
(v, a, Term v a)
(v, a, Term v a)
forall (f :: * -> *) a b. Functor f => Setter (f a) (f b) a b
mapped (((v, a, Term v a) -> Identity (v, a, Term v a))
-> [(v, a, Term v a)] -> Identity [(v, a, Term v a)])
-> ((Term v a -> Identity (Term v a))
-> (v, a, Term v a) -> Identity (v, a, Term v a))
-> (Term v a -> Identity (Term v a))
-> [(v, a, Term v a)]
-> Identity [(v, a, Term v a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Term v a -> Identity (Term v a))
-> (v, a, Term v a) -> Identity (v, a, Term v a)
forall s t a b. Field3 s t a b => Lens s t a b
Lens (v, a, Term v a) (v, a, Term v a) (Term v a) (Term v a)
_3) Term v a -> Term v a
f Map WatchKind [(v, a, Term v a)]
watches
prepareRewrite :: (Monoid a, Var v) => UnisonFile v a -> ([v] -> Term v a -> Term v a, UnisonFile v a, UnisonFile v a -> UnisonFile v a)
prepareRewrite :: forall a v.
(Monoid a, Var v) =>
UnisonFile v a
-> ([v] -> Term v a -> Term v a, UnisonFile v a,
UnisonFile v a -> UnisonFile v a)
prepareRewrite uf :: UnisonFile v a
uf@(UnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
_datas Map v (TypeReferenceId, EffectDeclaration v a)
_effects Map v (a, Term v a)
_terms Map WatchKind [(v, a, Term v a)]
watches) =
([v] -> Term v a -> Term v a
freshen, (Term v a -> Term v a) -> UnisonFile v a -> UnisonFile v a
forall v a.
(Term v a -> Term v a) -> UnisonFile v a -> UnisonFile v a
mapTerms Term v a -> Term v a
substs UnisonFile v a
uf, (Term v a -> Term v a) -> UnisonFile v a -> UnisonFile v a
forall v a.
(Term v a -> Term v a) -> UnisonFile v a -> UnisonFile v a
mapTerms Term v a -> Term v a
refToVar)
where
substs :: Term v a -> Term v a
substs = [(v, Term (F v a a) v ())] -> Term v a -> Term v a
forall (f :: * -> *) v b a.
(Foldable f, Functor f, Var v) =>
[(v, Term f v b)] -> Term f v a -> Term f v a
ABT.substsInheritAnnotation [(v, Term (F v a a) v ())]
varToRef
freshen :: [v] -> Term v a -> Term v a
freshen [v]
vs Term v a
tm = case (v -> v) -> Term v a -> [Term v a] -> [Term v a]
forall v (f :: * -> *) a.
(Var v, Traversable f) =>
(v -> v) -> Term f v a -> [Term f v a] -> [Term f v a]
ABT.freshenWrt v -> v
forall v. Var v => v -> v
Var.bakeId (UnisonFile v a -> Term v a
forall v a. (Var v, Monoid a) => UnisonFile v a -> Term v a
typecheckingTerm UnisonFile v a
uf) [Term v a
tm1] of
[Term v a
tm] -> Term v a
tm
[Term v a]
_ -> WatchKind -> Term v a
forall a. HasCallStack => WatchKind -> a
error WatchKind
"prepareRewrite bug (in freshen)"
where
tm0 :: Term v a
tm0 = [(a, v)] -> Term v a -> Term v a
forall v a (f :: * -> *).
Ord v =>
[(a, v)] -> Term f v a -> Term f v a
ABT.absChain' (a -> [a]
forall a. a -> [a]
repeat (Term v a -> a
forall (f :: * -> *) v a. Term f v a -> a
ABT.annotation Term v a
tm) [a] -> [v] -> [(a, v)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [v]
vs) Term v a
tm
tm1 :: Term v a
tm1 = Int -> Term v a -> Term v a
forall (f :: * -> *) v a. Int -> Term f v a -> Term f v a
ABT.dropAbs ([v] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [v]
vs) (Term v a -> Term v a
substs Term v a
tm0)
h :: Hash
h = ByteString -> Hash
Hash.fromByteString ByteString
"f0dd645e2382aba2035350297fb2a26263d1891965e5f351e19ae69317b1c866"
varToRef :: [(v, Term (F v a a) v ())]
varToRef =
[(v
v, () -> Reference -> Term (F v a a) v ()
forall v a vt at ap. Ord v => a -> Reference -> Term2 vt at ap v a
Term.ref () (Hash -> Pos -> Reference
forall h t. h -> Pos -> Reference' t h
Reference.Derived Hash
h Pos
i)) | (v
v, Pos
i) <- [v]
vs [v] -> [Pos] -> [(v, Pos)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [Pos
0 ..]]
where
vs :: [v]
vs = (Getting v (v, a, Term v a) v -> (v, a, Term v a) -> v
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting v (v, a, Term v a) v
forall s t a b. Field1 s t a b => Lens s t a b
Lens (v, a, Term v a) (v, a, Term v a) v v
_1 ((v, a, Term v a) -> v) -> [(v, a, Term v a)] -> [v]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (UnisonFile v a -> [(v, a, Term v a)]
forall v a. UnisonFile v a -> [(v, a, Term v a)]
termBindings UnisonFile v a
uf)) [v] -> [v] -> [v]
forall a. Semigroup a => a -> a -> a
<> (Map WatchKind [(v, a, Term v a)] -> [[(v, a, Term v a)]]
forall a. Map WatchKind a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Map WatchKind [(v, a, Term v a)]
watches [[(v, a, Term v a)]] -> ([(v, a, Term v a)] -> [v]) -> [v]
forall a b. [a] -> (a -> [b]) -> [b]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ((v, a, Term v a) -> v) -> [(v, a, Term v a)] -> [v]
forall a b. (a -> b) -> [a] -> [b]
map (Getting v (v, a, Term v a) v -> (v, a, Term v a) -> v
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting v (v, a, Term v a) v
forall s t a b. Field1 s t a b => Lens s t a b
Lens (v, a, Term v a) (v, a, Term v a) v v
_1))
vars :: Vector v
vars = [v] -> Vector v
forall a. [a] -> Vector a
Vector.fromList ((v, Term (F v a a) v ()) -> v
forall a b. (a, b) -> a
fst ((v, Term (F v a a) v ()) -> v)
-> [(v, Term (F v a a) v ())] -> [v]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(v, Term (F v a a) v ())]
varToRef)
refToVar :: Term v a -> Term v a
refToVar = (Term v a -> Term v a) -> Term v a -> Term v a
forall v (f :: * -> *) a.
(Ord v, Foldable f, Functor f) =>
(Term f v a -> Term f v a) -> Term f v a -> Term f v a
ABT.rebuildUp' Term v a -> Term v a
go
where
go :: Term v a -> Term v a
go tm :: Term v a
tm@(Term.Ref' (Reference.Derived Hash
h0 Pos
i)) | Hash
h Hash -> Hash -> Bool
forall a. Eq a => a -> a -> Bool
== Hash
h0 =
case Vector v
vars Vector v -> Int -> Maybe v
forall a. Vector a -> Int -> Maybe a
Vector.!? (Pos -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Pos
i) of
Just v
v -> a -> v -> Term v a
forall a v vt at ap. a -> v -> Term2 vt at ap v a
Term.var (Term v a -> a
forall (f :: * -> *) v a. Term f v a -> a
ABT.annotation Term v a
tm) v
v
Maybe v
Nothing -> WatchKind -> Term v a
forall a. HasCallStack => WatchKind -> a
error (WatchKind -> Term v a) -> WatchKind -> Term v a
forall a b. (a -> b) -> a -> b
$ WatchKind
"UnisonFile.prepareRewrite bug, index out of bounds: " WatchKind -> WatchKind -> WatchKind
forall a. [a] -> [a] -> [a]
++ Pos -> WatchKind
forall a. Show a => a -> WatchKind
show Pos
i
go Term v a
tm = Term v a
tm
rewrite :: (Var v, Eq a) => Set v -> (Term v a -> Maybe (Term v a)) -> UnisonFile v a -> ([v], UnisonFile v a)
rewrite :: forall v a.
(Var v, Eq a) =>
Set v
-> (Term v a -> Maybe (Term v a))
-> UnisonFile v a
-> ([v], UnisonFile v a)
rewrite Set v
leaveAlone Term (F v a a) v a -> Maybe (Term (F v a a) v a)
rewriteFn uf :: UnisonFile v a
uf@(UnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects Map v (a, Term (F v a a) v a)
_terms Map WatchKind [(v, a, Term (F v a a) v a)]
watches) =
([v]
rewritten, Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (a, Term (F v a a) v a)
-> Map WatchKind [(v, a, Term (F v a a) v a)]
-> UnisonFile v a
forall v a.
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (a, Term v a)
-> Map WatchKind [(v, a, Term v a)]
-> UnisonFile v a
UnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects ([(v, (a, Term (F v a a) v a))] -> Map v (a, Term (F v a a) v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(v, (a, Term (F v a a) v a))] -> Map v (a, Term (F v a a) v a))
-> [(v, (a, Term (F v a a) v a))] -> Map v (a, Term (F v a a) v a)
forall a b. (a -> b) -> a -> b
$ [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> [(v, (a, Term (F v a a) v a))]
forall {a} {a} {b}. [(a, a, Either b b)] -> [(a, (a, b))]
unEitherTerms [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
terms') ([(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> [(v, a, Term (F v a a) v a)]
forall {a} {b} {c}. [(a, b, Either c c)] -> [(a, b, c)]
unEither ([(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> [(v, a, Term (F v a a) v a)])
-> Map
WatchKind
[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> Map WatchKind [(v, a, Term (F v a a) v a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map
WatchKind
[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
watches'))
where
terms' :: [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
terms' = [(v, a, Term (F v a a) v a)]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
go (UnisonFile v a -> [(v, a, Term (F v a a) v a)]
forall v a. UnisonFile v a -> [(v, a, Term v a)]
termBindings UnisonFile v a
uf)
watches' :: Map
WatchKind
[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
watches' = [(v, a, Term (F v a a) v a)]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
go ([(v, a, Term (F v a a) v a)]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))])
-> Map WatchKind [(v, a, Term (F v a a) v a)]
-> Map
WatchKind
[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map WatchKind [(v, a, Term (F v a a) v a)]
watches
go :: [(v, a, Term (F v a a) v a)]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
go [(v, a, Term (F v a a) v a)]
tms = [(v
v, a
a, Either (Term (F v a a) v a) (Term (F v a a) v a)
tm') | (v
v, a
a, Term (F v a a) v a
tm) <- [(v, a, Term (F v a a) v a)]
tms, Either (Term (F v a a) v a) (Term (F v a a) v a)
tm' <- v
-> Term (F v a a) v a
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)]
f v
v Term (F v a a) v a
tm]
where
f :: v
-> Term (F v a a) v a
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)]
f v
v Term (F v a a) v a
tm | v -> Set v -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member v
v Set v
leaveAlone = [Term (F v a a) v a
-> Either (Term (F v a a) v a) (Term (F v a a) v a)
forall a b. a -> Either a b
Left Term (F v a a) v a
tm]
f v
_ Term (F v a a) v a
tm = [Either (Term (F v a a) v a) (Term (F v a a) v a)]
-> (Term (F v a a) v a
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)])
-> Maybe (Term (F v a a) v a)
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [Term (F v a a) v a
-> Either (Term (F v a a) v a) (Term (F v a a) v a)
forall a b. a -> Either a b
Left Term (F v a a) v a
tm] (Either (Term (F v a a) v a) (Term (F v a a) v a)
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either (Term (F v a a) v a) (Term (F v a a) v a)
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)])
-> (Term (F v a a) v a
-> Either (Term (F v a a) v a) (Term (F v a a) v a))
-> Term (F v a a) v a
-> [Either (Term (F v a a) v a) (Term (F v a a) v a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Term (F v a a) v a
-> Either (Term (F v a a) v a) (Term (F v a a) v a)
forall a b. b -> Either a b
Right) (Term (F v a a) v a -> Maybe (Term (F v a a) v a)
rewriteFn Term (F v a a) v a
tm)
rewritten :: [v]
rewritten = [v
v | (v
v, a
_, Right Term (F v a a) v a
_) <- [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
terms' [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
forall a. Semigroup a => a -> a -> a
<> [[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]]
-> [(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Map
WatchKind
[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
-> [[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]]
forall a. Map WatchKind a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Map
WatchKind
[(v, a, Either (Term (F v a a) v a) (Term (F v a a) v a))]
watches')]
unEitherTerms :: [(a, a, Either b b)] -> [(a, (a, b))]
unEitherTerms = ((a, a, Either b b) -> (a, (a, b)))
-> [(a, a, Either b b)] -> [(a, (a, b))]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(a
v, a
a, Either b b
e) -> (a
v, (a
a, (b -> b) -> (b -> b) -> Either b b -> b
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either b -> b
forall a. a -> a
id b -> b
forall a. a -> a
id Either b b
e)))
unEither :: [(a, b, Either c c)] -> [(a, b, c)]
unEither = ((a, b, Either c c) -> (a, b, c))
-> [(a, b, Either c c)] -> [(a, b, c)]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(a
v, b
a, Either c c
e) -> (a
v, b
a, (c -> c) -> (c -> c) -> Either c c -> c
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either c -> c
forall a. a -> a
id c -> c
forall a. a -> a
id Either c c
e))
typecheckedUnisonFile ::
forall v a.
(Var v) =>
Map v (Reference.Id, DataDeclaration v a) ->
Map v (Reference.Id, EffectDeclaration v a) ->
[[(v, a, Term v a, Type v a)]] ->
[(WatchKind, [(v, a, Term v a, Type v a)])] ->
TypecheckedUnisonFile v a
typecheckedUnisonFile :: forall v a.
Var v =>
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> [[(v, a, Term v a, Type v a)]]
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
-> TypecheckedUnisonFile v a
typecheckedUnisonFile Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects [[(v, a, Term v a, Type v a)]]
tlcs [(WatchKind, [(v, a, Term v a, Type v a)])]
watches =
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> [[(v, a, Term v a, Type v a)]]
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
-> TypecheckedUnisonFile v a
forall v a.
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> [[(v, a, Term v a, Type v a)]]
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
-> TypecheckedUnisonFile v a
TypecheckedUnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects [[(v, a, Term v a, Type v a)]]
tlcs [(WatchKind, [(v, a, Term v a, Type v a)])]
watches Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
hashImpl
where
hashImpl :: (Map v (a, Reference.Id, Maybe WatchKind, Term v a, Type v a))
hashImpl :: Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
hashImpl =
let
allTerms :: [(v, a, Term v a, Type v a)]
allTerms :: [(v, a, Term v a, Type v a)]
allTerms = [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join [[(v, a, Term v a, Type v a)]]
tlcs [(v, a, Term v a, Type v a)]
-> [(v, a, Term v a, Type v a)] -> [(v, a, Term v a, Type v a)]
forall a. [a] -> [a] -> [a]
++ [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join ((WatchKind, [(v, a, Term v a, Type v a)])
-> [(v, a, Term v a, Type v a)]
forall a b. (a, b) -> b
snd ((WatchKind, [(v, a, Term v a, Type v a)])
-> [(v, a, Term v a, Type v a)])
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
-> [[(v, a, Term v a, Type v a)]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(WatchKind, [(v, a, Term v a, Type v a)])]
watches)
types :: Map v (Type v a)
types :: Map v (Type v a)
types = [(v, Type v a)] -> Map v (Type v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(v
v, Type v a
t) | (v
v, a
_a, Term v a
_, Type v a
t) <- [(v, a, Term v a, Type v a)]
allTerms]
watchKinds :: Map v (Maybe WatchKind)
watchKinds :: Map v (Maybe WatchKind)
watchKinds =
[(v, Maybe WatchKind)] -> Map v (Maybe WatchKind)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(v, Maybe WatchKind)] -> Map v (Maybe WatchKind))
-> [(v, Maybe WatchKind)] -> Map v (Maybe WatchKind)
forall a b. (a -> b) -> a -> b
$
[(v
v, Maybe WatchKind
forall a. Maybe a
Nothing) | (v
v, a
_a, Term v a
_e, Type v a
_t) <- [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join [[(v, a, Term v a, Type v a)]]
tlcs]
[(v, Maybe WatchKind)]
-> [(v, Maybe WatchKind)] -> [(v, Maybe WatchKind)]
forall a. [a] -> [a] -> [a]
++ [(v
v, WatchKind -> Maybe WatchKind
forall a. a -> Maybe a
Just WatchKind
wk) | (WatchKind
wk, [(v, a, Term v a, Type v a)]
wkTerms) <- [(WatchKind, [(v, a, Term v a, Type v a)])]
watches, (v
v, a
_a, Term v a
_e, Type v a
_t) <- [(v, a, Term v a, Type v a)]
wkTerms]
hcs :: Map v (Reference.Id, Term v a, Type v a, a)
hcs :: Map v (TypeReferenceId, Term v a, Type v a, a)
hcs = Map v (Term v a, Type v a, a)
-> Map v (TypeReferenceId, Term v a, Type v a, a)
forall v a extra.
Var v =>
Map v (Term v a, Type v a, extra)
-> Map v (TypeReferenceId, Term v a, Type v a, extra)
Hashing.hashTermComponents (Map v (Term v a, Type v a, a)
-> Map v (TypeReferenceId, Term v a, Type v a, a))
-> Map v (Term v a, Type v a, a)
-> Map v (TypeReferenceId, Term v a, Type v a, a)
forall a b. (a -> b) -> a -> b
$ [(v, (Term v a, Type v a, a))] -> Map v (Term v a, Type v a, a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(v, (Term v a, Type v a, a))] -> Map v (Term v a, Type v a, a))
-> [(v, (Term v a, Type v a, a))] -> Map v (Term v a, Type v a, a)
forall a b. (a -> b) -> a -> b
$ (\(v
v, a
a, Term v a
e, Type v a
t) -> (v
v, (Term v a
e, Type v a
t, a
a))) ((v, a, Term v a, Type v a) -> (v, (Term v a, Type v a, a)))
-> [(v, a, Term v a, Type v a)] -> [(v, (Term v a, Type v a, a))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(v, a, Term v a, Type v a)]
allTerms
in [(v, (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a))]
-> Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (v
v, (a
a, TypeReferenceId
r, Maybe WatchKind
wk, Term v a
e, Type v a
t))
| (v
v, (TypeReferenceId
r, Term v a
e, Type v a
_typ, a
a)) <- Map v (TypeReferenceId, Term v a, Type v a, a)
-> [(v, (TypeReferenceId, Term v a, Type v a, a))]
forall k a. Map k a -> [(k, a)]
Map.toList Map v (TypeReferenceId, Term v a, Type v a, a)
hcs,
Just Type v a
t <- [v -> Map v (Type v a) -> Maybe (Type v a)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup v
v Map v (Type v a)
types],
Maybe WatchKind
wk <- [Maybe WatchKind -> v -> Map v (Maybe WatchKind) -> Maybe WatchKind
forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault (WatchKind -> Maybe WatchKind
forall a. HasCallStack => WatchKind -> a
error (WatchKind -> Maybe WatchKind) -> WatchKind -> Maybe WatchKind
forall a b. (a -> b) -> a -> b
$ v -> WatchKind
forall a. Show a => a -> WatchKind
show v
v WatchKind -> WatchKind -> WatchKind
forall a. [a] -> [a] -> [a]
++ WatchKind
" missing from watchKinds") v
v Map v (Maybe WatchKind)
watchKinds]
]
lookupDecl ::
(Ord v) =>
v ->
TypecheckedUnisonFile v a ->
Maybe (Reference.Id, DD.Decl v a)
lookupDecl :: forall v a.
Ord v =>
v -> TypecheckedUnisonFile v a -> Maybe (TypeReferenceId, Decl v a)
lookupDecl v
v TypecheckedUnisonFile v a
uf =
ASetter
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, Decl v a)
(DataDeclaration v a)
(Decl v a)
-> (DataDeclaration v a -> Decl v a)
-> (TypeReferenceId, DataDeclaration v a)
-> (TypeReferenceId, Decl v a)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, Decl v a)
(DataDeclaration v a)
(Decl v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, Decl v a)
(DataDeclaration v a)
(Decl v a)
_2 DataDeclaration v a -> Decl v a
forall a b. b -> Either a b
Right ((TypeReferenceId, DataDeclaration v a)
-> (TypeReferenceId, Decl v a))
-> Maybe (TypeReferenceId, DataDeclaration v a)
-> Maybe (TypeReferenceId, Decl v a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (v
-> Map v (TypeReferenceId, DataDeclaration v a)
-> Maybe (TypeReferenceId, DataDeclaration v a)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup v
v (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId' TypecheckedUnisonFile v a
uf))
Maybe (TypeReferenceId, Decl v a)
-> Maybe (TypeReferenceId, Decl v a)
-> Maybe (TypeReferenceId, Decl v a)
forall a. Maybe a -> Maybe a -> Maybe a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ASetter
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, Decl v a)
(EffectDeclaration v a)
(Decl v a)
-> (EffectDeclaration v a -> Decl v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> (TypeReferenceId, Decl v a)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, Decl v a)
(EffectDeclaration v a)
(Decl v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, Decl v a)
(EffectDeclaration v a)
(Decl v a)
_2 EffectDeclaration v a -> Decl v a
forall a b. a -> Either a b
Left ((TypeReferenceId, EffectDeclaration v a)
-> (TypeReferenceId, Decl v a))
-> Maybe (TypeReferenceId, EffectDeclaration v a)
-> Maybe (TypeReferenceId, Decl v a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (v
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Maybe (TypeReferenceId, EffectDeclaration v a)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup v
v (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId' TypecheckedUnisonFile v a
uf))
indexByReference ::
TypecheckedUnisonFile v a ->
(Map Reference.Id (a, Term v a, Type v a), Map Reference.Id (DD.Decl v a))
indexByReference :: forall v a.
TypecheckedUnisonFile v a
-> (Map TypeReferenceId (a, Term v a, Type v a),
Map TypeReferenceId (Decl v a))
indexByReference TypecheckedUnisonFile v a
uf = (Map TypeReferenceId (a, Term v a, Type v a)
tms, Map TypeReferenceId (Decl v a)
tys)
where
tys :: Map TypeReferenceId (Decl v a)
tys =
[(TypeReferenceId, Decl v a)] -> Map TypeReferenceId (Decl v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList (ASetter
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, Decl v a)
(DataDeclaration v a)
(Decl v a)
-> (DataDeclaration v a -> Decl v a)
-> (TypeReferenceId, DataDeclaration v a)
-> (TypeReferenceId, Decl v a)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, Decl v a)
(DataDeclaration v a)
(Decl v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, Decl v a)
(DataDeclaration v a)
(Decl v a)
_2 DataDeclaration v a -> Decl v a
forall a b. b -> Either a b
Right ((TypeReferenceId, DataDeclaration v a)
-> (TypeReferenceId, Decl v a))
-> [(TypeReferenceId, DataDeclaration v a)]
-> [(TypeReferenceId, Decl v a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map v (TypeReferenceId, DataDeclaration v a)
-> [(TypeReferenceId, DataDeclaration v a)]
forall a. Map v a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId' TypecheckedUnisonFile v a
uf))
Map TypeReferenceId (Decl v a)
-> Map TypeReferenceId (Decl v a) -> Map TypeReferenceId (Decl v a)
forall a. Semigroup a => a -> a -> a
<> [(TypeReferenceId, Decl v a)] -> Map TypeReferenceId (Decl v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList (ASetter
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, Decl v a)
(EffectDeclaration v a)
(Decl v a)
-> (EffectDeclaration v a -> Decl v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> (TypeReferenceId, Decl v a)
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
over ASetter
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, Decl v a)
(EffectDeclaration v a)
(Decl v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, Decl v a)
(EffectDeclaration v a)
(Decl v a)
_2 EffectDeclaration v a -> Decl v a
forall a b. a -> Either a b
Left ((TypeReferenceId, EffectDeclaration v a)
-> (TypeReferenceId, Decl v a))
-> [(TypeReferenceId, EffectDeclaration v a)]
-> [(TypeReferenceId, Decl v a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Map v (TypeReferenceId, EffectDeclaration v a)
-> [(TypeReferenceId, EffectDeclaration v a)]
forall a. Map v a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId' TypecheckedUnisonFile v a
uf))
tms :: Map TypeReferenceId (a, Term v a, Type v a)
tms =
[(TypeReferenceId, (a, Term v a, Type v a))]
-> Map TypeReferenceId (a, Term v a, Type v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
[ (TypeReferenceId
r, (a
a, Term v a
tm, Type v a
ty)) | (a
a, Reference.DerivedId TypeReferenceId
r, Maybe WatchKind
_wk, Term v a
tm, Type v a
ty) <- Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> [(a, Reference, Maybe WatchKind, Term v a, Type v a)]
forall k a. Map k a -> [a]
Map.elems (TypecheckedUnisonFile v a
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
hashTerms TypecheckedUnisonFile v a
uf)
]
allTerms :: (Ord v) => TypecheckedUnisonFile v a -> Map v (Term v a)
allTerms :: forall v a. Ord v => TypecheckedUnisonFile v a -> Map v (Term v a)
allTerms TypecheckedUnisonFile v a
uf =
[(v, Term v a)] -> Map v (Term v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(v
v, Term v a
t) | (v
v, a
_a, Term v a
t, Type v a
_) <- [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join ([[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)])
-> [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall a b. (a -> b) -> a -> b
$ TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
forall v a.
TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
topLevelComponents TypecheckedUnisonFile v a
uf]
topLevelComponents ::
TypecheckedUnisonFile v a ->
[[(v, a, Term v a, Type v a)]]
topLevelComponents :: forall v a.
TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
topLevelComponents TypecheckedUnisonFile v a
file =
TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
forall v a.
TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
topLevelComponents' TypecheckedUnisonFile v a
file [[(v, a, Term v a, Type v a)]]
-> [[(v, a, Term v a, Type v a)]] -> [[(v, a, Term v a, Type v a)]]
forall a. [a] -> [a] -> [a]
++ [[(v, a, Term v a, Type v a)]
comp | (WatchKind
TestWatch, [(v, a, Term v a, Type v a)]
comp) <- TypecheckedUnisonFile v a
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
forall v a.
TypecheckedUnisonFile v a
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
watchComponents TypecheckedUnisonFile v a
file]
termSignatureExternalLabeledDependencies ::
(Ord v) => TypecheckedUnisonFile v a -> Set LabeledDependency
termSignatureExternalLabeledDependencies :: forall v a.
Ord v =>
TypecheckedUnisonFile v a -> Set LabeledDependency
termSignatureExternalLabeledDependencies
(TypecheckedUnisonFile Map v (Reference, DataDeclaration v a)
dataDeclarations' Map v (Reference, EffectDeclaration v a)
effectDeclarations' [[(v, a, Term v a, Type v a)]]
_ [(WatchKind, [(v, a, Term v a, Type v a)])]
_ Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
hashTerms) =
Set LabeledDependency
-> Set LabeledDependency -> Set LabeledDependency
forall a. Ord a => Set a -> Set a -> Set a
Set.difference
( (Reference -> LabeledDependency)
-> Set Reference -> Set LabeledDependency
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map Reference -> LabeledDependency
LD.typeRef
(Set Reference -> Set LabeledDependency)
-> (Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> Set Reference)
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> Set LabeledDependency
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type v a -> Set Reference) -> [Type v a] -> Set Reference
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap Type v a -> Set Reference
forall v a. Ord v => Type v a -> Set Reference
Type.dependencies
([Type v a] -> Set Reference)
-> (Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> [Type v a])
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> Set Reference
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a, Reference, Maybe WatchKind, Term v a, Type v a) -> Type v a)
-> [(a, Reference, Maybe WatchKind, Term v a, Type v a)]
-> [Type v a]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(a
_a, Reference
_r, Maybe WatchKind
_wk, Term v a
_e, Type v a
t) -> Type v a
t)
([(a, Reference, Maybe WatchKind, Term v a, Type v a)]
-> [Type v a])
-> (Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> [(a, Reference, Maybe WatchKind, Term v a, Type v a)])
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> [Type v a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> [(a, Reference, Maybe WatchKind, Term v a, Type v a)]
forall a. Map v a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList
(Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> Set LabeledDependency)
-> Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
-> Set LabeledDependency
forall a b. (a -> b) -> a -> b
$ Map v (a, Reference, Maybe WatchKind, Term v a, Type v a)
hashTerms
)
( [LabeledDependency] -> Set LabeledDependency
forall a. Ord a => [a] -> Set a
Set.fromList ([LabeledDependency] -> Set LabeledDependency)
-> [LabeledDependency] -> Set LabeledDependency
forall a b. (a -> b) -> a -> b
$
(((Reference, DataDeclaration v a) -> LabeledDependency)
-> [(Reference, DataDeclaration v a)] -> [LabeledDependency]
forall a b. (a -> b) -> [a] -> [b]
map (Reference -> LabeledDependency
LD.typeRef (Reference -> LabeledDependency)
-> ((Reference, DataDeclaration v a) -> Reference)
-> (Reference, DataDeclaration v a)
-> LabeledDependency
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Reference, DataDeclaration v a) -> Reference
forall a b. (a, b) -> a
fst) ([(Reference, DataDeclaration v a)] -> [LabeledDependency])
-> (Map v (Reference, DataDeclaration v a)
-> [(Reference, DataDeclaration v a)])
-> Map v (Reference, DataDeclaration v a)
-> [LabeledDependency]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map v (Reference, DataDeclaration v a)
-> [(Reference, DataDeclaration v a)]
forall a. Map v a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList) Map v (Reference, DataDeclaration v a)
dataDeclarations'
[LabeledDependency] -> [LabeledDependency] -> [LabeledDependency]
forall a. Semigroup a => a -> a -> a
<> (((Reference, EffectDeclaration v a) -> LabeledDependency)
-> [(Reference, EffectDeclaration v a)] -> [LabeledDependency]
forall a b. (a -> b) -> [a] -> [b]
map (Reference -> LabeledDependency
LD.typeRef (Reference -> LabeledDependency)
-> ((Reference, EffectDeclaration v a) -> Reference)
-> (Reference, EffectDeclaration v a)
-> LabeledDependency
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Reference, EffectDeclaration v a) -> Reference
forall a b. (a, b) -> a
fst) ([(Reference, EffectDeclaration v a)] -> [LabeledDependency])
-> (Map v (Reference, EffectDeclaration v a)
-> [(Reference, EffectDeclaration v a)])
-> Map v (Reference, EffectDeclaration v a)
-> [LabeledDependency]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map v (Reference, EffectDeclaration v a)
-> [(Reference, EffectDeclaration v a)]
forall a. Map v a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList) Map v (Reference, EffectDeclaration v a)
effectDeclarations'
)
dependencies :: (Monoid a, Var v) => UnisonFile v a -> DefnsF Set TermReference TypeReference
dependencies :: forall a v.
(Monoid a, Var v) =>
UnisonFile v a -> DefnsF Set Reference Reference
dependencies UnisonFile v a
file =
[DefnsF Set Reference Reference] -> DefnsF Set Reference Reference
forall m. Monoid m => [m] -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold
[ Defns
{ $sel:terms:Defns :: Set Reference
terms = Set Reference
forall a. Set a
Set.empty,
$sel:types:Defns :: Set Reference
types =
[Set Reference] -> Set Reference
forall (f :: * -> *) a. (Foldable f, Ord a) => f (Set a) -> Set a
Set.unions
[ ((TypeReferenceId, DataDeclaration v a) -> Set Reference)
-> Map v (TypeReferenceId, DataDeclaration v a) -> Set Reference
forall m a. Monoid m => (a -> m) -> Map v a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (DataDeclaration v a -> Set Reference
forall v a. Ord v => DataDeclaration v a -> Set Reference
DD.typeDependencies (DataDeclaration v a -> Set Reference)
-> ((TypeReferenceId, DataDeclaration v a) -> DataDeclaration v a)
-> (TypeReferenceId, DataDeclaration v a)
-> Set Reference
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeReferenceId, DataDeclaration v a) -> DataDeclaration v a
forall a b. (a, b) -> b
snd) UnisonFile v a
file.dataDeclarationsId,
((TypeReferenceId, EffectDeclaration v a) -> Set Reference)
-> Map v (TypeReferenceId, EffectDeclaration v a) -> Set Reference
forall m a. Monoid m => (a -> m) -> Map v a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (DataDeclaration v a -> Set Reference
forall v a. Ord v => DataDeclaration v a -> Set Reference
DD.typeDependencies (DataDeclaration v a -> Set Reference)
-> ((TypeReferenceId, EffectDeclaration v a)
-> DataDeclaration v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> Set Reference
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EffectDeclaration v a -> DataDeclaration v a
forall v a. EffectDeclaration v a -> DataDeclaration v a
DD.toDataDecl (EffectDeclaration v a -> DataDeclaration v a)
-> ((TypeReferenceId, EffectDeclaration v a)
-> EffectDeclaration v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> DataDeclaration v a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeReferenceId, EffectDeclaration v a) -> EffectDeclaration v a
forall a b. (a, b) -> b
snd) UnisonFile v a
file.effectDeclarationsId
]
},
((a, Term2 v a a v a) -> DefnsF Set Reference Reference)
-> Map v (a, Term2 v a a v a) -> DefnsF Set Reference Reference
forall m a. Monoid m => (a -> m) -> Map v a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Term2 v a a v a -> DefnsF Set Reference Reference
forall v vt at ap a.
(Ord v, Ord vt) =>
Term2 vt at ap v a -> DefnsF Set Reference Reference
Term.dependencies (Term2 v a a v a -> DefnsF Set Reference Reference)
-> ((a, Term2 v a a v a) -> Term2 v a a v a)
-> (a, Term2 v a a v a)
-> DefnsF Set Reference Reference
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a, Term2 v a a v a) -> Term2 v a a v a
forall a b. (a, b) -> b
snd) UnisonFile v a
file.terms,
([(v, a, Term2 v a a v a)] -> DefnsF Set Reference Reference)
-> Map WatchKind [(v, a, Term2 v a a v a)]
-> DefnsF Set Reference Reference
forall m a. Monoid m => (a -> m) -> Map WatchKind a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (((v, a, Term2 v a a v a) -> DefnsF Set Reference Reference)
-> [(v, a, Term2 v a a v a)] -> DefnsF Set Reference Reference
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Term2 v a a v a -> DefnsF Set Reference Reference
forall v vt at ap a.
(Ord v, Ord vt) =>
Term2 vt at ap v a -> DefnsF Set Reference Reference
Term.dependencies (Term2 v a a v a -> DefnsF Set Reference Reference)
-> ((v, a, Term2 v a a v a) -> Term2 v a a v a)
-> (v, a, Term2 v a a v a)
-> DefnsF Set Reference Reference
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting (Term2 v a a v a) (v, a, Term2 v a a v a) (Term2 v a a v a)
-> (v, a, Term2 v a a v a) -> Term2 v a a v a
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Term2 v a a v a) (v, a, Term2 v a a v a) (Term2 v a a v a)
forall s t a b. Field3 s t a b => Lens s t a b
Lens
(v, a, Term2 v a a v a)
(v, a, Term2 v a a v a)
(Term2 v a a v a)
(Term2 v a a v a)
_3)) UnisonFile v a
file.watches
]
discardTypes :: (Ord v) => TypecheckedUnisonFile v a -> UnisonFile v a
discardTypes :: forall v a. Ord v => TypecheckedUnisonFile v a -> UnisonFile v a
discardTypes (TypecheckedUnisonFileId Map v (TypeReferenceId, DataDeclaration v a)
datas Map v (TypeReferenceId, EffectDeclaration v a)
effects [[(v, a, Term v a, Type v a)]]
terms [(WatchKind, [(v, a, Term v a, Type v a)])]
watches Map v (a, TypeReferenceId, Maybe WatchKind, Term v a, Type v a)
_) =
let watches' :: Map WatchKind [(v, a, Term v a)]
watches' = [(v, a, Term v a, Type v a)] -> [(v, a, Term v a)]
forall {a} {b} {c} {d}. [(a, b, c, d)] -> [(a, b, c)]
g ([(v, a, Term v a, Type v a)] -> [(v, a, Term v a)])
-> ([[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)])
-> [[(v, a, Term v a, Type v a)]]
-> [(v, a, Term v a)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall m. Monoid m => [m] -> m
mconcat ([[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a)])
-> Map WatchKind [[(v, a, Term v a, Type v a)]]
-> Map WatchKind [(v, a, Term v a)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(WatchKind, [(v, a, Term v a, Type v a)])]
-> Map WatchKind [[(v, a, Term v a, Type v a)]]
forall (f :: * -> *) k v.
(Foldable f, Ord k) =>
f (k, v) -> Map k [v]
List.multimap [(WatchKind, [(v, a, Term v a, Type v a)])]
watches
g :: [(a, b, c, d)] -> [(a, b, c)]
g [(a, b, c, d)]
tup3s = [(a
v, b
a, c
e) | (a
v, b
a, c
e, d
_t) <- [(a, b, c, d)]
tup3s]
in Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (a, Term v a)
-> Map WatchKind [(v, a, Term v a)]
-> UnisonFile v a
forall v a.
Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (a, Term v a)
-> Map WatchKind [(v, a, Term v a)]
-> UnisonFile v a
UnisonFileId (Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a)
forall a b. Coercible a b => a -> b
coerce Map v (TypeReferenceId, DataDeclaration v a)
datas) (Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall a b. Coercible a b => a -> b
coerce Map v (TypeReferenceId, EffectDeclaration v a)
effects) ([(v, (a, Term v a))] -> Map v (a, Term v a)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(v
v, (a
a, Term v a
trm)) | (v
v, a
a, Term v a
trm, Type v a
_typ) <- [[(v, a, Term v a, Type v a)]] -> [(v, a, Term v a, Type v a)]
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join [[(v, a, Term v a, Type v a)]]
terms]) Map WatchKind [(v, a, Term v a)]
watches'
declsToTypeLookup :: (Var v) => UnisonFile v a -> TL.TypeLookup v a
declsToTypeLookup :: forall v a. Var v => UnisonFile v a -> TypeLookup v a
declsToTypeLookup UnisonFile v a
uf =
Map Reference (Type v a)
-> Map Reference (DataDeclaration v a)
-> Map Reference (EffectDeclaration v a)
-> TypeLookup v a
forall v a.
Map Reference (Type v a)
-> Map Reference (DataDeclaration v a)
-> Map Reference (EffectDeclaration v a)
-> TypeLookup v a
TL.TypeLookup
Map Reference (Type v a)
forall a. Monoid a => a
mempty
(Map v (Reference, DataDeclaration v a)
-> Map Reference (DataDeclaration v a)
forall {k} {a}. Map k (Reference, a) -> Map Reference a
wrangle (UnisonFile v a -> Map v (Reference, DataDeclaration v a)
forall v a.
UnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations UnisonFile v a
uf))
(Map v (Reference, EffectDeclaration v a)
-> Map Reference (EffectDeclaration v a)
forall {k} {a}. Map k (Reference, a) -> Map Reference a
wrangle (UnisonFile v a -> Map v (Reference, EffectDeclaration v a)
forall v a.
UnisonFile v a -> Map v (Reference, EffectDeclaration v a)
effectDeclarations UnisonFile v a
uf))
where
wrangle :: Map k (Reference, a) -> Map Reference a
wrangle = [(Reference, a)] -> Map Reference a
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Reference, a)] -> Map Reference a)
-> (Map k (Reference, a) -> [(Reference, a)])
-> Map k (Reference, a)
-> Map Reference a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k (Reference, a) -> [(Reference, a)]
forall k a. Map k a -> [a]
Map.elems
typecheckedToTypeLookup :: TypecheckedUnisonFile v a -> TL.TypeLookup v a
typecheckedToTypeLookup :: forall v a. TypecheckedUnisonFile v a -> TypeLookup v a
typecheckedToTypeLookup TypecheckedUnisonFile v a
tuf =
Map Reference (Type v a)
-> Map Reference (DataDeclaration v a)
-> Map Reference (EffectDeclaration v a)
-> TypeLookup v a
forall v a.
Map Reference (Type v a)
-> Map Reference (DataDeclaration v a)
-> Map Reference (EffectDeclaration v a)
-> TypeLookup v a
TL.TypeLookup
Map Reference (Type v a)
forall a. Monoid a => a
mempty
(Map v (Reference, DataDeclaration v a)
-> Map Reference (DataDeclaration v a)
forall {k} {a}. Map k (Reference, a) -> Map Reference a
wrangle (TypecheckedUnisonFile v a -> Map v (Reference, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations' TypecheckedUnisonFile v a
tuf))
(Map v (Reference, EffectDeclaration v a)
-> Map Reference (EffectDeclaration v a)
forall {k} {a}. Map k (Reference, a) -> Map Reference a
wrangle (TypecheckedUnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
effectDeclarations' TypecheckedUnisonFile v a
tuf))
where
wrangle :: Map k (Reference, a) -> Map Reference a
wrangle = [(Reference, a)] -> Map Reference a
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Reference, a)] -> Map Reference a)
-> (Map k (Reference, a) -> [(Reference, a)])
-> Map k (Reference, a)
-> Map Reference a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map k (Reference, a) -> [(Reference, a)]
forall k a. Map k a -> [a]
Map.elems
nonEmpty :: TypecheckedUnisonFile v a -> Bool
nonEmpty :: forall v a. TypecheckedUnisonFile v a -> Bool
nonEmpty TypecheckedUnisonFile v a
uf =
Bool -> Bool
not (Map v (Reference, DataDeclaration v a) -> Bool
forall k a. Map k a -> Bool
Map.null (TypecheckedUnisonFile v a -> Map v (Reference, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a -> Map v (Reference, DataDeclaration v a)
dataDeclarations' TypecheckedUnisonFile v a
uf))
Bool -> Bool -> Bool
|| Bool -> Bool
not (Map v (Reference, EffectDeclaration v a) -> Bool
forall k a. Map k a -> Bool
Map.null (TypecheckedUnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (Reference, EffectDeclaration v a)
effectDeclarations' TypecheckedUnisonFile v a
uf))
Bool -> Bool -> Bool
|| ([(v, a, Term v a, Type v a)] -> Bool)
-> [[(v, a, Term v a, Type v a)]] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Bool -> Bool
not (Bool -> Bool)
-> ([(v, a, Term v a, Type v a)] -> Bool)
-> [(v, a, Term v a, Type v a)]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(v, a, Term v a, Type v a)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) (TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
forall v a.
TypecheckedUnisonFile v a -> [[(v, a, Term v a, Type v a)]]
topLevelComponents' TypecheckedUnisonFile v a
uf)
Bool -> Bool -> Bool
|| ((WatchKind, [(v, a, Term v a, Type v a)]) -> Bool)
-> [(WatchKind, [(v, a, Term v a, Type v a)])] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Bool -> Bool
not (Bool -> Bool)
-> ((WatchKind, [(v, a, Term v a, Type v a)]) -> Bool)
-> (WatchKind, [(v, a, Term v a, Type v a)])
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WatchKind, [(v, a, Term v a, Type v a)]) -> Bool
forall a. (WatchKind, a) -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null) (TypecheckedUnisonFile v a
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
forall v a.
TypecheckedUnisonFile v a
-> [(WatchKind, [(v, a, Term v a, Type v a)])]
watchComponents TypecheckedUnisonFile v a
uf)
hashConstructors ::
forall v a. (Ord v) => TypecheckedUnisonFile v a -> Map v Referent.Id
hashConstructors :: forall v a. Ord v => TypecheckedUnisonFile v a -> Map v Id
hashConstructors TypecheckedUnisonFile v a
file =
let ctors1 :: [(v, Id)]
ctors1 =
Map v (TypeReferenceId, DataDeclaration v a)
-> [(TypeReferenceId, DataDeclaration v a)]
forall k a. Map k a -> [a]
Map.elems (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId' TypecheckedUnisonFile v a
file) [(TypeReferenceId, DataDeclaration v a)]
-> ((TypeReferenceId, DataDeclaration v a) -> [(v, Id)])
-> [(v, Id)]
forall a b. [a] -> (a -> [b]) -> [b]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(TypeReferenceId
ref, DataDeclaration v a
dd) ->
[(v
v, ConstructorReferenceId -> ConstructorType -> Id
Referent.ConId (TypeReferenceId -> Pos -> ConstructorReferenceId
forall r. r -> Pos -> GConstructorReference r
ConstructorReference TypeReferenceId
ref Pos
i) ConstructorType
CT.Data) | (v
v, Pos
i) <- DataDeclaration v a -> [v]
forall v a. DataDeclaration v a -> [v]
DD.constructorVars DataDeclaration v a
dd [v] -> [Pos] -> [(v, Pos)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [Pos
0 ..]]
ctors2 :: [(v, Id)]
ctors2 =
Map v (TypeReferenceId, EffectDeclaration v a)
-> [(TypeReferenceId, EffectDeclaration v a)]
forall k a. Map k a -> [a]
Map.elems (TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId' TypecheckedUnisonFile v a
file) [(TypeReferenceId, EffectDeclaration v a)]
-> ((TypeReferenceId, EffectDeclaration v a) -> [(v, Id)])
-> [(v, Id)]
forall a b. [a] -> (a -> [b]) -> [b]
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \(TypeReferenceId
ref, EffectDeclaration v a
dd) ->
[(v
v, ConstructorReferenceId -> ConstructorType -> Id
Referent.ConId (TypeReferenceId -> Pos -> ConstructorReferenceId
forall r. r -> Pos -> GConstructorReference r
ConstructorReference TypeReferenceId
ref Pos
i) ConstructorType
CT.Effect) | (v
v, Pos
i) <- DataDeclaration v a -> [v]
forall v a. DataDeclaration v a -> [v]
DD.constructorVars (EffectDeclaration v a -> DataDeclaration v a
forall v a. EffectDeclaration v a -> DataDeclaration v a
DD.toDataDecl EffectDeclaration v a
dd) [v] -> [Pos] -> [(v, Pos)]
forall a b. [a] -> [b] -> [(a, b)]
`zip` [Pos
0 ..]]
in [(v, Id)] -> Map v Id
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(v, Id)]
ctors1 [(v, Id)] -> [(v, Id)] -> [(v, Id)]
forall a. [a] -> [a] -> [a]
++ [(v, Id)]
ctors2)
constructorsForDecls :: (Ord v) => Set v -> TypecheckedUnisonFile v a -> Set v
constructorsForDecls :: forall v a. Ord v => Set v -> TypecheckedUnisonFile v a -> Set v
constructorsForDecls Set v
types TypecheckedUnisonFile v a
uf =
let dataConstructors :: [v]
dataConstructors =
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, DataDeclaration v a)
dataDeclarationsId' TypecheckedUnisonFile v a
uf
Map v (TypeReferenceId, DataDeclaration v a)
-> (Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a))
-> Map v (TypeReferenceId, DataDeclaration v a)
forall a b. a -> (a -> b) -> b
& (v -> (TypeReferenceId, DataDeclaration v a) -> Bool)
-> Map v (TypeReferenceId, DataDeclaration v a)
-> Map v (TypeReferenceId, DataDeclaration v a)
forall k a. (k -> a -> Bool) -> Map k a -> Map k a
Map.filterWithKey (\v
k (TypeReferenceId, DataDeclaration v a)
_ -> v -> Set v -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member v
k Set v
types)
Map v (TypeReferenceId, DataDeclaration v a)
-> (Map v (TypeReferenceId, DataDeclaration v a)
-> [(TypeReferenceId, DataDeclaration v a)])
-> [(TypeReferenceId, DataDeclaration v a)]
forall a b. a -> (a -> b) -> b
& Map v (TypeReferenceId, DataDeclaration v a)
-> [(TypeReferenceId, DataDeclaration v a)]
forall k a. Map k a -> [a]
Map.elems
[(TypeReferenceId, DataDeclaration v a)]
-> ([(TypeReferenceId, DataDeclaration v a)]
-> [DataDeclaration v a])
-> [DataDeclaration v a]
forall a b. a -> (a -> b) -> b
& ((TypeReferenceId, DataDeclaration v a) -> DataDeclaration v a)
-> [(TypeReferenceId, DataDeclaration v a)]
-> [DataDeclaration v a]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TypeReferenceId, DataDeclaration v a) -> DataDeclaration v a
forall a b. (a, b) -> b
snd
[DataDeclaration v a] -> ([DataDeclaration v a] -> [v]) -> [v]
forall a b. a -> (a -> b) -> b
& (DataDeclaration v a -> [v]) -> [DataDeclaration v a] -> [v]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap DataDeclaration v a -> [v]
forall v a. DataDeclaration v a -> [v]
DD.constructorVars
effectConstructors :: [v]
effectConstructors =
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall v a.
TypecheckedUnisonFile v a
-> Map v (TypeReferenceId, EffectDeclaration v a)
effectDeclarationsId' TypecheckedUnisonFile v a
uf
Map v (TypeReferenceId, EffectDeclaration v a)
-> (Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a))
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall a b. a -> (a -> b) -> b
& (v -> (TypeReferenceId, EffectDeclaration v a) -> Bool)
-> Map v (TypeReferenceId, EffectDeclaration v a)
-> Map v (TypeReferenceId, EffectDeclaration v a)
forall k a. (k -> a -> Bool) -> Map k a -> Map k a
Map.filterWithKey (\v
k (TypeReferenceId, EffectDeclaration v a)
_ -> v -> Set v -> Bool
forall a. Ord a => a -> Set a -> Bool
Set.member v
k Set v
types)
Map v (TypeReferenceId, EffectDeclaration v a)
-> (Map v (TypeReferenceId, EffectDeclaration v a)
-> [(TypeReferenceId, EffectDeclaration v a)])
-> [(TypeReferenceId, EffectDeclaration v a)]
forall a b. a -> (a -> b) -> b
& Map v (TypeReferenceId, EffectDeclaration v a)
-> [(TypeReferenceId, EffectDeclaration v a)]
forall k a. Map k a -> [a]
Map.elems
[(TypeReferenceId, EffectDeclaration v a)]
-> ([(TypeReferenceId, EffectDeclaration v a)]
-> [DataDeclaration v a])
-> [DataDeclaration v a]
forall a b. a -> (a -> b) -> b
& ((TypeReferenceId, EffectDeclaration v a) -> DataDeclaration v a)
-> [(TypeReferenceId, EffectDeclaration v a)]
-> [DataDeclaration v a]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (EffectDeclaration v a -> DataDeclaration v a
forall v a. EffectDeclaration v a -> DataDeclaration v a
DD.toDataDecl (EffectDeclaration v a -> DataDeclaration v a)
-> ((TypeReferenceId, EffectDeclaration v a)
-> EffectDeclaration v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> DataDeclaration v a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeReferenceId, EffectDeclaration v a) -> EffectDeclaration v a
forall a b. (a, b) -> b
snd)
[DataDeclaration v a] -> ([DataDeclaration v a] -> [v]) -> [v]
forall a b. a -> (a -> b) -> b
& (DataDeclaration v a -> [v]) -> [DataDeclaration v a] -> [v]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap DataDeclaration v a -> [v]
forall v a. DataDeclaration v a -> [v]
DD.constructorVars
in [v] -> Set v
forall a. Ord a => [a] -> Set a
Set.fromList ([v]
dataConstructors [v] -> [v] -> [v]
forall a. Semigroup a => a -> a -> a
<> [v]
effectConstructors)
termNamespaceBindings :: (Ord v) => TypecheckedUnisonFile v a -> Set v
termNamespaceBindings :: forall v a. Ord v => TypecheckedUnisonFile v a -> Set v
termNamespaceBindings TypecheckedUnisonFile v a
uf =
Set v
terms Set v -> Set v -> Set v
forall a. Semigroup a => a -> a -> a
<> Set v
tests Set v -> Set v -> Set v
forall a. Semigroup a => a -> a -> a
<> Set v
datacons Set v -> Set v -> Set v
forall a. Semigroup a => a -> a -> a
<> Set v
effcons
where
terms :: Set v
terms = ([(v, a, Term v a, Type v a)] -> Set v)
-> [[(v, a, Term v a, Type v a)]] -> Set v
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ([v] -> Set v
forall a. Ord a => [a] -> Set a
Set.fromList ([v] -> Set v)
-> ([(v, a, Term v a, Type v a)] -> [v])
-> [(v, a, Term v a, Type v a)]
-> Set v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((v, a, Term v a, Type v a) -> v)
-> [(v, a, Term v a, Type v a)] -> [v]
forall a b. (a -> b) -> [a] -> [b]
map (Getting v (v, a, Term v a, Type v a) v
-> (v, a, Term v a, Type v a) -> v
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting v (v, a, Term v a, Type v a) v
forall s t a b. Field1 s t a b => Lens s t a b
Lens (v, a, Term v a, Type v a) (v, a, Term v a, Type v a) v v
_1)) TypecheckedUnisonFile v a
uf.topLevelComponents'
tests :: Set v
tests =
TypecheckedUnisonFile v a
uf.watchComponents [(WatchKind, [(v, a, Term v a, Type v a)])]
-> ([(WatchKind, [(v, a, Term v a, Type v a)])] -> Set v) -> Set v
forall a b. a -> (a -> b) -> b
& ((WatchKind, [(v, a, Term v a, Type v a)]) -> Set v)
-> [(WatchKind, [(v, a, Term v a, Type v a)])] -> Set v
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap \case
(WatchKind
WatchKind.TestWatch, [(v, a, Term v a, Type v a)]
watches) -> [v] -> Set v
forall a. Ord a => [a] -> Set a
Set.fromList (((v, a, Term v a, Type v a) -> v)
-> [(v, a, Term v a, Type v a)] -> [v]
forall a b. (a -> b) -> [a] -> [b]
map (Getting v (v, a, Term v a, Type v a) v
-> (v, a, Term v a, Type v a) -> v
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting v (v, a, Term v a, Type v a) v
forall s t a b. Field1 s t a b => Lens s t a b
Lens (v, a, Term v a, Type v a) (v, a, Term v a, Type v a) v v
_1) [(v, a, Term v a, Type v a)]
watches)
(WatchKind, [(v, a, Term v a, Type v a)])
_ -> Set v
forall a. Set a
Set.empty
datacons :: Set v
datacons = ((TypeReferenceId, DataDeclaration v a) -> Set v)
-> Map v (TypeReferenceId, DataDeclaration v a) -> Set v
forall m a. Monoid m => (a -> m) -> Map v a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap ([v] -> Set v
forall a. Ord a => [a] -> Set a
Set.fromList ([v] -> Set v)
-> ((TypeReferenceId, DataDeclaration v a) -> [v])
-> (TypeReferenceId, DataDeclaration v a)
-> Set v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataDeclaration v a -> [v]
forall v a. DataDeclaration v a -> [v]
DataDeclaration.constructorVars (DataDeclaration v a -> [v])
-> ((TypeReferenceId, DataDeclaration v a) -> DataDeclaration v a)
-> (TypeReferenceId, DataDeclaration v a)
-> [v]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
(DataDeclaration v a)
(TypeReferenceId, DataDeclaration v a)
(DataDeclaration v a)
-> (TypeReferenceId, DataDeclaration v a) -> DataDeclaration v a
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
(DataDeclaration v a)
(TypeReferenceId, DataDeclaration v a)
(DataDeclaration v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(TypeReferenceId, DataDeclaration v a)
(TypeReferenceId, DataDeclaration v a)
(DataDeclaration v a)
(DataDeclaration v a)
_2) TypecheckedUnisonFile v a
uf.dataDeclarationsId'
effcons :: Set v
effcons =
((TypeReferenceId, EffectDeclaration v a) -> Set v)
-> Map v (TypeReferenceId, EffectDeclaration v a) -> Set v
forall m a. Monoid m => (a -> m) -> Map v a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap
([v] -> Set v
forall a. Ord a => [a] -> Set a
Set.fromList ([v] -> Set v)
-> ((TypeReferenceId, EffectDeclaration v a) -> [v])
-> (TypeReferenceId, EffectDeclaration v a)
-> Set v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DataDeclaration v a -> [v]
forall v a. DataDeclaration v a -> [v]
DataDeclaration.constructorVars (DataDeclaration v a -> [v])
-> ((TypeReferenceId, EffectDeclaration v a)
-> DataDeclaration v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> [v]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. EffectDeclaration v a -> DataDeclaration v a
forall v a. EffectDeclaration v a -> DataDeclaration v a
DataDeclaration.toDataDecl (EffectDeclaration v a -> DataDeclaration v a)
-> ((TypeReferenceId, EffectDeclaration v a)
-> EffectDeclaration v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> DataDeclaration v a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting
(EffectDeclaration v a)
(TypeReferenceId, EffectDeclaration v a)
(EffectDeclaration v a)
-> (TypeReferenceId, EffectDeclaration v a)
-> EffectDeclaration v a
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
(EffectDeclaration v a)
(TypeReferenceId, EffectDeclaration v a)
(EffectDeclaration v a)
forall s t a b. Field2 s t a b => Lens s t a b
Lens
(TypeReferenceId, EffectDeclaration v a)
(TypeReferenceId, EffectDeclaration v a)
(EffectDeclaration v a)
(EffectDeclaration v a)
_2)
TypecheckedUnisonFile v a
uf.effectDeclarationsId'
typeNamespaceBindings :: (Ord v) => TypecheckedUnisonFile v a -> Set v
typeNamespaceBindings :: forall v a. Ord v => TypecheckedUnisonFile v a -> Set v
typeNamespaceBindings TypecheckedUnisonFile v a
uf =
Set v
datas Set v -> Set v -> Set v
forall a. Semigroup a => a -> a -> a
<> Set v
effs
where
datas :: Set v
datas = Map v (TypeReferenceId, DataDeclaration v a) -> Set v
forall k a. Map k a -> Set k
Map.keysSet TypecheckedUnisonFile v a
uf.dataDeclarationsId'
effs :: Set v
effs = Map v (TypeReferenceId, EffectDeclaration v a) -> Set v
forall k a. Map k a -> Set k
Map.keysSet TypecheckedUnisonFile v a
uf.effectDeclarationsId'