Ticket #4149 (closed proposal: fixed)

Opened 3 years ago

Last modified 3 years ago

Make Permissions type abstract

Reported by: igloo Owned by:
Priority: normal Milestone: Not GHC
Component: libraries/directory Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The Permissions type in System.Directory aims to be a lowest-common-denominator type. This makes it unsuitable for some tasks. For example, a copyPermissions primitive had to be implemented, as it is not possible to use the getPermissions and setPermissions functions to copy the permissions from one file to another:

$ ls -l foo*
-rwxr-x-wx 1 ian ian 0 Jun 23 21:27 foo1
---------- 1 ian ian 0 Jun 23 21:27 foo2
---------- 1 ian ian 0 Jun 23 21:27 foo3
$ hd -e 'System.Directory.copyPermissions "foo1" "foo2"'
$ hd -e 'System.Directory.getPermissions "foo1" >>= System.Directory.setPermissions "foo3"'
$ ls -l foo*                                            
-rwxr-x-wx 1 ian ian 0 Jun 23 21:27 foo1
-rwxr-x-wx 1 ian ian 0 Jun 23 21:27 foo2
-rwx------ 1 ian ian 0 Jun 23 21:27 foo3

I think we would be better served by the Permissions type being abstract in System.Directory, with the unix and Win32 packages providing the real definition, and some system-specific functions on it. This would allow the generic get/set functions to implement copyPermissions.

This proposal just does the step which has most potential to cause problems for packages that use the type: It makes the type abstract in System.Directory (and adds explicit setter functions, so no functionality is lost).

The type is also exported in Haskell 98's Directory module. I think this should get its own copy of the type.

Suggested discussion deadline: 9 July 2010.

Attachments

permissions-type-abstract.dpatch Download (3.9 KB) - added by igloo 3 years ago.
permissions-type-abstract-2.dpatch Download (3.9 KB) - added by igloo 3 years ago.

Change History

Changed 3 years ago by igloo

Changed 3 years ago by igloo

Changed 3 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Patch applied.

Duncan suggested naming the functions setOwner* rather than simply set*; I've incorporated this change.

Yitzchak asked about what breakage caused, but a Hackage regression test indicated there was no breakage.

When writing the H98 legacy code, I realised there was no way to create a Permissions value from scratch, so I took the liberty of also adding:

emptyPermissions :: Permissions
Note: See TracTickets for help on using tickets.