1 {-# LANGUAGE DeriveFunctor #-}
2 {-# LANGUAGE TypeFamilies #-}
3 module Language.Symantic.Grammar.Source where
7 import Text.Show (Show)
8 import Data.Functor (Functor)
9 import Data.Typeable (Typeable)
12 class Source src where
14 instance Source () where
17 -- ** Class 'SourceInj'
18 class Source src => SourceInj a src where
20 instance SourceInj a () where
23 -- ** Type family 'SourceOf'
24 type family SourceOf a
26 -- ** Type 'Sourceable'
27 class Source (SourceOf a) => Sourceable a where
28 sourceOf :: a -> SourceOf a
29 setSource :: a -> SourceOf a -> a
32 withSource :: SourceInj src (SourceOf a) => Sourceable a => a -> src -> a
33 withSource a src = a `setSource` sourceInj src
35 -- ** Type 'Source_Input'
36 type family Source_Input (src :: *) :: *
37 type instance Source_Input () = ()
44 } deriving (Eq, Ord, Show, Typeable)
47 -- | Attach a 'Source' to something.
52 } deriving (Eq, Functor, Ord, Show, Typeable)