1 {-# LANGUAGE DeriveAnyClass #-}
3 module Literate.Database where
5 import Data.List qualified as List
7 import Literate.Document qualified as Doc
8 import Literate.Prelude
10 class Get to from where
13 newtype Ors a = Ors {unOrs :: Set a}
14 deriving (Eq, Ord, Show, Generic)
15 deriving newtype (NFData)
17 instance (Ord a, Doc.ToInline a) => Doc.ToInline (Ors a) where
23 & List.intersperse " | "
26 instance Ord a => IsList (Ors a) where
28 fromList = Ors . fromList
29 toList = toList . unOrs
31 newtype Ands a = Ands {unAnds :: Set a}
32 deriving (Eq, Ord, Show, Generic)
33 deriving newtype (NFData)
35 instance Ord a => IsList (Ands a) where
36 type Item (Ands a) = a
37 fromList = Ands . fromList
38 toList = toList . unAnds
40 instance (Ord a, Doc.ToInline a) => Doc.ToInline (Ands a) where
46 & List.intersperse " & "
49 data Boolean a = BooleanTrue a | BooleanFalse a
50 deriving (Eq, Ord, Show, Generic, NFData)