{-|
Module      : StrictUnit
Description : Strict unit type
Copyright   : (c) Eric Mertens, 2016
License     : ISC
Maintainer  : emertens@gmail.com

This module provides a unit type where the 'Monoid' and 'Semigroup'
instances are strict in their append operations. This is a helper
module for "LensUtils".

-}

module StrictUnit
  ( StrictUnit(..)
  ) where

import           Data.Semigroup (stimes, stimesIdempotent)

-- | Unit data type with a strict 'Semigroup' and 'Monoid' instances.
data StrictUnit = StrictUnit

-- | '<>' is strict, 'stimes' is /O(1)/
instance Semigroup StrictUnit where
  <> :: StrictUnit -> StrictUnit -> StrictUnit
(<>)   = StrictUnit -> StrictUnit -> StrictUnit
seq
  stimes :: b -> StrictUnit -> StrictUnit
stimes = b -> StrictUnit -> StrictUnit
forall b a. Integral b => b -> a -> a
stimesIdempotent

-- | 'mappend' is strict
instance Monoid StrictUnit where
  mempty :: StrictUnit
mempty  = StrictUnit
StrictUnit
  mappend :: StrictUnit -> StrictUnit -> StrictUnit
mappend = StrictUnit -> StrictUnit -> StrictUnit
forall a. Semigroup a => a -> a -> a
(<>)