# LANGUAGE UndecidableInstances , FlexibleContexts , MultiParamTypeClasses , FlexibleInstances #

-----------------------------------------------------------------------------
-- |
  Module       :   Data . Monoid . Reducer . 
  Copyright    :   ( c )   2009
-- License     :  BSD-style
-- Maintainer  :  
-- Stability   :  experimental
-- Portability :  non-portable (MPTCs)
--
-----------------------------------------------------------------------------

module Data.Monoid.Reducer.Char
    ( module Data.Monoid.Reducer
    , CharReducer
    , invalidChar
    , fromChar
    ) where

import Data.Monoid.Reducer
import Data.Word (Word8)

  | Provides a mechanism for the UTF8 ' Monoid ' to report invalid characters to one or more monoids .

class Reducer Char m => CharReducer m where
    fromChar :: Char -> m 
    fromChar = unit

    invalidChar :: [Word8] -> m
    invalidChar = const mempty

instance (CharReducer m, CharReducer m') =>  CharReducer (m,m') where
    invalidChar bs = (invalidChar bs, invalidChar bs)

instance (CharReducer m, CharReducer m', CharReducer m'') =>  CharReducer (m,m',m'') where
    invalidChar bs = (invalidChar bs, invalidChar bs, invalidChar bs)

instance (CharReducer m, CharReducer m', CharReducer m'', CharReducer m''') =>  CharReducer (m,m',m'',m''') where
    invalidChar bs = (invalidChar bs, invalidChar bs, invalidChar bs, invalidChar bs)

instance CharReducer [Char]

---------------------------------------------------------------------------
 |
 License     :  BSD-style
 Maintainer  :  
 Stability   :  experimental
 Portability :  non-portable (MPTCs)

---------------------------------------------------------------------------
# LANGUAGE UndecidableInstances , FlexibleContexts , MultiParamTypeClasses , FlexibleInstances #

  Module       :   Data . Monoid . Reducer . 
  Copyright    :   ( c )   2009

module Data.Monoid.Reducer.Char
    ( module Data.Monoid.Reducer
    , CharReducer
    , invalidChar
    , fromChar
    ) where

import Data.Monoid.Reducer
import Data.Word (Word8)

  | Provides a mechanism for the UTF8 ' Monoid ' to report invalid characters to one or more monoids .

class Reducer Char m => CharReducer m where
    fromChar :: Char -> m 
    fromChar = unit

    invalidChar :: [Word8] -> m
    invalidChar = const mempty

instance (CharReducer m, CharReducer m') =>  CharReducer (m,m') where
    invalidChar bs = (invalidChar bs, invalidChar bs)

instance (CharReducer m, CharReducer m', CharReducer m'') =>  CharReducer (m,m',m'') where
    invalidChar bs = (invalidChar bs, invalidChar bs, invalidChar bs)

instance (CharReducer m, CharReducer m', CharReducer m'', CharReducer m''') =>  CharReducer (m,m',m'',m''') where
    invalidChar bs = (invalidChar bs, invalidChar bs, invalidChar bs, invalidChar bs)

instance CharReducer [Char]
