-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Adapt to MonadFail-related changes in base-4.13
`base-4.13` removes the `fail` method from the `Monad` class, leaving it exclusively as a method of `MonadFail`, which is now re-exported from the `Prelude`. This patch mirrors these changes on the `singletons` side: * `Fail`/`sFail` has been ripped out of `{P,S}Monad` in favor of new `{P,S}MonadFail` classes. * A couple of functions in `singletons` needed to have their `Monad` constraints strengthened to `MonadFail` to mirror similar changes in `th-desugar`. Addresses one bullet point of #356. [ci skip]
- Loading branch information
1 parent
16f2970
commit 90fd5cd
Showing
13 changed files
with
103 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE InstanceSigs #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Singletons.Prelude.Monad.Fail | ||
-- Copyright : (C) 2019 Ryan Scott | ||
-- License : BSD-style (see LICENSE) | ||
-- Maintainer : Ryan Scott | ||
-- Stability : experimental | ||
-- Portability : non-portable | ||
-- | ||
-- Defines the promoted and singled versions of the 'MonadFail' type class. | ||
-- | ||
---------------------------------------------------------------------------- | ||
|
||
module Data.Singletons.Prelude.Monad.Fail ( | ||
PMonadFail(..), SMonadFail(..), | ||
|
||
-- * Defunctionalization symbols | ||
FailSym0, FailSym1 | ||
) where | ||
|
||
import Data.Kind | ||
import Data.Singletons.Prelude.Instances | ||
import Data.Singletons.Prelude.Monad.Internal | ||
import Data.Singletons.Single | ||
|
||
$(singletonsOnly [d| | ||
-- -| 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 'Control.Monad.>>=', | ||
-- | ||
-- @ | ||
-- fail s >>= f = fail s | ||
-- @ | ||
-- | ||
-- If your 'Monad' is also 'Control.Monad.MonadPlus', a popular definition is | ||
-- | ||
-- @ | ||
-- fail _ = mzero | ||
-- @ | ||
-- | ||
-- @since 4.9.0.0 | ||
class Monad m => MonadFail (m :: Type -> Type) where | ||
fail :: String -> m a | ||
|
||
instance MonadFail Maybe where | ||
fail _ = Nothing | ||
|
||
instance MonadFail [] where | ||
fail _ = [] | ||
|]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters