forked from purescript/purescript-control
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlus.purs
More file actions
28 lines (24 loc) · 826 Bytes
/
Copy pathPlus.purs
File metadata and controls
28 lines (24 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Control.Plus
( class Plus
, empty
, module Control.Alt
, module Data.Functor
) where
import Control.Alt (class Alt, alt, (<|>))
import Data.Functor (class Functor, map, void, ($>), (<#>), (<$), (<$>))
-- | The `Plus` type class extends the `Alt` type class with a value that
-- | should be the left and right identity for `(<|>)`.
-- |
-- | It is similar to `Monoid`, except that it applies to types of
-- | kind `* -> *`, like `Array` or `List`, rather than concrete types like
-- | `String` or `Number`.
-- |
-- | `Plus` instances should satisfy the following laws:
-- |
-- | - Left identity: `empty <|> x == x`
-- | - Right identity: `x <|> empty == x`
-- | - Annihilation: `f <$> empty == empty`
class Alt f <= Plus f where
empty :: forall a. f a
instance plusArray :: Plus Array where
empty = []