(.module: [lux (#- and int) [control [functor (#+ Contravariant)] [monad (#+ Monad do)]] [data ["." error (#+ Error)] [collection ["." list ("#;." fold)]]] [time ["." instant (#+ Instant)]] ["." io (#+ IO)] [world [binary (#+ Binary)]] [host (#+ import:)]]) (import: #long java/lang/String) (do-template [] [(import: #long (new [long]))] [java/sql/Date] [java/sql/Time] [java/sql/Timestamp] ) (`` (import: #long java/sql/PreparedStatement (~~ (do-template [ ] [( [int ] #try void)] [setBoolean boolean] [setByte byte] [setShort short] [setInt int] [setLong long] [setFloat float] [setDouble double] [setString java/lang/String] [setBytes (Array byte)] [setDate java/sql/Date] [setTime java/sql/Time] [setTimestamp java/sql/Timestamp] )))) (type: #export (Input a) (-> a [Nat java/sql/PreparedStatement] (Error [Nat java/sql/PreparedStatement]))) (structure: #export contravariant (Contravariant Input) (def: (map-1 f fb) (function (fa value circumstance) (fb (f value) circumstance)))) (def: #export (and pre post) (All [l r] (-> (Input l) (Input r) (Input [l r]))) (function (_ [left right] context) (do error.monad [context (pre left context)] (post right context)))) (def: #export (fail error) (All [a] (-> Text (Input a))) (function (_ value [idx context]) (#error.Failure error))) (def: #export empty (Input Any) (function (_ value context) (#error.Success context))) (do-template [ ] [(def: #export (Input ) (function (_ value [idx statement]) (do error.monad [_ ( (.int idx) value statement)] (wrap [(.inc idx) statement]))))] [boolean Bit java/sql/PreparedStatement::setBoolean] [byte Int java/sql/PreparedStatement::setByte] [short Int java/sql/PreparedStatement::setShort] [int Int java/sql/PreparedStatement::setInt] [long Int java/sql/PreparedStatement::setLong] [float Frac java/sql/PreparedStatement::setFloat] [double Frac java/sql/PreparedStatement::setDouble] [string Text java/sql/PreparedStatement::setString] [bytes Binary java/sql/PreparedStatement::setBytes] ) (do-template [ ] [(def: #export (Input Instant) (function (_ value [idx statement]) (do error.monad [_ ( (.int idx) ( (instant.to-millis value)) statement)] (wrap [(.inc idx) statement]))))] [date java/sql/PreparedStatement::setDate java/sql/Date::new] [time java/sql/PreparedStatement::setTime java/sql/Time::new] [time-stamp java/sql/PreparedStatement::setTimestamp java/sql/Timestamp::new] )