Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9a73563009
Fetching contributors…

Cannot retrieve contributors at this time

executable file 175 lines (152 sloc) 5.741 kb
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
--------------------------------------------------------------------------------
-- $Id: BuiltInRules.hs,v 1.2 2003/12/18 18:27:46 graham Exp $
--
-- Copyright (c) 2003, G. KLYNE. All rights reserved.
-- See end of this file for licence information.
--------------------------------------------------------------------------------
-- |
-- Module : BuiltInRules
-- Copyright : (c) 2003, Graham Klyne
-- License : GPL V2
--
-- Maintainer : Graham Klyne
-- Stability : provisional
-- Portability : H98
--
-- This module collects references and provides access to all of the
-- rulesets, variable binding modifiers and variable binding filters
-- built in to Swish.
--
--------------------------------------------------------------------------------

module Swish.HaskellRDF.BuiltInRules
    ( findRDFOpenVarBindingModifier
    , rdfRulesetMap
    , allRulesets, allDatatypeRulesets
    )
where

import Swish.HaskellRDF.BuiltInDatatypes
    ( allDatatypes )

import Swish.HaskellRDF.RDFVarBinding
    ( RDFOpenVarBindingModify
    , rdfVarBindingUriRef, rdfVarBindingBlank
    , rdfVarBindingLiteral
    , rdfVarBindingUntypedLiteral, rdfVarBindingTypedLiteral
    , rdfVarBindingXMLLiteral, rdfVarBindingDatatyped
    , rdfVarBindingMemberProp
    )

import Swish.HaskellRDF.RDFRuleset
    ( RDFRuleset, RDFRulesetMap )

import Swish.HaskellRDF.RDFProofContext
    ( rulesetRDF
    , rulesetRDFS
    , rulesetRDFD )

import Swish.HaskellRDF.VarBinding
    ( nullVarBindingModify
    , makeVarFilterModify
    , varFilterEQ, varFilterNE
    )

import Swish.HaskellRDF.Datatype
    ( typeRules
    , typeMkModifiers
    )

import Swish.HaskellUtils.LookupMap
    ( LookupMap(..)
    , mapFindMaybe
    )

import Swish.HaskellUtils.Namespace
    ( ScopedName(..) )

------------------------------------------------------------
-- Declare variable binding filters list
------------------------------------------------------------

-- |List of rdfOpenVarBindingModify values for predefined filters
--
rdfVarBindingFilters :: [RDFOpenVarBindingModify]
rdfVarBindingFilters =
    [ filter1 rdfVarBindingUriRef
    , filter1 rdfVarBindingBlank
    , filter1 rdfVarBindingLiteral
    , filter1 rdfVarBindingUntypedLiteral
    , filter1 rdfVarBindingTypedLiteral
    , filter1 rdfVarBindingXMLLiteral
    , filter1 rdfVarBindingMemberProp
    , filter2 rdfVarBindingDatatyped
    -- , filterN nullVarBindingModify
    , filter2 varFilterEQ
    , filter2 varFilterNE
    ]
    where
        filter1 f lbs = makeVarFilterModify $ f (lbs!!0)
        filter2 f lbs = makeVarFilterModify $ f (lbs!!0) (lbs!!1)
        -- filterN f lbs = makeVarFilterModify $ f ...

------------------------------------------------------------
-- Declare variable binding modifiers map
------------------------------------------------------------

rdfVarBindingModifiers :: [RDFOpenVarBindingModify]
rdfVarBindingModifiers =
    [ nullVarBindingModify
    ]

------------------------------------------------------------
-- Find a named built-in OpenVarBindingModifier
------------------------------------------------------------

allOpenVarBindingModify :: [RDFOpenVarBindingModify]
allOpenVarBindingModify =
    rdfVarBindingFilters ++
    rdfVarBindingModifiers ++
    dtsVarBindingModifiers

-- dtsVarBindingModifiers = concatMap dtVarBindingModifiers allDatatypes
dtsVarBindingModifiers = concatMap typeMkModifiers allDatatypes

{-
dtVarBindingModifiers dtval =
map (makeRdfDtOpenVarBindingModify dtval) (tvalMod dtval)
-}

findRDFOpenVarBindingModifier :: ScopedName -> Maybe RDFOpenVarBindingModify
findRDFOpenVarBindingModifier nam =
    mapFindMaybe nam (LookupMap allOpenVarBindingModify)

------------------------------------------------------------
-- Lookup map for built-in rulesets
------------------------------------------------------------

rdfRulesetMap :: RDFRulesetMap
rdfRulesetMap = LookupMap allRulesets

allRulesets :: [RDFRuleset]
allRulesets =
    [ rulesetRDF
    , rulesetRDFS
    , rulesetRDFD
    ]
    ++ allDatatypeRulesets

allDatatypeRulesets :: [RDFRuleset]
allDatatypeRulesets = map typeRules allDatatypes

--------------------------------------------------------------------------------
--
-- Copyright (c) 2003, G. KLYNE. All rights reserved.
--
-- This file is part of Swish.
--
-- Swish is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- Swish is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Swish; if not, write to:
-- The Free Software Foundation, Inc.,
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
--------------------------------------------------------------------------------
-- $Source: /file/cvsdev/HaskellRDF/BuiltInRules.hs,v $
-- $Author: graham $
-- $Revision: 1.2 $
-- $Log: BuiltInRules.hs,v $
-- Revision 1.2 2003/12/18 18:27:46 graham
-- Datatyped literal inferences all working
-- (except equivalent literals with different datatypes)
--
-- Revision 1.1 2003/12/17 16:56:39 graham
-- Split content of BuiltInMap into separate modules, to avoid recursive
-- module dependency with RDFProofContext.
--
Something went wrong with that request. Please try again.