[grapefruit] Sampling the record of signals

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Tue Apr 28 11:56:06 EDT 2009


Am Freitag, 24. April 2009 23:25 schrieb Roman Cheplyaka:
> I had the problem that I had to cast HomSignalStyle to SignalStyle and
> didn't know if it's prossible.

Casting a record of one specific signal style into a record of another style 
is not directly supported. However, you can build a HomSignalStyle record or 
FunctorStyle record in the first place instead of first building a 
SignalStyle record and then converting this.

If you just write a record expression where all values are of the same signal 
type (CSignal, SSignal, …) with the same era, the type of this record 
expression is polymorphic and covers both SignalStyle and FunctorStyle. For 
example, the type of

    X :& () := DSignal.empty :& () := DSignal.empty

is

    (DSignal era () ~ Value style sort1, DSignal era () ~ Value style sort2)
    => (X :& () ::: sort1 :& () ::: sort2) style

This can be specialized to

    (X :& () ::: DSignal `Of` () :& () ::: DSignal `Of` ()) (SignalStyle era)

and also to

    (X :& () ::: () :& () ::: ()) (FunctorStyle (DSignal era))

Best wishes,
Wolfgang



More information about the Grapefruit mailing list