unisonweb / base_v1

Unison base libraries, published using V1 codebase format
24 stars 14 forks source link

Add common combinators on functions. #29

Closed runarorama closed 4 years ago

runarorama commented 4 years ago

Adds a number of higher-order combinators on functions:

Includes example use cases in docs.

Code review

The changes summarized below are available for you to review, using the following command:

pull-request.load https://github.com/unisonweb/base:.trunk.Function https://github.com/runarorama/mybase:.curry.Function

Added definitions:

The changes summarized below are available for you to review, using the following command:

pull-request.load https://github.com/unisonweb/base:.trunk.Function https://github.com/runarorama/mybase:.curry.Function

Added definitions:

 curry                                    : ((a, b) ->{e} c) -> a -> b ->{e} c (+3 metadata)
 curry.doc                                : Doc (+2 metadata)
 fix                                      : ('{e} a ->{e} a) ->{e} a (+3 metadata)
 fix.doc                                  : Doc (+2 metadata)
 fix.examples.factorial.explicitRecursion : Nat (+2 metadata)
 fix.examples.factorial.fixpoint          : Nat (+2 metadata)
 flip                                     : (a ->{e} b ->{e} c) -> b -> a ->{e} c (+3 metadata)
 flip.doc                                 : Doc (+2 metadata)
 on                                       : (b ->{e} b ->{e} c)
                                          -> (a ->{e} b)
                                          -> a
                                          -> a
                                          ->{e} c (+3 metadata)
 on.doc                                   : Doc (+2 metadata)
 on.examples.equalOn                      : Boolean (+2 metadata)
 uncurry                                  : (a ->{e} b ->{e} c) -> (a, b) ->{e} c (+3 metadata)
 uncurry.doc                              : Doc (+2 metadata)
anovstrup commented 4 years ago

Cool to see fix in Unison! (I tried to figure it out back in November, and I think I gave up.)

Minor: the names of the fix examples should replace "fib" with "fac" or "factorial" (both examples compute 7! rather than a Fibonacci value).

runarorama commented 4 years ago

@anovstrup Thanks for the correction! Updated with a fix, as it were.

pchiusano commented 4 years ago

@runarorama great!

@aryairani would you like to take a crack at reviewing and merging this one? It LGTM, I don’t even have any bikeshedding comments.

pchiusano commented 4 years ago

Great, merged in Unison hash: #paot3nh9k1