|
|
1
|
+{-# LANGUAGE CPP #-}
|
|
1
|
2
|
{-# LANGUAGE Trustworthy #-}
|
|
2
|
3
|
{-# LANGUAGE DeriveGeneric #-}
|
|
3
|
4
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
| ... |
... |
@@ -64,8 +65,13 @@ import GHC.Internal.Data.Data (Data) |
|
64
|
65
|
|
|
65
|
66
|
import GHC.Internal.Base (
|
|
66
|
67
|
Alternative(..), Applicative(..), Functor(..), Monad(..), MonadPlus(..),
|
|
67
|
|
- ap, const, liftA, liftA3, liftM, liftM2, thenA, (.), (<**>),
|
|
|
68
|
+ ap, const, liftA, liftA3, liftM, liftM2, (.), (<**>),
|
|
68
|
69
|
)
|
|
|
70
|
+#if __GLASGOW_HASKELL__ < 1000
|
|
|
71
|
+import GHC.Internal.Base (id)
|
|
|
72
|
+#else
|
|
|
73
|
+import GHC.Internal.Base (thenA)
|
|
|
74
|
+#endif
|
|
69
|
75
|
import GHC.Internal.Functor.ZipList (ZipList(..))
|
|
70
|
76
|
import GHC.Internal.Types
|
|
71
|
77
|
import GHC.Generics
|
| ... |
... |
@@ -148,3 +154,19 @@ deriving instance (Typeable (a :: Type -> Type -> Type), Typeable b, Typeable c, |
|
148
|
154
|
|
|
149
|
155
|
optional :: Alternative f => f a -> f (Maybe a)
|
|
150
|
156
|
optional v = Just <$> v <|> pure Nothing
|
|
|
157
|
+
|
|
|
158
|
+#if __GLASGOW_HASKELL__ < 1000
|
|
|
159
|
+
|
|
|
160
|
+-- | Sequence two `Applicative` actions, discarding the result of the first one.
|
|
|
161
|
+--
|
|
|
162
|
+-- Defined as `thenA fa fb = (id <$ fa) <*> fb`.
|
|
|
163
|
+--
|
|
|
164
|
+-- This can be used to explicitly define `(*>) = thenA`, which is the default
|
|
|
165
|
+-- definition.
|
|
|
166
|
+--
|
|
|
167
|
+-- @since 4.23.0.0
|
|
|
168
|
+thenA :: Applicative f => f a -> f b -> f b
|
|
|
169
|
+thenA fa fb = (id <$ fa) <*> fb
|
|
|
170
|
+{-# INLINEABLE thenA #-}
|
|
|
171
|
+
|
|
|
172
|
+#endif |