{-# LANGUAGE DeriveAnyClass #-} module Literate.Database where import Data.List qualified as List import Literate.Document qualified as Doc import Literate.Prelude class Get to from where get :: from -> to newtype Ors a = Ors {unOrs :: Set a} deriving (Eq, Ord, Show, Generic) deriving newtype (NFData) instance (Ord a, Doc.ToInline a) => Doc.ToInline (Ors a) where toInline xs = xs & unOrs & toList <&> Doc.toInline & List.intersperse " | " & Doc.toInline instance Ord a => IsList (Ors a) where type Item (Ors a) = a fromList = Ors . fromList toList = toList . unOrs newtype Ands a = Ands {unAnds :: Set a} deriving (Eq, Ord, Show, Generic) deriving newtype (NFData) instance Ord a => IsList (Ands a) where type Item (Ands a) = a fromList = Ands . fromList toList = toList . unAnds instance (Ord a, Doc.ToInline a) => Doc.ToInline (Ands a) where toInline xs = xs & unAnds & toList <&> Doc.toInline & List.intersperse " & " & Doc.toInline data Boolean a = BooleanTrue a | BooleanFalse a deriving (Eq, Ord, Show, Generic, NFData)