in-other-words-0.2.0.0: A higher-order effect system where the sky's the limit
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Select

Synopsis

Effect

newtype Select s m a where Source #

An effect for backtracking search.

Constructors

Select :: (forall r. (a -> m (s, r)) -> m r) -> Select s m a 

Instances

Instances details
Eff (Shift (s, r)) m => Handler (SelectH r) (Select s) m Source # 
Instance details

Defined in Control.Effect.Internal.Select

Actions

select :: Eff (Select s) m => (forall r. (a -> m (s, r)) -> m r) -> m a Source #

Perform a search: capture the continuation of the program, so that you may test values of a and observe what corresponding s each value would result in at the end of the program (which may be seen as the evaluation of a). When you find a satisfactory a, you may return the associated r.

The way higher-order actions interact with the continuation depends on the interpretation of Select. In general, you cannot expect to interact with the continuation in any meaningful way: for example, you should not assume that you will be able to catch an exception thrown at some point in the future of the computation by using catch on the continuation.

Interpretations

runSelect :: forall s a m p. (Carrier m, Threaders '[ContThreads] m p) => (a -> m s) -> SelectC s a m a -> m a Source #

Run a Select s effect by providing an evaluator for the final result of type a.

Derivs (SelectC s r m) = Select s ': Derivs m
Prims  (SelectC s r m) = Prims m

Carriers

data SelectC s r m a Source #

Instances

Instances details
MonadBase b m => MonadBase b (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

liftBase :: b α -> SelectC s r m α #

MonadTrans (SelectC s r) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

lift :: Monad m => m a -> SelectC s r m a #

Monad (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

(>>=) :: SelectC s r m a -> (a -> SelectC s r m b) -> SelectC s r m b #

(>>) :: SelectC s r m a -> SelectC s r m b -> SelectC s r m b #

return :: a -> SelectC s r m a #

Functor (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

fmap :: (a -> b) -> SelectC s r m a -> SelectC s r m b #

(<$) :: a -> SelectC s r m b -> SelectC s r m a #

MonadFail m => MonadFail (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

fail :: String -> SelectC s r m a #

Applicative (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

pure :: a -> SelectC s r m a #

(<*>) :: SelectC s r m (a -> b) -> SelectC s r m a -> SelectC s r m b #

liftA2 :: (a -> b -> c) -> SelectC s r m a -> SelectC s r m b -> SelectC s r m c #

(*>) :: SelectC s r m a -> SelectC s r m b -> SelectC s r m b #

(<*) :: SelectC s r m a -> SelectC s r m b -> SelectC s r m a #

MonadIO m => MonadIO (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

liftIO :: IO a -> SelectC s r m a #

MonadThrow m => MonadThrow (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

throwM :: Exception e => e -> SelectC s r m a #

MonadCatch m => MonadCatch (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Methods

catch :: Exception e => SelectC s r m a -> (e -> SelectC s r m a) -> SelectC s r m a #

(Carrier m, Threads (FreeT (ContBase (m (s, r)) (s, r))) (Prims m)) => Carrier (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

Associated Types

type Derivs (SelectC s r m) :: [Effect] Source #

type Prims (SelectC s r m) :: [Effect] Source #

Methods

algPrims :: Algebra' (Prims (SelectC s r m)) (SelectC s r m) a Source #

reformulate :: Monad z => Reformulation' (Derivs (SelectC s r m)) (Prims (SelectC s r m)) (SelectC s r m) z a Source #

algDerivs :: Algebra' (Derivs (SelectC s r m)) (SelectC s r m) a Source #

type Derivs (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

type Derivs (SelectC s r m) = Derivs (ReinterpretC (SelectH r) (Select s) '[Shift (s, r)] (ShiftC (s, r) m))
type Prims (SelectC s r m) Source # 
Instance details

Defined in Control.Effect.Internal.Select

type Prims (SelectC s r m) = Prims (ReinterpretC (SelectH r) (Select s) '[Shift (s, r)] (ShiftC (s, r) m))