Control.Monad.Fail

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
Safe Haskell Trustworthy
Language Haskell2010

Description

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

class Monad m => MonadFail m where Source

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

Minimal complete definition

fail

Methods

fail :: String -> m a Source

Instances

MonadFail []

Methods

fail :: String -> [a] Source

MonadFail Maybe

Methods

fail :: String -> Maybe a Source

MonadFail IO

Methods

fail :: String -> IO a Source

MonadFail ReadP

Methods

fail :: String -> ReadP a Source

MonadFail ReadPrec

Methods

fail :: String -> ReadPrec a Source

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.0.1/docs/html/libraries/base-4.9.0.0/Control-Monad-Fail.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部