{-|
Module      : Generate arbitrary events
Description : Functions for generating arbitrary events
Copyright   : (c) NoviSci, Inc 2020
License     : BSD3
Maintainer  : bsaul@novisci.com
-}

{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Safe #-}

module Hasklepias.Types.Context.Arbitrary() where

import Test.QuickCheck              ( Arbitrary(arbitrary), elements, sublistOf ) 
import Data.Function                ( (.) )
import Data.Functor                 ( Functor(fmap) )
import Data.List                    ( map )
import Data.Set                     ( fromList )
import Hasklepias.Types.Context     ( Concept
                                    , Concepts
                                    , Context
                                    , context
                                    , toConcepts
                                    , packConcepts
                                    , packConcept)

conceptChoices :: [Concept]
conceptChoices :: [Concept]
conceptChoices = (Text -> Concept) -> [Text] -> [Concept]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Concept
packConcept [Text
"A", Text
"B", Text
"C", Text
"D", Text
"E", Text
"F", Text
"G", Text
"H", Text
"I", Text
"J"]

instance Arbitrary Concept where
    arbitrary :: Gen Concept
arbitrary = [Concept] -> Gen Concept
forall a. [a] -> Gen a
elements [Concept]
conceptChoices

instance Arbitrary Context where
    arbitrary :: Gen Context
arbitrary = ([Concept] -> Context) -> Gen [Concept] -> Gen Context
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Concepts -> Context
context (Concepts -> Context)
-> ([Concept] -> Concepts) -> [Concept] -> Context
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set Concept -> Concepts
toConcepts (Set Concept -> Concepts)
-> ([Concept] -> Set Concept) -> [Concept] -> Concepts
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Concept] -> Set Concept
forall a. Ord a => [a] -> Set a
fromList) ([Concept] -> Gen [Concept]
forall a. [a] -> Gen [a]
sublistOf [Concept]
conceptChoices)

-- instance Arbitrary Concepts where
--     arbitrary = fmap fromList (sublistOf conceptChoices)