interruptible.cabal 3.4 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.1.1
  5. synopsis: Monad transformers that can be run and resumed later, conserving their context.
  6. description:
  7. Given an inner monad @M@ and a transformer @T@, if T is an interruptible transformer,
  8. it becomes possible to intercalate functions over its context with functions over the
  9. inner monad. That is, code like this:
  10. .
  11. @
  12. runT (f 1 >>= g)
  13. where
  14. f :: Int -> T M a
  15. g :: a -> T M b
  16. @
  17. .
  18. Can be broken up like this:
  19. .
  20. @
  21. do
  22. let c0 = inTCtx 1
  23. c1 <- resume f ct1
  24. _ <- resume g ct2
  25. @
  26. .
  27. That makes it possible to intercalate the execution of different contexts, and
  28. treat contexts like data, for iterating or returning them.
  29. .
  30. As shown on the example, interruptible transformers are resumed with the @resume@ function.
  31. State may be managed by specialized functions usually named as @inTransfomerCtx@ and
  32. @peelTransformerCtx@ that enclose a value in an initial context and retrieve the
  33. value from a context.
  34. .
  35. Interruptible transformers can be stacked. On this case, they must be resumed with a
  36. composition of @resume@ calls, and their contexts must be created and peeled on the inverse
  37. order that they appear on the stack. Like:
  38. .
  39. @
  40. do
  41. let c0 = inT2Ctx . inT1Ctx $ 1
  42. c1 <- (resume . resume) f ct1
  43. _ <- (resume . resume) g ct2
  44. where
  45. f :: Monad m => Int -> T1 T2 M a
  46. g :: Monad m => a -> T1 T2 M b
  47. @
  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