Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added map function.

  • Loading branch information...
commit 32ca6b1bc33c8aabd5d33b114ba6af3547d5f971 1 parent 4e237a9
@tomlokhorst authored
Showing with 3 additions and 0 deletions.
  1. +3 −0  src/Generic/Data/List.hs
View
3  src/Generic/Data/List.hs
@@ -34,6 +34,9 @@ instance (RecFunC j, ListC j) => Functor j [] where
singleton :: ListC j => j a -> j [a]
singleton a = a `cons` nil
+map :: (ListC j, RecFunC j) => (j a -> j b) -> j [a] -> j [b]
+map f = foldr (\y ys -> f y `cons` ys) nil
+
foldr :: (RecFunC j, ListC j) => (j a -> j b -> j b) -> j b -> j [a] -> j b
foldr f b xs = fix (\r -> lam (list b (\y ys -> f y (r `app` ys)))) `app` xs

0 comments on commit 32ca6b1

Please sign in to comment.
Something went wrong with that request. Please try again.