monopati-0.1.3: Well-typed paths

Safe HaskellSafe
LanguageHaskell2010

System.Monopati.Posix

Contents

Synopsis

CRUD operations for filesystem

current :: IO (Maybe (Absolute Path To Directory)) Source #

Return Nothing, if current working directory is root (cwd)

home :: IO (Maybe (Absolute Path To Directory)) Source #

Retrieve absolute path of home directory (echo ~)

create :: Absolute Path To Directory -> IO () Source #

Create a directory (mkdir)

change :: Absolute Path To Directory -> IO () Source #

Change directory (cd)

remove :: Absolute Path To Directory -> IO () Source #

Remove directory (rm -rf)

Pure combinators

data Points Source #

What the path points to?

Constructors

Directory 
File 

data Origin Source #

What is the beginning of the path?

Constructors

Root

(/) Starting point for absolute path

Current

(~/) Relatively current working directory

Home

(~/) Indication of home directory

Vague

Uncertain relative path

data To Source #

Dummy type needed only for beautiful type declarations

type Path = Cofree Maybe String Source #

Path is non-empty sequence of folders or file (in the end)

newtype Outline (origin :: Origin) (points :: Points) Source #

The internal type of path representation

Constructors

Outline 

Fields

Instances
Eq (Outline origin points) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Methods

(==) :: Outline origin points -> Outline origin points -> Bool #

(/=) :: Outline origin points -> Outline origin points -> Bool #

Read (Outline Root Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Root File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Current Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Current File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Home Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Home File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Vague Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Read (Outline Vague File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Root Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Root File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Current Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Current File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Home Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Home File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Vague Directory) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

Show (Outline Vague File) Source # 
Instance details

Defined in System.Monopati.Posix.Combinators

type family Absolute (path :: Type) (to :: Type) (points :: Points) :: Type where ... Source #

Equations

Absolute Path To points = Outline Root points 

type family Currently (path :: Type) (to :: Type) (points :: Points) :: Type where ... Source #

Equations

Currently Path To points = Outline Current points 

type family Homeward (path :: Type) (to :: Type) (points :: Points) :: Type where ... Source #

Equations

Homeward Path To points = Outline Home points 

type family Relative (path :: Type) (to :: Type) (points :: Points) :: Type where ... Source #

Equations

Relative Path To points = Outline Vague points 

type family Incompleted (outline :: Origin) :: Constraint where ... Source #

Equations

Incompleted Current = () 
Incompleted Home = () 
Incompleted Vague = () 

deeper :: Relative Path To points -> Maybe (Relative Path To points) Source #

Take the next piece of relative path

part :: String -> Outline origin points Source #

Immerse string into a path, filter slashes

parent :: Absolute Path To points -> Maybe (Absolute Path To Directory) Source #

Take parent directory of current pointed entity

(<^>) :: forall origin points. Incompleted origin => Outline origin Directory -> Relative Path To points -> Outline origin points Source #

Add relative path to uncompleted path

(<.^>) :: Currently Path To Directory -> Relative Path To points -> Currently Path To points Source #

"./etc/" + "usr/local/" + = "./etc/usr/local/"

(<~^>) :: Homeward Path To Directory -> Relative Path To points -> Homeward Path To points Source #

"~/etc/" + "usr/local/" + = "~/etc/usr/local/"

(<^^>) :: Relative Path To Directory -> Relative Path To points -> Relative Path To points Source #

"etc/" + "usr/local/" + = "etc/usr/local/"

(</>) :: forall origin points. Incompleted origin => Absolute Path To Directory -> Outline origin points -> Absolute Path To points Source #

Absolutize uncompleted path

(</.>) :: Absolute Path To Directory -> Currently Path To points -> Absolute Path To points Source #

"/usr/local/" + "./etc/" = "/usr/local/etc/"

(</~>) :: Absolute Path To Directory -> Homeward Path To points -> Absolute Path To points Source #

"/usr/local/" + "~/etc/" = "/usr/local/etc/"

(</^>) :: Absolute Path To Directory -> Relative Path To points -> Absolute Path To points Source #

"/usr/bin/" + "git" = "/usr/bin/git"