managed alternatives and similar packages
Based on the "Control" category.
Alternatively, view managed alternatives based on common mentions on social networks and blogs.
-
transient
A full stack, reactive architecture for general purpose programming. Algebraic and monadically composable primitives for concurrency, parallelism, event handling, transactions, multithreading, Web, and distributed computing with complete de-inversion of control (No callbacks, no blocking, pure state) -
selective
Selective Applicative Functors: Declare Your Effects Statically, Select Which to Execute Dynamically -
auto
Haskell DSL and platform providing denotational, compositional api for discrete-step, locally stateful, interactive programs, games & automations. http://hackage.haskell.org/package/auto -
ComonadSheet
A library for expressing "spreadsheet-like" computations with absolute and relative references, using fixed-points of n-dimensional comonads. -
transient-universe
A Cloud monad based on transient for the creation of Web and reactive distributed applications that are fully composable, where Web browsers are first class nodes in the cloud -
monad-validate
DISCONTINUED. (NOTE: REPOSITORY MOVED TO NEW OWNER: https://github.com/lexi-lambda/monad-validate) A Haskell monad transformer library for data validation -
distributed-process-platform
DEPRECATED (Cloud Haskell Platform) in favor of distributed-process-extras, distributed-process-async, distributed-process-client-server, distributed-process-registry, distributed-process-supervisor, distributed-process-task and distributed-process-execution -
effect-monad
Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects. -
ixmonad
Provides 'graded monads' and 'parameterised monads' to Haskell, enabling fine-grained reasoning about effects.
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of managed or a related project?
README
managed
This library contains the Managed
monad, which is a small building block for
wrapping resources that you acquire in an exception-safe way using a callback.
The Managed
type is really simple::
newtype Managed a = Managed { with :: forall r . (a -> IO r) -> IO r }
... and it's a special case of two other monads:
Managed a = Codensity IO a = forall r . ContT r IO a
The main reason for defining a separate type is to simplify inferred types and
to provide additional type class instances. Also, the Managed
monad has a
less intimidating name so I feel more comfortable using it to teach beginners.
The most useful feature of Managed
is that it automatically lifts the Monoid
and Num
type classes. All Applicative
s can auto-lift these two type classes
and by chaining Applicative
s you can extend types with new functionality while
still preserving their Monoid
and Num
operations.
This type was popularized by the mvc
library, and I received several requests
to split this type out into a small and separate library.
Quick Example
Install stack
and run:
$ stack install managed pipes
Then compile and run the following small program which copies "inFile.txt"
to
"outFile.txt"
:
import Control.Monad.Managed
import System.IO
import Pipes
import qualified Pipes.Prelude as Pipes
main = runManaged $ do
hIn <- managed (withFile "inFile.txt" ReadMode)
hOut <- managed (withFile "outFile.txt" WriteMode)
liftIO $ runEffect $ Pipes.fromHandle hIn >-> Pipes.toHandle hOut
$ stack ghc -- -O2 example.hs
$ cat inFile.txt
ABC
$ ./example
$ cat outFile.txt
ABC
Read the documentation in the Control.Monad.Managed
module to learn more about
how to use the Managed
type.
Development Status
The API is mostly stable. I might add a few utility functions later on that
wrap withXXX
functions from base
in the Managed
monad, but for now I'm
waiting for people to reach a decision on split-base
before adding these.
How to contribute
Use the
Managed
type in your own libraryWrite tutorials explaining how to use this library
License (BSD 3-clause)
Copyright (c) 2014 Gabriel Gonzalez All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of Gabriel Gonzalez nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*Note that all licence references and agreements mentioned in the managed README section above
are relevant to that project's source code only.