Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Handling h where
- Handling :: {..} -> Handling h
- Uninitialized :: Handling h
- type Destructors m = IntMap (Destructor m)
- data HandlingState m = HandlingState {
- nHandles :: Key
- destructors :: Destructors m
- type HandlingStateT m = StateT (HandlingState m) m
- initHandlingState :: HandlingState m
- runHandlingStateT :: Monad m => HandlingStateT m a -> m a
- runHandlingStateC :: forall m a b. (Monad m, Typeable m) => Cell (HandlingStateT m) a b -> Cell m a b
- runHandlingState :: (Monad m, Typeable m) => LiveProgram (HandlingStateT m) -> LiveProgram m
- garbageCollected :: Monad m => HandlingStateT m a -> HandlingStateT m a
- data Destructor m = Destructor {
- isRegistered :: Bool
- action :: m ()
- register :: Monad m => m () -> HandlingStateT m Key
- reregister :: Monad m => m () -> Key -> HandlingStateT m ()
- insertDestructor :: m () -> Key -> Destructors m -> Destructors m
- unregisterAll :: Monad m => HandlingStateT m ()
- destroyUnregistered :: Monad m => HandlingStateT m ()
- dataTypeHandling :: DataType
- handlingConstr :: Constr
- uninitializedConstr :: Constr
- dataTypeDestructor :: DataType
- destructorConstr :: Constr
Documentation
data Handling h where Source #
Instances
Typeable h => Data (Handling h) Source # | |
Defined in LiveCoding.HandlingState gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Handling h -> c (Handling h) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Handling h) # toConstr :: Handling h -> Constr # dataTypeOf :: Handling h -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Handling h)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Handling h)) # gmapT :: (forall b. Data b => b -> b) -> Handling h -> Handling h # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Handling h -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Handling h -> r # gmapQ :: (forall d. Data d => d -> u) -> Handling h -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Handling h -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Handling h -> m (Handling h) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Handling h -> m (Handling h) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Handling h -> m (Handling h) # |
type Destructors m = IntMap (Destructor m) Source #
data HandlingState m Source #
Hold a map of registered handle keys and destructors
HandlingState | |
|
Instances
Typeable m => Data (HandlingState m) Source # | |
Defined in LiveCoding.HandlingState gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> HandlingState m -> c (HandlingState m) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (HandlingState m) # toConstr :: HandlingState m -> Constr # dataTypeOf :: HandlingState m -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (HandlingState m)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (HandlingState m)) # gmapT :: (forall b. Data b => b -> b) -> HandlingState m -> HandlingState m # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> HandlingState m -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> HandlingState m -> r # gmapQ :: (forall d. Data d => d -> u) -> HandlingState m -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> HandlingState m -> u # gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> HandlingState m -> m0 (HandlingState m) # gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> HandlingState m -> m0 (HandlingState m) # gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> HandlingState m -> m0 (HandlingState m) # | |
(Typeable m, Launchable m) => Launchable (HandlingStateT m) Source # | |
Defined in LiveCoding.RuntimeIO.Launch runIO :: LiveProgram (HandlingStateT m) -> LiveProgram IO Source # |
type HandlingStateT m = StateT (HandlingState m) m Source #
In this monad, handles can be registered, and their destructors automatically executed. It is basically a monad in which handles are automatically garbage collected.
runHandlingStateT :: Monad m => HandlingStateT m a -> m a Source #
Handle the HandlingStateT
effect _without_ garbage collection.
Apply this to your main loop after calling foreground
.
Since there is no garbage collection, don't use this function for live coding.
runHandlingStateC :: forall m a b. (Monad m, Typeable m) => Cell (HandlingStateT m) a b -> Cell m a b Source #
Apply this to your main live cell before passing it to the runtime.
On the first tick, it initialises the HandlingState
at "no handles".
On every step, it does:
- Unregister all handles
- Register currently present handles
- Destroy all still unregistered handles (i.e. those that were removed in the last tick)
runHandlingState :: (Monad m, Typeable m) => LiveProgram (HandlingStateT m) -> LiveProgram m Source #
Like runHandlingStateC
, but for whole live programs.
garbageCollected :: Monad m => HandlingStateT m a -> HandlingStateT m a Source #
data Destructor m Source #
Destructor | |
|
Instances
Typeable m => Data (Destructor m) Source # | |
Defined in LiveCoding.HandlingState gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Destructor m -> c (Destructor m) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Destructor m) # toConstr :: Destructor m -> Constr # dataTypeOf :: Destructor m -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Destructor m)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Destructor m)) # gmapT :: (forall b. Data b => b -> b) -> Destructor m -> Destructor m # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Destructor m -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Destructor m -> r # gmapQ :: (forall d. Data d => d -> u) -> Destructor m -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Destructor m -> u # gmapM :: Monad m0 => (forall d. Data d => d -> m0 d) -> Destructor m -> m0 (Destructor m) # gmapMp :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> Destructor m -> m0 (Destructor m) # gmapMo :: MonadPlus m0 => (forall d. Data d => d -> m0 d) -> Destructor m -> m0 (Destructor m) # |
reregister :: Monad m => m () -> Key -> HandlingStateT m () Source #
insertDestructor :: m () -> Key -> Destructors m -> Destructors m Source #
unregisterAll :: Monad m => HandlingStateT m () Source #
destroyUnregistered :: Monad m => HandlingStateT m () Source #