-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathDefaultMorphism.hs
48 lines (37 loc) · 1.46 KB
/
DefaultMorphism.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{- |
Module : $Header$
Description : supply a default morphism for a given signature type
Copyright : (c) C. Maeder, and Uni Bremen 2002-2006
License : GPLv2 or higher, see LICENSE.txt
Maintainer : Christian.Maeder@dfki.de
Stability : provisional
Portability : portable
Supply a default morphism for a given signature type
-}
-- due to functional deps the instance for Logic.Category cannot be supplied
module Common.DefaultMorphism
( DefaultMorphism(..) -- constructor is only exported for ATC
, ideOfDefaultMorphism
, compOfDefaultMorphism
, defaultInclusion
) where
import Common.Keywords
import Common.Doc
import Common.DocUtils
data DefaultMorphism sign = MkMorphism
{ domOfDefaultMorphism :: sign
, codOfDefaultMorphism :: sign
} deriving (Show, Eq, Ord)
instance Pretty a => Pretty (DefaultMorphism a) where
pretty = printDefaultMorphism pretty
printDefaultMorphism :: (a -> Doc) -> DefaultMorphism a -> Doc
printDefaultMorphism fA (MkMorphism s t) =
text "inclusion" $+$ specBraces (fA s) $+$ text mapsTo <+> specBraces (fA t)
ideOfDefaultMorphism :: sign -> DefaultMorphism sign
ideOfDefaultMorphism s = MkMorphism s s
compOfDefaultMorphism :: Monad m => DefaultMorphism sign
-> DefaultMorphism sign -> m (DefaultMorphism sign)
compOfDefaultMorphism (MkMorphism s1 _) (MkMorphism _ s3) =
return $ MkMorphism s1 s3
defaultInclusion :: Monad m => sign -> sign -> m (DefaultMorphism sign)
defaultInclusion s = return . MkMorphism s