freer-effects-0.3.0.0: Implementation of effect system for Haskell.

Copyright (c) 2016 Allele Dev; 2017 Ixperta Solutions s.r.o. BSD3 ixcom-core@ixperta.com experimental GHC specific language extensions. None Haskell2010

Description

Internal machinery for this effects library. This includes:

• Eff data type, for expressing effects.
• NonDet data type, for nondeterministic effects.
• Functions for facilitating the construction of effects and their handlers.

Using http://okmij.org/ftp/Haskell/extensible/Eff1.hs as a starting point.

Synopsis

data Eff effs a Source #

The Eff monad provides a way to use effects in Haskell, in such a way that different types of effects can be interleaved, and so that the produced code is efficient.

Constructors

 Val a Pure value (return = pure = Val). E (Union effs b) (Arrs effs b a) Sending a request of type Union effs with the continuation Arrs r b a.

Instances

 Monad (Eff effs) Source # Methods(>>=) :: Eff effs a -> (a -> Eff effs b) -> Eff effs b #(>>) :: Eff effs a -> Eff effs b -> Eff effs b #return :: a -> Eff effs a #fail :: String -> Eff effs a # Functor (Eff effs) Source # Methodsfmap :: (a -> b) -> Eff effs a -> Eff effs b #(<) :: a -> Eff effs b -> Eff effs a # Applicative (Eff effs) Source # Methodspure :: a -> Eff effs a #(<*>) :: Eff effs (a -> b) -> Eff effs a -> Eff effs b #(*>) :: Eff effs a -> Eff effs b -> Eff effs b #(<*) :: Eff effs a -> Eff effs b -> Eff effs a # Member NonDet effs => Alternative (Eff effs) Source # Methodsempty :: Eff effs a #(<|>) :: Eff effs a -> Eff effs a -> Eff effs a #some :: Eff effs a -> Eff effs [a] #many :: Eff effs a -> Eff effs [a] # Member NonDet effs => MonadPlus (Eff effs) Source # Methodsmzero :: Eff effs a #mplus :: Eff effs a -> Eff effs a -> Eff effs a # type Arr effs a b = a -> Eff effs b Source # Effectful arrow type: a function from a :: * to b :: * that also does effects denoted by effs :: [* -> *]. type Arrs effs a b = FTCQueue (Eff effs) a b Source # An effectful function from a :: * to b :: * that is a composition of several effectful functions. The paremeter eff :: [* -> *] describes the overall effect. The composition members are accumulated in a type-aligned queue. Open Union Open Union (type-indexed co-product) of effects. Fast Type-aligned Queue Fast type-aligned queue optimized to effectful functions of type (a -> m b). Sending Arbitrary Effect send :: Member eff effs => eff a -> Eff effs a Source # Send a request and wait for a reply. Handling Effects run :: Eff '[] a -> a Source # Runs a set of Effects. Requires that all effects are consumed. Typically composed as follows: run . runEff1 eff1Arg . runEff2 eff2Arg1 eff2Arg2 someProgram

runM :: Monad m => Eff '[m] a -> m a Source #

Runs a set of Effects. Requires that all effects are consumed, except for a single effect known to be a monad. The value returned is a computation in that monad. This is useful for plugging in traditional transformer stacks.

Building Effect Handlers

Arguments

 :: (a -> Eff effs b) Handle a pure value. -> (forall v. eff v -> Arr effs v b -> Eff effs b) Handle a request for effect of type eff :: * -> *. -> Eff (eff ': effs) a -> Eff effs b Result with effects of type eff :: * -> * handled.

Given a request, either handle it or relay it.

Arguments

 :: s -> (s -> a -> Eff effs b) Handle a pure value. -> (forall v. s -> eff v -> (s -> Arr effs v b) -> Eff effs b) Handle a request for effect of type eff :: * -> *. -> Eff (eff ': effs) a -> Eff effs b Result with effects of type eff :: * -> * handled.

Parameterized handleRelay. Allows sending along some state of type s :: * to be handled for the target effect, or relayed to a handler that can- handle the target effect.

interpose :: Member eff effs => (a -> Eff effs b) -> (forall v. eff v -> Arr effs v b -> Eff effs b) -> Eff effs a -> Eff effs b Source #

Intercept the request and possibly reply to it, but leave it unhandled.

Low-level Functions for Building Effect Handlers

qApp :: Arrs effs b w -> b -> Eff effs w Source #

Function application in the context of an array of effects, Arrs effs b w.

qComp :: Arrs effs a b -> (Eff effs b -> Eff effs' c) -> Arr effs' a c Source #

Composition of effectful arrows (Arrs). Allows for the caller to change the effect environment, as well.

Nondeterminism Effect

data NonDet a where Source #

A data type for representing nondeterminstic choice.

Constructors

 MZero :: NonDet a MPlus :: NonDet Bool
{"ft_lang_label":"__label__en","ft_lang_prob":0.8537199,"math_prob":0.8890437,"size":4139,"snap":"2022-05-2022-21","text_gpt3_token_len":1209,"char_repetition_ratio":0.20193471,"word_repetition_ratio":0.41169307,"special_character_ratio":0.3073206,"punctuation_ratio":0.13292684,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9644466,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-01-19T08:48:28Z\",\"WARC-Record-ID\":\"<urn:uuid:42ced2b1-6ee5-4d42-b0ba-dcdfe93e2983>\",\"Content-Length\":\"25487\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:796e5fad-4e52-40bd-a500-9e3cf0818d09>\",\"WARC-Concurrent-To\":\"<urn:uuid:8f1ec051-427e-4ed7-a123-013d6c26cbf5>\",\"WARC-IP-Address\":\"147.75.55.189\",\"WARC-Target-URI\":\"https://hackage-origin.haskell.org/package/freer-effects-0.3.0.0/candidate/docs/Control-Monad-Freer-Internal.html\",\"WARC-Payload-Digest\":\"sha1:5JZPI3JVBMS65XFIIWWCEQBNN7M5C75L\",\"WARC-Block-Digest\":\"sha1:R5K3ZUKDLWJOD4JHLUFOAEAJCLPF67KM\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-05/CC-MAIN-2022-05_segments_1642320301264.36_warc_CC-MAIN-20220119064554-20220119094554-00526.warc.gz\"}"}