Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

export 'nothing' and 'just' patterns

Ignore-this: b18b749825448c91dc49dd0537a8e90f

darcs-hash:20110212215536-1e371-dcc8cb92fa7f975744c925a43b967f3b9570f6d3.gz
  • Loading branch information...
commit bfd8e7f9053d2ab2716d6c54642c71e53fadb6f1 1 parent 6d3c00f
Brent Yorgey authored
Showing with 9 additions and 5 deletions.
  1. +9 −5 Data/Pattern/Common.hs
View
14 Data/Pattern/Common.hs
@@ -24,10 +24,12 @@ module Data.Pattern.Common (
mk0, mk1, mk2, mk3, mk4, mk5,
-- * Tuple patterns
tup0, tup1, tup2, tup3, tup4, tup5,
+ -- * @Maybe@ patterns
+ nothing, just,
-- * @Either@ patterns
left, right,
-- * List patterns
- nil, cons,
+ nil, cons
) where
import Data.Pattern.Base
@@ -121,11 +123,13 @@ left = mk1 (either Just (const Nothing))
right :: Pat1 b (Either a b)
right = mk1 (either (const Nothing) Just)
-mk2 :: (a -> Maybe (b,c)) -> Pat2 b c a
-mk2 g b c = mk1 g (tup2 b c)
+-- | Matches @Nothing@.
+nothing :: Pat0 (Maybe a)
+nothing = is isNothing
-mk3 :: (a -> Maybe (b,c,d)) -> Pat3 b c d a
-mk3 g b c d = mk1 g (tup3 b c d)
+-- | Matches @Just@.
+just :: Pat1 a (Maybe a)
+just = mk1 id
-- | Matches the empty list.
nil :: Pat0 [a]
Please sign in to comment.
Something went wrong with that request. Please try again.