purescript / purescript-record

Functions for working with records and polymorphic labels
BSD 3-Clause "New" or "Revised" License
70 stars 31 forks source link

Add an `unsafeHas` function #13

Closed natefaubion closed 7 years ago

natefaubion commented 7 years ago

I know this is a somewhat dubious request :P but I'd like an unsafeHas function. I would like to add something to purescript-variant for partial matching with a record (right now it must always be total). It's possible for me to do this by contracting the variant first, which essentially does the "has" check for me, but it requires me to build a List of IsSymbol constraints on every invocation, and then walk the list to see if the variant tag is within bounds. However, if I have a record of case eliminators, then I could just use an unsafeHas function to do the dynamic lookup instead, which wouldn't require any IsSymbol constraints.

paf31 commented 7 years ago

I'd be fine with adding it.