packages feed

fail (empty) → 4.9.0.0

raw patch · 4 files changed

+144/−0 lines, 4 filesdep +basesetup-changed

Dependencies added: base

Files

+ Control/Monad/Fail.hs view
@@ -0,0 +1,84 @@+-- |+-- Module      :  Control.Monad.Fail+-- Copyright   :  (C) 2015 David Luposchainsky,+--                (C) 2015 Herbert Valerio Riedel+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  libraries@haskell.org+-- Stability   :  provisional+-- Portability :  portable+--+-- Transitional module providing the 'MonadFail' class and primitive+-- instances.+--+-- This module can be imported for defining forward compatible+-- 'MonadFail' instances:+--+-- @+-- import qualified Control.Monad.Fail as Fail+--+-- instance Monad Foo where+--   (>>=) = {- ...bind impl... -}+--+--   -- Provide legacy 'fail' implementation for when+--   -- new-style MonadFail desugaring is not enabled.+--   fail = Fail.fail+--+-- instance Fail.MonadFail Foo where+--   fail = {- ...fail implementation... -}+-- @+--+-- See <https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail>+-- for more details.+--+-- @since 4.9.0.0+--+module Control.Monad.Fail ( MonadFail(fail) ) where++import qualified Prelude as P+import Prelude hiding (fail)++import Text.ParserCombinators.ReadP+import Text.ParserCombinators.ReadPrec++-- | When a value is bound in @do@-notation, the pattern on the left+-- hand side of @<-@ might not match. In this case, this class+-- provides a function to recover.+--+-- A 'Monad' without a 'MonadFail' instance may only be used in conjunction+-- with pattern that always match, such as newtypes, tuples, data types with+-- only a single data constructor, and irrefutable patterns (@~pat@).+--+-- Instances of 'MonadFail' should satisfy the following law: @fail s@ should+-- be a left zero for '>>=',+--+-- @+-- fail s >>= f  =  fail s+-- @+--+-- If your 'Monad' is also 'MonadPlus', a popular definition is+--+-- @+-- fail _ = mzero+-- @+--+-- @since 4.9.0.0+class Monad m => MonadFail m where+    fail :: String -> m a++-- instances provided by base-4.9++instance MonadFail Maybe where+    fail _ = Nothing++instance MonadFail [] where+    fail _ = []++instance MonadFail IO where+    fail = P.fail++instance MonadFail ReadPrec where+    fail = P.fail -- = P (\_ -> fail s)++instance MonadFail ReadP where+    fail = P.fail
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, David Luposchainsky & Herbert Valerio Riedel++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 Herbert Valerio Riedel 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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ fail.cabal view
@@ -0,0 +1,28 @@+name:                fail+version:             4.9.0.0+synopsis:            Forward-compatible MonadFail class+homepage:            https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail+license:             BSD3+license-file:        LICENSE+author:              Herbert Valerio Riedel+maintainer:          libraries@haskell.org+category:            Development+build-type:          Simple+cabal-version:       >=1.10+description:+  This package contains the "Control.Monad.Fail" module providing the+  <https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail MonadFail>+  class that became available in+  <https://hackage.haskell.org/package/base-4.9.0.0 base-4.9.0.0>+  for older @base@ package versions.+  .+  This package turns into an empty package when used with GHC versions+  which already provide the "Control.Monad.Fail" module to make way for+  GHC's own "Control.Monad.Fail" module.++library+  default-language: Haskell2010++  if !impl(ghc >= 8.0)+    exposed-modules: Control.Monad.Fail+    build-depends:   base >=4.3 && <4.9