Open skabbass1 opened 7 years ago
My experience with contracts mostly comes from the Racket programming language. The Racket Guide has a document describing contracts called Simple Contracts on Functions, which covers most of what we want. There's a few gotchas involved though:
map
with a parametric contract wouldn't be able to insert random elements into the array it's given without violating the contract.zip_with : (a -> b -> c) -> [a] -> [b] -> [c]
function is given arrays of equal length.We might have to roll our own library for this, I've not yet found a python contracts implementation that handles all of the above.
This will be fun to work on!
Currently, there are no checks in place to ensure that functions passed as arguments to pyramda functions conform to a specific contract in terms of signature and return values. For example, the function passed to pyramda's flip function must accept atleast two arguments or the function passed to filter must be a predicate.
Libraries such as sanctuary might provide a good paradigm for implementing such contract checking