Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parent and dirrename should return In MonadThrow m #33

Closed
harendra-kumar opened this issue Jul 24, 2016 · 9 comments
Closed

parent and dirrename should return In MonadThrow m #33

harendra-kumar opened this issue Jul 24, 2016 · 9 comments
Labels

Comments

@harendra-kumar
Copy link
Collaborator

Should this be fixed?

>> isParentOf $(mkAbsDir "/") $(mkAbsDir "/")
False
>> parent $(mkAbsDir "/")
"/"
>> 
@chrisdone
Copy link
Member

It's definitely an inconsistency.

@harendra-kumar
Copy link
Collaborator Author

There are two ways to fix that. Let parent throw an exception on / or let isParentOf return true in case of /. Unix traditionally allows cd .. when you are in root dir so the latter might be in line with that.

@chrisdone
Copy link
Member

Indeed, the magicness of the root directory seems to give us no option but to pick something not great. isParentOf returning true for the same two arguments seems to mess with people's intuition of hierarchy.

Putting parent in MonadThrow m is inconvenient, but it is more correct. Perhaps we can plan a migration path.

@harendra-kumar
Copy link
Collaborator Author

The two options wrt root dir sound like this:

  1. Sorry, its a dead end you can't go beyond this
  2. You try to go up, you succeed and you find yourself in the same place

The first one is a more explicit and intuitive handling than the latter. Looks like a better option to me as well though a bit more inconvenient compared to the other one.

@chrisdone
Copy link
Member

Indeed. I think (1) is explicit and the kind of thing this library is about.

@harendra-kumar
Copy link
Collaborator Author

Throw an exception or return a Maybe?

@mrkkrp
Copy link
Collaborator

mrkkrp commented Jul 25, 2016

I think it should throw just like all the other functions. It's more flexible and you can always get a Maybe value from MonadThrow m => ... m a.

harendra-kumar added a commit to harendra-kumar/path that referenced this issue Jul 25, 2016
`isParentOf` does not treat root dir as a parent of itself while `parent` does.
Make `parent` fail for root dir.
harendra-kumar added a commit to harendra-kumar/path that referenced this issue Jul 25, 2016
`isParentOf` does not treat root dir as a parent of itself while `parent` does.
Make `parent` fail for root dir.
@chrisdone chrisdone changed the title parent and isParentOf are inconsistent in the handling of root dir. paretnt Aug 21, 2016
@chrisdone chrisdone changed the title paretnt parent and dirrename should return In MonadThrow m Aug 21, 2016
@mrkkrp
Copy link
Collaborator

mrkkrp commented Mar 1, 2017

Should this be considered a duplicate of #18? Can we close it in favor of that issue?

@mrkkrp
Copy link
Collaborator

mrkkrp commented Mar 2, 2017

Closing in favor of #18. Should be resolved in version 0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants