HSFFIG.FieldAccess
Documentation
class FieldAccess a b c | a c -> b whereSource
A multi-parameter class with functional dependencies is declared to enable access
to structures/unions members. The functional dependencies a b c | a c -> b specify
that type of b (type of the member) depends entirely on the types a (phantom type
identifying structure/union) and c (phantom type identifying the member, a.k.a. member
selector), and there may be only one type of b for every possible combination of a and c.
Indeed:
struct a {
int x;
};
struct b {
float x;
};
both structures contain a member with the same name, but different types.
HSFFIG will generate the following instances for the structures above:
instance HSFFIG.FieldAccess.FieldAccess S_a ((CInt)) V_x where z --> V_x = (#peek __quote__(struct a), x) z (z, V_x) <-- v = (#poke __quote__(struct a), x) z v ... instance HSFFIG.FieldAccess.FieldAccess S_b ((CFloat)) V_x where z --> V_x = (#peek __quote__(struct b), x) z (z, V_x) <-- v = (#poke __quote__(struct b), x) z v
That is, when the member identified by selector V_x is fetched from
struct a (S_a), an integer value is returned. But when the member with
the same name is retrieved from struct b, a float value is returned.
Methods
Arguments
| :: Ptr a | |
| -> c | |
| -> b | retrieves a function reference from a member of structure |