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
- Host: GitHub
- URL: https://github.com/epost/haskell-ubi-sunt
- Owner: epost
- Created: 2015-09-22T20:22:25.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-09-22T20:23:02.000Z (about 10 years ago)
- Last Synced: 2025-02-08T07:11:54.812Z (8 months ago)
- Language: Haskell
- Size: 105 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
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_SRCagainst 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_EXAMPLEgives 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