-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | enumerate all the values in a finite type (automatically) -- -- provides -- -- -- -- see the Enumerable module for extensive documentation. @package enumerate @version 0.2.2 module Enumerate.Extra int2natural :: Int -> Natural -- | the power set of a set of values. -- --
--   >>> (powerset2matrix . powerSet . Set.fromList) [1..3]
--   [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
--   
powerSet :: (Ord a) => Set a -> Set (Set a) -- |
--   >>> (powerset2matrix . dropEach . Set.fromList) [1..3]
--   [[1,2],[1,3],[2,3]]
--   
dropEach :: (Ord a) => Set a -> Set (Set a) -- | convert a power set to an isomorphic matrix, sorting the entries. -- -- (for doctest) powerset2matrix :: Set (Set a) -> [[a]] -- | (for doctest) printMappings :: (Show a) => [[a]] -> IO () -- | enumerate all values in a finite type. -- -- e.g. -- --
--   data A
--     = A0 Bool
--     | A1 (Either Bool) (Maybe Bool)
--     | A2 (Bool, Bool)
--     | A3 (Set Bool)
--     deriving (Show,Generic,Enumerable)
--   
--   > enumerate
--   A0 False
--   A0 True
--   A1 ...
--   
--   > cardinality ([]::[A])
--   
-- -- see the Enumerable class for documentation. -- -- see Enumerate.Example for examples. -- -- can also help automatically derive QuickCheck -- instances: -- --
--   newtype ValidString = ValidString String
--    deriving (Show)
--   validStrings :: [String]
--   makeValidString :: String -> Maybe ValidString
--   makeValidString s = if s member validStrings then Just (ValidString s) else Nothing
--   instance Enumerable ValidString where enumerated = ValidString <$> validStrings ... -- manually (since normal String's are infinite)
--   instance Arbitrary ValidString where arbitrary = elements enumerated
--   
--   data ValidName = ValidName ValidString ValidString | CoolValidName [ValidString]
--    deriving (Show,Generic)
--   instance Enumerable ValidName -- automatically
--   
--   instance Arbitrary ValidName where arbitrary = elements enumerated
--   
-- -- Provides instances for all base types (whenever possible): -- -- -- -- background on Generics: -- -- -- -- also provides instances for: -- -- -- -- related packages: -- -- module Enumerate.Types -- | enumerate the set of all values in a (finitely enumerable) type. -- enumerates depth first. -- -- generalizes Enums to any finite/discrete type. an Enumerable is -- either: -- -- -- -- can be implemented automatically via its Generic instance. -- -- laws: -- -- -- -- (Bounded constraint elided for convenience, but relevant.) -- -- ("inputs" a type, outputs a list of values). -- -- Every type in base (that can be an instance) is an instance. class Enumerable a where enumerated = to <$> genumerated cardinality _ = genericLength (enumerated :: [a]) enumerated :: Enumerable a => [a] enumerated :: (Enumerable a, Generic a, GEnumerable (Rep a)) => [a] cardinality :: Enumerable a => proxy a -> Natural -- | wrap any (Bounded a, Enum a) to be a Enumerable via -- boundedEnumerated. -- -- (avoids OverlappingInstances). newtype WrappedBoundedEnum a WrappedBoundedEnum :: a -> WrappedBoundedEnum a [unwrapBoundedEnum] :: WrappedBoundedEnum a -> a -- | (phantom in a) -- |
--   -- (toInteger prevents overflow)
--   
-- --
--   >>> 1 + toInteger (maxBound::Int8) - toInteger (minBound::Int8)
--   256
--   
-- |
--   >>> 1 + toInteger (maxBound::Int16) - toInteger (minBound::Int16)
--   65536
--   
-- | there are only a million (1,114,112) characters. -- --
--   >>> import Data.Char (ord,chr)  -- 'ord', 'chr'
--   
-- --
--   >>> ord minBound
--   0
--   
-- --
--   >>> ord maxBound
--   1114111
--   
-- --
--   >>> length [chr 0 ..]
--   1114112
--   
-- | the sum type. -- -- the cardinality is the sum of the cardinalities of a -- and b. -- --
--   >>> cardinality ([] :: [Either Bool Ordering])
--   5
--   
-- | the product type. -- -- the cardinality is the product of the cardinalities of -- a and b. -- --
--   >>> cardinality ([] :: [(Bool,Ordering)])
--   6
--   
-- | 3 -- | 4 -- | 5 -- | 6 -- | 7 -- | the cardinality is the cardinality of the powerSet of -- a, i.e. 2^|a|. warning: it grows quickly. don't try -- to take the power set of Char! or even Word8. -- -- the cardinality call is efficient (depending on the efficiency -- of the base type's call). you should be able to safely call -- enumerateBelow, unless the arithmetic itself becomes too large. -- --
--   >>> enumerated :: [Set Bool]
--   [fromList [],fromList [False],fromList [False,True],fromList [True]]
--   
-- | (a can be any Enumerable, unlike the Enum -- instance where a is an Integral). -- | the cardinality is a product of cardinalities. -- | "Generic Enumerable", lifted to unary type constructors. class GEnumerable f genumerated :: GEnumerable f => [f x] gcardinality :: GEnumerable f => proxy f -> Natural -- | empty list -- | singleton list -- | call enumerated -- | multiply lists with concatMap -- | add lists with (<>) -- | ignore selector metadata -- | ignore constructor metadata -- | ignore datatype metadata -- | for non-Generic Bounded Enums: -- --
--   instance Enumerable _ where
--    enumerated = boundedEnumerated
--    cardinality = boundedCardinality
--   
boundedEnumerated :: (Bounded a, Enum a) => [a] -- | for non-Generic Bounded Enums. -- -- Assuming Bounded is correct, safely stop the enumeration (and -- know where to start). -- -- behavior may be undefined when the cardinality of a is larger -- than the cardinality of Int. this should be okay, as -- Int is at least as big as Int64, which is at least -- as big as all the monomorphic types in base that instantiate -- Bounded. you can double-check with: -- --
--   >>> boundedCardinality (const(undefined::Int))   -- platform specific
--   18446744073709551616
--   
-- --
--   -- i.e. 1 + 9223372036854775807 - (-9223372036854775808)
--   
-- -- works with non-zero-based Enum instances, like Int64 or a -- custom toEnum/fromEnum. assumes the enumeration's numbering -- is contiguous, e.g. if fromEnum 0 and fromEnum 2 -- both exist, then fromEnum 1 should exist too. boundedCardinality :: forall proxy a. (Bounded a, Enum a) => proxy a -> Natural -- | for non-Generic Enums: -- --
--   instance Enumerable ... where
--    enumerated = enumEnumerated
--   
-- -- the enum should still be bounded. enumEnumerated :: (Enum a) => [a] -- | for non-Generic Bounded Indexed (Ix) types: -- --
--   instance Enumerable _ where
--    enumerated = indexedEnumerated
--    cardinality = indexedCardinality
--   
indexedEnumerated :: (Bounded a, Ix a) => [a] -- | for non-Generic Bounded Indexed (Ix) types. indexedCardinality :: forall proxy a. (Bounded a, Ix a) => proxy a -> Natural -- | enumerate only when the cardinality is small enough. returns the -- cardinality when too large. -- --
--   >>> enumerateBelow 2 :: Either Natural [Bool]
--   Left 2
--   
-- --
--   >>> enumerateBelow 100 :: Either Natural [Bool]
--   Right [False,True]
--   
-- -- useful when you've established that traversing a list below some -- length and consuming its values is reasonable for your application. -- e.g. after benchmarking, you think you can process a billion entries -- within a minute. enumerateBelow :: forall a. (Enumerable a) => Natural -> Either Natural [a] -- | enumerate only when completely evaluating the list doesn't timeout -- (before the given number of microseconds). -- --
--   >>> enumerateTimeout (2 * 10^6) :: IO (Maybe [Bool])  -- two seconds
--   Just [False,True]
--   
enumerateTimeout :: (Enumerable a, NFData a) => Int -> IO (Maybe [a]) instance Enumerate.Types.Enumerable Data.Void.Void instance Enumerate.Types.Enumerable () instance Enumerate.Types.Enumerable GHC.Types.Bool instance Enumerate.Types.Enumerable GHC.Types.Ordering instance Enumerate.Types.Enumerable (Data.Proxy.Proxy a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Functor.Identity.Identity a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Functor.Const.Const a b) instance a ~ b => Enumerate.Types.Enumerable (a Data.Type.Equality.:~: b) instance GHC.Types.Coercible a b => Enumerate.Types.Enumerable (Data.Type.Coercion.Coercion a b) instance Enumerate.Types.Enumerable GHC.Int.Int8 instance Enumerate.Types.Enumerable GHC.Word.Word8 instance Enumerate.Types.Enumerable GHC.Int.Int16 instance Enumerate.Types.Enumerable GHC.Word.Word16 instance Enumerate.Types.Enumerable GHC.Types.Char instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b) => Enumerate.Types.Enumerable (Data.Either.Either a b) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (GHC.Base.Maybe a) instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b) => Enumerate.Types.Enumerable (a, b) instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b, Enumerate.Types.Enumerable c) => Enumerate.Types.Enumerable (a, b, c) instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b, Enumerate.Types.Enumerable c, Enumerate.Types.Enumerable d) => Enumerate.Types.Enumerable (a, b, c, d) instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b, Enumerate.Types.Enumerable c, Enumerate.Types.Enumerable d, Enumerate.Types.Enumerable e) => Enumerate.Types.Enumerable (a, b, c, d, e) instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b, Enumerate.Types.Enumerable c, Enumerate.Types.Enumerable d, Enumerate.Types.Enumerable e, Enumerate.Types.Enumerable f) => Enumerate.Types.Enumerable (a, b, c, d, e, f) instance (Enumerate.Types.Enumerable a, Enumerate.Types.Enumerable b, Enumerate.Types.Enumerable c, Enumerate.Types.Enumerable d, Enumerate.Types.Enumerable e, Enumerate.Types.Enumerable f, Enumerate.Types.Enumerable g) => Enumerate.Types.Enumerable (a, b, c, d, e, f, g) instance (Enumerate.Types.Enumerable a, GHC.Classes.Ord a) => Enumerate.Types.Enumerable (Data.Set.Base.Set a) instance Enumerate.Types.Enumerable GHC.Unicode.GeneralCategory instance Enumerate.Types.Enumerable GHC.IO.IOMode.IOMode instance Enumerate.Types.Enumerable GHC.IO.Device.SeekMode instance Enumerate.Types.Enumerable GHC.Exception.ArithException instance Enumerate.Types.Enumerable GHC.IO.Exception.AsyncException instance Enumerate.Types.Enumerable Control.Exception.Base.NonTermination instance Enumerate.Types.Enumerable Control.Exception.Base.NestedAtomically instance Enumerate.Types.Enumerable GHC.IO.Exception.BlockedIndefinitelyOnMVar instance Enumerate.Types.Enumerable GHC.IO.Exception.BlockedIndefinitelyOnSTM instance Enumerate.Types.Enumerable GHC.IO.Exception.AllocationLimitExceeded instance Enumerate.Types.Enumerable GHC.IO.Exception.Deadlock instance Enumerate.Types.Enumerable GHC.IO.Handle.Types.Newline instance Enumerate.Types.Enumerable GHC.IO.Handle.Types.NewlineMode instance Enumerate.Types.Enumerable Text.Printf.FormatAdjustment instance Enumerate.Types.Enumerable Text.Printf.FormatSign instance Enumerate.Types.Enumerable Data.Monoid.All instance Enumerate.Types.Enumerable Data.Monoid.Any instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Monoid.Dual a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Monoid.First a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Monoid.Last a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Monoid.Sum a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Monoid.Product a) instance Enumerate.Types.Enumerable (a -> a) => Enumerate.Types.Enumerable (Data.Monoid.Endo a) instance Enumerate.Types.Enumerable (f a) => Enumerate.Types.Enumerable (Data.Monoid.Alt f a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Complex.Complex a) instance Enumerate.Types.Enumerable Foreign.C.Types.CChar instance Enumerate.Types.Enumerable Foreign.C.Types.CWchar instance Enumerate.Types.Enumerable Foreign.C.Types.CSChar instance Enumerate.Types.Enumerable Foreign.C.Types.CUChar instance Enumerate.Types.Enumerable Foreign.C.Types.CShort instance Enumerate.Types.Enumerable Foreign.C.Types.CUShort instance Enumerate.Types.Enumerable GHC.Generics.Associativity instance (GHC.Enum.Bounded a, GHC.Enum.Enum a) => Enumerate.Types.Enumerable (Enumerate.Types.WrappedBoundedEnum a) instance (Enumerate.Types.Enumerable (f a), Enumerate.Types.Enumerable (Data.Vinyl.Core.Rec f as)) => Enumerate.Types.Enumerable (Data.Vinyl.Core.Rec f (a : as)) instance Enumerate.Types.Enumerable (Data.Vinyl.Core.Rec f '[]) instance Enumerate.Types.GEnumerable GHC.Generics.V1 instance Enumerate.Types.GEnumerable GHC.Generics.U1 instance Enumerate.Types.Enumerable a => Enumerate.Types.GEnumerable (GHC.Generics.K1 GHC.Generics.R a) instance (Enumerate.Types.GEnumerable f, Enumerate.Types.GEnumerable g) => Enumerate.Types.GEnumerable (f GHC.Generics.:*: g) instance (Enumerate.Types.GEnumerable f, Enumerate.Types.GEnumerable g) => Enumerate.Types.GEnumerable (f GHC.Generics.:+: g) instance Enumerate.Types.GEnumerable f => Enumerate.Types.GEnumerable (GHC.Generics.M1 GHC.Generics.S t f) instance Enumerate.Types.GEnumerable f => Enumerate.Types.GEnumerable (GHC.Generics.M1 GHC.Generics.C t f) instance Enumerate.Types.GEnumerable f => Enumerate.Types.GEnumerable (GHC.Generics.M1 GHC.Generics.D t f) module Enumerate.Orphans.GHC instance Enumerate.Types.Enumerable System.Posix.Types.CIno instance Enumerate.Types.Enumerable System.Posix.Types.CMode instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Data.Ord.Down a) instance Enumerate.Types.Enumerable GHC.Exts.SpecConstrAnnotation instance Enumerate.Types.Enumerable GHC.IO.Buffer.BufferState instance Enumerate.Types.Enumerable GHC.IO.Device.IODeviceType instance Enumerate.Types.Enumerable GHC.IO.Encoding.Failure.CodingFailureMode instance Enumerate.Types.Enumerable GHC.IO.Encoding.Types.CodingProgress instance Enumerate.Types.Enumerable GHC.RTS.Flags.DoTrace instance Enumerate.Types.Enumerable GHC.RTS.Flags.DoHeapProfile instance Enumerate.Types.Enumerable GHC.RTS.Flags.DoCostCentres instance Enumerate.Types.Enumerable GHC.RTS.Flags.GiveGCStats -- | orphan instances, of Enumerable, for large types (i.e. -- Word32 / Word64 / Int32 / Int64). -- -- see: -- -- -- -- (that are included for completeness, but not exported by default (i.e. -- by Enumerate). you probably want build-time instance-resolution -- errors instead of probable runtime non-termination). module Enumerate.Orphans.Large -- | finite but too large. 2^64 is a few billion. -- --
--   >>> 1 + toInteger (maxBound::Int32) - toInteger (minBound::Int32)
--   4294967296
--   
-- | finite but too large. 2^64 is over a billion billion. -- -- e.g. reifyFunction (which takes time linear in the domain) on a -- function of type (:: Int -> Bool), won't terminate anytime -- soon. -- --
--   >>> 1 + toInteger (maxBound::Int64) - toInteger (minBound::Int64)
--   18446744000000000000
--   
-- | finite but too large. -- --
--   >>> 1 + toInteger (maxBound::Int) - toInteger (minBound::Int)
--   ...
--   
instance Enumerate.Types.Enumerable GHC.Int.Int32 instance Enumerate.Types.Enumerable GHC.Word.Word32 instance Enumerate.Types.Enumerable GHC.Int.Int64 instance Enumerate.Types.Enumerable GHC.Word.Word64 instance Enumerate.Types.Enumerable GHC.Types.Int instance Enumerate.Types.Enumerable GHC.Types.Word -- | usage: -- --
--   data A = ...
--   
--   instance Bounded A where
--    minBound = minBound_enumerable array_A
--    maxBound = maxBound_enumerable array_A
--   
--   instance Enum A where
--    toEnum   = toEnum_enumerable   array_A
--    fromEnum = fromEnum_enumerable table_A
--   
--   -- CAF
--   array_A :: Array Int A
--   array_A = array_enumerable
--   
--   -- CAF
--   table_A :: Map A Int
--   table_A = table_enumerable
--   
--   -- we must pass in CAFs
--   -- (i.e. expressions that are top-level and unconstrained),
--   -- which will be shared between all calls to minBoundmaxBoundtoEnum/fromEnum.
--   -- TODO must we?
--   
-- -- -- -- (also see the source of Enumerate.Example) module Enumerate.Enum minBound_enumerable :: forall a. (Enumerable a) => Array Int a -> a maxBound_enumerable :: forall a. (Enumerable a) => Array Int a -> a toEnum_enumerable :: forall a. (Enumerable a) => Array Int a -> (Int -> a) fromEnum_enumerable :: forall a. (Enumerable a, Ord a) => Map a Int -> (a -> Int) minBound_enumerable' :: forall a. (Enumerable a) => a maxBound_enumerable' :: forall a. (Enumerable a) => a toEnum_enumerable' :: forall a. (Enumerable a) => (Int -> a) fromEnum_enumerable' :: forall a. (Enumerable a, Ord a) => (a -> Int) array_enumerable :: forall a. (Enumerable a) => Array Int a table_enumerable :: forall a. (Enumerable a, Ord a) => Map a Int toEnumDefault :: forall a. (Enumerable a) => Int -> a fromEnumDefault :: forall a. (Enumerable a, Ord a) => a -> Int -- | the cardinality of a finite type, at the type-level. module Enumerate.Cardinality -- | a type is finite, i.e. has a bounded size. -- -- laws: -- -- -- -- e.g. -- --
--   >>> reifyCardinality ([]::[Bool])
--   2
--   
class Finite a where type Cardinality a :: Nat type Cardinality a = GCardinality (Rep a) where { type family Cardinality a :: Nat; type Cardinality a = GCardinality (Rep a); } -- |
--   0
--   
-- |
--   1
--   
-- |
--   2
--   
-- |
--   3
--   
-- |
--   2^8
--   
-- |
--   2^8
--   
-- |
--   2^16
--   
-- |
--   2^16
--   
-- |
--   1114112
--   
-- |
--   1 + a
--   
-- |
--   a + b
--   
-- | the cardinality is a product of cardinalities. -- |
--   a*b
--   
-- |
--   a*b*c
--   
-- |
--   a*b*c*d
--   
-- |
--   a*b*c*d*e
--   
-- |
--   a*b*c*d*e*f
--   
-- |
--   a*b*c*d*e*f*g
--   
-- |
--   2^a
--   
-- |
--   b^a
--   
-- |
--   >>> reifyCardinality ([]::[Bool])
--   2
--   
reifyCardinality :: forall a proxy. (KnownNat (Cardinality a)) => proxy a -> Natural -- | typechecks only when the constraint is satisifed. -- -- a constaint. type CardinalityWithin n a = IsCardinalityWithin n a ~ True -- | a predicate, inclusive. -- --
--   > type CardinalityWithinAMillion a = CardinalityWithin 1000000 a
--   > :kind! CardinalityWithinAMillion Bool
--   True
--   > :kind! CardinalityWithinAMillion Char
--   False
--   
type IsCardinalityWithin n a = Cardinality a <=? n instance Enumerate.Cardinality.Finite Data.Void.Void instance Enumerate.Cardinality.Finite () instance Enumerate.Cardinality.Finite GHC.Types.Bool instance Enumerate.Cardinality.Finite GHC.Types.Ordering instance Enumerate.Cardinality.Finite (Data.Proxy.Proxy a) instance Enumerate.Cardinality.Finite GHC.Int.Int8 instance Enumerate.Cardinality.Finite GHC.Word.Word8 instance Enumerate.Cardinality.Finite GHC.Int.Int16 instance Enumerate.Cardinality.Finite GHC.Word.Word16 instance Enumerate.Cardinality.Finite GHC.Types.Char instance Enumerate.Cardinality.Finite a => Enumerate.Cardinality.Finite (GHC.Base.Maybe a) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b) => Enumerate.Cardinality.Finite (Data.Either.Either a b) instance (Enumerate.Cardinality.Finite (f a), Enumerate.Cardinality.Finite (Data.Vinyl.Core.Rec f as)) => Enumerate.Cardinality.Finite (Data.Vinyl.Core.Rec f (a : as)) instance Enumerate.Cardinality.Finite (Data.Vinyl.Core.Rec f '[]) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b) => Enumerate.Cardinality.Finite (a, b) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b, Enumerate.Cardinality.Finite c) => Enumerate.Cardinality.Finite (a, b, c) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b, Enumerate.Cardinality.Finite c, Enumerate.Cardinality.Finite d) => Enumerate.Cardinality.Finite (a, b, c, d) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b, Enumerate.Cardinality.Finite c, Enumerate.Cardinality.Finite d, Enumerate.Cardinality.Finite e) => Enumerate.Cardinality.Finite (a, b, c, d, e) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b, Enumerate.Cardinality.Finite c, Enumerate.Cardinality.Finite d, Enumerate.Cardinality.Finite e, Enumerate.Cardinality.Finite f) => Enumerate.Cardinality.Finite (a, b, c, d, e, f) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b, Enumerate.Cardinality.Finite c, Enumerate.Cardinality.Finite d, Enumerate.Cardinality.Finite e, Enumerate.Cardinality.Finite f, Enumerate.Cardinality.Finite g) => Enumerate.Cardinality.Finite (a, b, c, d, e, f, g) instance Enumerate.Cardinality.Finite a => Enumerate.Cardinality.Finite (Data.Set.Base.Set a) instance (Enumerate.Cardinality.Finite a, Enumerate.Cardinality.Finite b) => Enumerate.Cardinality.Finite (a -> b) -- | enumerate all values in a finite type. -- -- e.g. -- --
--   >>> :set -XDeriveGeneric
--   
--   >>> :set -XDeriveAnyClass
--   
-- -- given: -- --
--   -- an Enumerable can be automatically derived,
--   -- even though it's a nested sum type (and thus not an Enum).
--   data Edit = Edit Action Slice Region
--    deriving (Show,Read,Eq,Ord,Generic,Enumerable)
--   
--   data Action
--    = Select
--    | Copy
--    | Delete
--    deriving (Show,Read,Eq,Ord,Enum,Bounded,Generic,Enumerable)
--   
--   data Slice
--    = Whole
--    | Backwards
--    | Forwards
--    deriving (Show,Read,Eq,Ord,Enum,Bounded,Generic,Enumerable)
--   
--   data Region
--    = Character
--    | Token
--    | Line
--    deriving (Show,Read,Eq,Ord,Enum,Bounded,Generic,Enumerable)
--   
-- -- we can enumerate every possible editing action: -- --
--   > enumerated :: [Edit]
--   Edit Select Whole Character
--   Edit Select Whole Token
--   Edit Select Whole Line
--   Edit Select Backwards Character
--   Edit Select Backwards Token
--   Edit Select Backwards Line
--   Edit Select Forwards Character
--   Edit Select Forwards Token
--   Edit Select Forwards Line
--   Edit Copy Whole Character
--   Edit Copy Whole Token
--   Edit Copy Whole Line
--   Edit Copy Backwards Character
--   Edit Copy Backwards Token
--   Edit Copy Backwards Line
--   Edit Copy Forwards Character
--   Edit Copy Forwards Token
--   Edit Copy Forwards Line
--   Edit Delete Whole Character
--   Edit Delete Whole Token
--   Edit Delete Whole Line
--   Edit Delete Backwards Character
--   Edit Delete Backwards Token
--   Edit Delete Backwards Line
--   Edit Delete Forwards Character
--   Edit Delete Forwards Token
--   Edit Delete Forwards Line
--   
-- -- see Enumerate.Types for detailed documentation. -- -- the modules Enumerate.Large and Enumerate.Function have -- orphan instances for large types, and aren't reexported by default. -- this makes attempting to enumerate them a type error, rather than -- runtime non-termination. -- -- See the source of Enumerate.Example for an example. module Enumerate -- | ## Bounded Enum instance -- -- You can (semi-)automatically derive efficient 'Bounded'/'Enum' -- instances: -- --
--   instance Bounded (Demo Bool) where
--    minBound = minBound_enumerable array_DemoBool
--    maxBound = maxBound_enumerable array_DemoBool
--   
--   instance Enum (Demo Bool) where
--    toEnum   = toEnum_enumerable   array_DemoBool
--    fromEnum = fromEnum_enumerable table_DemoBool
--   
--   -- CAF
--   array_DemoBool :: Array Int (Demo Bool)
--   array_DemoBool = array_enumerable
--   
--   -- CAF
--   table_DemoBool :: Map (Demo Bool) Int
--   table_DemoBool = table_enumerable
--   
-- -- ## Run -- --
--   stack build && stack exec -- enumerable-example
--   
-- -- outputs: -- --
--   -- A Void
--   >>> cardinality ([]::[A Void])
--   1
--   >>> _ <- traverse print (enumerated :: [A Void])
--   A3 (fromList [])
--   
--   
--   -- A ()
--   >>> cardinality ([]::[A ()])
--   8
--   >>> _ <- traverse print (enumerated :: [A ()])
--   A0 ()
--   A1 Nothing (Left ())
--   A1 Nothing (Right ())
--   A1 (Just ()) (Left ())
--   A1 (Just ()) (Right ())
--   A2 ((),())
--   A3 (fromList [])
--   A3 (fromList [()])
--   
--   
--   -- A Bool
--   >>> cardinality ([]::[A Bool])
--   22
--   >>> _ <- traverse print (enumerated :: [A Bool])
--   A0 False
--   A0 True
--   A1 Nothing (Left False)
--   A1 Nothing (Left True)
--   A1 Nothing (Right False)
--   A1 Nothing (Right True)
--   A1 (Just False) (Left False)
--   A1 (Just False) (Left True)
--   A1 (Just False) (Right False)
--   A1 (Just False) (Right True)
--   A1 (Just True) (Left False)
--   A1 (Just True) (Left True)
--   A1 (Just True) (Right False)
--   A1 (Just True) (Right True)
--   A2 (False,False)
--   A2 (False,True)
--   A2 (True,False)
--   A2 (True,True)
--   A3 (fromList [])
--   A3 (fromList [False])
--   A3 (fromList [False,True])
--   A3 (fromList [True])
--   
--   
--   -- A Ordering
--   >>> cardinality ([]::[A Ordering])
--   44
--   >>>_ <- traverse print (enumerated :: [A Ordering])
--   A0 LT
--   A0 EQ
--   A0 GT
--   A1 Nothing (Left LT)
--   A1 Nothing (Left EQ)
--   A1 Nothing (Left GT)
--   A1 Nothing (Right LT)
--   A1 Nothing (Right EQ)
--   A1 Nothing (Right GT)
--   A1 (Just LT) (Left LT)
--   A1 (Just LT) (Left EQ)
--   A1 (Just LT) (Left GT)
--   A1 (Just LT) (Right LT)
--   A1 (Just LT) (Right EQ)
--   A1 (Just LT) (Right GT)
--   A1 (Just EQ) (Left LT)
--   A1 (Just EQ) (Left EQ)
--   A1 (Just EQ) (Left GT)
--   A1 (Just EQ) (Right LT)
--   A1 (Just EQ) (Right EQ)
--   A1 (Just EQ) (Right GT)
--   A1 (Just GT) (Left LT)
--   A1 (Just GT) (Left EQ)
--   A1 (Just GT) (Left GT)
--   A1 (Just GT) (Right LT)
--   A1 (Just GT) (Right EQ)
--   A1 (Just GT) (Right GT)
--   A2 (LT,LT)
--   A2 (LT,EQ)
--   A2 (LT,GT)
--   A2 (EQ,LT)
--   A2 (EQ,EQ)
--   A2 (EQ,GT)
--   A2 (GT,LT)
--   A2 (GT,EQ)
--   A2 (GT,GT)
--   A3 (fromList [])
--   A3 (fromList [LT])
--   A3 (fromList [LT,EQ])
--   A3 (fromList [LT,EQ,GT])
--   A3 (fromList [LT,GT])
--   A3 (fromList [EQ])
--   A3 (fromList [EQ,GT])
--   A3 (fromList [GT])
--   
module Enumerate.Example main :: IO [()] -- | (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)
--   
data Demo a Demo0 :: Void -> Demo a Demo1 :: Demo a Demo2 :: Bool -> (Maybe Bool) -> Demo a Demo3 :: a -> Demo a data A a A0 :: a -> A a A1 :: (Maybe a) -> (Either a a) -> A a A2 :: (a, a) -> A a A3 :: (Set a) -> A a -- | (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
--   
demoEnumerated :: [Demo Bool] array_DemoBool :: Array Int (Demo Bool) table_DemoBool :: Map (Demo Bool) Int instance (GHC.Classes.Ord a, Enumerate.Types.Enumerable a) => Enumerate.Types.Enumerable (Enumerate.Example.A a) instance GHC.Generics.Generic (Enumerate.Example.A a) instance GHC.Show.Show a => GHC.Show.Show (Enumerate.Example.A a) instance Enumerate.Types.Enumerable a => Enumerate.Types.Enumerable (Enumerate.Example.Demo a) instance GHC.Generics.Generic (Enumerate.Example.Demo a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Enumerate.Example.Demo a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Enumerate.Example.Demo a) instance GHC.Show.Show a => GHC.Show.Show (Enumerate.Example.Demo a) instance GHC.Enum.Bounded (Enumerate.Example.Demo GHC.Types.Bool) instance GHC.Enum.Enum (Enumerate.Example.Demo GHC.Types.Bool) -- | test that nullary method calls are shared. -- -- TODO cross-module benchmark and core check. -- --
--   stack build --flag enumerate:dump-core && open core/Enumerate.Test.html
--   
module Enumerate.Test data B a B0 :: a -> B a B1 :: (Maybe a) -> (Either a a) -> B a B2 :: (a, a) -> B a B3 :: (Set a) -> B a things :: [B Bool] instance (GHC.Classes.Ord a, Enumerate.Types.Enumerable a) => Enumerate.Types.Enumerable (Enumerate.Test.B a) instance GHC.Generics.Generic (Enumerate.Test.B a) instance GHC.Classes.Ord a => GHC.Classes.Ord (Enumerate.Test.B a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Enumerate.Test.B a) instance GHC.Show.Show a => GHC.Show.Show (Enumerate.Test.B a) instance GHC.Enum.Bounded (Enumerate.Test.B GHC.Types.Bool) instance GHC.Enum.Enum (Enumerate.Test.B GHC.Types.Bool)