Created
June 23, 2014 21:49
-
-
Save fronx/0fe9124f5e1236bc84ff to your computer and use it in GitHub Desktop.
Revisions
-
fronx created this gist
Jun 23, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ module NestedLists where data NestedList a = Nest [NestedList a] | Item a deriving Show nestedList = Nest [ Item 1 , Item 2 , Nest [ Item 3 , Nest [ Item 4 , Item 5 ] , Item 6 ] ] instance Functor NestedList where fmap f (Item x) = Item (f x) fmap f (Nest nest) = Nest ((fmap . fmap) f nest) main = do print $ fmap (*2) nestedList