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 unsafeHas #14

Closed natefaubion closed 7 years ago

paulyoung commented 7 years ago

@natefaubion could you help me understand what makes this "unsafe"?

natefaubion commented 7 years ago

It's unsafe because it violates referential transparency. The type signature says it works forall r. { | r }, but you are able to observe more than that.

natefaubion commented 7 years ago

Maybe referential transparency isn’t the right word? There isn’t a use for this function in safe code since the whole point of records is that you know the fields statically, making this kind of check unnecessary. The only use case for it is if you are making a dynamic assertion about records, which I would consider inherently unsafe. Maybe “disingenuousHas” is a better name? :D

paf31 commented 7 years ago

Thanks!