The current PureScript generator will generate some cumbresome code:
make = ... -- Meant to both type check and generate, at runtime, the class
m1 :: Tailwind
m1 = "m-1"
m2 :: Tailwind
m2 = "m-2"
-- And so on...
This comes with 2 downsides:
- It's extremely verbose, taking 4 lines per css class, when tailwind generates 25,000 classes, do the math 😄
- As mentioned in the code snippet above, there is a compile validatation, but also some runtime computation, since we need to turn a list of classes into a string
The idea is to use type level checking (close to what https://github.com/kcsongor/purescript-safe-printf achieves):
-- Type level logic
type M1 = SProxy "m-1"
type M2 = SProxy "m-2"
And it could be used as follow:
myClasses = Tailwind.validate (SProxy :: _ "m-1 m-2")
This approach comes with 3 benefits:
- It's shorter
- No runtime cost,
validate will just take the compile time string, and reflect it into the runtime realm
- Can potentially handles some exotic class names
It also comes with 2 drawbacks:
- Less flexible (bye bye Monoid and Foldable goodies)
- It's more verbose on the call side (because of the SProxy value, unfortunately PureScript used to have the following syntax:
@"m-1 m-2" like in Haskell but it got dropped).
I think the change should be opt-in, and we should expose 2 generators: purescript and purescript-typelevel
The current PureScript generator will generate some cumbresome code:
This comes with 2 downsides:
The idea is to use type level checking (close to what https://github.com/kcsongor/purescript-safe-printf achieves):
And it could be used as follow:
This approach comes with 3 benefits:
validatewill just take the compile time string, and reflect it into the runtime realmIt also comes with 2 drawbacks:
@"m-1 m-2"like in Haskell but it got dropped).I think the change should be opt-in, and we should expose 2 generators:
purescriptandpurescript-typelevel