S.min ('1') ('02') =>'02'
Why is this even possible? (yes type coercion... but this is Sanctuary) Can Sanctuary be configured so that Nothing is returned when Strings are used? Is there an elegant way to deal with this?
S.min ('1') ('02') =>'02'
Why is this even possible? (yes type coercion... but this is Sanctuary) Can Sanctuary be configured so that Nothing is returned when Strings are used? Is there an elegant way to deal with this?
Let's consider the type of
S.min:Stringsatisfies the requirements of Ord, soString -> String -> Stringis one possible specialization:If you are dealing with inputs that should be numbers but may not be, the best approach is to deal with the uncertainty up front:
Then, you could use
S.lift2to transformS.mininto a function that can operate onMaybe Numbervalues:The signature above can be specialized like so:
The final step is to apply
S.lift2 (S.min)to the trusted inputs:Here is a full working example: