Skip to content

Integration with colour library #3

@georgefst

Description

@georgefst

Firstly, thanks! This is a really neat library. I have a draft of the same idea lying around somewhere, but I didn't get far with it. Yours is much better anyway, with the nice error messages, and little things like allowing non-alpha colours to have ff on the end (good because VSCode tends to insert them). I wouldn't have added named colours, or the & type synonym, but I guess neither of those things get in the way.

Anyway, given that Haskell does have a de facto standard colour library, would you consider adding first-class support for it?

The code is as simple as:

instance (IsWebColor s) => IsLabel s (Colour Double) where
    fromLabel = webColor @s \r g b -> sRGB24 r g b
instance (IsWebColorAlpha s) => IsLabel s (AlphaColour Double) where
    fromLabel = webColorAlpha @s \r g b a -> sRGB24 r g b `withOpacity` (fromIntegral a / 255)

And colour has no dependencies of its own beyond base, so it isn't much to take on.

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