{-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-}
module Autolib.Letters where
import Autolib.Set
class Ord b => Letters a b | a -> b where
letters :: a -> Set b
instance ( Letters a c, Letters b c ) => Letters (a, b) c where
letters :: (a, b) -> Set c
letters (a
a, b
b) = Set c -> Set c -> Set c
forall {a}. Ord a => Set a -> Set a -> Set a
union (a -> Set c
forall a b. Letters a b => a -> Set b
letters a
a) (b -> Set c
forall a b. Letters a b => a -> Set b
letters b
b)
instance Letters a c => Letters [a] c where
letters :: [a] -> Set c
letters [a]
xs = [Set c] -> Set c
forall {f :: * -> *} {a}. (Foldable f, Ord a) => f (Set a) -> Set a
unionManySets ([Set c] -> Set c) -> [Set c] -> Set c
forall a b. (a -> b) -> a -> b
$ (a -> Set c) -> [a] -> [Set c]
forall a b. (a -> b) -> [a] -> [b]
map a -> Set c
forall a b. Letters a b => a -> Set b
letters [a]
xs