purescript-contrib / purescript-pathy

A type-safe abstraction for platform-independent file system paths.
Apache License 2.0
33 stars 17 forks source link

add eitherRelAbs #32

Closed safareli closed 6 years ago

safareli commented 6 years ago

also express maybeRel maybeAbs using eitherRelAbs

garyb commented 6 years ago

This seems a bit questionable, as it should already be known from the types whether a path is Abs or Rel, should it not?

cryogenian commented 6 years ago

@garyb Not really e.g. forall s. Path s a b. We can do following

class AbsOrRel s where 
  absOrRel :: forall a b s. Path s a b -> Either (Path Rel a b) (Path Abs a b)

Do you think it would be better?

garyb commented 6 years ago

I'm just not sure how we'd end up with a path value that already isn't Rel or Abs in the types? It makes sense that there can be functions that operate on Path with polymorphic Abs/Rel, I just don't know how we'd actually have one that has it unspecified.

safareli commented 6 years ago

@garyb good point I went all they up and at some point the information was lost i.e. forall x was used instead of the Path.Rel so the use case I had for it is not relevant any more.

But I the I like the idea of having one function which returns either vs two which return maybe. As Path is Either Rel or Abs and the function proposed describes that statement in more clear form then maybes.

garyb commented 6 years ago

But I the I like the idea of having one function which returns either vs two which return maybe

I agree with that, but I don't think we need maybeRel / maybeAbs either :smile: (aside from an internal implementation thing perhaps).

safareli commented 6 years ago

will be fixed as part of #33