Nick Smith
12/06/2020, 6:46 AMEmmanuel Oga
12/06/2020, 7:32 AMEmmanuel Oga
12/06/2020, 7:32 AMEmmanuel Oga
12/06/2020, 7:35 AMPhilipp Krüger
12/06/2020, 8:59 AMNick Smith
12/06/2020, 9:17 AMNick Smith
12/06/2020, 9:48 AMWill
12/06/2020, 5:54 PMNick Smith
12/06/2020, 10:26 PMNick Smith
12/06/2020, 10:30 PMAndrew F
12/07/2020, 5:57 AMset-size(my_set)
, where set-size
is implemented by dynamic dispatch on its argument.
This also reminds me of the idea of records as (dependently typed) functions from a key type to whatever thing the struct was constructed with (or updated with? Hmm).wtaysom
12/07/2020, 7:37 AMNick Smith
12/07/2020, 8:11 AMwtaysom
12/07/2020, 8:29 AMa -> Maybe b
, generally.
I guess a potential important difference can be whether you want to model order. For instance, Rubyist that I am, the keys in a Hash
are ordered and I use this all the time. In another context, you may not want to keep that information around.
Another thought that I had while trying to remember the pattern calculus is why prefer a composition operator like this
<+> :: (a -> Maybe b) -> (a -> Maybe b) -> (a -> Maybe b)
(f <+> g) x = f x `orElse` g x
over something that collects all the results:
<*> :: (a -> [b]) -> (a -> [b]) -> (a -> [b])
(f <*> g) x = f x ++ g x
And so on.wtaysom
12/07/2020, 8:30 AMNick Smith
12/07/2020, 8:33 AMNick Smith
12/07/2020, 8:35 AM