<commit_before>-- |
-- Module      : Test.LeanCheck.FunListable
-- Copyright   : (c) 2015-2018 <NAME>
-- License     : 3-Clause BSD  (see the file LICENSE)
-- Maintainer  : <NAME> <<EMAIL>>
--
-- This module is part of LeanCheck,
-- a simple enumerative property-based testing library.
--
-- This module exports a 'Listable' instance for function enumeration by means
-- of a 'FunListable' typeclass (similar to 'CoListable').
--
-- This module /does not currently work/, it it just a sketch and a stub.
module Test.LeanCheck.Function.Listable.FunListable (FunListable (..)) where


import Test.LeanCheck
import Test.LeanCheck.Tiers
import Test.LeanCheck.Utils (Nat(..), Nat2(..), Nat3(..))
import Data.Maybe (fromMaybe)


sndArgTypeOf :: b -> (a -> b -> c) -> b
x `sndArgTypeOf` _ = x


instance (FunListable a, Listable b) => Listable (a -> b) where
  tiers = concatMapT mkfss funtiers
    where
    mkfss (n, mkf) = mapT mkf (products (replicate n tiers)
                    `suchThat` validResults (undefined `sndArgTypeOf` mkf))


(\+:/) :: [[a]] -> [[a]] -> [[a]]
xss \+:/ yss = xss \/ ([]:yss)
infixr 9 \+:/


class FunListable a where
  validResults   :: a -> [b] -> Bool
  validResults   x  =  not . invalidResults x
  invalidResults :: a -> [b] -> Bool
  invalidResults x  =  not .   validResults x
  funtiers :: [[ (Int, [b] -> (a -> b)) ]]

-- maybe the other function FunListable needs is a okResults that checks if
-- results follow required pattern for each type:
--   * for lists, there shouldnt be repeated element suffix
--        a,a,a,a,a,b is ok
--        a,b,c,d,e,e is not ok.
--   * for integers, there shouldnt be adjacent repeated elements
--        a,b,a,b,a,b,a,b is ok
--        a,b,c,d,e,f,f,g is not ok
--        of course, this for the enumeration where I have the points.<commit_msg>document the FunListable typeclass<commit_after>-- |
-- Module      : Test.LeanCheck.FunListable
-- Copyright   : (c) 2015-2018 <NAME>
-- License     : 3-Clause BSD  (see the file LICENSE)
-- Maintainer  : <NAME> <<EMAIL>>
--
-- This module is part of LeanCheck,
-- a simple enumerative property-based testing library.
--
-- This module exports a 'Listable' instance for function enumeration by means
-- of a 'FunListable' typeclass (similar to 'CoListable').
--
-- This module /does not currently work/, it it just a sketch and a stub.
module Test.LeanCheck.Function.Listable.FunListable (FunListable (..)) where


import Test.LeanCheck
import Test.LeanCheck.Tiers
import Test.LeanCheck.Utils (Nat(..), Nat2(..), Nat3(..))
import Data.Maybe (fromMaybe)


sndArgTypeOf :: b -> (a -> b -> c) -> b
x `sndArgTypeOf` _ = x


instance (FunListable a, Listable b) => Listable (a -> b) where
  tiers = concatMapT mkfss funtiers
    where
    mkfss (n, mkf) = mapT mkf (products (replicate n tiers)
                    `suchThat` validResults (undefined `sndArgTypeOf` mkf))


(\+:/) :: [[a]] -> [[a]] -> [[a]]
xss \+:/ yss = xss \/ ([]:yss)
infixr 9 \+:/


-- | This typeclass _does not currently work_.  It is a stub and a sketch.
--
-- 'FunListable' is similar to 'CoListable' but a bit more complex to avoid
-- some repetitions.
class FunListable a where
  validResults   :: a -> [b] -> Bool
  validResults   x  =  not . invalidResults x
  invalidResults :: a -> [b] -> Bool
  invalidResults x  =  not .   validResults x
  funtiers :: [[ (Int, [b] -> (a -> b)) ]]

-- maybe the other function FunListable needs is a okResults that checks if
-- results follow required pattern for each type:
--   * for lists, there shouldnt be repeated element suffix
--        a,a,a,a,a,b is ok
--        a,b,c,d,e,e is not ok.
--   * for integers, there shouldnt be adjacent repeated elements
--        a,b,a,b,a,b,a,b is ok
--        a,b,c,d,e,f,f,g is not ok
--        of course, this for the enumeration where I have the points.
{'fraction_non_alphanumeric': 0.14315569487983282, 'fraction_numerical': 0.006269592476489028, 'mean_word_length': 2.783596837944664, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3395997', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1265, 'n_words': 449}