Update base for latest Safe Haskell.
[packages/base.git] / Control / Monad / Group.hs
1 {-# LANGUAGE Trustworthy #-}
2
3 -----------------------------------------------------------------------------
4 -- |
5 -- Module : Control.Monad.Group
6 -- Copyright : (c) Nils Schweinsberg 2011,
7 -- (c) University Tuebingen 2011
8 -- License : BSD-style (see the file libraries/base/LICENSE)
9 -- Maintainer : libraries@haskell.org
10 -- Stability : experimental
11 -- Portability : non-portable
12 --
13 -- Monadic grouping (used for monad comprehensions)
14 --
15 -----------------------------------------------------------------------------
16
17 {-# LANGUAGE CPP, MultiParamTypeClasses, FlexibleInstances #-}
18
19 module Control.Monad.Group where
20
21 import Prelude
22 #if defined(__GLASGOW_HASKELL__)
23 import GHC.Exts (groupWith)
24 #endif
25
26 -- | `MonadGroup` type class without restrictions on the type `t`
27 class Monad m => MonadGroup m t where
28 mgroupWith :: (a -> t) -> m a -> m (m a)
29
30 #if defined(__GLASGOW_HASKELL__)
31 -- | Grouping instance for lists using the `groupWith` function from the
32 -- "GHC.Exts" library
33 instance Ord t => MonadGroup [] t where
34 mgroupWith = groupWith
35 #endif
36