packages feed

recollections-0.1.1.0: test-kmettoverse/Nested/Outer.hs

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}

module Nested.Outer (checks) where

import Data.Distributive (Distributive(..))
import Data.Foldable (toList)
import Data.Functor.Rep (Representable(..))
import Data.Recollections.TH
import GHC.Generics
import Nested.Inner qualified as Inner

data Tag
  = Front Inner.Tag
  | Local
  | Back Inner.Tag
  deriving (Eq, Ord, Show)

mkCollection ''Tag
mkIndices ''Tag
mkDistributive ''Tag
mkRepresentable ''Tag
mkBounded ''Tag
mkEnum ''Tag

checks :: [(String, Bool)]
checks =
  [ ("nested index . indices", all (\t -> index indices t == t) [minBound .. maxBound])
  , ("nested tabulate id", tabulate id == indices)
  , ("nested distribute", distribute (Just indices) == fmap Just indices)
  , ("nested enum order", toList indices == [minBound .. maxBound])
  ]