{-# LANGUAGE CPP #-}
module Algebra.Heyting.BoolRing
( BoolRing (..)
, Semiring (..)
, (<+>)
) where
import Prelude hiding (not)
import Data.Monoid (Monoid (..))
#if __GLASGOW_HASKELL__ < 804
import Data.Semigroup (Semigroup (..))
#endif
import Algebra.Lattice (bottom, top, (/\), (\/))
import Data.Semiring (Semiring (..), (<+>))
import Algebra.Heyting
newtype BoolRing a = BoolRing { getBoolRing :: a }
instance HeytingAlgebra a => Semigroup (BoolRing a) where
(BoolRing a) <> (BoolRing b) = BoolRing $ (not a /\ b) \/ (a /\ not b)
instance HeytingAlgebra a => Monoid (BoolRing a) where
mempty = BoolRing bottom
#if __GLASGOW_HASKELL__ <= 804
mappend = (<>)
#endif
instance HeytingAlgebra a => Semiring (BoolRing a) where
BoolRing a <.> BoolRing b = BoolRing (a \/ b)
one = BoolRing top