<commit_before>{-# LANGUAGE TypeFamilies #-}

module TypedMorphism (
      mapping
    , typedMorphism
    , TypedMorphism
) where

import Graph (Graph)
import GraphMorphism
import Morphism
import Valid

data TypedMorphism a b = TypedMorphism {
                              getDomain   :: GraphMorphism a b
                            , getCodomain :: GraphMorphism a b
                            , getMapping  :: GraphMorphism a b
                         }

typedMorphism = TypedMorphism
mapping = getMapping

instance (Eq a, Eq b) => Eq (TypedMorphism a b) where
    (TypedMorphism dom1 cod1 m1) == (TypedMorphism dom2 cod2 m2) =
        dom1 == dom2 &&
        cod1 == cod2 &&
        m1 == m2

instance (Eq a, Eq b) => Morphism (TypedMorphism a b) where
    type Obj (TypedMorphism a b) = GraphMorphism a b

    domain = getDomain
    codomain = getCodomain
    compose t1 t2 =
        TypedMorphism (domain t1)
                      (codomain t2)
                      $ compose (getMapping t1)
                                (getMapping t2)
    id t = TypedMorphism t t (Morphism.id $ domain t)
    monomorphism = monomorphism . mapping
    epimorphism = epimorphism . mapping
    isomorphism = isomorphism . mapping


instance (Eq a, Eq b) => Valid (TypedMorphism a b) where
    valid (TypedMorphism dom cod m) =
        valid dom &&
        valid cod &&<commit_msg>TypedMorphism -> TypedGraphMorphism<commit_after>{-# LANGUAGE TypeFamilies #-}

module TypedGraphMorphism (
      mapping
    , typedMorphism
    , TypedGraphMorphism
) where

import Graph (Graph)
import GraphMorphism
import Morphism
import Valid

data TypedGraphMorphism a b = TypedGraphMorphism {
                              getDomain   :: GraphMorphism a b
                            , getCodomain :: GraphMorphism a b
                            , getMapping  :: GraphMorphism a b
                         }

typedMorphism = TypedGraphMorphism
mapping = getMapping

instance (Eq a, Eq b) => Eq (TypedGraphMorphism a b) where
    (TypedGraphMorphism dom1 cod1 m1) == (TypedGraphMorphism dom2 cod2 m2) =
        dom1 == dom2 &&
        cod1 == cod2 &&
        m1 == m2

instance (Eq a, Eq b) => Morphism (TypedGraphMorphism a b) where
    type Obj (TypedGraphMorphism a b) = GraphMorphism a b

    domain = getDomain
    codomain = getCodomain
    compose t1 t2 =
        TypedGraphMorphism (domain t1)
                      (codomain t2)
                      $ compose (getMapping t1)
                                (getMapping t2)
    id t = TypedGraphMorphism t t (Morphism.id $ domain t)
    monomorphism = monomorphism . mapping
    epimorphism = epimorphism . mapping
    isomorphism = isomorphism . mapping


instance (Eq a, Eq b) => Valid (TypedGraphMorphism a b) where
    valid (TypedGraphMorphism dom cod m) =
        valid dom &&
        valid cod &&
{'fraction_non_alphanumeric': 0.07027406886858749, 'fraction_numerical': 0.012649332396345749, 'mean_word_length': 1.9472049689440993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6406081', 'n_tokens_mistral': 901, 'n_tokens_neox': 839, 'n_words': 269}