{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}

-- | This module provides the 'Propagator' class
module Data.Propagator.Class where

import Control.Exception

-- | The Propagator class defines some functions shared by different propagator
-- implementations. This backs the generic "Data.Propagator.Purify" wrapper.
class Propagator p x | p -> x where
    newProp :: IO p
    newConstProp :: x -> IO p
    freezeProp :: p -> IO ()
    readProp :: p -> IO x

-- | Exception thrown by a propagator when attempting to change the value of a frozen propagator
data WriteToFrozenPropagatorException = WriteToFrozenPropagatorException
   deriving Int -> WriteToFrozenPropagatorException -> ShowS
[WriteToFrozenPropagatorException] -> ShowS
WriteToFrozenPropagatorException -> String
(Int -> WriteToFrozenPropagatorException -> ShowS)
-> (WriteToFrozenPropagatorException -> String)
-> ([WriteToFrozenPropagatorException] -> ShowS)
-> Show WriteToFrozenPropagatorException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WriteToFrozenPropagatorException] -> ShowS
$cshowList :: [WriteToFrozenPropagatorException] -> ShowS
show :: WriteToFrozenPropagatorException -> String
$cshow :: WriteToFrozenPropagatorException -> String
showsPrec :: Int -> WriteToFrozenPropagatorException -> ShowS
$cshowsPrec :: Int -> WriteToFrozenPropagatorException -> ShowS
Show
instance Exception WriteToFrozenPropagatorException