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 'SourceInj'
15 class Source src => SourceInj a src where
17 instance SourceInj 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 :: SourceInj src (SourceOf a) => Sourced a => a -> src -> a
30 withSource a src = a `setSource` sourceInj 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)