Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Branch m = Branch {
- _history :: UnwrappedBranch m
- type UnwrappedBranch m = Causal m (Branch0 m)
- data Branch0 m
- data Raw
- type Star r n = Star r n
- type NamespaceHash m = HashFor (Branch0 m)
- branch0 :: forall m. Star Referent NameSegment -> Star TypeReference NameSegment -> Map NameSegment (Branch m) -> Map NameSegment (PatchHash, m Patch) -> Branch0 m
- one :: Branch0 m -> Branch m
- cons :: Applicative m => Branch0 m -> Branch m -> Branch m
- mergeNode :: forall m. Applicative m => Branch0 m -> (CausalHash, m (Branch m)) -> (CausalHash, m (Branch m)) -> Branch m
- uncons :: Applicative m => Branch m -> m (Maybe (Branch0 m, Branch m))
- empty :: Branch m
- empty0 :: Branch0 m
- discardHistory :: Applicative m => Branch m -> Branch m
- discardHistory0 :: Applicative m => Branch0 m -> Branch0 m
- transform :: Functor m => (forall a. m a -> n a) -> Branch m -> Branch n
- transform0 :: Functor m => (forall a. m a -> n a) -> Branch0 m -> Branch0 n
- isEmpty :: Branch m -> Bool
- isEmpty0 :: Branch0 m -> Bool
- isOne :: Branch m -> Bool
- before :: Monad m => Branch m -> Branch m -> m Bool
- lca :: Monad m => Branch m -> Branch m -> m (Maybe (Branch m))
- history :: Iso' (Branch m) (UnwrappedBranch m)
- head :: Branch m -> Branch0 m
- head_ :: Lens' (Branch m) (Branch0 m)
- headHash :: Branch m -> CausalHash
- children :: Lens' (Branch0 m) (Map NameSegment (Branch m))
- nonEmptyChildren :: Branch0 m -> Map NameSegment (Branch m)
- deepEdits' :: Branch0 m -> Map Name (PatchHash, m Patch)
- toList0 :: Branch0 m -> [(Path, Branch0 m)]
- namespaceStats :: Branch0 m -> NamespaceStats
- step :: Applicative m => (Branch0 m -> Branch0 m) -> Branch m -> Branch m
- stepManyAt :: forall m f. (Monad m, Foldable f) => f (Path, Branch0 m -> Branch0 m) -> Branch m -> Branch m
- stepManyAtM :: (Monad m, Monad n, Foldable f) => f (Path, Branch0 m -> n (Branch0 m)) -> Branch m -> n (Branch m)
- stepEverywhere :: Applicative m => (Branch0 m -> Branch0 m) -> Branch0 m -> Branch0 m
- batchUpdates :: forall f m. (Monad m, Foldable f) => f (Path, Branch0 m -> Branch0 m) -> Branch0 m -> Branch0 m
- batchUpdatesM :: forall m n f. (Monad m, Monad n, Foldable f) => f (Path, Branch0 m -> n (Branch0 m)) -> Branch0 m -> n (Branch0 m)
- data UpdateStrategy
- addTermName :: Referent -> NameSegment -> Branch0 m -> Branch0 m
- addTypeName :: TypeReference -> NameSegment -> Branch0 m -> Branch0 m
- deleteTermName :: Referent -> NameSegment -> Branch0 m -> Branch0 m
- annihilateTermName :: NameSegment -> Branch0 m -> Branch0 m
- annihilateTypeName :: NameSegment -> Branch0 m -> Branch0 m
- deleteTypeName :: TypeReference -> NameSegment -> Branch0 m -> Branch0 m
- setChildBranch :: NameSegment -> Branch m -> Branch0 m -> Branch0 m
- replacePatch :: Applicative m => NameSegment -> Patch -> Branch0 m -> Branch0 m
- deletePatch :: NameSegment -> Branch0 m -> Branch0 m
- getMaybePatch :: Applicative m => NameSegment -> Branch0 m -> m (Maybe Patch)
- getPatch :: Applicative m => NameSegment -> Branch0 m -> m Patch
- modifyPatches :: Monad m => NameSegment -> (Patch -> Patch) -> Branch0 m -> m (Branch0 m)
- getAt :: Path -> Branch m -> Maybe (Branch m)
- getAt' :: Path -> Branch m -> Branch m
- getAt0 :: Path -> Branch0 m -> Branch0 m
- modifyAt :: Applicative m => Path -> (Branch m -> Branch m) -> Branch m -> Branch m
- modifyAtM :: forall n m. (Functor n, Applicative m) => Path -> (Branch m -> n (Branch m)) -> Branch m -> n (Branch m)
- children0 :: IndexedTraversal' NameSegment (Branch0 m) (Branch0 m)
- withoutLib :: Branch0 m -> Branch0 m
- withoutTransitiveLibs :: Branch0 m -> Branch0 m
- deleteLibdep :: NameSegment -> Branch0 m -> Branch0 m
- deleteLibdeps :: Branch0 m -> Branch0 m
- terms :: Lens' (Branch0 m) (Star Referent NameSegment)
- types :: Lens' (Branch0 m) (Star TypeReference NameSegment)
- edits :: Lens' (Branch0 m) (Map NameSegment (PatchHash, m Patch))
- deepTerms :: Branch0 m -> Relation Referent Name
- deepTypes :: Branch0 m -> Relation TypeReference Name
- deepDefns :: Branch0 m -> DefnsF (Relation Name) Referent TypeReference
- deepEdits :: Branch0 m -> Map Name PatchHash
- deepPaths :: Branch0 m -> Set Path
- deepReferents :: Branch0 m -> Set Referent
- deepTermReferences :: Branch0 m -> Set TermReference
- deepTermReferenceIds :: Branch0 m -> Set TermReferenceId
- deepTypeReferences :: Branch0 m -> Set TypeReference
- deepTypeReferenceIds :: Branch0 m -> Set TypeReferenceId
- consBranchSnapshot :: forall m. Monad m => Branch m -> Branch m -> Branch m
Branch types
A node in the Unison namespace hierarchy along with its history.
type UnwrappedBranch m = Causal m (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 Patch
s 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.
type NamespaceHash m = HashFor (Branch0 m) Source #
A Hash for a namespace itself, it doesn't incorporate any history.
Branch construction
branch0 :: forall m. Star Referent NameSegment -> Star TypeReference NameSegment -> Map NameSegment (Branch m) -> Map NameSegment (PatchHash, m Patch) -> Branch0 m Source #
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
Branch tests
properties
head_ :: Lens' (Branch m) (Branch0 m) Source #
Update the head of the current causal. This re-hashes the current causal head after modifications.
headHash :: Branch m -> CausalHash Source #
nonEmptyChildren :: Branch0 m -> Map NameSegment (Branch m) Source #
deepEdits' :: Branch0 m -> Map Name (PatchHash, m Patch) Source #
a version of deepEdits
that returns the `m Patch` as well.
namespaceStats :: Branch0 m -> NamespaceStats Source #
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
stepEverywhere :: Applicative m => (Branch0 m -> Branch0 m) -> Branch0 m -> Branch0 m Source #
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 #
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 |
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 |
addTermName :: Referent -> NameSegment -> Branch0 m -> Branch0 m Source #
addTypeName :: TypeReference -> NameSegment -> Branch0 m -> Branch0 m Source #
deleteTermName :: Referent -> NameSegment -> Branch0 m -> Branch0 m Source #
annihilateTermName :: NameSegment -> Branch0 m -> Branch0 m Source #
annihilateTypeName :: NameSegment -> Branch0 m -> Branch0 m Source #
deleteTypeName :: TypeReference -> NameSegment -> Branch0 m -> Branch0 m Source #
setChildBranch :: NameSegment -> Branch m -> Branch0 m -> Branch0 m Source #
replacePatch :: Applicative m => NameSegment -> Patch -> Branch0 m -> Branch0 m Source #
deletePatch :: NameSegment -> Branch0 m -> Branch0 m Source #
getMaybePatch :: Applicative m => NameSegment -> Branch0 m -> m (Maybe Patch) Source #
getPatch :: Applicative m => NameSegment -> Branch0 m -> m Patch Source #
modifyPatches :: Monad m => NameSegment -> (Patch -> Patch) -> Branch0 m -> m (Branch0 m) Source #
Children queries
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
types :: Lens' (Branch0 m) (Star TypeReference NameSegment) Source #
Term/type queries
deepTermReferences :: Branch0 m -> Set TermReference Source #
deepTermReferenceIds :: Branch0 m -> Set TermReferenceId Source #
deepTypeReferences :: Branch0 m -> Set TypeReference Source #
deepTypeReferenceIds :: Branch0 m -> Set TypeReferenceId Source #
consBranchSnapshot :: forall m. Monad m => Branch m -> Branch m -> Branch m Source #
head
Cons's the current state of consBranchSnapshot
basehead
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)