sanctuary-js / sanctuary-type-classes

:rainbow: Standard library for Fantasy Land
MIT License
233 stars 21 forks source link

Defining instances for "native" JS values (that are not Fantasy-Land compatible) #110

Open masaeedu opened 5 years ago

masaeedu commented 5 years ago

It would be nice to be able to access the same facilities Sanctuary uses to define instances for types like Array, StrMap, etc. to define instances for even more "unwrapped" values, with type membership dictated by user-specifiable predicates.

I think this might eventually boil down to the same feature as "implement static land support", but there might be other ways to accomplish this.

davidchambers commented 5 years ago

I love this proposal. Could you provide a rough idea of how it might work in practice?

masaeedu commented 5 years ago

I'll put a longer response here when I have a bit of time, but unfortunately the answer so far is that I don't actually know. I've been reading a lot about various implementations of typeclass-ish things that allow for implementations to be grafted onto existing data, but there's various tradeoffs, and most of them seem to rely on information that isn't easy to obtain without static analysis.