-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeriveFunctorFoldableTest.hs
38 lines (31 loc) · 1.1 KB
/
DeriveFunctorFoldableTest.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
module DeriveFunctorFoldableTest where
import DeriveFunctorFoldable
import Language.Haskell.TH
data Tree a = Nil | Leaf a | Node (Tree a) (Tree a) deriving Show
data Tree' a = Leaf' a | Node' (Tree' a) a (Tree' a) deriving Show
data List a = Empty | Cons a (List a) deriving Show
data Option a = None | Some a deriving Show
data Error a b = Err a | Ok b deriving Show
data Foobar a b c = Foo a b c | Bar String Int (Foobar a b c)
type StringError = Error String
deriveFoldable ''Tree
deriveFoldable ''Tree'
deriveFoldable ''List
deriveFoldable ''Option
deriveFoldable ''Error
deriveFoldable ''Foobar
--deriveFoldable ''StringError
deriveFunctor ''Tree
deriveFunctor ''Tree'
deriveFunctor ''List
deriveFunctor ''Option
deriveFunctor ''Error
deriveFunctor ''Foobar
--deriveFunctor ''StringError
sampleTree :: Tree Int
sampleTree = Node (Node (Leaf 1) Nil) (Node (Node (Node (Leaf 2) (Leaf 3)) Nil) (Leaf 4))
sampleTree' :: Tree' Double
sampleTree' = Node' (Node' (Leaf' 3.0) 6.0 (Leaf' 8.0)) 9.5 (Leaf' 32.0)