2015-11-18 22:23:28 +03:00
|
|
|
module Categorizable where
|
2015-11-18 22:23:35 +03:00
|
|
|
|
2015-11-27 20:02:15 +03:00
|
|
|
import Term
|
|
|
|
import Control.Comonad.Cofree
|
2015-11-18 22:23:35 +03:00
|
|
|
import Data.Set
|
|
|
|
|
|
|
|
class Categorizable a where
|
|
|
|
categories :: a -> Set String
|
2015-11-18 22:25:53 +03:00
|
|
|
|
2015-11-27 20:02:15 +03:00
|
|
|
instance Categorizable annotation => Categorizable (Term a annotation) where
|
|
|
|
categories (annotation :< _) = categories annotation
|
|
|
|
|
2015-11-18 22:25:53 +03:00
|
|
|
comparable :: Categorizable a => a -> a -> Bool
|
2015-11-27 22:49:51 +03:00
|
|
|
comparable a b = not . Data.Set.null $ intersection (categories a) (categories b)
|