packages feed

recollections-0.1.0.0: test/Spec.hs

{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}

module Main (main) where

import Data.Recollections.TH
import GHC.Generics

data Things
  = This
  | That
  | Something
  | Else
  | Entirely
  deriving (Eq, Ord, Show, Enum, Bounded, Generic)

mkCollection ''Things
mkIndices ''Things
mkDistribute ''Things
mkIndex ''Things
mkTabulate ''Things

-- data Collection a = Collection
--   { this, that, something, else', entirely :: a
--   }
--   deriving stock (Eq, Show, Generic1, Functor, Foldable, Traversable)
--   deriving Applicative via (Generically1 Collection)

main :: IO ()
main = do
  putStrLn $ "Applicative: " <>  show (pure @Collection ())
  putStrLn ""
  putStrLn $ "indices: " <>  show indices
  putStrLn ""
  putStrLn $ "indices, numeric: " <>  show (fmap fromEnum indices)
  putStrLn ""
  putStrLn $ "Representable.index: " <>  show ([ (t, t == index indices t) | t <- [minBound .. maxBound] ])
  putStrLn ""
  putStrLn $ "Representable.tabulate show: " <>  show (tabulate show)
  putStrLn ""
  putStrLn $ "Ditributive.distribute: " <>  show (distribute [indices])
  putStrLn ""
  putStrLn $ "Ditributive.collect: " <>  show (distribute . fmap (\thing -> pure $ thing == This) $ indices)