Package fj.control.db
Class DB<A>
java.lang.Object
fj.control.db.DB<A>
The DB monad represents a database action, or a value within the context of a database connection.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal F
<Connection, Callable<A>> Returns the callable-valued function projection of this database action.final <B> DB
<B> Binds the given action across the result of this database action.static <A> DB
<A> db
(F<Connection, A> f) Constructs a database action as a function from a database connection to a value.static <A> DB
<A> db
(Try1<Connection, A, SQLException> t) Constructs a database action as a function from a database connection to a value.static <A> DB
<A> Removes one layer of monadic structure.Promotes any given function so that it transforms between values in the database.final <B> DB
<B> Map a function over the result of this action.abstract A
run
(Connection c) Executes the database action, given a database connection.static <A> DB
<A> unit
(A a) Constructs a database action that returns the given value completely intact.
-
Constructor Details
-
DB
public DB()
-
-
Method Details
-
run
Executes the database action, given a database connection.- Parameters:
c
- The connection against which to execute the action.- Returns:
- The result of the action.
- Throws:
SQLException
- if a database error occurred.
-
db
Constructs a database action as a function from a database connection to a value.- Parameters:
f
- A function from a database connection to a value.- Returns:
- A database action representing the given function.
-
db
Constructs a database action as a function from a database connection to a value.- Parameters:
t
- A function from a database connection to a value allowed to throw SQLException- Returns:
- A database action representing the given function.
-
asFunction
Returns the callable-valued function projection of this database action.- Returns:
- The callable-valued function which is isomorphic to this database action.
-
map
Map a function over the result of this action.- Parameters:
f
- The function to map over the result.- Returns:
- A new database action that applies the given function to the result of this action.
-
liftM
Promotes any given function so that it transforms between values in the database.- Parameters:
f
- The function to promote.- Returns:
- A function equivalent to the given one, which operates on values in the database.
-
unit
Constructs a database action that returns the given value completely intact.- Parameters:
a
- A value to be wrapped in a database action.- Returns:
- A new database action that returns the given value.
-
bind
Binds the given action across the result of this database action.- Parameters:
f
- The function to bind across the result of this database action.- Returns:
- A new database action equivalent to applying the given function to the result of this action.
-
join
Removes one layer of monadic structure.- Parameters:
a
- A database action that results in another.- Returns:
- A new database action equivalent to the result of the given action.
-