interruptible.cabal 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. -- Initial interruptible.cabal generated by cabal init. For further
  2. -- documentation, see http://haskell.org/cabal/users-guide/
  3. name: interruptible
  4. version: 0.1.2.0
  5. synopsis: Monad transformers that can be run and resumed later, conserving their context.
  6. description:
  7. This package provides the functionality needed to intercalate the execution of different
  8. transformers, and passing their state around as values for resuming later. Further
  9. explanations for where to use it is available at the sealgram blog:
  10. <https://sealgram.com/blog/interruptible-monad-transformers.html>. The following is about
  11. how to use the package:
  12. .
  13. Given an inner monad @M@ and a transformer @T@, if T is an interruptible transformer,
  14. it becomes possible to intercalate functions over its context with functions over the
  15. inner monad. That is, code like this:
  16. .
  17. > runT (f 1 >>= g)
  18. > where
  19. > f :: Int -> T M a
  20. > g :: a -> T M b
  21. .
  22. Can be broken up like this:
  23. .
  24. > do
  25. > let c0 = inTCtx 1
  26. > resume f c0 >>=
  27. > resume g
  28. .
  29. That makes it possible to intercalate the execution of different contexts, and
  30. treat contexts like data, for iterating or returning them.
  31. .
  32. As shown on the example, interruptible transformers are resumed with the @resume@ function.
  33. State may be managed by specialized functions usually named as @inTransfomerCtx@ and
  34. @peelTransformerCtx@ that enclose a value in an initial context and retrieve the
  35. value from a context.
  36. .
  37. Interruptible transformers can be stacked. On this case, they must be resumed with a
  38. composition of @resume@ calls, and their contexts must be created and peeled on the inverse
  39. order that they appear on the stack. Like:
  40. .
  41. > do
  42. > let c0 = inT2Ctx . inT1Ctx $ 1
  43. > (resume . resume) f c0 >>=
  44. > (resume . resume) g
  45. > where
  46. > f :: Monad m => Int -> T1 T2 M a
  47. > g :: Monad m => a -> T1 T2 M b
  48. .
  49. For convenience, the @Interruptible@ module exports the @resume2@ to @resume5@
  50. functions as composotions of resume. They can be composed further as in
  51. @resume7 = resume3 . resume4@ if necessary.
  52. .
  53. This package also contains the appliable instantiations of Interruptible for the mtl transformers,
  54. the @intercalateWith@ function, that intercalates calls of a function through a list
  55. of contexts and parameters, and the @SafeIO@ module that lifts IOException treatment from the
  56. base monad into the current resumed context.
  57. homepage: https://sealgram.com/git/haskell/interruptible/
  58. license: BSD3
  59. license-file: LICENSE
  60. author: Marcos Dumay de Medeiros
  61. maintainer: marcos@marcosdumay.com
  62. --copyright:
  63. category: Control
  64. build-type: Simple
  65. -- extra-source-files:
  66. cabal-version: >=1.10
  67. source-repository head
  68. type: git
  69. location: https://sealgram.com/git/haskell/interruptible/
  70. branch: master
  71. source-repository this
  72. type: git
  73. location: https://sealgram.com/git/haskell/interruptible/
  74. tag: 0.1.1.1
  75. library
  76. exposed-modules:
  77. Control.Monad.Trans.Interruptible
  78. Control.Monad.Trans.SafeIO
  79. other-modules: Control.Monad.Trans.Interruptible.Class
  80. other-extensions: TypeFamilies
  81. build-depends:
  82. base >=4.7 && <5,
  83. transformers,
  84. monad-control,
  85. lifted-base,
  86. either
  87. hs-source-dirs: src
  88. default-language: Haskell2010
  89. Test-suite all
  90. type: detailed-0.9
  91. test-module: Test
  92. hs-source-dirs:
  93. test
  94. build-depends:
  95. base >=4.7 && <5.0,
  96. Cabal >= 1.9.2,
  97. either,
  98. transformers,
  99. interruptible
  100. ghc-options: -Wall -fno-warn-unused-do-bind -fwarn-incomplete-patterns -threaded
  101. default-language: Haskell2010