1 {-# LANGUAGE DeriveFunctor #-}
2 {-# LANGUAGE TypeFamilies #-}
3 module Language.Symantic.Grammar.Source where
5 import Data.Functor (Functor)
6 import Data.Typeable (Typeable)
11 instance Source () where
14 -- ** Class 'Inj_Source'
15 class Source src => Inj_Source a src where
16 inj_Source :: a -> src
17 instance Inj_Source a () where
20 -- ** Type family 'SourceOf'
21 type family SourceOf a
24 class Source (SourceOf a) => Sourced a where
25 sourceOf :: a -> SourceOf a
26 setSource :: a -> SourceOf a -> a
29 withSource :: Inj_Source src (SourceOf a) => Sourced a => a -> src -> a
30 withSource a src = a `setSource` inj_Source src
32 -- ** Type 'Source_Input'
33 type family Source_Input (src :: *) :: *
34 type instance Source_Input () = ()
41 } deriving (Eq, Ord, Show, Typeable)
44 -- | Attach a 'Source' to something.
49 } deriving (Eq, Functor, Ord, Show, Typeable)