-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | The Observer pattern
--
-- This is a simple Haskell implementation of the Observer pattern,
-- specified as a typeclass with one example instance (demonstrating
-- synchronous notifications). It is based on Observable.hs by Bastiaan
-- Heeren, originally from
-- http://www.cs.uu.nl/wiki/bin/view/Afp0607/ExerciseWXHaskell
@package simple-observer
@version 0.0.1
-- | An implementation of the Observer pattern, based on Observable.hs by
-- Bastiaan Heeren, originally from
-- http://www.cs.uu.nl/wiki/bin/view/Afp0607/ExerciseWXHaskell
--
-- This module defines the Subject typeclass, specifying the
-- capabilities of an observable value. See other modules in the package
-- for example implementations of this typeclass.
module Control.Observer
-- | A type class for observable objects. A minimal implementation
-- implements all of these functions.
class Subject sub val | sub -> val
getValue :: Subject sub val => sub -> IO val
setValue' :: Subject sub val => sub -> val -> IO ()
addObserver :: Subject sub val => sub -> (val -> IO ()) -> IO ()
getObservers :: Subject sub val => sub -> IO [val -> IO ()]
-- | Update the subject value, and notify observers.
setValue :: Subject sub val => sub -> val -> IO ()
-- | Notify observers that the subject's value has changed. Rarely called
-- explicitly: usually called via setValue.
notifyObservers :: Subject sub val => sub -> IO ()
-- | Apply an update function to the subject value, and notify observers.
changeValue :: Subject sub val => sub -> (val -> val) -> IO ()
-- | Add an observer which doesn't care about the subject's value, only
-- that it's changed.
addConstObserver :: Subject sub val => sub -> IO () -> IO ()
-- | A synchronous implementation of the Subject typeclass, , based
-- on Observable.hs by Bastiaan Heeren, originally from
-- http://www.cs.uu.nl/wiki/bin/view/Afp0607/ExerciseWXHaskell
--
-- The Subject implementation defined in this module uses
-- MVars to provide a simple and threadsafe synchronous
-- implementation of the Observer design pattern.
--
-- Note that no constructor for Sub is exported: client code must
-- use the createSub smart constructor.
module Control.Observer.Synchronous
-- | Threadsafe synchronous Subject implementation.
data Sub a
-- | Smart constructor for Sub.
createSub :: a -> IO (Sub a)
instance Subject (Sub a) a