fused-effects-0.1.0.0: A fast, flexible, fused effect system.

Control.Effect.NonDet

Synopsis

# Documentation

data NonDet (m :: * -> *) k Source #

Constructors

 Empty Choose (Bool -> k)
Instances
 Source # Instance detailsDefined in Control.Effect.NonDet.Internal Methodshandle :: Functor f => f () -> (forall x. f (m x) -> n (f x)) -> NonDet m (m a) -> NonDet n (n (f a)) Source # Source # Instance detailsDefined in Control.Effect.NonDet.Internal Methodsfmap' :: (a -> b) -> NonDet m a -> NonDet m b Source #hmap :: (forall x. m x -> n x) -> NonDet m a -> NonDet n a Source # Source # Instance detailsDefined in Control.Effect.NonDet.Internal Methodsfmap :: (a -> b) -> NonDet m a -> NonDet m b #(<$) :: a -> NonDet m b -> NonDet m a # (Alternative f, Monad f, Traversable f, Carrier sig m, Effect sig, Applicative m) => Carrier (NonDet :+: sig) (AltC f m) Source # Instance detailsDefined in Control.Effect.NonDet Methodsret :: a -> AltC f m a Source #eff :: (NonDet :+: sig) (AltC f m) (AltC f m a) -> AltC f m a Source # class Applicative f => Alternative (f :: * -> *) where # A monoid on applicative functors. If defined, some and many should be the least solutions of the equations: • some v = (:) <$> v <*> many v
• many v = some v <|> pure []

Minimal complete definition

Methods

empty :: f a #

The identity of <|>

(<|>) :: f a -> f a -> f a infixl 3 #

An associative binary operation

some :: f a -> f [a] #

One or more.

many :: f a -> f [a] #

Zero or more.

Instances
 Since: base-2.1 Instance detailsDefined in GHC.Base Methodsempty :: [a] #(<|>) :: [a] -> [a] -> [a] #some :: [a] -> [[a]] #many :: [a] -> [[a]] # Since: base-2.1 Instance detailsDefined in GHC.Base Methodsempty :: Maybe a #(<|>) :: Maybe a -> Maybe a -> Maybe a #some :: Maybe a -> Maybe [a] #many :: Maybe a -> Maybe [a] # Since: base-4.9.0.0 Instance detailsDefined in GHC.Base Methodsempty :: IO a #(<|>) :: IO a -> IO a -> IO a #some :: IO a -> IO [a] #many :: IO a -> IO [a] # Since: base-4.9.0.0 Instance detailsDefined in Data.Semigroup Methodsempty :: Option a #(<|>) :: Option a -> Option a -> Option a #some :: Option a -> Option [a] #many :: Option a -> Option [a] # Since: base-4.11.0.0 Instance detailsDefined in Control.Applicative Methods(<|>) :: ZipList a -> ZipList a -> ZipList a #some :: ZipList a -> ZipList [a] #many :: ZipList a -> ZipList [a] # Since: base-4.6.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodsempty :: ReadP a #(<|>) :: ReadP a -> ReadP a -> ReadP a #some :: ReadP a -> ReadP [a] #many :: ReadP a -> ReadP [a] # Since: base-4.5.0.0 Instance detailsDefined in Text.ParserCombinators.ReadP Methodsempty :: P a #(<|>) :: P a -> P a -> P a #some :: P a -> P [a] #many :: P a -> P [a] # Alternative (U1 :: * -> *) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: U1 a #(<|>) :: U1 a -> U1 a -> U1 a #some :: U1 a -> U1 [a] #many :: U1 a -> U1 [a] # Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsempty :: WrappedMonad m a #(<|>) :: WrappedMonad m a -> WrappedMonad m a -> WrappedMonad m a #some :: WrappedMonad m a -> WrappedMonad m [a] #many :: WrappedMonad m a -> WrappedMonad m [a] # Since: base-4.6.0.0 Instance detailsDefined in Control.Arrow Methodsempty :: ArrowMonad a a0 #(<|>) :: ArrowMonad a a0 -> ArrowMonad a a0 -> ArrowMonad a a0 #some :: ArrowMonad a a0 -> ArrowMonad a [a0] #many :: ArrowMonad a a0 -> ArrowMonad a [a0] # Alternative (Proxy :: * -> *) Since: base-4.9.0.0 Instance detailsDefined in Data.Proxy Methodsempty :: Proxy a #(<|>) :: Proxy a -> Proxy a -> Proxy a #some :: Proxy a -> Proxy [a] #many :: Proxy a -> Proxy [a] # (Member NonDet sig, Carrier sig carrier) => Alternative (Eff carrier) # Run computations nondeterministically.run (runNonDet empty) == []run (runNonDet empty) == Nothingrun (runNonDet (pure a <|> pure b)) == [a, b]run (runNonDet (pure a <|> pure b)) == Just aAssociativity:run (runNonDet ((pure a <|> pure b) <|> pure c)) == (run (runNonDet (pure a <|> (pure b <|> pure c))) :: [Integer])run (runNonDet ((pure a <|> pure b) <|> pure c)) == (run (runNonDet (pure a <|> (pure b <|> pure c))) :: Maybe Integer)Left-identity:run (runNonDet (empty <|> pure b)) == (run (runNonDet (pure b)) :: [Integer])run (runNonDet (empty <|> pure b)) == (run (runNonDet (pure b)) :: Maybe Integer)Right-identity:run (runNonDet (pure a <|> empty)) == (run (runNonDet (pure a)) :: [Integer])run (runNonDet (pure a <|> empty)) == (run (runNonDet (pure a)) :: Maybe Integer) Instance detailsDefined in Control.Effect.Internal Methodsempty :: Eff carrier a #(<|>) :: Eff carrier a -> Eff carrier a -> Eff carrier a #some :: Eff carrier a -> Eff carrier [a] #many :: Eff carrier a -> Eff carrier [a] # Alternative f => Alternative (Rec1 f) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: Rec1 f a #(<|>) :: Rec1 f a -> Rec1 f a -> Rec1 f a #some :: Rec1 f a -> Rec1 f [a] #many :: Rec1 f a -> Rec1 f [a] # (ArrowZero a, ArrowPlus a) => Alternative (WrappedArrow a b) Since: base-2.1 Instance detailsDefined in Control.Applicative Methodsempty :: WrappedArrow a b a0 #(<|>) :: WrappedArrow a b a0 -> WrappedArrow a b a0 -> WrappedArrow a b a0 #some :: WrappedArrow a b a0 -> WrappedArrow a b [a0] #many :: WrappedArrow a b a0 -> WrappedArrow a b [a0] # Alternative f => Alternative (Alt f) Instance detailsDefined in Data.Semigroup.Internal Methodsempty :: Alt f a #(<|>) :: Alt f a -> Alt f a -> Alt f a #some :: Alt f a -> Alt f [a] #many :: Alt f a -> Alt f [a] # (Functor m, Monad m, Error e) => Alternative (ErrorT e m) Instance detailsDefined in Control.Monad.Trans.Error Methodsempty :: ErrorT e m a #(<|>) :: ErrorT e m a -> ErrorT e m a -> ErrorT e m a #some :: ErrorT e m a -> ErrorT e m [a] #many :: ErrorT e m a -> ErrorT e m [a] # (Alternative f, Alternative g) => Alternative (f :*: g) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: (f :*: g) a #(<|>) :: (f :*: g) a -> (f :*: g) a -> (f :*: g) a #some :: (f :*: g) a -> (f :*: g) [a] #many :: (f :*: g) a -> (f :*: g) [a] # (Alternative f, Alternative g) => Alternative (Product f g) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Product Methodsempty :: Product f g a #(<|>) :: Product f g a -> Product f g a -> Product f g a #some :: Product f g a -> Product f g [a] #many :: Product f g a -> Product f g [a] # Alternative f => Alternative (M1 i c f) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: M1 i c f a #(<|>) :: M1 i c f a -> M1 i c f a -> M1 i c f a #some :: M1 i c f a -> M1 i c f [a] #many :: M1 i c f a -> M1 i c f [a] # (Alternative f, Applicative g) => Alternative (f :.: g) Since: base-4.9.0.0 Instance detailsDefined in GHC.Generics Methodsempty :: (f :.: g) a #(<|>) :: (f :.: g) a -> (f :.: g) a -> (f :.: g) a #some :: (f :.: g) a -> (f :.: g) [a] #many :: (f :.: g) a -> (f :.: g) [a] # (Alternative f, Applicative g) => Alternative (Compose f g) Since: base-4.9.0.0 Instance detailsDefined in Data.Functor.Compose Methodsempty :: Compose f g a #(<|>) :: Compose f g a -> Compose f g a -> Compose f g a #some :: Compose f g a -> Compose f g [a] #many :: Compose f g a -> Compose f g [a] #

runNonDet :: (Alternative f, Monad f, Traversable f, Carrier sig m, Effect sig, Applicative m) => Eff (AltC f m) a -> m (f a) Source #

Run a NonDet effect, collecting all branches’ results into an Alternative functor.

Using '[]' as the Alternative functor will produce all results, while Maybe will return only the first.

run (runNonDet (pure a)) == [a]
run (runNonDet (pure a)) == Just a

newtype AltC f m a Source #

Constructors

 AltC FieldsrunAltC :: m (f a)
Instances
 (Alternative f, Monad f, Traversable f, Carrier sig m, Effect sig, Applicative m) => Carrier (NonDet :+: sig) (AltC f m) Source # Instance detailsDefined in Control.Effect.NonDet Methodsret :: a -> AltC f m a Source #eff :: (NonDet :+: sig) (AltC f m) (AltC f m a) -> AltC f m a Source #