diff options
author | RyanGlScott <ryan.gl.scott@gmail.com> | 2016-02-29 12:28:18 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-02-29 13:42:02 +0100 |
commit | 171d95df24dc2d9d0c1a3af9e75f021438a7da50 (patch) | |
tree | 0a587d60a22eed012b7a35f2a053a8017b70cdf2 /libraries/base/Data/Proxy.hs | |
parent | 46f3775c683faeb710c9dc22f360f39334947d73 (diff) | |
download | haskell-171d95df24dc2d9d0c1a3af9e75f021438a7da50.tar.gz |
Missing Proxy instances, make U1 instance more Proxy-like
This accomplishes three things:
* Adds missing `Alternative`, `MonadPlus`, and `MonadZip` instances for
`Proxy`
* Adds a missing `MonadPlus` instance for `U1`
* Changes several existing `U1` instances to use lazy pattern-matching,
exactly how `Proxy` does it (in case we ever replace `U1` with
`Proxy`). This is technically a breaking change (albeit an extremely
minor one).
Test Plan: ./validate
Reviewers: austin, ekmett, hvr, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1962
GHC Trac Issues: #11650
Diffstat (limited to 'libraries/base/Data/Proxy.hs')
-rw-r--r-- | libraries/base/Data/Proxy.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libraries/base/Data/Proxy.hs b/libraries/base/Data/Proxy.hs index 9f602ea0c8..f0760e855d 100644 --- a/libraries/base/Data/Proxy.hs +++ b/libraries/base/Data/Proxy.hs @@ -89,10 +89,18 @@ instance Applicative Proxy where _ <*> _ = Proxy {-# INLINE (<*>) #-} +instance Alternative Proxy where + empty = Proxy + {-# INLINE empty #-} + _ <|> _ = Proxy + {-# INLINE (<|>) #-} + instance Monad Proxy where _ >>= _ = Proxy {-# INLINE (>>=) #-} +instance MonadPlus Proxy + -- | 'asProxyTypeOf' is a type-restricted version of 'const'. -- It is usually used as an infix operator, and its typing forces its first -- argument (which is usually overloaded) to have the same type as the tag |