At the moment concepts are represented by a concrete datatype:
-- Abstract concepts
-- * s is the type of states
-- * e is the type of events
data Concept s e = Concept
{
initial :: s -> Bool,
excited :: e -> s -> Bool,
invariant :: s -> Bool
}
This is later used to define circuit concepts:
-- Circuit primitives
-- Parameter a stands for the alphabet of signals
newtype State a = State (a -> Bool)
data Transition a = Transition
{
signal :: a,
newValue :: Bool -- Transition x True corresponds to x+
}
type CircuitConcept a = Concept (State a) (Transition a)
Although this works relatively well now, it is not very flexible. In particular, expressions that combine concepts together cannot be interpreted in different contexts. Consider the following example:
buffer :: Eq a => a -> a -> CircuitConcept a
buffer a b = rise a ~> rise b <> fall a ~> fall b
cElement :: Eq a => a -> a -> a -> CircuitConcept a
cElement a b c = buffer a c <> buffer b c
Given data Signal = X | Y | Z, we can only interpret cElement X Y Z as an expression of type CircuitConcept Signal, which is basically a state graph represented by a collection of Boolean functions.
This is not the only interpretation of interest. In particular, we might want to interpret cElement X Y Z as a compact description of an STG, which could be stored in a .g file for processing by standard tools like petrify or workcraft.
This brings up the following problem: how do we redesign concepts in such a way that cElement and other expressions become polymorphic and the following two interpretations become possible:
deriveFSM :: CircuitConcept c => c a -> FSM a
deriveSTG :: CircuitConcept c => c a -> STG a
The first one should be equivalent to the current interpretation, but the second one should produce an STG datatype instead. The implementation of both of these functions could in fact be as simple as id. Actual work will be done behind the scenes by magic Haskell type inference.
At the moment concepts are represented by a concrete datatype:
This is later used to define circuit concepts:
Although this works relatively well now, it is not very flexible. In particular, expressions that combine concepts together cannot be interpreted in different contexts. Consider the following example:
Given
data Signal = X | Y | Z, we can only interpretcElement X Y Zas an expression of typeCircuitConcept Signal, which is basically a state graph represented by a collection of Boolean functions.This is not the only interpretation of interest. In particular, we might want to interpret
cElement X Y Zas a compact description of an STG, which could be stored in a.gfile for processing by standard tools likepetrifyorworkcraft.This brings up the following problem: how do we redesign concepts in such a way that
cElementand other expressions become polymorphic and the following two interpretations become possible:The first one should be equivalent to the current interpretation, but the second one should produce an STG datatype instead. The implementation of both of these functions could in fact be as simple as
id. Actual work will be done behind the scenes by magic Haskell type inference.