Skip to content

Instantly share code, notes, and snippets.

@oisdk
Created July 2, 2018 01:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oisdk/cfb418b9be8b73d4a0e898ec64e497cc to your computer and use it in GitHub Desktop.
Save oisdk/cfb418b9be8b73d4a0e898ec64e497cc to your computer and use it in GitHub Desktop.
import Data.Functor.Foldable
zipo :: (Recursive f, Recursive g)
=> (Base f (g -> c) -> Base g g -> c)
-> f -> g -> c
zipo alg xs = cata (\x -> alg x . project) xs
zipoFix :: Functor f => (f (Fix f -> a) -> f (Fix f) -> a) -> Fix f -> Fix f -> a
zipoFix = zipo
zip :: [a] -> [b] -> [(a,b)]
zip = zipo alg
where
alg Nil _ = []
alg _ Nil = []
alg (Cons x xs) (Cons y ys) = (x,y) : xs ys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment