Skip to content
Newer
Older
100644 20 lines (12 sloc) 568 Bytes
681336e @batterseapower Initial commit of katas
authored
1 {-# LANGUAGE ExistentialQuantification #-}
2
3 -- Data type from Max Rabkin's "Beautiful Folding" (http://squing.blogspot.com/2008/11/beautiful-folding.html):
4 -- Fold over list of type |[b]| with result of type |c|
5 data Fold b c = forall a. F (a -> b -> a) a (a -> c)
6
7
8 -- Data type after existential elimination, Oleg-style:
9 data Fold' b c = F' (b -> Fold' b c) c
10
11 back :: Fold' b c -> Fold b c
12 back f' = F (\(F' x _) b -> x b) f' (\(F' _ y) -> y)
13
14 forth :: Fold b c -> Fold' b c
15 forth (F x a y) = F' (\b -> forth (F x (x a b) y)) (y a)
16
17
18 main :: IO ()
19 main = return ()
Something went wrong with that request. Please try again.