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
module FoldyList where | |
data FoldyList a = | |
FoldyCons (FoldyHead a) (FoldyTail a) | |
type FoldyHead a = (a -> a -> a) | |
type FoldyTail a = [a] | |
instance Show q => Show (FoldyList q) where | |
show (FoldyCons x y) = show $ foldr1 x y | |
flist :: FoldyList Int | |
flist = FoldyCons (+) [3,4,5] | |
main = print flist |
I wouldn't call it FoldyCons, as that appears to be confusing. You're not really Cons'ing, so much as applying.
ReplyDeleteMaybe, FoldyBuild?
Hmm... how is FoldyCons (+) [3,4,5] better than just writing foldr1 (+) [3,4,5] in the first place?
ReplyDelete