1 -----------------------------------------------------------------------------
3 -- Module : Control.Monad.Group
4 -- Copyright : (c) Nils Schweinsberg 2011,
5 -- (c) University Tuebingen 2011
6 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
11 -- Monadic grouping (used for monad comprehensions)
13 -----------------------------------------------------------------------------
15 {-# LANGUAGE CPP, MultiParamTypeClasses, FlexibleInstances #-}
17 module Control.Monad.Group where
20 #if defined(__GLASGOW_HASKELL__)
21 import GHC.Exts (groupWith)
24 -- | `MonadGroup` type class without restrictions on the type `t`
25 class Monad m => MonadGroup m t where
26 mgroupWith :: (a -> t) -> m a -> m (m a)
28 #if defined(__GLASGOW_HASKELL__)
29 -- | Grouping instance for lists using the `groupWith` function from the
31 instance Ord t => MonadGroup [] t where
32 mgroupWith = groupWith