evilsoft / crocks

A collection of well known Algebraic Data Types for your utter enjoyment.
https://crocks.dev
ISC License
1.59k stars 102 forks source link

Correct getPropOr type annotation #492

Closed jakubbarczyk closed 4 years ago

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 9c809c4e5210e7c07b80e251225a1021f8c32f73 on jakubbarczyk:patch-1 into 3a9d5651da12065bc83d7bbc471e8702229ad03d on evilsoft:master.

dalefrancis88 commented 4 years ago

I know we discussed this on gitter, but actually i'm wondering if getPathOr has the wrong sig a -> (String | Integer) -> b -> a i think is that way because the first param is a default value for the property, b is the object you pulling from and then the final value is the value of that property or the default so an argument could be made that the default and the value are from the same set a, correct?

With getPathOr having a sig of a -> [ (String | Integer) ] -> b -> c really the only way for that to work would be that if a was considered always subset of c

What are your thoughts @evilsoft?

evilsoft commented 4 years ago

With getPathOr having a sig of a -> [ (String | Integer) ] -> b -> c really the only way for that to work would be that if a was considered always subset of c

That is :100: correct, getPathOr is the faulty siggy here. For exactly the reasons you specified! Good :eyes: !