unison-parser-typechecker-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.Codebase.Branch

Synopsis

Branch types

newtype Branch m Source #

A node in the Unison namespace hierarchy along with its history.

Constructors

Branch 

Instances

Instances details
Eq (Branch m) Source # 
Instance details

Defined in Unison.Codebase.Branch.Type

Methods

(==) :: Branch m -> Branch m -> Bool #

(/=) :: Branch m -> Branch m -> Bool #

Ord (Branch m) Source # 
Instance details

Defined in Unison.Codebase.Branch.Type

Methods

compare :: Branch m -> Branch m -> Ordering #

(<) :: Branch m -> Branch m -> Bool #

(<=) :: Branch m -> Branch m -> Bool #

(>) :: Branch m -> Branch m -> Bool #

(>=) :: Branch m -> Branch m -> Bool #

max :: Branch m -> Branch m -> Branch m #

min :: Branch m -> Branch m -> Branch m #

AsEmpty (Branch m) Source # 
Instance details

Defined in Unison.Codebase.Branch

Methods

_Empty :: Prism' (Branch m) () #

data Branch0 m Source #

A node in the Unison namespace hierarchy.

$sel:_terms:Branch0 and $sel:_types:Branch0 are the declarations at this level. $sel:_children:Branch0 are the nodes one level below us. $sel:_edits:Branch0 are the Patchs stored at this node in the code.

The remaining fields are derived from the four above. None of the record fields are exported to avoid accidental tweaking without updating the associated derived fields.

Use either the lensy accessors or the field getters.

Instances

Instances details
Eq (Branch0 m) Source # 
Instance details

Defined in Unison.Codebase.Branch.Type

Methods

(==) :: Branch0 m -> Branch0 m -> Bool #

(/=) :: Branch0 m -> Branch0 m -> Bool #

ContentAddressable (Branch0 m) Source # 
Instance details

Defined in Unison.Codebase.Branch

Methods

contentHash :: Branch0 m -> Hash #

data Raw Source #

type Star r n = Star r n Source #

type NamespaceHash m = HashFor (Branch0 m) Source #

A Hash for a namespace itself, it doesn't incorporate any history.

Branch construction

mergeNode :: forall m. Applicative m => Branch0 m -> (CausalHash, m (Branch m)) -> (CausalHash, m (Branch m)) -> Branch m Source #

Construct a two-parent merge node.

discardHistory :: Applicative m => Branch m -> Branch m Source #

Discards the history of a Branch and its children, recursively

discardHistory0 :: Applicative m => Branch0 m -> Branch0 m Source #

Discards the history of a Branch0's children, recursively

transform :: Functor m => (forall a. m a -> n a) -> Branch m -> Branch n Source #

transform0 :: Functor m => (forall a. m a -> n a) -> Branch0 m -> Branch0 n Source #

Branch tests

isEmpty :: Branch m -> Bool Source #

Checks whether a branch is empty AND has no history.

before :: Monad m => Branch m -> Branch m -> m Bool Source #

lca :: Monad m => Branch m -> Branch m -> m (Maybe (Branch m)) Source #

properties

head_ :: Lens' (Branch m) (Branch0 m) Source #

Update the head of the current causal. This re-hashes the current causal head after modifications.

deepEdits' :: Branch0 m -> Map Name (PatchHash, m Patch) Source #

a version of deepEdits that returns the `m Patch` as well.

toList0 :: Branch0 m -> [(Path, Branch0 m)] Source #

what does this do? —AI

step

step :: Applicative m => (Branch0 m -> Branch0 m) -> Branch m -> Branch m Source #

Perform an update over the current branch and create a new causal step.

stepManyAt :: forall m f. (Monad m, Foldable f) => f (Path, Branch0 m -> Branch0 m) -> Branch m -> Branch m Source #

Run a series of updates at specific locations, aggregating all changes into a single causal step. History is managed according to UpdateStrategy.

stepManyAtM :: (Monad m, Monad n, Foldable f) => f (Path, Branch0 m -> n (Branch0 m)) -> Branch m -> n (Branch m) Source #

Run a series of updates at specific locations. History is managed according to the UpdateStrategy

batchUpdates :: forall f m. (Monad m, Foldable f) => f (Path, Branch0 m -> Branch0 m) -> Branch0 m -> Branch0 m Source #

Perform updates over many locations within a branch by batching up operations on sub-branches as much as possible without affecting semantics. This operation does not create any causal conses, the operations are performed directly on the current head of the provided branch and child branches. It's the caller's responsibility to apply updates in history however they choose.

batchUpdatesM :: forall m n f. (Monad m, Monad n, Foldable f) => f (Path, Branch0 m -> n (Branch0 m)) -> Branch0 m -> n (Branch0 m) Source #

Batch many updates. This allows us to apply the updates while minimizing redundant traversals. Semantics of operations are preserved by ensuring that all updates will always see changes by updates before them in the list.

This method does not step any branches on its own, all causal changes must be performed in the updates themselves, or this batch update must be provided to 'stepManyAt(M)'.

data UpdateStrategy Source #

Constructors

CompressHistory

Compress all changes into a single causal cons. The resulting branch will have at most one new causal cons at each branch.

Note that this does NOT allow updates to add histories at children. E.g. if the root.editme branch has history: A -> B -> C and you use makeSetBranch to update it to a new branch with history X -> Y -> Z, CompressHistory will result in a history for root.editme of: A -> B -> C -> Z. A snapshot of the most recent state of the updated branch is appended to the existing history, if the new state is equal to the existing state, no new history nodes are appended.

AllowRewritingHistory

Preserves any history changes made within the update.

Note that this allows you to clobber the history child branches if you want. E.g. if the root.editme branch has history: A -> B -> C and you use makeSetBranch to update it to a new branch with history X -> Y -> Z, AllowRewritingHistory will result in a history for root.editme of: X -> Y -> Z. The history of the updated branch is replaced entirely.

Children queries

modifyAt :: Applicative m => Path -> (Branch m -> Branch m) -> Branch m -> Branch m Source #

modifyAtM :: forall n m. (Functor n, Applicative m) => Path -> (Branch m -> n (Branch m)) -> Branch m -> n (Branch m) Source #

children0 :: IndexedTraversal' NameSegment (Branch0 m) (Branch0 m) Source #

Traverse the head branch of all direct children. The index of the traversal is the name of that child branch according to the parent.

Libdep manipulations

withoutLib :: Branch0 m -> Branch0 m Source #

Remove any lib subtrees reachable within the branch. Note: This DOES affect the hash.

withoutTransitiveLibs :: Branch0 m -> Branch0 m Source #

Remove any transitive libs reachable within the branch. Note: This DOES affect the hash.

deleteLibdep :: NameSegment -> Branch0 m -> Branch0 m Source #

deleteLibdep name branch deletes the libdep named name from branch, if it exists.

deleteLibdeps :: Branch0 m -> Branch0 m Source #

deleteLibdeps branch deletes all libdeps from branch.

Branch termstypesedits

Termtypeedits lenses

Term/type queries

consBranchSnapshot :: forall m. Monad m => Branch m -> Branch m -> Branch m Source #

head consBranchSnapshot base Cons's the current state of head onto base as-is. Consider whether you really want this behaviour or the behaviour of squashMerge That is, it does not perform any common ancestor detection, or change reconciliation, it sets the current state of the base branch to the new state as a new causal step (or returns the existing base if there are no)

Orphan instances

AsEmpty (Branch m) Source # 
Instance details

Methods

_Empty :: Prism' (Branch m) () #

ContentAddressable (Branch0 m) Source # 
Instance details

Methods

contentHash :: Branch0 m -> Hash #