-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Provides a nice API for rendering data types that change -- over time. -- -- Instances of Renderable conform to a simple API that makes their -- visual representations composable through hashing and cacheing. Also -- provided are some convenience functions for writing Renderable -- instances. Not provided are actual rendering functions. @package renderable @version 0.1.0.0 module Data.Renderable -- | A Primitive is the smallest thing can can be rendered in your -- graphics system. Some examples are points, lines, triangles and other -- shapes. class Primitive a where { type family PrimM a :: * -> *; type family PrimT a :: *; type family PrimR a :: *; } -- | Allocate resources for rendering the primitive and return a monadic -- call that renders the primitive using a transform. Tuple that with a -- call to clean up the allocated resources. compilePrimitive :: (Primitive a, Monad (PrimM a)) => PrimR a -> a -> (PrimM a) (Rendering (PrimM a) (PrimT a)) -- | Element is an existential type that can be used to enclose instances -- of Primitive in order to contain them all in a heterogeneous list. -- m, r and t must be shared with all -- Primitive instances stored in the heterogeneous list of Elements. data Element m r t Element :: a -> Element m r t -- | A Composite is a type that can be broken down into a list of -- transformed primitives. class Composite a m r t -- | Break down a Composite into a heterogeneous list of transformed -- primitives. composite :: Composite a m r t => a -> [(t, Element m r t)] -- | A rendering is a type that contains some effectful computation for -- displaying something given a transform. It also contains an effectful -- computation for cleaning up any resources allocated during its -- creation. type Rendering m t = (m (), t -> m ()) -- | A cache of renderings. type Cache m t = IntMap (Rendering m t) -- | Render a datatype using renderings stored in the given cache, return a -- new cache that can be used to render the next datatype. renderData :: (Composite a m r t, Hashable a, Monad m, Monoid t) => r -> Cache m t -> a -> m (Cache m t) instance Data.Hashable.Class.Hashable (Data.Renderable.Element m r t) instance GHC.Classes.Eq (Data.Renderable.Element m r t) instance GHC.Base.Monad m => GHC.Base.Monoid (Data.Renderable.Rendering m t) instance GHC.Base.Monoid t => Data.Renderable.Composite (Data.Renderable.Element m r t) m r t instance (GHC.Base.Monoid t, Data.Renderable.Composite a m r t) => Data.Renderable.Composite (t, a) m r t instance Data.Renderable.Composite a m r t => Data.Renderable.Composite (GHC.Base.Maybe a) m r t instance Data.Renderable.Composite a m r t => Data.Renderable.Composite [a] m r t