    {-# LANGUAGE CPP #-}
    {-# OPTIONS_GHC -fno-warn-orphans #-}
    {-| Instances for QuickCheck's Arbitrary. -}
    module Lua.Arbitrary () where

    import Lua
    import Test.QuickCheck

    instance Arbitrary Lua.Integer where
      arbitrary :: Gen Integer
    arbitrary = Gen Integer
    forall a. Integral a => Gen a
    arbitrarySizedIntegral
      shrink :: Integer -> [Integer]
    shrink = Integer -> [Integer]
    forall a. Integral a => a -> [a]
    shrinkIntegral

    instance Arbitrary Lua.Number where
      arbitrary :: Gen Number
    arbitrary = Double -> Number
    Lua.Number (Double -> Number) -> Gen Double -> Gen Number
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Gen Double
    forall a. Arbitrary a => Gen a
    arbitrary
      shrink :: Number -> [Number]
    shrink = Number -> [Number]
    forall a. RealFrac a => a -> [a]
    shrinkRealFrac

    instance Arbitrary Lua.TypeCode where
      arbitrary :: Gen TypeCode
    arbitrary = [TypeCode] -> Gen TypeCode
    forall a. HasCallStack => [a] -> Gen a
    elements
        [ TypeCode
    LUA_TNONE
        , TypeCode
    LUA_TNIL
        , TypeCode
    LUA_TBOOLEAN
        , TypeCode
    LUA_TLIGHTUSERDATA
        , TypeCode
    LUA_TNUMBER
        , TypeCode
    LUA_TSTRING
        , TypeCode
    LUA_TTABLE
        , TypeCode
    LUA_TFUNCTION
        , TypeCode
    LUA_TUSERDATA
        , TypeCode
    LUA_TTHREAD
        ]
      shrink :: TypeCode -> [TypeCode]
    shrink = TypeCode -> [TypeCode]
    forall a. a -> [a]
    shrinkNothing

    instance Arbitrary Lua.StatusCode where
      arbitrary :: Gen StatusCode
    arbitrary = [StatusCode] -> Gen StatusCode
    forall a. HasCallStack => [a] -> Gen a
    elements
        [ StatusCode
    LUA_OK
        , StatusCode
    LUA_YIELD
        , StatusCode
    LUA_ERRRUN
        , StatusCode
    LUA_ERRSYNTAX
        , StatusCode
    LUA_ERRMEM
    #if !MIN_VERSION_lua(2,2,0)
        , LUA_ERRGCMM
    #endif
        , StatusCode
    LUA_ERRERR
        , StatusCode
    LUA_ERRFILE
        ]
      shrink :: StatusCode -> [StatusCode]
    shrink = StatusCode -> [StatusCode]
    forall a. a -> [a]
    shrinkNothing

    instance Arbitrary Lua.OPCode where
      arbitrary :: Gen OPCode
    arbitrary = [OPCode] -> Gen OPCode
    forall a. HasCallStack => [a] -> Gen a
    elements
        [ OPCode
    LUA_OPEQ
        , OPCode
    LUA_OPLT
        , OPCode
    LUA_OPLE
        ]
      shrink :: OPCode -> [OPCode]
    shrink = OPCode -> [OPCode]
    forall a. a -> [a]
    shrinkNothing