3 ms·
edit: misread the parent as saying the opposite of what it actually meant > The Haskellite approach would also say that "what operations are available on that
by uryga 7y ago
edit: misread the parent as saying the opposite of what it actually meant
> The Haskellite approach would also say that "what operations are available on that thing" is the wrong way round; you define your operation, and the type signature tells you what kind of things will work with it.
i'm not sure if i understand. using typeclasses i can define a Haskell function for summing collections:
sum :: (Foldable f, Monoid a) => f a -> a
sum x = foldr (<>) mempty x
and it'll work for any Foldable collection (supporting `reduce`) of Monoidal values (supporting "addition", or the `<>` operator) - lists of strings, trees of ints, etc. that sounds a lot like "define your operation, and the type signature tells you what kind of things will work with it"
- pjc50 7y agoYes, that's what I meant. This is very different from having to extend Foldable to achieve the same thing.
- uryga 7y agoah sorry, i was skimming and misread your comment as > The Haskellite approach that says "what operations are available on that thing" is the wrong way round which left me pretty confused!