Verified Commit deca53aa authored by Camil Staps's avatar Camil Staps 🙂

Remove ApplicativeExtra

parent b67d7c50
Pipeline #16224 passed with stage
in 1 minute and 19 seconds
......@@ -17,11 +17,13 @@ class (<*>) infixl 4 f :: !(f (a -> b)) (f a) -> f b
class Applicative f | Functor, pure, <*> f
class ApplicativeExtra f | Applicative f
class <* f | Applicative f
where
(<*) infixl 4 :: !(f a) (f b) -> f a
(<*) fa fb = pure (\x _->x) <*> fa <*> fb
class *> f | Applicative f
where
(*>) infixl 4 :: !(f a) (f b) -> f b
(*>) fa fb = pure (\_ x->x) <*> fa <*> fb
......
definition module Control.Monad.State
from Control.Monad import class Monad
from Control.Applicative import class pure, class <*>, class Applicative, class ApplicativeExtra, class Alternative
from Control.Applicative import class pure, class <*>, class Applicative, class *>, class <*, class Alternative
from Data.Functor import class Functor
from Data.Functor.Identity import :: Identity
from Control.Monad.Trans import class MonadTrans
......@@ -16,11 +16,11 @@ put :: s -> StateT s m () | Monad m
modify :: (s -> s) -> StateT s m () | Monad m
gets :: (s -> a) -> StateT s m a | Monad m
runState :: .(StateT s Identity a) s -> (a, s)
runStateT :: u:(StateT v:s m a) v:s -> m w:(a, v:s), [w <= v,u <= w]
runStateT :: !u:(StateT v:s m a) v:s -> m w:(a, v:s), [w <= v,u <= w]
evalState :: .(StateT s Identity a) s -> a
evalStateT :: .(StateT s m a) s -> m a | Monad m
evalStateT :: !.(StateT s m a) s -> m a | Monad m
execState :: .(StateT s Identity a) s -> s
execStateT :: .(StateT s m a) s -> m s | Monad m
execStateT :: !.(StateT s m a) s -> m s | Monad m
mapState :: ((a, s) -> (b, s)) .(StateT s Identity a) -> StateT s Identity b
mapStateT :: ((m (a, s)) -> (m` (b, s))) .(StateT s m a) -> StateT s m` b
withState :: (s -> s) .(StateT s m c) -> StateT s m c
......@@ -28,10 +28,11 @@ withStateT :: (s -> s) .(StateT s m c) -> StateT s m c
transformStateT :: (s2 -> s1) (a s1 -> (a, s2)) (StateT s1 m a) -> (StateT s2 m a) | Functor m
instance Functor (StateT s m) | Monad m
instance Functor (StateT s m) | Functor m
instance pure (StateT s m) | pure m
instance <*> (StateT s m) | Monad m
instance ApplicativeExtra (StateT s m) | Monad m
instance *> (StateT s m) | Monad m
instance <* (StateT s m) | Monad m
instance Alternative (StateT s m) | Alternative m
instance Monad (StateT s m) | Monad m
instance MonadTrans (StateT s)
......@@ -11,8 +11,9 @@ import Control.Monad.Trans
from StdFunc import o
from StdTuple import fst, snd
instance Functor (StateT s m) | Monad m where
fmap f m = StateT (\s -> fmap (\(a, s`) -> (f a, s`)) (runStateT m s))
instance Functor (StateT s m) | Functor m
where
fmap f m = StateT \s -> fmap (\(a, s`) -> (f a, s`)) (runStateT m s)
instance pure (StateT s m) | pure m
where
......@@ -20,9 +21,15 @@ where
instance <*> (StateT s m) | Monad m
where
(<*>) sf sa = ap sf sa
(<*>) sf sa = liftM2 id sf sa
instance *> (StateT s m) | Monad m
where
*> fa fb = liftA2 (\a b -> b) fa fb
instance ApplicativeExtra (StateT s m) | Monad m
instance <* (StateT s m) | Monad m
where
<* fa fb = liftA2 (\a b -> a) fa fb
instance Alternative (StateT s m) | Alternative m where
empty = StateT (const empty)
......@@ -52,19 +59,19 @@ gets f = state (\s -> (f s, s))
runState :: .(StateT s Identity a) s -> (a, s)
runState m s = runIdentity (runStateT m s)
runStateT :: u:(StateT v:s m a) v:s -> m w:(a, v:s), [w <= v,u <= w]
runStateT :: !u:(StateT v:s m a) v:s -> m w:(a, v:s), [w <= v,u <= w]
runStateT (StateT f) s = f s
evalState :: .(StateT s Identity a) s -> a
evalState m s = fst (runState m s)
evalStateT :: .(StateT s m a) s -> m a | Monad m
evalStateT :: !.(StateT s m a) s -> m a | Monad m
evalStateT m s = runStateT m s >>= \(a, _) -> pure a
execState :: .(StateT s Identity a) s -> s
execState m s = snd (runState m s)
execStateT :: .(StateT s m a) s -> m s | Monad m
execStateT :: !.(StateT s m a) s -> m s | Monad m
execStateT m s = runStateT m s >>= \(_, s`) -> pure s`
mapState :: ((a, s) -> (b, s)) .(StateT s Identity a) -> StateT s Identity b
......
......@@ -5,7 +5,7 @@ definition module Data.Either
* used inside generic functions, since most generic functions treat this
* type in a special way which may lead to strange behavior.
*/
from Control.Applicative import class pure, class <*>, class Applicative, class ApplicativeExtra, class Alternative
from Control.Applicative import class pure, class <*>, class Applicative, class *>, class <*, class Alternative
from Control.Monad import class Monad
from Data.Functor import class Functor
from Data.Monoid import class Monoid, class Semigroup
......@@ -19,7 +19,8 @@ from Data.GenEq import generic gEq
instance Functor (Either a)
instance pure (Either e)
instance <*> (Either e)
instance ApplicativeExtra (Either e)
instance *> (Either e)
instance <* (Either e)
instance Monad (Either e)
instance Foldable (Either a)
......
......@@ -25,11 +25,13 @@ where
(<*>) (Left e) _ = Left e
(<*>) (Right f) r = fmap f r
instance ApplicativeExtra (Either e)
instance *> (Either e)
where
(*>) (Right _) e = e
(*>) (Left l) _ = Left l
instance <* (Either e)
where
(<*) (Left l) _ = Left l
(<*) _ (Left l) = Left l
(<*) x _ = x
......
definition module Data.Foldable
from Control.Applicative import class pure(pure), class <*>, class Applicative, class ApplicativeExtra, :: Const, class Alternative(empty,<|>)
from Control.Applicative import class pure(pure), class <*>, class Applicative,
class *>, class <*, :: Const, class Alternative(empty,<|>)
from Control.Monad import class Monad(bind), >>=, class MonadPlus(mzero,mplus)
from Data.Functor import class Functor
from Data.Monoid import class Monoid, class Semigroup
......@@ -105,7 +106,7 @@ foldlM :: (b a -> m b) b (t a) -> m b | Foldable t & Monad m
* Map each element of a structure to an action, evaluate these actions from
* left to right, and ignore the results.
*/
traverse_ :: (a -> f b) (t a) -> f () | Foldable t & ApplicativeExtra f
traverse_ :: (a -> f b) (t a) -> f () | Foldable t & *> f
/**
* `for_` is {{`traverse_`}} with its arguments flipped.
......@@ -129,7 +130,7 @@ forM_ :== flip mapM_
* Evaluate each action in the structure from left to right, and ignore the
* results.
*/
sequenceA_ :: (t (f a)) -> f () | Foldable t & ApplicativeExtra f
sequenceA_ :: (t (f a)) -> f () | Foldable t & *> f
/**
* Evaluate each monadic action in the structure from left to right, and ignore
......
......@@ -46,13 +46,13 @@ foldlM :: (b a -> m b) b (t a) -> m b | Foldable t & Monad m
foldlM f z0 xs = foldr f` pure xs z0
where f` x k z = f z x >>= k
traverse_ :: (a -> f b) (t a) -> f () | Foldable t & ApplicativeExtra f
traverse_ :: (a -> f b) (t a) -> f () | Foldable t & *> f
traverse_ f x = foldr ((*>) o f) (pure ()) x
mapM_ :: (a -> m b) (t a) -> m () | Foldable t & Monad m
mapM_ f x = foldr ((\ma mb -> ma >>= \_ -> mb) o f) (pure ()) x
sequenceA_ :: (t (f a)) -> f () | Foldable t & ApplicativeExtra f
sequenceA_ :: (t (f a)) -> f () | Foldable t & *> f
sequenceA_ x = foldr (*>) (pure ()) x
concat :: (t [a]) -> [a] | Foldable t
......
......@@ -7,7 +7,7 @@ import StdMaybe
from StdOverloaded import class ==(..)
from Data.Functor import class Functor
from Control.Applicative import class pure, class <*>, class Applicative, class ApplicativeExtra, class Alternative
from Control.Applicative import class pure, class <*>, class Applicative, class *>, class <*, class Alternative
from Control.Monad import class Monad, class MonadPlus
from Control.Monad.Trans import class MonadTrans
from Data.Monoid import class Semigroup, class Monoid
......@@ -18,7 +18,8 @@ from Data.GenEq import generic gEq
instance Functor Maybe
instance pure Maybe
instance <*> Maybe
instance ApplicativeExtra Maybe
instance *> Maybe
instance <* Maybe
instance Alternative Maybe
instance Monad Maybe
instance MonadPlus Maybe
......
......@@ -23,11 +23,13 @@ where
(<*>) Nothing _ = Nothing
(<*>) (Just f) ma = fmap f ma
instance ApplicativeExtra Maybe
instance *> Maybe
where
(*>) (Just _) m = m
(*>) _ _ = Nothing
instance <* Maybe
where
(<*) Nothing _ = Nothing
(<*) m (Just _) = m
(<*) _ _ = Nothing
......
definition module Text.Parsers.Simple.Core
from Control.Applicative import class pure, class <*>, class Applicative, class ApplicativeExtra, class Alternative
from Control.Applicative import class pure, class <*>, class Applicative, class *>, class <*, class Alternative
from Control.Monad import class Monad, class MonadPlus
from Data.Either import :: Either
from Data.Functor import class Functor
......@@ -13,7 +13,8 @@ from StdOverloaded import class ==
instance Functor (Parser t)
instance pure (Parser t)
instance <*> (Parser t)
instance ApplicativeExtra (Parser t)
instance *> (Parser t)
instance <* (Parser t)
instance Alternative (Parser t)
instance Monad (Parser t)
instance MonadPlus (Parser t)
......
......@@ -23,7 +23,8 @@ instance <*> (Parser t)
where
(<*>) l r = ap l r
instance ApplicativeExtra (Parser t)
instance *> (Parser t)
instance <* (Parser t)
instance Alternative (Parser t) where
empty = pFail
......
......@@ -2,7 +2,7 @@ definition module Text.Parsers.ZParsers.ParsersKernel
from StdEnv import class Eq, class toString, class ==
from Data.Maybe import :: Maybe(..)
from Control.Applicative import class pure, class <*>, class Applicative, class ApplicativeExtra, class Alternative
from Control.Applicative import class pure, class <*>, class Applicative, class *>, class <*, class Alternative
from Control.Monad import class Monad
from Data.Functor import class Functor
......@@ -60,9 +60,9 @@ instance Monad (Gram f) | Functor f
mkP :: !(Gram f a) -> f a | Monad f & Applicative f & Alternative f
sepBy :: !(Gram f a) (f b) -> f a | Monad, ApplicativeExtra, Alternative f
sepBy :: !(Gram f a) (f b) -> f a | Monad, *>, Alternative f
insertSep :: (f b) !(Gram f a) -> Gram f a | Monad, ApplicativeExtra, Alternative f
insertSep :: (f b) !(Gram f a) -> Gram f a | Monad, *>, Alternative f
gmList :: !(Gram f a) -> Gram f [a] | Functor f
......
......@@ -196,18 +196,18 @@ mkP (Gram l_a m_a) = foldr (<|>) (maybe empty pure m_a)
where mkP_Alt (Seq f_b2a g_b) = f_b2a <*> mkP g_b
mkP_Alt (Bind f_b b2g_a) = f_b >>= (mkP o b2g_a)
sepBy :: !(Gram f a) (f b) -> f a | Monad, ApplicativeExtra, Alternative f
sepBy :: !(Gram f a) (f b) -> f a | Monad, *>, Alternative f
sepBy g sep = mkP (insertSep sep g)
insertSep :: (f b) !(Gram f a) -> Gram f a | Monad, ApplicativeExtra, Alternative f
insertSep :: (f b) !(Gram f a) -> Gram f a | Monad, *>, Alternative f
insertSep sep (Gram na ea) = Gram (map insertSepInAlt na) ea
where insertSepInAlt (Seq fb2a gb) = Seq fb2a (prefixSepInGram sep gb)
insertSepInAlt (Bind fc c2ga) = Bind fc (insertSep sep o c2ga)
prefixSepInGram :: (f b) (Gram f a) -> Gram f a | Monad, ApplicativeExtra, Alternative f
prefixSepInGram :: (f b) (Gram f a) -> Gram f a | Monad, *>, Alternative f
prefixSepInGram sep (Gram na ne) = Gram (map (prefixSepInAlt sep) na) ne
prefixSepInAlt :: (f a) (PAlt f b) -> PAlt f b | Monad, ApplicativeExtra, Alternative f
prefixSepInAlt :: (f a) (PAlt f b) -> PAlt f b | Monad, *>, Alternative f
prefixSepInAlt sep (Seq fb2a gb) = Seq (sep *> fb2a) (prefixSepInGram sep gb)
prefixSepInAlt _ _ = abort "prefixSepInAlt called on non-Seq\n"
......
......@@ -51,7 +51,7 @@ run_tartest: tartest
$(RM) -r _tartest-old _tartest _tartest.tar
clean:
$(RM) -r $(BINARIES) Clean\ System\ Files
$(RM) -r $(filter-out checktest,$(BINARIES)) _tartest* Clean\ System\ Files
.FORCE:
.PHONY: all run clean .FORCE
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment