-
-
Save rightfold/bde32a98f424b661da35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you could say | |
> ordBy :: Eq a => (a -> a -> Ordering) -> instance Ord a | |
> ordBy f = instance Ord a where compare = f | |
and then something like | |
> sort #(ordBy blabla) xs | |
then you don't need `sortBy` anymore! | |
You could even have two instances `Monoid Int`! | |
> sumInt :: instance Monoid Int | |
> sumInt = instance Monoid Int where | |
> mempty = 0 | |
> mappend = (+) | |
> | |
> productInt :: instance Monoid Int | |
> productInt = instance Monoid Int where | |
> mempty = 1 | |
> mappend = (*) | |
> | |
> sum = mconcat #sumInt | |
> product = mconcat #productInt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment