<commit_before>{-# LANGUAGE GADTs , EmptyDataDecls , ExistentialQuantification , RankNTypes #-}

module OpenCog.AtomSpace.Types (
    TruthVal (..)
  , AtomName (..)
  , Atom (..)
  , AtomGen (..)
  , appAtomGen
  , TNumberNode
  , TConceptNode
  ) where

type AtomName = String

data TruthVal = SimpleTruthVal Double Double
              | CountTruthVal Double Double Double
              | IndefiniteTruthVal Double Double Double Double
    deriving Show

data TConceptNode
data TNumberNode

data AtomGen where
    AtomGen :: Atom a -> AtomGen

appAtomGen :: (forall a. Atom a -> b) -> AtomGen -> b
appAtomGen f (AtomGen at) = f at

data Atom a where -- TODO: Review the types constraints, add Attention Values, etc.
    -- Predicate
    Predicate   :: AtomName -> Atom (Atom a -> TruthVal)
    And         :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Or          :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Implication :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Equivalence :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Evaluation  :: (Atom (Atom a -> TruthVal))  ->
                      Atom [AtomGen] -> (Maybe TruthVal) -> Atom a

    -- Concept
    Concept       :: AtomName -> Atom TConceptNode
    Inheritance   :: Atom TConceptNode -> Atom TConceptNode -> (Maybe TruthVal) -> Atom a
    Similarity    :: Atom TConceptNode -> Atom TConceptNode -> (Maybe TruthVal) -> Atom a
    Member        :: Atom TConceptNode -> Atom TConceptNode -> (Maybe TruthVal) -> Atom a
    SatisfyingSet :: Atom (Atom a -> TruthVal) -> Atom TConceptNode

    -- Number
    Number :: (Num a) => a -> Atom TNumberNode

    -- List
    List :: [AtomGen] -> Atom [AtomGen]

<commit_msg>Add Show instance to Atom types.<commit_after>{-# LANGUAGE GADTs , EmptyDataDecls , ExistentialQuantification , RankNTypes #-}

module OpenCog.AtomSpace.Types (
    TruthVal (..)
  , AtomName (..)
  , Atom (..)
  , AtomGen (..)
  , appAtomGen
  , TNumberNode
  , TConceptNode
  ) where

type AtomName = String

data TruthVal = SimpleTruthVal Double Double
              | CountTruthVal Double Double Double
              | IndefiniteTruthVal Double Double Double Double
    deriving Show

data TConceptNode
data TNumberNode

data AtomGen where
    AtomGen :: Atom a -> AtomGen

appAtomGen :: (forall a. Atom a -> b) -> AtomGen -> b
appAtomGen f (AtomGen at) = f at

data Atom a where -- TODO: Review the types constraints, add Attention Values, etc.
    -- Predicate
    Predicate   :: AtomName -> Atom (Atom a -> TruthVal)
    And         :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Or          :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Implication :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Equivalence :: Atom a -> Atom a -> (Maybe TruthVal) -> Atom a
    Evaluation  :: (Atom (Atom a -> TruthVal))  ->
                      Atom [AtomGen] -> (Maybe TruthVal) -> Atom a

    -- Concept
    Concept       :: AtomName -> Atom TConceptNode
    Inheritance   :: Atom TConceptNode -> Atom TConceptNode -> (Maybe TruthVal) -> Atom a
    Similarity    :: Atom TConceptNode -> Atom TConceptNode -> (Maybe TruthVal) -> Atom a
    Member        :: Atom TConceptNode -> Atom TConceptNode -> (Maybe TruthVal) -> Atom a
    SatisfyingSet :: Atom (Atom a -> TruthVal) -> Atom TConceptNode

    -- Number
    Number :: (Num a,Show a) => a -> Atom TNumberNode

    -- List
    List :: [AtomGen] -> Atom [AtomGen]

instance Show AtomGen where
    show (AtomGen at) = concat' ["AtomGen",show at]

instance Show (Atom a) where
    show (Predicate n)         = concat' ["Predicate",show n]
    show (And a1 a2 m)         = concat' ["And",show a1,show a2,show m]
    show (Or a1 a2 m)          = concat' ["Or",show a1,show a2,show m]
    show (Implication a1 a2 m) = concat' ["Implication",show a1,show a2,show m]
    show (Equivalence a1 a2 m) = concat' ["Equivalence",show a1,show a2,show m]
    show (Evaluation a1 a2 m)  = concat' ["Evaluation",show a1,show a2,show m]
    show (Concept n)           = concat' ["Concept",show n]
    show (Inheritance a1 a2 m) = concat' ["Inheritance",show a1,show a2,show m]
    show (Similarity a1 a2 m)  = concat' ["Similarity",show a1,show a2,show m]
    show (Member a1 a2 m)      = concat' ["Member",show a1,show a2,show m]
    show (SatisfyingSet a)     = concat' ["SatisfyingSet",show a]
    show (Number n)            = concat' ["Number",show n]
    show (List l)              = concat' ["List",show l]

concat' (a:b:xs) = a ++ " " ++ concat' (b:xs)
concat' (b:[])   = b
concat' []       = ""

{'fraction_non_alphanumeric': 0.12516440157825515, 'fraction_numerical': 0.0070144673388864535, 'mean_word_length': 2.454201362604088, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 77, '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': '5000585', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1578, 'n_words': 496}