definition:
|
uniqueUpdate :: (Read t, Show t, Eq a, Show a) =>
String -> (Key -> t -> Dynamic) -> (Key -> t -> en)
-> (en -> Key) -> (en -> a) -> en -> Transaction ()
uniqueUpdate ename entrypred info2entry keyf selector obj =
let oldkey = keyf obj
in
getDB (getDBInfo entrypred oldkey) |>>=
maybe (errorT (TError KeyNotExistsError
("database contains no entry for key: "++show oldkey)))
(\oldt -> getDB (allDBKeyInfos entrypred) |>>= \kis ->
let oldentry = info2entry oldkey oldt
entries = filter (\e -> selector obj == selector e)
(map (uncurry info2entry) kis)
in if null entries ||
(length entries == 1 && selector oldentry == selector obj)
then doneT
else errorT (TError UniqueError
(ename++" entry for unique attribute "
++show (selector obj)++" already exists")))
|
demand:
|
no demanded arguments
|
deterministic:
|
deterministic operation
|
failfree:
|
<FAILING>
|
indeterministic:
|
referentially transparent operation
|
infix:
|
no fixity defined
|
iotype:
|
{(_,_,_,_,_,_,_,_,_,_) |-> _}
|
name:
|
uniqueUpdate
|
precedence:
|
no precedence defined
|
result-values:
|
_
|
signature:
|
(Prelude.Read a, Prelude.Show a, Prelude.Eq c, Prelude.Show c) => String
-> (Prelude.Int -> a -> Database.KeyDatabaseSQLite.Dynamic) -> (Prelude.Int -> a
-> b) -> (b -> Prelude.Int) -> (b -> c) -> b
-> Database.KeyDatabaseSQLite.Transaction ()
|
solution-complete:
|
operation might suspend on free variables
|
terminating:
|
possibly non-terminating
|
totally-defined:
|
possibly non-reducible on same data term
|