packages feed

monad-interleave 0.1 → 0.2

raw patch · 7 files changed

+150/−60 lines, 7 filesdep ~basesetup-changednew-uploader

Dependency ranges changed: base

Files

+ Changelog.md view
@@ -0,0 +1,5 @@+# 0.2+- Update for latest ghcs while keeping compatibility with GHCs up to 7.0.4++# 0.1+- Initial release
− Control/Monad/Interleave.hs
@@ -1,35 +0,0 @@--------------------------------------------------------------------------------- |--- Module     : Control.Monad.Interleave--- Copyright  : Copyright (c) , Patrick Perry <patperry@stanford.edu>--- License    : BSD3--- Maintainer : Patrick Perry <patperry@stanford.edu>--- Stability  : experimental------ Monads with an unsaveInterleaveIO-like operation.-----module Control.Monad.Interleave (-    MonadInterleave(..),-    ) where--import Control.Monad.ST-import qualified Control.Monad.ST.Lazy as Lazy-import System.IO.Unsafe---- | Monads that have an operation like 'unsafeInterleaveIO'.-class Monad m => MonadInterleave m where-    -- | Get the baton from the monad without doing any computation.-    unsafeInterleave :: m a -> m a--instance MonadInterleave IO where-    unsafeInterleave = unsafeInterleaveIO-    {-# INLINE unsafeInterleave #-}-    -instance MonadInterleave (ST s) where-    unsafeInterleave = unsafeInterleaveST-    {-# INLINE unsafeInterleave #-}-    -instance MonadInterleave (Lazy.ST s) where-    unsafeInterleave = Lazy.unsafeInterleaveST-    {-# INLINE unsafeInterleave #-}
LICENSE view
@@ -1,4 +1,5 @@ Copyright (c) Patrick Perry <patperry@stanford.edu> 2009+Copyright (c) Sergey Vinokurov <serg.foo@gmail.com> 2022  All rights reserved. 
+ Readme.md view
@@ -0,0 +1,3 @@+# Synopsis++MTL-style abstraction over `unsafeInterleaveIO`.
− Setup.lhs
@@ -1,6 +0,0 @@-#!/usr/bin/env runhaskell-> import Distribution.Simple-> import System.Cmd->-> main = defaultMain->
monad-interleave.cabal view
@@ -1,21 +1,100 @@-name:            monad-interleave-version:         0.1-homepage:        http://github.com/patperry/monad-interleave-synopsis:        Monads with an unsaveInterleaveIO-like operation.+cabal-version: 2.2+name:+  monad-interleave+version:+  0.2+synopsis:+  Monads with an unsaveInterleaveIO-like operation. description:-    A type class for monads that have an \"unsafeInterleave\" operation.-    Instances are provided for IO and both strict and lazy ST.-category:        Monads-license:         BSD3-license-file:    LICENSE-copyright:       (c) 2009. Patrick Perry <patperry@stanford.edu>-author:          Patrick Perry-maintainer:      Patrick Perry <patperry@stanford.edu>-cabal-version: >= 1.2.0-build-type:      Custom-tested-with:     GHC ==6.10.1+  A type class for monads that have an \"unsafeInterleave\" operation.+  Instances are provided for IO and both strict and lazy ST.+category:+  Monads+license:+  BSD-3-Clause+license-file:+  LICENSE+copyright:+  (c) 2009. Patrick Perry <patperry@stanford.edu>+  (c) 2022. Sergey Vinokurov <serg.foo@gmail.com>+author:+  Patrick Perry+maintainer:+  Sergey Vinokurov <serg.foo@gmail.com> -library-    exposed-modules: Control.Monad.Interleave-    build-depends:   base-    ghc-options:     -Wall+build-type:+  Simple++tested-with:+  GHC == 7.0.4,+  GHC == 7.2.2,+  GHC == 7.4.2,+  GHC == 7.6.3,+  GHC == 7.8.4,+  GHC == 7.10.3,+  GHC == 8.0.2,+  GHC == 8.2.2,+  GHC == 8.4.4,+  GHC == 8.6.5,+  GHC == 8.8.4,+  GHC == 8.10.7,+  GHC == 9.0.2,+  GHC == 9.2.4,+  GHC == 9.4.2,+  GHC == 9.4.2,+  GHC == 9.4.2++extra-source-files:+  Readme.md+  Changelog.md++homepage:+  https://github.com/sergv/monad-interleave+bug-reports:+  https://github.com/sergv/monad-interleave/issues++source-repository head+  type: git+  location: https://github.com/sergv/monad-interleave.git++common ghc-options+  default-language:+    Haskell2010++  if impl(ghc < 8.0)+    ghc-options:+      -Wall++  if impl(ghc >= 8.0)+    ghc-options:+      -Weverything+      -Wno-all-missed-specialisations+      -Wno-implicit-prelude+      -Wno-missed-specialisations+      -Wno-missing-import-lists+      -Wno-missing-local-signatures+      -Wno-missing-safe-haskell-mode+      -Wno-safe+      -Wno-type-defaults+      -Wno-unsafe++  if impl(ghc >= 8.8)+    ghc-options:+      -Wno-missing-deriving-strategies++  if impl(ghc >= 8.10)+    ghc-options:+      -Wno-prepositive-qualified-module++  if impl(ghc >= 9.2)+    ghc-options:+      -Wno-missing-kind-signatures++library name+  import: ghc-options+  exposed-modules:+    Control.Monad.Interleave+  hs-source-dirs:+    src+  build-depends:+    , base >= 4 && <5
+ src/Control/Monad/Interleave.hs view
@@ -0,0 +1,43 @@+-----------------------------------------------------------------------------+-- |+-- Module     : Control.Monad.Interleave+-- Copyright  : Copyright (c) Patrick Perry <patperry@stanford.edu>, Sergey Vinokurov <serg.foo@gmail.com>+-- License    : BSD3+-- Maintainer : Sergey Vinokurov <serg.foo@gmail.com>+--+-- Monads with an unsaveInterleaveIO-like operation.++{-# LANGUAGE CPP #-}++module Control.Monad.Interleave+  ( MonadInterleave(..)+  ) where++import qualified Control.Monad.ST as Strict (ST)+import qualified Control.Monad.ST.Lazy as Lazy (ST)+import System.IO.Unsafe++#if MIN_VERSION_base(4, 4, 0)+import qualified Control.Monad.ST.Lazy.Unsafe as Lazy (unsafeInterleaveST)+import qualified Control.Monad.ST.Unsafe as Strict (unsafeInterleaveST)+#else+import qualified Control.Monad.ST as Strict (unsafeInterleaveST)+import qualified Control.Monad.ST.Lazy as Lazy (unsafeInterleaveST)+#endif++-- | Monads that have an operation like 'unsafeInterleaveIO'.+class Monad m => MonadInterleave m where+  -- | Get the baton from the monad without doing any computation.+  unsafeInterleave :: m a -> m a++instance MonadInterleave IO where+  {-# INLINE unsafeInterleave #-}+  unsafeInterleave = unsafeInterleaveIO++instance MonadInterleave (Strict.ST s) where+  {-# INLINE unsafeInterleave #-}+  unsafeInterleave = Strict.unsafeInterleaveST++instance MonadInterleave (Lazy.ST s) where+  {-# INLINE unsafeInterleave #-}+  unsafeInterleave = Lazy.unsafeInterleaveST