-- |
-- Module      : Test.LeanCheck.Instances.Array
-- Copyright   : (c) 2019-2022 Rudy Matela
-- License     : 3-Clause BSD  (see the file LICENSE)
-- Maintainer  : Rudy Matela <rudy@matela.com.br>
--
-- Declares 'Listable' 'Array'
--
-- This 'Listable' instance imposes a 'Num' restriction on the index.
module Test.LeanCheck.Instances.Array () where

import Test.LeanCheck
import Data.Array

instance (Num i, Ix i, Listable i, Listable a) => Listable (Array i a) where
  tiers :: [[Array i a]]
tiers = forall a b c. (Listable a, Listable b) => (a -> b -> c) -> [[c]]
cons2 forall {i} {e}. (Ix i, Num i) => i -> [e] -> Array i e
mkArray
    where
    mkArray :: i -> [e] -> Array i e
mkArray i
l [e]
xs = forall i e. Ix i => (i, i) -> [e] -> Array i e
listArray (i
l, i
l forall a. Num a => a -> a -> a
+ forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (t :: * -> *) a. Foldable t => t a -> Int
length [e]
xs forall a. Num a => a -> a -> a
- Int
1)) [e]
xs