Skip to content

Commit fe62b9c

Browse files
committed
Merge pull request #15 from michaelficarra/perms-ring
add Semiring instance for Perm
2 parents 4860bd3 + 3387dd9 commit fe62b9c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ instance semigroupPerm :: Semigroup Perm
221221
```
222222

223223

224+
#### `semiringPerm`
225+
226+
``` purescript
227+
instance semiringPerm :: Semiring Perm
228+
```
229+
230+
224231
#### `none`
225232

226233
``` purescript

src/Node/FS/Perms.purs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ instance semigroupPerm :: Semigroup Perm where
5050
(<>) (Perm { r = r0, w = w0, x = x0 }) (Perm { r = r1, w = w1, x = x1 }) =
5151
Perm { r: r0 || r1, w: w0 || w1, x: x0 || x1 }
5252

53+
instance semiringPerm :: Semiring Perm where
54+
(+) = (<>)
55+
zero = none
56+
(*) (Perm { r = r0, w = w0, x = x0 }) (Perm { r = r1, w = w1, x = x1 }) =
57+
Perm { r: r0 && r1, w: w0 && w1, x: x0 && x1 }
58+
one = all
59+
5360
-- | Create a `Perm` value. The arguments represent the readable, writable, and
5461
-- | executable permissions, in that order.
5562
mkPerm :: Boolean -> Boolean -> Boolean -> Perm

0 commit comments

Comments
 (0)