Ah that is essentially what we see in elm-css, right?
In that,
-- Css.Structure
type Compatible =
Compatible
is used as a static tag, and functions return records with .value
and many “compatibility” fields. For example px
returns records compatible against .length
, .calc
, .fontSize
and so on. While functions such as fontSize
takes
type alias FontSize compatible =
{ compatible | value : String, fontSize : Compatible }
so that they only take values with .fontSize : Compatible
in them.
I was really amazed by how strong it is to express such kind of compatibility in type-safe manner, with Elm’s type system.