hadronized / quaazar

Realtime 3D engine
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

Effectful streaming #19

Closed hadronized closed 9 years ago

hadronized commented 9 years ago

Introducing effectful streaming

So far, we’ve used a static model. We use SceneRel and Cache (in backends) to implement effects-by-interpreters. That is about to change.

Instead of compiling the whole model into a renderer, we’ll stream model objects to sinks the same way pipes does. That provides a huge flexibility. That is the logical way to go on since our Renderer module, in Core, already embeds such a way of doing.

Implementation details

Manage, Managed and H

H stands for handle. That type is used to represent some objects. No one can build H values except photon itself.

That is done through a typeclass: Manage. This typeclass exports two methods: manage and drop:

class Manage a e where
  manage :: a -> H -> e
  drop :: Managed a -> e

data Managed a = Managed {
    handle  :: H
  , managed :: a
  } deriving (Eq,Show)

class (Monad m) => Effect e m where
  effect :: e -> m ()