Skip to content

RFC for array styles zero-cost method #632

@MoOx

Description

@MoOx

The problem

It's a bit too verbose to write Style.(array([| style1, style2 |])). This solution is nice, especially for zero-cost, but I have found something useful that might be added here.

Considered solution

Tuples are encoded as array by bucklescript. We could leverage this by adding methods similar to this:

external _2: (('a, 'a)) => 'a = "%identity";
external _3: (('a, 'a, 'a)) => 'a = "%identity";
external _4: (('a, 'a, 'a, 'a)) => 'a = "%identity";
external _5: (('a, 'a, 'a, 'a)) => 'a = "%identity";
external _6: (('a, 'a, 'a, 'a, 'a)) => 'a = "%identity";

external _2options: ((option('a), option('a))) => 'a = "%identity";
external _3options: ((option('a), option('a), option('a))) => 'a = "%identity";
external _4options: ((option('a), option('a), option('a), option('a))) => 'a = "%identity";
external _5options: ((option('a), option('a), option('a), option('a))) => 'a = "%identity";
external _6options: ((option('a), option('a), option('a), option('a), option('a))) => 'a = "%identity";

This might help to replace

Style.array([| style1, style2 |])

by

Style._2(style1, style2)

Open to ideas for the naming. I would like to something short since it's the purpose of this new methods :D

Alternatives solutions

More Ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions