on master help sign in
remove example in preference of test
commit49cb34d97c5fc20229114110ad940c255a75ee59 authorAgentM <agentm@themactionfaction.com> dateWed 13 Jun 2018, 17:21 (8 years ago) parentd8ab441
1 file changed−43
examples/NonEmptyListAtomable.hs−43
examples/NonEmptyListAtomable.hsdeleted−43
@@ -1,43 +0,0 @@
1−{-# LANGUAGE DeriveGeneric, DeriveAnyClass, OverloadedStrings #-}
2−import ProjectM36.Client
3−import ProjectM36.Relation.Show.Term
4−import GHC.Generics
5−import Data.Text
6−import Data.Binary
7−import Control.DeepSeq
8−import qualified Data.Map as M
9−import qualified Data.Text.IO as TIO
10−import Data.Proxy
11−import Data.List.NonEmpty
12−
13−data AtLeastOne = NonEmpty Int
14− deriving (Generic, Show, Eq, Binary, NFData, Atomable)
15−
16−main :: IO ()
17−main = do
18− --connect to the database
19− let connInfo = InProcessConnectionInfo NoPersistence emptyNotificationCallback []
20− eCheck v = do
21− x <- v
22− case x of
23− Left err -> error (show err)
24− Right x' -> pure x'
25− conn <- eCheck $ connectProjectM36 connInfo
26−
27− --create a database session at the default branch of the fresh database
28− sessionId <- eCheck $ createSessionAtHead conn "master"
29−
30− --create the data type in the database context
31− eCheck $ executeDatabaseContextExpr sessionId conn (toAddTypeExpr (Proxy :: Proxy AtLeastOne))
32−
33− --create a relation with the new AtLeastOne AtomType
34− let nonempty = NakedAtomExpr (toAtom ((1 ::Int):|[]) )
35− let list = NakedAtomExpr (toAtom ((1 ::Int):[]) )
36− eCheck $ executeDatabaseContextExpr sessionId conn (Assign "people" (MakeRelationFromExprs Nothing [
37− TupleExpr (M.fromList [("nonempty", nonempty), ("list", list)])]))
38−
39− let restrictionPredicate = AttributeEqualityPredicate "atleastone" nonempty
40− peopleRel <- eCheck $ executeRelationalExpr sessionId conn (Restrict restrictionPredicate (RelationVariable "people" ()))
41−
42− TIO.putStrLn (showRelation peopleRel)
43−