Hoogle Search
Within LTS Haskell 24.39 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
pubSubForever :: Connection -> PubSubController -> IO () -> IO ()hedis Database.Redis.Sentinel Open a connection to the Redis server, register to all channels in the PubSubController, and process messages and subscription change requests forever. The only way this will ever exit is if there is an exception from the network code or an unhandled exception in a MessageCallback or PMessageCallback. For example, if the network connection to Redis dies, pubSubForever will throw a ConnectionLost. When such an exception is thrown, you can recall pubSubForever with the same PubSubController which will open a new connection and resubscribe to all the channels which are tracked in the PubSubController. The general pattern is therefore during program startup create a PubSubController and fork a thread which calls pubSubForever in a loop (using an exponential backoff algorithm such as the retry package to not hammer the Redis server if it does die). For example,
myhandler :: ByteString -> IO () myhandler msg = putStrLn $ unpack $ decodeUtf8 msg onInitialComplete :: IO () onInitialComplete = putStrLn "Redis acknowledged that mychannel is now subscribed" main :: IO () main = do conn <- connect defaultConnectInfo pubSubCtrl <- newPubSubController [("mychannel", myhandler)] [] concurrently ( forever $ pubSubForever conn pubSubCtrl onInitialComplete `catch` (\(e :: SomeException) -> do putStrLn $ "Got error: " ++ show e threadDelay $ 50*1000) -- TODO: use exponential backoff ) $ restOfYourProgram {- elsewhere in your program, use pubSubCtrl to change subscriptions -}At most one active pubSubForever can be running against a single PubSubController at any time. If two active calls to pubSubForever share a single PubSubController there will be deadlocks. If you do want to process messages using multiple connections to Redis, you can create more than one PubSubController. For example, create one PubSubController for each getNumCapabilities and then create a Haskell thread bound to each capability each calling pubSubForever in a loop. This will create one network connection per controller/capability and allow you to register separate channels and callbacks for each controller, spreading the load across the capabilities.xclaimForce :: XClaimOpts -> Boolhedis Database.Redis.Sentinel No documentation available.
bifor :: (Bitraversable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f (t c d)relude Relude.Foldable.Reexport bifor is bitraverse with the structure as the first argument. For a version that ignores the results, see bifor_.
Examples
Basic usage:>>> bifor (Left []) listToMaybe (find even) Nothing
>>> bifor (Left [1, 2, 3]) listToMaybe (find even) Just (Left 1)
>>> bifor (Right [4, 5]) listToMaybe (find even) Just (Right 4)
>>> bifor ([1, 2, 3], [4, 5]) listToMaybe (find even) Just (1,4)
>>> bifor ([], [4, 5]) listToMaybe (find even) Nothing
bifor_ :: (Bifoldable t, Applicative f) => t a b -> (a -> f c) -> (b -> f d) -> f ()relude Relude.Foldable.Reexport As bitraverse_, but with the structure as the primary argument. For a version that doesn't ignore the results, see bifor.
Examples
Basic usage:>>> bifor_ ("Hello", True) print (print . show) "Hello" "True">>> bifor_ (Right True) print (print . show) "True"
>>> bifor_ (Left "Hello") print (print . show) "Hello"
-
diagrams-core Diagrams.Core Type class for things t which can be transformed.
data
Transformation (v :: Type -> Type) ndiagrams-core Diagrams.Core General (affine) transformations, represented by an invertible linear map, its transpose, and a vector representing a translation component. By the transpose of a linear map we mean simply the linear map corresponding to the transpose of the map's matrix representation. For example, any scale is its own transpose, since scales are represented by matrices with zeros everywhere except the diagonal. The transpose of a rotation is the same as its inverse. The reason we need to keep track of transposes is because it turns out that when transforming a shape according to some linear map L, the shape's normal vectors transform according to L's inverse transpose. (For a more detailed explanation and proof, see https://wiki.haskell.org/Diagrams/Dev/Transformations.) This is exactly what we need when transforming bounding functions, which are defined in terms of perpendicular (i.e. normal) hyperplanes. For more general, non-invertible transformations, see Diagrams.Deform (in diagrams-lib).
transform :: Transformable t => Transformation (V t) (N t) -> t -> tdiagrams-core Diagrams.Core Apply a transformation to an object.
module Diagrams.Core.
Transform Diagrams defines the core library of primitives forming the basis of an embedded domain-specific language for describing and rendering diagrams. The Transform module defines generic transformations parameterized by any vector space.
-
diagrams-core Diagrams.Core.Transform Type class for things t which can be transformed.
data
Transformation (v :: Type -> Type) ndiagrams-core Diagrams.Core.Transform General (affine) transformations, represented by an invertible linear map, its transpose, and a vector representing a translation component. By the transpose of a linear map we mean simply the linear map corresponding to the transpose of the map's matrix representation. For example, any scale is its own transpose, since scales are represented by matrices with zeros everywhere except the diagonal. The transpose of a rotation is the same as its inverse. The reason we need to keep track of transposes is because it turns out that when transforming a shape according to some linear map L, the shape's normal vectors transform according to L's inverse transpose. (For a more detailed explanation and proof, see https://wiki.haskell.org/Diagrams/Dev/Transformations.) This is exactly what we need when transforming bounding functions, which are defined in terms of perpendicular (i.e. normal) hyperplanes. For more general, non-invertible transformations, see Diagrams.Deform (in diagrams-lib).