Created
July 25, 2021 18:08
-
-
Save guibou/e05e42314f8e749e64aea8aa97bdd9fc to your computer and use it in GitHub Desktop.
`foldLR` automatically uses `foldl` or `foldr` depending on the folding function.
This file contains hidden or 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
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE FunctionalDependencies #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| class Fold f t acc | f -> t acc where | |
| foldLR :: Foldable foldable => f -> acc -> foldable t -> acc | |
| instance Fold (t -> acc -> acc) t acc where | |
| foldLR = foldr | |
| instance Fold (acc -> t -> acc) t acc where | |
| foldLR = foldl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment