unison-codebase-0.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

U.Codebase.Term

Synopsis

Documentation

type Term v = Term (F v) v () Source #

type HashableTerm v = Term (F' Text HashableTermRef TypeRef HashableTermLink TypeLink v) v () Source #

A version of Term but where TermRefs never have a Nothing Hash, but instead self references are filled with User Variable references to the relevant piece of the component in a component map.

type F vt = F' Text TermRef TypeRef TermLink TypeLink vt Source #

Base functor for terms in the Unison codebase

data F' text termRef typeRef termLink typeLink vt a Source #

Generalized version. We could generalize further to allow sharing within terms.

Constructors

Int Int64 
Nat Word64 
Float Double 
Boolean Bool 
Text text 
Char Char 
Ref termRef 
Constructor typeRef ConstructorId 
Request typeRef ConstructorId 
Handle a a 
App a a 
Ann a (TypeR typeRef vt) 
List (Seq a) 
If a a a 
And a a 
Or a a 
Lam a 
LetRec [a] a 
Let a a 
Match a [MatchCase text typeRef a] 
TermLink termLink 
TypeLink typeLink 

Instances

Instances details
Foldable (F' text termRef typeRef termLink typeLink vt) Source # 
Instance details

Defined in U.Codebase.Term

Methods

fold :: Monoid m => F' text termRef typeRef termLink typeLink vt m -> m #

foldMap :: Monoid m => (a -> m) -> F' text termRef typeRef termLink typeLink vt a -> m #

foldMap' :: Monoid m => (a -> m) -> F' text termRef typeRef termLink typeLink vt a -> m #

foldr :: (a -> b -> b) -> b -> F' text termRef typeRef termLink typeLink vt a -> b #

foldr' :: (a -> b -> b) -> b -> F' text termRef typeRef termLink typeLink vt a -> b #

foldl :: (b -> a -> b) -> b -> F' text termRef typeRef termLink typeLink vt a -> b #

foldl' :: (b -> a -> b) -> b -> F' text termRef typeRef termLink typeLink vt a -> b #

foldr1 :: (a -> a -> a) -> F' text termRef typeRef termLink typeLink vt a -> a #

foldl1 :: (a -> a -> a) -> F' text termRef typeRef termLink typeLink vt a -> a #

toList :: F' text termRef typeRef termLink typeLink vt a -> [a] #

null :: F' text termRef typeRef termLink typeLink vt a -> Bool #

length :: F' text termRef typeRef termLink typeLink vt a -> Int #

elem :: Eq a => a -> F' text termRef typeRef termLink typeLink vt a -> Bool #

maximum :: Ord a => F' text termRef typeRef termLink typeLink vt a -> a #

minimum :: Ord a => F' text termRef typeRef termLink typeLink vt a -> a #

sum :: Num a => F' text termRef typeRef termLink typeLink vt a -> a #

product :: Num a => F' text termRef typeRef termLink typeLink vt a -> a #

Traversable (F' text termRef typeRef termLink typeLink vt) Source # 
Instance details

Defined in U.Codebase.Term

Methods

traverse :: Applicative f => (a -> f b) -> F' text termRef typeRef termLink typeLink vt a -> f (F' text termRef typeRef termLink typeLink vt b) #

sequenceA :: Applicative f => F' text termRef typeRef termLink typeLink vt (f a) -> f (F' text termRef typeRef termLink typeLink vt a) #

mapM :: Monad m => (a -> m b) -> F' text termRef typeRef termLink typeLink vt a -> m (F' text termRef typeRef termLink typeLink vt b) #

sequence :: Monad m => F' text termRef typeRef termLink typeLink vt (m a) -> m (F' text termRef typeRef termLink typeLink vt a) #

Functor (F' text termRef typeRef termLink typeLink vt) Source # 
Instance details

Defined in U.Codebase.Term

Methods

fmap :: (a -> b) -> F' text termRef typeRef termLink typeLink vt a -> F' text termRef typeRef termLink typeLink vt b #

(<$) :: a -> F' text termRef typeRef termLink typeLink vt b -> F' text termRef typeRef termLink typeLink vt a #

(Show text, Show termRef, Show vt, Show a, Show termLink, Show typeLink, Show typeRef) => Show (F' text termRef typeRef termLink typeLink vt a) Source # 
Instance details

Defined in U.Codebase.Term

Methods

showsPrec :: Int -> F' text termRef typeRef termLink typeLink vt a -> ShowS #

show :: F' text termRef typeRef termLink typeLink vt a -> String #

showList :: [F' text termRef typeRef termLink typeLink vt a] -> ShowS #

data MatchCase t r a Source #

Constructors

MatchCase (Pattern t r) (Maybe a) a 

Instances

Instances details
Generic1 (MatchCase t r :: Type -> Type) Source # 
Instance details

Defined in U.Codebase.Term

Associated Types

type Rep1 (MatchCase t r) :: k -> Type #

Methods

from1 :: forall (a :: k). MatchCase t r a -> Rep1 (MatchCase t r) a #

to1 :: forall (a :: k). Rep1 (MatchCase t r) a -> MatchCase t r a #

Foldable (MatchCase t r) Source # 
Instance details

Defined in U.Codebase.Term

Methods

fold :: Monoid m => MatchCase t r m -> m #

foldMap :: Monoid m => (a -> m) -> MatchCase t r a -> m #

foldMap' :: Monoid m => (a -> m) -> MatchCase t r a -> m #

foldr :: (a -> b -> b) -> b -> MatchCase t r a -> b #

foldr' :: (a -> b -> b) -> b -> MatchCase t r a -> b #

foldl :: (b -> a -> b) -> b -> MatchCase t r a -> b #

foldl' :: (b -> a -> b) -> b -> MatchCase t r a -> b #

foldr1 :: (a -> a -> a) -> MatchCase t r a -> a #

foldl1 :: (a -> a -> a) -> MatchCase t r a -> a #

toList :: MatchCase t r a -> [a] #

null :: MatchCase t r a -> Bool #

length :: MatchCase t r a -> Int #

elem :: Eq a => a -> MatchCase t r a -> Bool #

maximum :: Ord a => MatchCase t r a -> a #

minimum :: Ord a => MatchCase t r a -> a #

sum :: Num a => MatchCase t r a -> a #

product :: Num a => MatchCase t r a -> a #

Traversable (MatchCase t r) Source # 
Instance details

Defined in U.Codebase.Term

Methods

traverse :: Applicative f => (a -> f b) -> MatchCase t r a -> f (MatchCase t r b) #

sequenceA :: Applicative f => MatchCase t r (f a) -> f (MatchCase t r a) #

mapM :: Monad m => (a -> m b) -> MatchCase t r a -> m (MatchCase t r b) #

sequence :: Monad m => MatchCase t r (m a) -> m (MatchCase t r a) #

Functor (MatchCase t r) Source # 
Instance details

Defined in U.Codebase.Term

Methods

fmap :: (a -> b) -> MatchCase t r a -> MatchCase t r b #

(<$) :: a -> MatchCase t r b -> MatchCase t r a #

Generic (MatchCase t r a) Source # 
Instance details

Defined in U.Codebase.Term

Associated Types

type Rep (MatchCase t r a) :: Type -> Type #

Methods

from :: MatchCase t r a -> Rep (MatchCase t r a) x #

to :: Rep (MatchCase t r a) x -> MatchCase t r a #

(Show t, Show r, Show a) => Show (MatchCase t r a) Source # 
Instance details

Defined in U.Codebase.Term

Methods

showsPrec :: Int -> MatchCase t r a -> ShowS #

show :: MatchCase t r a -> String #

showList :: [MatchCase t r a] -> ShowS #

type Rep1 (MatchCase t r :: Type -> Type) Source # 
Instance details

Defined in U.Codebase.Term

type Rep (MatchCase t r a) Source # 
Instance details

Defined in U.Codebase.Term

type Rep (MatchCase t r a) = D1 ('MetaData "MatchCase" "U.Codebase.Term" "unison-codebase-0.0.0-AFzt1HmKDX512erVMwvK3i" 'False) (C1 ('MetaCons "MatchCase" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pattern t r)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe a)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))))

data Pattern t r Source #

Instances

Instances details
Foldable (Pattern t) Source # 
Instance details

Defined in U.Codebase.Term

Methods

fold :: Monoid m => Pattern t m -> m #

foldMap :: Monoid m => (a -> m) -> Pattern t a -> m #

foldMap' :: Monoid m => (a -> m) -> Pattern t a -> m #

foldr :: (a -> b -> b) -> b -> Pattern t a -> b #

foldr' :: (a -> b -> b) -> b -> Pattern t a -> b #

foldl :: (b -> a -> b) -> b -> Pattern t a -> b #

foldl' :: (b -> a -> b) -> b -> Pattern t a -> b #

foldr1 :: (a -> a -> a) -> Pattern t a -> a #

foldl1 :: (a -> a -> a) -> Pattern t a -> a #

toList :: Pattern t a -> [a] #

null :: Pattern t a -> Bool #

length :: Pattern t a -> Int #

elem :: Eq a => a -> Pattern t a -> Bool #

maximum :: Ord a => Pattern t a -> a #

minimum :: Ord a => Pattern t a -> a #

sum :: Num a => Pattern t a -> a #

product :: Num a => Pattern t a -> a #

Traversable (Pattern t) Source # 
Instance details

Defined in U.Codebase.Term

Methods

traverse :: Applicative f => (a -> f b) -> Pattern t a -> f (Pattern t b) #

sequenceA :: Applicative f => Pattern t (f a) -> f (Pattern t a) #

mapM :: Monad m => (a -> m b) -> Pattern t a -> m (Pattern t b) #

sequence :: Monad m => Pattern t (m a) -> m (Pattern t a) #

Functor (Pattern t) Source # 
Instance details

Defined in U.Codebase.Term

Methods

fmap :: (a -> b) -> Pattern t a -> Pattern t b #

(<$) :: a -> Pattern t b -> Pattern t a #

Generic (Pattern t r) Source # 
Instance details

Defined in U.Codebase.Term

Associated Types

type Rep (Pattern t r) :: Type -> Type #

Methods

from :: Pattern t r -> Rep (Pattern t r) x #

to :: Rep (Pattern t r) x -> Pattern t r #

(Show t, Show r) => Show (Pattern t r) Source # 
Instance details

Defined in U.Codebase.Term

Methods

showsPrec :: Int -> Pattern t r -> ShowS #

show :: Pattern t r -> String #

showList :: [Pattern t r] -> ShowS #

type Rep (Pattern t r) Source # 
Instance details

Defined in U.Codebase.Term

type Rep (Pattern t r) = D1 ('MetaData "Pattern" "U.Codebase.Term" "unison-codebase-0.0.0-AFzt1HmKDX512erVMwvK3i" 'False) (((C1 ('MetaCons "PUnbound" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "PVar" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PBoolean" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))) :+: ((C1 ('MetaCons "PInt" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int64)) :+: C1 ('MetaCons "PNat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64))) :+: (C1 ('MetaCons "PFloat" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double)) :+: C1 ('MetaCons "PText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 t))))) :+: ((C1 ('MetaCons "PChar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Char)) :+: (C1 ('MetaCons "PConstructor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 r) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ConstructorId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Pattern t r]))) :+: C1 ('MetaCons "PAs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pattern t r))))) :+: ((C1 ('MetaCons "PEffectPure" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pattern t r))) :+: C1 ('MetaCons "PEffectBind" 'PrefixI 'False) ((S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 r) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 ConstructorId)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Pattern t r]) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pattern t r))))) :+: (C1 ('MetaCons "PSequenceLiteral" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Pattern t r])) :+: C1 ('MetaCons "PSequenceOp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pattern t r)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SeqOp) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Pattern t r))))))))

data SeqOp Source #

Constructors

PCons 
PSnoc 
PConcat 

Instances

Instances details
Show SeqOp Source # 
Instance details

Defined in U.Codebase.Term

Methods

showsPrec :: Int -> SeqOp -> ShowS #

show :: SeqOp -> String #

showList :: [SeqOp] -> ShowS #

Eq SeqOp Source # 
Instance details

Defined in U.Codebase.Term

Methods

(==) :: SeqOp -> SeqOp -> Bool #

(/=) :: SeqOp -> SeqOp -> Bool #

extraMap :: forall text termRef typeRef termLink typeLink vt text' termRef' typeRef' termLink' typeLink' vt' v a. (Ord v, Ord vt') => (text -> text') -> (termRef -> termRef') -> (typeRef -> typeRef') -> (termLink -> termLink') -> (typeLink -> typeLink') -> (vt -> vt') -> Term (F' text termRef typeRef termLink typeLink vt) v a -> Term (F' text' termRef' typeRef' termLink' typeLink' vt') v a Source #

extraMapM :: forall m text termRef typeRef termLink typeLink vt text' termRef' typeRef' termLink' typeLink' vt' v a. (Ord v, Ord vt', Monad m) => (text -> m text') -> (termRef -> m termRef') -> (typeRef -> m typeRef') -> (termLink -> m termLink') -> (typeLink -> m typeLink') -> (vt -> m vt') -> Term (F' text termRef typeRef termLink typeLink vt) v a -> m (Term (F' text' termRef' typeRef' termLink' typeLink' vt') v a) Source #

rmapPattern :: (t -> t') -> (r -> r') -> Pattern t r -> Pattern t' r' Source #

rmapPatternM :: Applicative m => (t -> m t') -> (r -> m r') -> Pattern t r -> m (Pattern t' r') Source #

dependencies :: (Ord termRef, Ord typeRef, Ord termLink, Ord typeLink, Ord v) => Term (F' text termRef typeRef termLink typeLink vt) v a -> (Set termRef, Set typeRef, Set termLink, Set typeLink) Source #

unhashComponent Source #

Arguments

:: forall v extra. Var v 
=> Hash

The hash of the component, this is used to fill in self-references.

-> (Id -> v)

A function to convert a reference to a variable. The actual var names aren't important.

-> Map Id (Term v, extra) 
-> Map Id (v, HashableTerm v, extra)

The component with all self-references replaced with variable references.

Given the pieces of a single term component, replaces all Nothing self-referential hashes with a variable reference to the relevant piece of the component in the component map.