enumerate-0.1.1: enumerate all the values in a finite type (automatically)

Safe HaskellNone
LanguageHaskell2010

Data.Enumerate.Example

Synopsis

Documentation

main :: IO () Source

data Demo a Source

(for documentation)

demonstrates: empty type, unit type, product type, sum type, type variable.

with {-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}, the derivation is a one-liner:

data Demo a = ... deriving (Show,Generic,Enumerable)

Constructors

Demo0 Void 
Demo1 
Demo2 Bool (Maybe Bool) 
Demo3 a 

Instances

demoEnumerated :: [Demo Bool] Source

(for documentation)

demoEnumerated = enumerated
>>> traverse print demoEnumerated
Demo1
Demo2 False Nothing
Demo2 False (Just False)
Demo2 False (Just True)
Demo2 True Nothing
Demo2 True (Just False)
Demo2 True (Just True)
Demo3 False
Demo3 True