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

Unison.Codebase.Path

Synopsis

Documentation

data Path Source #

A Path is an internal structure representing some namespace in the codebase.

Foo.Bar.baz becomes [Foo, Bar, "baz"].

Instances

Instances details
Monoid Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

mempty :: Path #

mappend :: Path -> Path -> Path #

mconcat :: [Path] -> Path #

Semigroup Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

(<>) :: Path -> Path -> Path #

sconcat :: NonEmpty Path -> Path #

stimes :: Integral b => b -> Path -> Path #

IsList Path Source #

Meant for use mostly in doc-tests where it's sometimes convenient to specify paths as lists.

Instance details

Defined in Unison.Codebase.Path

Associated Types

type Item Path #

Methods

fromList :: [Item Path] -> Path #

fromListN :: Int -> [Item Path] -> Path #

toList :: Path -> [Item Path] #

Show Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

showsPrec :: Int -> Path -> ShowS #

show :: Path -> String #

showList :: [Path] -> ShowS #

Eq Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

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

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

Ord Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

compare :: Path -> Path -> Ordering #

(<) :: Path -> Path -> Bool #

(<=) :: Path -> Path -> Bool #

(>) :: Path -> Path -> Bool #

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

max :: Path -> Path -> Path #

min :: Path -> Path -> Path #

Namey Path Source # 
Instance details

Defined in Unison.Codebase.Path

Pathy Path Source # 
Instance details

Defined in Unison.Codebase.Path

From Path Text Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

from :: Path -> Text #

Resolve Absolute Path Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Path Path Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path -> Path -> Path Source #

Resolve Path' Path Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path' -> Path -> Path' Source #

Recursive Path (XNor NameSegment) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Absolute (Split Path) (Split Absolute) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Path (Split Path) (Split Path) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve (Split Absolute) (Split Path) (Split Absolute) Source # 
Instance details

Defined in Unison.Codebase.Path

type Item Path Source # 
Instance details

Defined in Unison.Codebase.Path

data Path' Source #

A namespace that may be either absolute or relative, This is the most general type that should be used.

Instances

Instances details
Show Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

showsPrec :: Int -> Path' -> ShowS #

show :: Path' -> String #

showList :: [Path'] -> ShowS #

Eq Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

(==) :: Path' -> Path' -> Bool #

(/=) :: Path' -> Path' -> Bool #

Ord Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

compare :: Path' -> Path' -> Ordering #

(<) :: Path' -> Path' -> Bool #

(<=) :: Path' -> Path' -> Bool #

(>) :: Path' -> Path' -> Bool #

(>=) :: Path' -> Path' -> Bool #

max :: Path' -> Path' -> Path' #

min :: Path' -> Path' -> Path' #

Namey Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Pathy Path' Source # 
Instance details

Defined in Unison.Codebase.Path

From Path' Text Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

from :: Path' -> Text #

Resolve Absolute Path' Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Path' Path Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path' -> Path -> Path' Source #

Resolve Path' Path' Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path' -> Path' -> Path' Source #

class Pathy path where Source #

Minimal complete definition

descend, prefix, split, toText

Methods

ascend :: path -> Maybe path Source #

descend :: path -> NameSegment -> path Source #

prefix :: path -> Path -> path Source #

split :: path -> Maybe (Split path) Source #

unsplit :: Split path -> path Source #

toText :: path -> Text Source #

Instances

Instances details
Pathy Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Pathy Path Source # 
Instance details

Defined in Unison.Codebase.Path

Pathy Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Pathy ProjectPath Source # 
Instance details

Defined in Unison.Codebase.ProjectPath

Pathy ProjectPathNames Source # 
Instance details

Defined in Unison.Codebase.ProjectPath

class Pathy path => Namey path where Source #

Minimal complete definition

nameFromSplit

Methods

nameFromSplit :: Split path -> Name Source #

toName :: path -> Maybe Name Source #

Convert a path' to a Name

Instances

Instances details
Namey Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Namey Path Source # 
Instance details

Defined in Unison.Codebase.Path

Namey Path' Source # 
Instance details

Defined in Unison.Codebase.Path

newtype Absolute Source #

An absolute from the current project root

Constructors

Absolute 

Fields

Instances

Instances details
Show Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Eq Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Ord Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Namey Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Pathy Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

From Absolute Text Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

from :: Absolute -> Text #

Resolve Absolute Path Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Absolute Path' Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Recursive Absolute (XNor NameSegment) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Absolute (Split Path) (Split Absolute) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve (Split Absolute) (Split Path) (Split Absolute) Source # 
Instance details

Defined in Unison.Codebase.Path

class Resolve l r o where Source #

Methods

resolve :: l -> r -> o Source #

Instances

Instances details
Resolve Absolute Path Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Absolute Path' Absolute Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Path Path Path Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path -> Path -> Path Source #

Resolve Path' Path Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path' -> Path -> Path' Source #

Resolve Path' Path' Path' Source # 
Instance details

Defined in Unison.Codebase.Path

Methods

resolve :: Path' -> Path' -> Path' Source #

Resolve Absolute (Split Path) (Split Absolute) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve Path (Split Path) (Split Path) Source # 
Instance details

Defined in Unison.Codebase.Path

Resolve (Split Absolute) (Split Path) (Split Absolute) Source # 
Instance details

Defined in Unison.Codebase.Path

pattern Current :: Path Source #

pattern Current' :: Path' Source #

pattern Root :: Absolute Source #

pattern Root' :: Path' Source #

maybePrefix :: Path' -> Path' -> Maybe Path' Source #

Returns Nothing if the second argument is absolute. A common pattern is fromMaybe path $ maybePrefix prefix path to use the unmodified path in that case.

unprefix :: Path -> Path' -> Path' Source #

examples: unprefix foo.bar .blah == .blah (absolute paths left alone) unprefix foo.bar id == id (relative paths starting w/ nonmatching prefix left alone) unprefix foo.bar foo.bar.baz == baz (relative paths w/ common prefix get stripped)

maybePrefixName :: Path' -> Name -> Maybe Name Source #

Returns Nothing if the second argument is absolute. A common pattern is fromMaybe name $ maybePrefixName prefix name to use the unmodified path in that case.

unprefixName :: Path -> Name -> Maybe Name Source #

Remove a path prefix from a name. Returns Nothing if there are no remaining segments to construct the name from.

>>> unprefixName (Relative $ fromList ["base", "List"]) (Name.unsafeFromText "base.List.map")
Just (Name Relative (NameSegment {toText = "map"} :| []))

type Split path = (path, NameSegment) Source #

utilities

longestPathPrefix :: Absolute -> Absolute -> (Absolute, Path, Path) Source #

Finds the longest shared path prefix of two paths. Returns (shared prefix, path to first location from shared prefix, path to second location from shared prefix)

>>> longestPathPrefix ("a" :< "b" :< "x" :< Empty) ("a" :< "b" :< "c" :< Empty)
(a.b,x,c)
>>> longestPathPrefix Empty ("a" :< "b" :< "c" :< Empty)
(,,a.b.c)

tests

conversions

unsafeParseText' :: Text -> Path' Source #

Construct a Path' from a text

>>> fromText' "a.b.c"
a.b.c
>>> fromText' ".a.b.c"
.a.b.c
>>> show $ fromText' ""
""

splitFromName :: Name -> Split Path Source #

>>> splitFromName "a.b.c"
(a.b,c)
>>> splitFromName "foo"
(,foo)