GithubHelp home page GithubHelp logo

superfunc / tp Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 0.0 38 KB

Strongly Typed Paths for Idris

License: MIT License

Idris 96.50% Shell 3.50%
unix functional-programming idris path-manipulation toilet

tp's Introduction

TP: An idris package for typed, unix-style, path manipulation.

Build status badge

Overview:

This repo provides an idris package, System.Posix.Paths for typed path manipulation. I'd like to add some neat usage of dependent types to this library, but the initial library just has Haskell-style, strongly-typed, paths.

The core pieces are:

  • Path: An opaque path type that encodes the kind(file/directory) and anchoring(absolute/relative).
  • mkRelativeFile: Create a relative file from a string repr.
  • mkRelativeDirectory: Create a relative directory from a string repr.
  • mkAbsoluteFile: Create an absolute file from a string repr.
  • mkAbsoluteDirectory: Create an absolute directory from a string repr.
  • concat: Join two paths together.
  • str: Get a string repr of a path.
  • Eq: Paths can be compared by usual equality methods.
  • Show: Pretty print path information.

Note that many of these operations, concat for example, restrict the type of paths that can be used via the kind/anchoring, preventing a large class of errors. In other cases, we use Maybe to encode possible failure, such as in the case of the mk functions.

Usage:

The tests provide decent examples for the time being. Once things have been cleaned up, I'll try to provide more thorough examples here.

Dependencies:

None

Disclaimer(s):

  1. Contributions are very welcome.
  1. This work is my sole effort and is in no way associated with or sponsored by my current, past, or future employer(s).

tp's People

Contributors

superfunc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tp's Issues

Clean up pack/unpack nonsense

Currently the code turns strings into char lists all over the place(and back) because its easier to write recursive functions on them. This should be cleaned up somehow.

Consider Different Structure

Transferring a nice sugg from @gallais on reddit to here:

Wouldn't it make sense to store the path as:

  • a starting point (i.e. whether it's relative or absolute)
  • a list of directory names
  • (possibly) a file name and (possibly) an extension rather than a sum type of strings? In other words: expose the structure rather than storing validated raw data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.