Skip to content

examples would be helpful #3

@cad0p

Description

@cad0p

Hi, could you provide us a simple example of how to use your tests to test if a functor instance is ok?

Thanks

example below

class Functor f where
  fmap :: (a -> b) -> f a -> f b

data Tree a = Leaf a | Node (Tree a) (Tree a)
  deriving Show

{-|
  Example: 
  >fmap (+1) ( Node (Leaf 1) (Leaf 2) )
-}
instance Functor Tree where
  fmap f (Leaf a) = Leaf (f a)
  fmap f (Node a b) = Node (fmap f a) (fmap f b)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions