• This repository has been archived on 07/Jul/2020
  • Stars
    star
    3
  • Rank 3,844,583 (Top 78 %)
  • Language
    Haskell
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Abstract data type for canonical paths with some pretty operations. Not maintained anymore.

CanonicalPath

VERY IMPORTANT

Some time ago system-filepath was deprecated. I haven't updated this library since, because I still think about the reasons for it to exist. Actually I have some plans on rewriting it, but it will very breaking in terms of compatibility. Keep in touch.

UPDATE

Please, checkout the path-extra library that also knows how to canonicalize path.


FilePath is very deceptive, because it's just a synonym for String, so actually it can be anything - your mothers name or path to file you want to edit. Just look at the type signature of function readFile:

readFile :: FilePath -> IO String

You can translate it as follows:

readFile :: String -> IO String

Well, it is known that IO actions are dangerous by themselves. And here comes another problem - you need to be sure that the path you pass to function is at least well constructed. For this purpose you can use well known FilePath data type. It solves a lot of problems and comes beefed with multiple cool utilities. And also it is build around Text instead of String. Awesome!

So why do we need yet another path library? The answer is simple - we want to use paths like $HOME/.app.cfg, ~/.zshrc or /full/path/to/existing/file/or/dir in our code without any additional overhead. CanonicalPath is named so because it tries to canonicalize given path (FilePath or Text) using canonicalizePath function. It also will extract any variables it finds in path (like $VARNAME, %VARNAME% and special ~/). But these steps both may fail. Thats why this library provides functions that return Maybe CanonicalPath or Either Text CanonicalPath.

CanonicalPath also comes with additional useful property. When it is created, it points to real file or directory. Honestly, it can't guarantee that this path will refer to existing file or directory always (someone can remove or move it to another path - and it's almost impossible to be aware of such cruelty), but you can always reconstruct CanonicalPath.

One more thing about path canonicalization. As I mentioned before, under the hood it uses canonicalizePath function. So here are two warnings. Firstly, it behaves differently on different platforms. Sometime too damn differently. So you better watch your steps. Secondly, it's impossible to guarantee that the implication same file/dir <=> same canonicalizedPath holds in either direction: this function can make only a best-effort attempt.

Happy Haskell Hacking!

Documentation

All documentation can be found on Hackage.

Contribute!

Pull requests are welcome.

More Repositories

1

homebrew-emacs-plus

Emacs Plus formulae for the Homebrew package manager
Ruby
2,143
star
2

vulpea

A collection of functions for note taking based on `org` and `org-roam`.
Emacs Lisp
222
star
3

flyspell-correct

Distraction-free words correction with flyspell via selected interface.
Emacs Lisp
196
star
4

environment

dotfiles
Emacs Lisp
121
star
5

elpa-mirror

Mirror for some Emacs package archives
Emacs Lisp
96
star
6

dotbot-brew

Install brew packages using dotbot
Python
42
star
7

vino

It's your cellar, your dear cantina.
Emacs Lisp
36
star
8

counsel-osx-app

Launch OSX applications via ivy interface
Emacs Lisp
24
star
9

UnityLibrarySwitcher

Unity plugin for switching build targets, git branches without endless assets reimport. Not maintained anymore.
C#
19
star
10

git-config-manager

Manage git repository configurations with ease
Haskell
8
star
11

mirror-elpa

(To) mirror Emacs Lisp Package Archive(s)
Shell
8
star
12

d12frosted.io

Personal site
Haskell
8
star
13

orgability

Reading list manager for Emacs with offline access support.
Emacs Lisp
7
star
14

publicatorg

Make your vulpea notes public
Emacs Lisp
5
star
15

fancy-yank

apply transformation upon yanking
Emacs Lisp
4
star
16

emacs-addiction-mode

M-x doctor instead of C-x C-c
Emacs Lisp
4
star
17

barberry.io

Emacs Lisp
4
star
18

emacs-ukrainian-input-method

Ukrainian macOS-like input method
Emacs Lisp
4
star
19

org-drawer-list

Tame your lists in a drawer
Emacs Lisp
3
star
20

emacs-plus-basis

Emacs Lisp
3
star
21

env-extra

Safe helpers for accessing and modifying environment variables
Haskell
2
star
22

talks

TeX
2
star
23

d12frosted

1
star
24

path-extra

Path helpers for my personal projects
Haskell
1
star
25

bomberman-player

Haskell
1
star
26

fish-mode

Major mode for editing fish shell scripts
Emacs Lisp
1
star