mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-12-01 13:52:12 +03:00
25 lines
645 B
Markdown
25 lines
645 B
Markdown
### Composing relations (for LTS-8)
|
|
|
|
Copy the following to "helloworld.hs" for LTS-8:
|
|
|
|
{% highlight haskell %}
|
|
import Database.Relational.Query
|
|
import Data.Int (Int32)
|
|
|
|
hello :: Relation () (Int32, String)
|
|
hello = relation $ return (value 0 >< value "Hello")
|
|
|
|
world :: Relation () (Int32, String)
|
|
world = relation $ return (value 0 >< value "World!")
|
|
|
|
helloWorld :: Relation () ((Int32, String), String)
|
|
helloWorld = relation $ do
|
|
h <- query hello
|
|
w <- query world
|
|
on $ h ! fst' .=. w ! fst'
|
|
return $ (,) |$| ((,) |$| h ! fst' |*| h ! snd') |*| w ! snd'
|
|
|
|
main :: IO ()
|
|
main = putStrLn $ show helloWorld ++ ";"
|
|
{% endhighlight %}
|