Add example with deep BaseCases

This commit is contained in:
lyxia 2016-08-15 00:11:59 +02:00
parent f875f7f0f6
commit ee3ca768f7

View File

@ -1,8 +1,10 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
import GHC.Generics ( Generic )
import GHC.Generics ( Generic, Rep )
import Test.QuickCheck
import Generic.Random.Generic
@ -12,4 +14,13 @@ data Tree a = Leaf | Node (Tree a) a (Tree a)
instance Arbitrary a => Arbitrary (Tree a) where
arbitrary = genericArbitrary' @'Z
main = sample (arbitrary :: Gen (Tree ()))
data Bush a = Tip a | Fork (Bush a) (Bush a)
deriving (Show, Generic)
instance (Arbitrary a, BaseCases' 'Z a) => Arbitrary (Bush a) where
arbitrary = genericArbitraryFrequency' @('S 'Z) [1, 2]
main = do
sample (arbitrary :: Gen (Tree ()))
putStrLn ""
sample (arbitrary :: Gen (Bush ()))