{-# Language ImplicitParams #-}
module Cryptol.IR.TraverseNames where
import Data.Set(Set)
import qualified Data.Set as Set
import Data.Functor.Identity
import Cryptol.ModuleSystem.Name(nameUnique)
import Cryptol.Utils.RecordMap(traverseRecordMap)
import Cryptol.Parser.Position(Located(..))
import Cryptol.TypeCheck.AST
import Cryptol.TypeCheck.FFI.FFIType
traverseNames ::
(TraverseNames t, Applicative f) => (Name -> f Name) -> (t -> f t)
traverseNames :: forall t (f :: * -> *).
(TraverseNames t, Applicative f) =>
(Name -> f Name) -> t -> f t
traverseNames Name -> f Name
f = let ?name = ?name::Name -> f Name
Name -> f Name
f in t -> f t
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
t -> f t
traverseNamesIP
mapNames :: (TraverseNames t) => (Name -> Name) -> t -> t
mapNames :: forall t. TraverseNames t => (Name -> Name) -> t -> t
mapNames Name -> Name
f t
x = t
result
where
Identity t
result = let ?name = Name -> Identity Name
forall a. a -> Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Name -> Identity Name) -> (Name -> Name) -> Name -> Identity Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Name -> Name
f
in t -> Identity t
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
t -> f t
traverseNamesIP t
x
class TraverseNames t where
traverseNamesIP :: (Applicative f, ?name :: Name -> f Name) => t -> f t
instance TraverseNames a => TraverseNames [a] where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[a] -> f [a]
traverseNamesIP = (a -> f a) -> [a] -> f [a]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP
instance TraverseNames a => TraverseNames (Maybe a) where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Maybe a -> f (Maybe a)
traverseNamesIP = (a -> f a) -> Maybe a -> f (Maybe a)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP
instance (Ord a, TraverseNames a) => TraverseNames (Set a) where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Set a -> f (Set a)
traverseNamesIP = ([a] -> Set a) -> f [a] -> f (Set a)
forall a b. (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [a] -> Set a
forall a. Ord a => [a] -> Set a
Set.fromList (f [a] -> f (Set a)) -> (Set a -> f [a]) -> Set a -> f (Set a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> f [a]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[a] -> f [a]
traverseNamesIP ([a] -> f [a]) -> (Set a -> [a]) -> Set a -> f [a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set a -> [a]
forall a. Set a -> [a]
Set.toList
instance TraverseNames a => TraverseNames (Located a) where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Located a -> f (Located a)
traverseNamesIP (Located Range
r a
a) = Range -> a -> Located a
forall a. Range -> a -> Located a
Located Range
r (a -> Located a) -> f a -> f (Located a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP a
a
instance TraverseNames Name where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP = ?name::Name -> f Name
Name -> f Name
?name
instance (Ord a, TraverseNames a) => TraverseNames (ExportSpec a) where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
ExportSpec a -> f (ExportSpec a)
traverseNamesIP (ExportSpec Map Namespace (Set a)
mp) = Map Namespace (Set a) -> ExportSpec a
forall name. Map Namespace (Set name) -> ExportSpec name
ExportSpec (Map Namespace (Set a) -> ExportSpec a)
-> f (Map Namespace (Set a)) -> f (ExportSpec a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Set a -> f (Set a))
-> Map Namespace (Set a) -> f (Map Namespace (Set a))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Map Namespace a -> f (Map Namespace b)
traverse Set a -> f (Set a)
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Set a -> f (Set a)
traverseNamesIP Map Namespace (Set a)
mp
instance TraverseNames Expr where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
expr =
case Expr
expr of
EList [Expr]
es Type
t -> [Expr] -> Type -> Expr
EList ([Expr] -> Type -> Expr) -> f [Expr] -> f (Type -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Expr] -> f [Expr]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Expr] -> f [Expr]
traverseNamesIP [Expr]
es f (Type -> Expr) -> f Type -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
ETuple [Expr]
es -> [Expr] -> Expr
ETuple ([Expr] -> Expr) -> f [Expr] -> f Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Expr] -> f [Expr]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Expr] -> f [Expr]
traverseNamesIP [Expr]
es
ERec RecordMap Ident Expr
mp -> RecordMap Ident Expr -> Expr
ERec (RecordMap Ident Expr -> Expr)
-> f (RecordMap Ident Expr) -> f Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Ident -> Expr -> f Expr)
-> RecordMap Ident Expr -> f (RecordMap Ident Expr)
forall (t :: * -> *) a b c.
Applicative t =>
(a -> b -> t c) -> RecordMap a b -> t (RecordMap a c)
traverseRecordMap (\Ident
_ -> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP) RecordMap Ident Expr
mp
ESel Expr
e Selector
l -> (Expr -> Selector -> Expr
`ESel` Selector
l) (Expr -> Expr) -> f Expr -> f Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
ESet Type
t Expr
e1 Selector
l Expr
e2 -> Type -> Expr -> Selector -> Expr -> Expr
ESet (Type -> Expr -> Selector -> Expr -> Expr)
-> f Type -> f (Expr -> Selector -> Expr -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
f (Expr -> Selector -> Expr -> Expr)
-> f Expr -> f (Selector -> Expr -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e1
f (Selector -> Expr -> Expr) -> f Selector -> f (Expr -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Selector -> f Selector
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Selector
l
f (Expr -> Expr) -> f Expr -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e2
EIf Expr
e1 Expr
e2 Expr
e3 -> Expr -> Expr -> Expr -> Expr
EIf (Expr -> Expr -> Expr -> Expr)
-> f Expr -> f (Expr -> Expr -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e1
f (Expr -> Expr -> Expr) -> f Expr -> f (Expr -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e2
f (Expr -> Expr) -> f Expr -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e3
ECase Expr
e Map Ident CaseAlt
as Maybe CaseAlt
d -> Expr -> Map Ident CaseAlt -> Maybe CaseAlt -> Expr
ECase (Expr -> Map Ident CaseAlt -> Maybe CaseAlt -> Expr)
-> f Expr -> f (Map Ident CaseAlt -> Maybe CaseAlt -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
f (Map Ident CaseAlt -> Maybe CaseAlt -> Expr)
-> f (Map Ident CaseAlt) -> f (Maybe CaseAlt -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CaseAlt -> f CaseAlt)
-> Map Ident CaseAlt -> f (Map Ident CaseAlt)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Map Ident a -> f (Map Ident b)
traverse CaseAlt -> f CaseAlt
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
CaseAlt -> f CaseAlt
traverseNamesIP Map Ident CaseAlt
as
f (Maybe CaseAlt -> Expr) -> f (Maybe CaseAlt) -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (CaseAlt -> f CaseAlt) -> Maybe CaseAlt -> f (Maybe CaseAlt)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse CaseAlt -> f CaseAlt
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
CaseAlt -> f CaseAlt
traverseNamesIP Maybe CaseAlt
d
EComp Type
t1 Type
t2 Expr
e [[Match]]
mss -> Type -> Type -> Expr -> [[Match]] -> Expr
EComp (Type -> Type -> Expr -> [[Match]] -> Expr)
-> f Type -> f (Type -> Expr -> [[Match]] -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t1
f (Type -> Expr -> [[Match]] -> Expr)
-> f Type -> f (Expr -> [[Match]] -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t2
f (Expr -> [[Match]] -> Expr) -> f Expr -> f ([[Match]] -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
f ([[Match]] -> Expr) -> f [[Match]] -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [[Match]] -> f [[Match]]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[[Match]] -> f [[Match]]
traverseNamesIP [[Match]]
mss
EVar Name
x -> Name -> Expr
EVar (Name -> Expr) -> f Name -> f Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
ETAbs TParam
tp Expr
e -> TParam -> Expr -> Expr
ETAbs (TParam -> Expr -> Expr) -> f TParam -> f (Expr -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TParam -> f TParam
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TParam -> f TParam
traverseNamesIP TParam
tp f (Expr -> Expr) -> f Expr -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
ETApp Expr
e Type
t -> Expr -> Type -> Expr
ETApp (Expr -> Type -> Expr) -> f Expr -> f (Type -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e f (Type -> Expr) -> f Type -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
EApp Expr
e1 Expr
e2 -> Expr -> Expr -> Expr
EApp (Expr -> Expr -> Expr) -> f Expr -> f (Expr -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e1 f (Expr -> Expr) -> f Expr -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e2
EAbs Name
x Type
t Expr
e -> Name -> Type -> Expr -> Expr
EAbs (Name -> Type -> Expr -> Expr)
-> f Name -> f (Type -> Expr -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
f (Type -> Expr -> Expr) -> f Type -> f (Expr -> Expr)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
f (Expr -> Expr) -> f Expr -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
ELocated Range
r Expr
e -> Range -> Expr -> Expr
ELocated Range
r (Expr -> Expr) -> f Expr -> f Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
EProofAbs Type
p Expr
e -> Type -> Expr -> Expr
EProofAbs (Type -> Expr -> Expr) -> f Type -> f (Expr -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
p f (Expr -> Expr) -> f Expr -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
EProofApp Expr
e -> Expr -> Expr
EProofApp (Expr -> Expr) -> f Expr -> f Expr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
EWhere Expr
e [DeclGroup]
ds -> Expr -> [DeclGroup] -> Expr
EWhere (Expr -> [DeclGroup] -> Expr) -> f Expr -> f ([DeclGroup] -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e f ([DeclGroup] -> Expr) -> f [DeclGroup] -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [DeclGroup] -> f [DeclGroup]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[DeclGroup] -> f [DeclGroup]
traverseNamesIP [DeclGroup]
ds
EPropGuards [([Type], Expr)]
gs Type
t -> [([Type], Expr)] -> Type -> Expr
EPropGuards ([([Type], Expr)] -> Type -> Expr)
-> f [([Type], Expr)] -> f (Type -> Expr)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (([Type], Expr) -> f ([Type], Expr))
-> [([Type], Expr)] -> f [([Type], Expr)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ([Type], Expr) -> f ([Type], Expr)
forall {f :: * -> *} {a} {a}.
(Applicative f, ?name::Name -> f Name, TraverseNames a,
TraverseNames a) =>
(a, a) -> f (a, a)
doG [([Type], Expr)]
gs f (Type -> Expr) -> f Type -> f Expr
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
where doG :: (a, a) -> f (a, a)
doG (a
xs, a
e) = (,) (a -> a -> (a, a)) -> f a -> f (a -> (a, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP a
xs f (a -> (a, a)) -> f a -> f (a, a)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP a
e
instance TraverseNames CaseAlt where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
CaseAlt -> f CaseAlt
traverseNamesIP (CaseAlt [(Name, Type)]
xs Expr
e) =
[(Name, Type)] -> Expr -> CaseAlt
CaseAlt ([(Name, Type)] -> Expr -> CaseAlt)
-> f [(Name, Type)] -> f (Expr -> CaseAlt)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Name, Type) -> f (Name, Type))
-> [(Name, Type)] -> f [(Name, Type)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Name, Type) -> f (Name, Type)
forall {f :: * -> *} {a} {a}.
(Applicative f, ?name::Name -> f Name, TraverseNames a,
TraverseNames a) =>
(a, a) -> f (a, a)
doPair [(Name, Type)]
xs f (Expr -> CaseAlt) -> f Expr -> f CaseAlt
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
where doPair :: (a, a) -> f (a, a)
doPair (a
x,a
y) = (,) (a -> a -> (a, a)) -> f a -> f (a -> (a, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP a
x f (a -> (a, a)) -> f a -> f (a, a)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f a
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
a -> f a
traverseNamesIP a
y
instance TraverseNames Match where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Match -> f Match
traverseNamesIP Match
mat =
case Match
mat of
From Name
x Type
t1 Type
t2 Expr
e -> Name -> Type -> Type -> Expr -> Match
From (Name -> Type -> Type -> Expr -> Match)
-> f Name -> f (Type -> Type -> Expr -> Match)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
f (Type -> Type -> Expr -> Match)
-> f Type -> f (Type -> Expr -> Match)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t1
f (Type -> Expr -> Match) -> f Type -> f (Expr -> Match)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t2
f (Expr -> Match) -> f Expr -> f Match
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
Let Decl
d -> Decl -> Match
Let (Decl -> Match) -> f Decl -> f Match
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decl -> f Decl
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Decl -> f Decl
traverseNamesIP Decl
d
instance TraverseNames DeclGroup where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
DeclGroup -> f DeclGroup
traverseNamesIP DeclGroup
dg =
case DeclGroup
dg of
NonRecursive Decl
d -> Decl -> DeclGroup
NonRecursive (Decl -> DeclGroup) -> f Decl -> f DeclGroup
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Decl -> f Decl
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Decl -> f Decl
traverseNamesIP Decl
d
Recursive [Decl]
ds -> [Decl] -> DeclGroup
Recursive ([Decl] -> DeclGroup) -> f [Decl] -> f DeclGroup
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Decl] -> f [Decl]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Decl] -> f [Decl]
traverseNamesIP [Decl]
ds
instance TraverseNames Decl where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Decl -> f Decl
traverseNamesIP Decl
decl = Name -> Schema -> DeclDef -> Decl
mk (Name -> Schema -> DeclDef -> Decl)
-> f Name -> f (Schema -> DeclDef -> Decl)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (Decl -> Name
dName Decl
decl)
f (Schema -> DeclDef -> Decl) -> f Schema -> f (DeclDef -> Decl)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Schema -> f Schema
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Schema -> f Schema
traverseNamesIP (Decl -> Schema
dSignature Decl
decl)
f (DeclDef -> Decl) -> f DeclDef -> f Decl
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DeclDef -> f DeclDef
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
DeclDef -> f DeclDef
traverseNamesIP (Decl -> DeclDef
dDefinition Decl
decl)
where mk :: Name -> Schema -> DeclDef -> Decl
mk Name
nm Schema
sig DeclDef
def = Decl
decl { dName = nm
, dSignature = sig
, dDefinition = def
}
instance TraverseNames DeclDef where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
DeclDef -> f DeclDef
traverseNamesIP DeclDef
d =
case DeclDef
d of
DeclDef
DPrim -> DeclDef -> f DeclDef
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure DeclDef
d
DForeign FFIFunType
t Maybe Expr
me -> FFIFunType -> Maybe Expr -> DeclDef
DForeign (FFIFunType -> Maybe Expr -> DeclDef)
-> f FFIFunType -> f (Maybe Expr -> DeclDef)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FFIFunType -> f FFIFunType
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
FFIFunType -> f FFIFunType
traverseNamesIP FFIFunType
t f (Maybe Expr -> DeclDef) -> f (Maybe Expr) -> f DeclDef
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Expr -> f (Maybe Expr)
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Maybe Expr -> f (Maybe Expr)
traverseNamesIP Maybe Expr
me
DExpr Expr
e -> Expr -> DeclDef
DExpr (Expr -> DeclDef) -> f Expr -> f DeclDef
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Expr -> f Expr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Expr -> f Expr
traverseNamesIP Expr
e
instance TraverseNames Schema where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Schema -> f Schema
traverseNamesIP (Forall [TParam]
as [Type]
ps Type
t) =
[TParam] -> [Type] -> Type -> Schema
Forall ([TParam] -> [Type] -> Type -> Schema)
-> f [TParam] -> f ([Type] -> Type -> Schema)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [TParam] -> f [TParam]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[TParam] -> f [TParam]
traverseNamesIP [TParam]
as
f ([Type] -> Type -> Schema) -> f [Type] -> f (Type -> Schema)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP [Type]
ps
f (Type -> Schema) -> f Type -> f Schema
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
instance TraverseNames TParam where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TParam -> f TParam
traverseNamesIP TParam
tp = TPFlavor -> TVarInfo -> TParam
mk (TPFlavor -> TVarInfo -> TParam)
-> f TPFlavor -> f (TVarInfo -> TParam)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TPFlavor -> f TPFlavor
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TPFlavor -> f TPFlavor
traverseNamesIP (TParam -> TPFlavor
tpFlav TParam
tp)
f (TVarInfo -> TParam) -> f TVarInfo -> f TParam
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TVarInfo -> f TVarInfo
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TVarInfo -> f TVarInfo
traverseNamesIP (TParam -> TVarInfo
tpInfo TParam
tp)
where mk :: TPFlavor -> TVarInfo -> TParam
mk TPFlavor
f TVarInfo
i = case TPFlavor
f of
TPModParam Name
x ->
TParam
tp { tpUnique = nameUnique x, tpFlav = f, tpInfo = i }
TPFlavor
_ -> TParam
tp { tpFlav = f, tpInfo = i }
instance TraverseNames TPFlavor where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TPFlavor -> f TPFlavor
traverseNamesIP TPFlavor
tpf =
case TPFlavor
tpf of
TPModParam Name
x -> Name -> TPFlavor
TPModParam (Name -> TPFlavor) -> f Name -> f TPFlavor
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TPFlavor
TPUnifyVar -> TPFlavor -> f TPFlavor
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TPFlavor
tpf
TPSchemaParam Name
x -> Name -> TPFlavor
TPSchemaParam (Name -> TPFlavor) -> f Name -> f TPFlavor
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TPTySynParam Name
x -> Name -> TPFlavor
TPTySynParam (Name -> TPFlavor) -> f Name -> f TPFlavor
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TPPropSynParam Name
x -> Name -> TPFlavor
TPPropSynParam (Name -> TPFlavor) -> f Name -> f TPFlavor
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TPNominalParam Name
x -> Name -> TPFlavor
TPNominalParam (Name -> TPFlavor) -> f Name -> f TPFlavor
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TPPrimParam Name
x -> Name -> TPFlavor
TPPrimParam (Name -> TPFlavor) -> f Name -> f TPFlavor
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
instance TraverseNames TVarInfo where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TVarInfo -> f TVarInfo
traverseNamesIP (TVarInfo Range
r TypeSource
s) = Range -> TypeSource -> TVarInfo
TVarInfo Range
r (TypeSource -> TVarInfo) -> f TypeSource -> f TVarInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TypeSource -> f TypeSource
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TypeSource -> f TypeSource
traverseNamesIP TypeSource
s
instance TraverseNames TypeSource where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TypeSource -> f TypeSource
traverseNamesIP TypeSource
src =
case TypeSource
src of
TVFromModParam Name
x -> Name -> TypeSource
TVFromModParam (Name -> TypeSource) -> f Name -> f TypeSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TVFromSignature Name
x -> Name -> TypeSource
TVFromSignature (Name -> TypeSource) -> f Name -> f TypeSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TypeSource
TypeWildCard -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeOfRecordField {} -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeOfTupleField {} -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
TypeOfSeqElement -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
LenOfSeq -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeParamInstNamed Name
x Ident
i -> Name -> Ident -> TypeSource
TypeParamInstNamed (Name -> Ident -> TypeSource) -> f Name -> f (Ident -> TypeSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
f (Ident -> TypeSource) -> f Ident -> f TypeSource
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Ident -> f Ident
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Ident
i
TypeParamInstPos Name
x Int
i -> Name -> Int -> TypeSource
TypeParamInstPos (Name -> Int -> TypeSource) -> f Name -> f (Int -> TypeSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
f (Int -> TypeSource) -> f Int -> f TypeSource
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> f Int
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Int
i
DefinitionOf Name
x -> Name -> TypeSource
DefinitionOf (Name -> TypeSource) -> f Name -> f TypeSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
TypeSource
LenOfCompGen -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeOfArg ArgDescr
arg -> ArgDescr -> TypeSource
TypeOfArg (ArgDescr -> TypeSource) -> f ArgDescr -> f TypeSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ArgDescr -> f ArgDescr
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
ArgDescr -> f ArgDescr
traverseNamesIP ArgDescr
arg
TypeSource
TypeOfRes -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
FunApp -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
TypeOfIfCondExpr -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
TypeFromUserAnnotation -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
GeneratorOfListComp -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
TypeErrorPlaceHolder -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
CasedExpression -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
TypeSource
ConPat -> TypeSource -> f TypeSource
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TypeSource
src
instance TraverseNames ArgDescr where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
ArgDescr -> f ArgDescr
traverseNamesIP ArgDescr
arg = Maybe Name -> ArgDescr
mk (Maybe Name -> ArgDescr) -> f (Maybe Name) -> f ArgDescr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Name -> f (Maybe Name)
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Maybe Name -> f (Maybe Name)
traverseNamesIP (ArgDescr -> Maybe Name
argDescrFun ArgDescr
arg)
where mk :: Maybe Name -> ArgDescr
mk Maybe Name
n = ArgDescr
arg { argDescrFun = n }
instance TraverseNames Type where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
ty =
case Type
ty of
TCon TCon
tc [Type]
ts -> TCon -> [Type] -> Type
TCon TCon
tc ([Type] -> Type) -> f [Type] -> f Type
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP [Type]
ts
TVar TVar
x -> TVar -> Type
TVar (TVar -> Type) -> f TVar -> f Type
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TVar -> f TVar
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TVar -> f TVar
traverseNamesIP TVar
x
TUser Name
x [Type]
ts Type
t -> Name -> [Type] -> Type -> Type
TUser (Name -> [Type] -> Type -> Type)
-> f Name -> f ([Type] -> Type -> Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP Name
x
f ([Type] -> Type -> Type) -> f [Type] -> f (Type -> Type)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP [Type]
ts
f (Type -> Type) -> f Type -> f Type
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP Type
t
TRec RecordMap Ident Type
rm -> RecordMap Ident Type -> Type
TRec (RecordMap Ident Type -> Type)
-> f (RecordMap Ident Type) -> f Type
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Ident -> Type -> f Type)
-> RecordMap Ident Type -> f (RecordMap Ident Type)
forall (t :: * -> *) a b c.
Applicative t =>
(a -> b -> t c) -> RecordMap a b -> t (RecordMap a c)
traverseRecordMap ((Type -> f Type) -> Ident -> Type -> f Type
forall a b. a -> b -> a
const Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP) RecordMap Ident Type
rm
TNominal NominalType
nt [Type]
ts -> NominalType -> [Type] -> Type
TNominal (NominalType -> [Type] -> Type)
-> f NominalType -> f ([Type] -> Type)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NominalType -> f NominalType
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
NominalType -> f NominalType
traverseNamesIP NominalType
nt f ([Type] -> Type) -> f [Type] -> f Type
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP [Type]
ts
instance TraverseNames TVar where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TVar -> f TVar
traverseNamesIP TVar
tvar =
case TVar
tvar of
TVFree Int
x Kind
k Set TParam
ys TVarInfo
i -> Int -> Kind -> Set TParam -> TVarInfo -> TVar
TVFree Int
x Kind
k (Set TParam -> TVarInfo -> TVar)
-> f (Set TParam) -> f (TVarInfo -> TVar)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Set TParam -> f (Set TParam)
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Set TParam -> f (Set TParam)
traverseNamesIP Set TParam
ys f (TVarInfo -> TVar) -> f TVarInfo -> f TVar
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TVarInfo -> f TVarInfo
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TVarInfo -> f TVarInfo
traverseNamesIP TVarInfo
i
TVBound TParam
x -> TParam -> TVar
TVBound (TParam -> TVar) -> f TParam -> f TVar
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TParam -> f TParam
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TParam -> f TParam
traverseNamesIP TParam
x
instance TraverseNames NominalType where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
NominalType -> f NominalType
traverseNamesIP NominalType
nt =
Name
-> [TParam]
-> Kind
-> [Type]
-> NominalTypeDef
-> Maybe Fixity
-> Maybe Text
-> NominalType
NominalType
(Name
-> [TParam]
-> Kind
-> [Type]
-> NominalTypeDef
-> Maybe Fixity
-> Maybe Text
-> NominalType)
-> f Name
-> f ([TParam]
-> Kind
-> [Type]
-> NominalTypeDef
-> Maybe Fixity
-> Maybe Text
-> NominalType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (NominalType -> Name
ntName NominalType
nt)
f ([TParam]
-> Kind
-> [Type]
-> NominalTypeDef
-> Maybe Fixity
-> Maybe Text
-> NominalType)
-> f [TParam]
-> f (Kind
-> [Type]
-> NominalTypeDef
-> Maybe Fixity
-> Maybe Text
-> NominalType)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [TParam] -> f [TParam]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[TParam] -> f [TParam]
traverseNamesIP (NominalType -> [TParam]
ntParams NominalType
nt)
f (Kind
-> [Type]
-> NominalTypeDef
-> Maybe Fixity
-> Maybe Text
-> NominalType)
-> f Kind
-> f ([Type]
-> NominalTypeDef -> Maybe Fixity -> Maybe Text -> NominalType)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Kind -> f Kind
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NominalType -> Kind
ntKind NominalType
nt)
f ([Type]
-> NominalTypeDef -> Maybe Fixity -> Maybe Text -> NominalType)
-> f [Type]
-> f (NominalTypeDef -> Maybe Fixity -> Maybe Text -> NominalType)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP (NominalType -> [Type]
ntConstraints NominalType
nt)
f (NominalTypeDef -> Maybe Fixity -> Maybe Text -> NominalType)
-> f NominalTypeDef
-> f (Maybe Fixity -> Maybe Text -> NominalType)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> NominalTypeDef -> f NominalTypeDef
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
NominalTypeDef -> f NominalTypeDef
traverseNamesIP (NominalType -> NominalTypeDef
ntDef NominalType
nt)
f (Maybe Fixity -> Maybe Text -> NominalType)
-> f (Maybe Fixity) -> f (Maybe Text -> NominalType)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Fixity -> f (Maybe Fixity)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NominalType -> Maybe Fixity
ntFixity NominalType
nt)
f (Maybe Text -> NominalType) -> f (Maybe Text) -> f NominalType
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Text -> f (Maybe Text)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (NominalType -> Maybe Text
ntDoc NominalType
nt)
instance TraverseNames NominalTypeDef where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
NominalTypeDef -> f NominalTypeDef
traverseNamesIP NominalTypeDef
def =
case NominalTypeDef
def of
Struct StructCon
c -> StructCon -> NominalTypeDef
Struct (StructCon -> NominalTypeDef) -> f StructCon -> f NominalTypeDef
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StructCon -> f StructCon
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
StructCon -> f StructCon
traverseNamesIP StructCon
c
Enum [EnumCon]
cs -> [EnumCon] -> NominalTypeDef
Enum ([EnumCon] -> NominalTypeDef) -> f [EnumCon] -> f NominalTypeDef
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [EnumCon] -> f [EnumCon]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[EnumCon] -> f [EnumCon]
traverseNamesIP [EnumCon]
cs
NominalTypeDef
Abstract -> NominalTypeDef -> f NominalTypeDef
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure NominalTypeDef
Abstract
instance TraverseNames StructCon where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
StructCon -> f StructCon
traverseNamesIP StructCon
c =
Name -> RecordMap Ident Type -> StructCon
StructCon (Name -> RecordMap Ident Type -> StructCon)
-> f Name -> f (RecordMap Ident Type -> StructCon)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (StructCon -> Name
ntConName StructCon
c)
f (RecordMap Ident Type -> StructCon)
-> f (RecordMap Ident Type) -> f StructCon
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Ident -> Type -> f Type)
-> RecordMap Ident Type -> f (RecordMap Ident Type)
forall (t :: * -> *) a b c.
Applicative t =>
(a -> b -> t c) -> RecordMap a b -> t (RecordMap a c)
traverseRecordMap ((Type -> f Type) -> Ident -> Type -> f Type
forall a b. a -> b -> a
const Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP) (StructCon -> RecordMap Ident Type
ntFields StructCon
c)
instance TraverseNames EnumCon where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
EnumCon -> f EnumCon
traverseNamesIP EnumCon
c =
Name -> Int -> [Type] -> Bool -> Maybe Text -> EnumCon
EnumCon (Name -> Int -> [Type] -> Bool -> Maybe Text -> EnumCon)
-> f Name -> f (Int -> [Type] -> Bool -> Maybe Text -> EnumCon)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (EnumCon -> Name
ecName EnumCon
c)
f (Int -> [Type] -> Bool -> Maybe Text -> EnumCon)
-> f Int -> f ([Type] -> Bool -> Maybe Text -> EnumCon)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> f Int
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EnumCon -> Int
ecNumber EnumCon
c)
f ([Type] -> Bool -> Maybe Text -> EnumCon)
-> f [Type] -> f (Bool -> Maybe Text -> EnumCon)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP (EnumCon -> [Type]
ecFields EnumCon
c)
f (Bool -> Maybe Text -> EnumCon)
-> f Bool -> f (Maybe Text -> EnumCon)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> f Bool
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EnumCon -> Bool
ecPublic EnumCon
c)
f (Maybe Text -> EnumCon) -> f (Maybe Text) -> f EnumCon
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Text -> f (Maybe Text)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EnumCon -> Maybe Text
ecDoc EnumCon
c)
instance TraverseNames ModTParam where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
ModTParam -> f ModTParam
traverseNamesIP ModTParam
nt = Name -> ModTParam
mk (Name -> ModTParam) -> f Name -> f ModTParam
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (ModTParam -> Name
mtpName ModTParam
nt)
where
mk :: Name -> ModTParam
mk Name
x = ModTParam
nt { mtpName = x }
instance TraverseNames ModVParam where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
ModVParam -> f ModVParam
traverseNamesIP ModVParam
nt = Name -> Schema -> ModVParam
mk (Name -> Schema -> ModVParam) -> f Name -> f (Schema -> ModVParam)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (ModVParam -> Name
mvpName ModVParam
nt)
f (Schema -> ModVParam) -> f Schema -> f ModVParam
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Schema -> f Schema
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Schema -> f Schema
traverseNamesIP (ModVParam -> Schema
mvpType ModVParam
nt)
where
mk :: Name -> Schema -> ModVParam
mk Name
x Schema
t = ModVParam
nt { mvpName = x, mvpType = t }
instance TraverseNames FFIFunType where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
FFIFunType -> f FFIFunType
traverseNamesIP FFIFunType
fi = [FFIType] -> FFIType -> FFIFunType
mk ([FFIType] -> FFIType -> FFIFunType)
-> f [FFIType] -> f (FFIType -> FFIFunType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [FFIType] -> f [FFIType]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[FFIType] -> f [FFIType]
traverseNamesIP (FFIFunType -> [FFIType]
ffiArgTypes FFIFunType
fi)
f (FFIType -> FFIFunType) -> f FFIType -> f FFIFunType
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FFIType -> f FFIType
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
FFIType -> f FFIType
traverseNamesIP (FFIFunType -> FFIType
ffiRetType FFIFunType
fi)
where
mk :: [FFIType] -> FFIType -> FFIFunType
mk [FFIType]
as FFIType
b =
FFIFunType
{ ffiTParams :: [TParam]
ffiTParams = FFIFunType -> [TParam]
ffiTParams FFIFunType
fi
, ffiArgTypes :: [FFIType]
ffiArgTypes = [FFIType]
as
, ffiRetType :: FFIType
ffiRetType = FFIType
b
}
instance TraverseNames FFIType where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
FFIType -> f FFIType
traverseNamesIP FFIType
ft =
case FFIType
ft of
FFIType
FFIBool -> FFIType -> f FFIType
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FFIType
ft
FFIBasic FFIBasicType
_ -> FFIType -> f FFIType
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure FFIType
ft
FFIArray [Type]
sz FFIBasicType
t -> ([Type] -> FFIBasicType -> FFIType
`FFIArray` FFIBasicType
t) ([Type] -> FFIType) -> f [Type] -> f FFIType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP [Type]
sz
FFITuple [FFIType]
ts -> [FFIType] -> FFIType
FFITuple ([FFIType] -> FFIType) -> f [FFIType] -> f FFIType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [FFIType] -> f [FFIType]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[FFIType] -> f [FFIType]
traverseNamesIP [FFIType]
ts
FFIRecord RecordMap Ident FFIType
mp -> RecordMap Ident FFIType -> FFIType
FFIRecord (RecordMap Ident FFIType -> FFIType)
-> f (RecordMap Ident FFIType) -> f FFIType
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Ident -> FFIType -> f FFIType)
-> RecordMap Ident FFIType -> f (RecordMap Ident FFIType)
forall (t :: * -> *) a b c.
Applicative t =>
(a -> b -> t c) -> RecordMap a b -> t (RecordMap a c)
traverseRecordMap
(\Ident
_ -> FFIType -> f FFIType
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
FFIType -> f FFIType
traverseNamesIP) RecordMap Ident FFIType
mp
instance TraverseNames TySyn where
traverseNamesIP :: forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
TySyn -> f TySyn
traverseNamesIP TySyn
ts = Name -> [TParam] -> [Type] -> Type -> TySyn
mk (Name -> [TParam] -> [Type] -> Type -> TySyn)
-> f Name -> f ([TParam] -> [Type] -> Type -> TySyn)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Name -> f Name
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Name -> f Name
traverseNamesIP (TySyn -> Name
tsName TySyn
ts)
f ([TParam] -> [Type] -> Type -> TySyn)
-> f [TParam] -> f ([Type] -> Type -> TySyn)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [TParam] -> f [TParam]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[TParam] -> f [TParam]
traverseNamesIP (TySyn -> [TParam]
tsParams TySyn
ts)
f ([Type] -> Type -> TySyn) -> f [Type] -> f (Type -> TySyn)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Type] -> f [Type]
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
[Type] -> f [Type]
traverseNamesIP (TySyn -> [Type]
tsConstraints TySyn
ts)
f (Type -> TySyn) -> f Type -> f TySyn
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type -> f Type
forall t (f :: * -> *).
(TraverseNames t, Applicative f, ?name::Name -> f Name) =>
t -> f t
forall (f :: * -> *).
(Applicative f, ?name::Name -> f Name) =>
Type -> f Type
traverseNamesIP (TySyn -> Type
tsDef TySyn
ts)
where mk :: Name -> [TParam] -> [Type] -> Type -> TySyn
mk Name
n [TParam]
ps [Type]
cs Type
t =
TySyn { tsName :: Name
tsName = Name
n
, tsParams :: [TParam]
tsParams = [TParam]
ps
, tsConstraints :: [Type]
tsConstraints = [Type]
cs
, tsDef :: Type
tsDef = Type
t
, tsDoc :: Maybe Text
tsDoc = TySyn -> Maybe Text
tsDoc TySyn
ts
}