An open API service indexing awesome lists of open source software.

https://github.com/epost/haskell-ubi-sunt

Predicate logic and relational algebra querying experiments
https://github.com/epost/haskell-ubi-sunt

Last synced: 6 months ago
JSON representation

Predicate logic and relational algebra querying experiments

Awesome Lists containing this project

README

          

#+title:Predicate logic and relational algebra querying experiments in Haskell

Evaluating a relational algebra expression (~RelExp~) like this:

#+BEGIN_SRC haskell
main = do
let
relExp1 :: RelExp
relExp1 =
Project ["fname", "mname", "type"] $
Select (AttrEq "type" (AStr "function")) $
NatJoin (Rel ["f", "type" ] typeAttr) $
NatJoin (Rel ["m", "mname"] nameAttr) $
NatJoin (Rel ["f", "m" ] definedInAttr) $
RelExp (Rel ["f", "fname"] nameAttr)

putStrLn . dumpRel . eval $ relExp1
#+END_SRC

against the following data:

#+BEGIN_EXAMPLE
nameAttr =
[ [AAtom 1, AStr "map" ]
, [AAtom 2, AStr "ap" ]
, [AAtom 3, AStr "lift2" ]
, [AAtom 4, AStr "lift3" ]
, [AAtom 10, AStr "Control.Functor" ]
, [AAtom 11, AStr "Control.Applicative" ]
, [AAtom 20, AStr "purescript-functors" ]
, [AAtom 21, AStr "purescript-applicative" ]
]

definedInAttr =
[ [AAtom 1, AAtom 10]
, [AAtom 2, AAtom 11]
, [AAtom 3, AAtom 11]
, [AAtom 4, AAtom 11]
, [AAtom 10, AAtom 20]
, [AAtom 11, AAtom 21]
]

typeAttr =
[ [AAtom 1, AStr "function" ]
, [AAtom 2, AStr "function" ]
, [AAtom 3, AStr "function" ]
, [AAtom 4, AStr "function" ]
, [AAtom 10, AStr "module" ]
, [AAtom 11, AStr "module" ]
, [AAtom 20, AStr "library" ]
, [AAtom 21, AStr "library" ]
]
#+END_EXAMPLE

gives us:

#+BEGIN_EXAMPLE
attrs = ["fname","mname","type"]
rows =
[AStr "map",AStr "Control.Functor",AStr "function"]
[AStr "ap",AStr "Control.Applicative",AStr "function"]
[AStr "lift2",AStr "Control.Applicative",AStr "function"]
[AStr "lift3",AStr "Control.Applicative",AStr "function"]
#+END_EXAMPLE