It's not quite done yet, I still want to write chapters on e.g. the EuclideanRing and Field classes, but there's plenty there already to get your teeth into. Feedback is very welcome (see the introduction).
droplet is a type-safe SQL library targeting (so far, only) Postgres. Two main features set it apart from similar PureScript (or Haskell) libraries:
SQL like DSL
The eDSL used tries to stay as close as possible to regular SQL. IMO, this has the advantage of making the translation from PureScript to SQL transparent, specially for more complex queries.
So far, most common usage SQL keywords are supported, e.g., SELECT INSERT DELETE UPDATE UNION PREPARE, etc.
Query mapper
Query result rows are always expressed as records, with projected columns as keys. The query mapper can also be used independently from the DSL, in case raw SQL strings are needed.
Feedback is highly welcomed. Specially ideas to improve error messages or ease the current type class abuse :)
Basically, So PureScript compiles all functions with curried and we use immutable data, large number of function calls and copying data slows down execution.
It particularly affected indicators under CPU throttling environment.
I've done a lot of things for performance.
But if you want to make any library faster, there are effective approaches not limited to libraries.
Approaches:
Do not use monad transformer and so on as far as possible
Use Effect.Uncurried and Data.Function.Uncurried
halogen-vdom uses this approach too.
Do not use immutable data as far as possible
You can check why these approaches is effective by checking compiled JavaScript.
PureScript example:
fooReaderT :: ReaderT Unit Effect Int
fooReaderT = do
u <- ask
liftEffect $ add_ u 1 2
fooEffect :: Unit -> Effect Int
fooEffect u =
add_ u 1 2
add_ :: Unit -> Int -> Int -> Effect Int
add_ _ a b = pure $ a + b
fooEffectFn :: EffectFn1 Unit Int
fooEffectFn = mkEffectFn1 \u ->
runEffectFn3 addEffectFn u 1 2
addEffectFn :: EffectFn3 Unit Int Int Int
addEffectFn = mkEffectFn3 _ a b ->
pure $ a + b
Compiled JavaScript:
var add_ = function (v) {
return function (a) {
return function (b) {
return Control_Applicative.pure(Effect.applicativeEffect)(a + b | 0);
};
};
};
var fooEffect = function (u) {
return add_(u)(1)(2);
};
var fooReaderT = Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Effect.bindEffect))(Control_Monad_Reader_Class.ask(Control_Monad_Reader_Trans.monadAskReaderT(Effect.monadEffect)))(function (u) {
return Effect_Class.liftEffect(Control_Monad_Reader_Trans.monadEffectReader(Effect_Class.monadEffectEffect))(add_(u)(1)(2));
});
var addEffectFn = function (v, a, b) {
return a + b | 0;
};
var fooEffectFn = function (u) {
return addEffectFn(u, 1, 2);
};
Some of you might remember that last year, I started working on a guide to the PureScript numeric type class hierarchy in the Prelude - that is, Semiring, Ring, and all the subclasses up to Field - aimed at people who haven't necessarily studied mathematics beyond a high school level. (Previously: https://www.reddit.com/r/purescript/comments/69hgqv/purescript_numeric_hierarchy_guide/)
Now, I'm very pleased to announce that it's essentially complete; everything I wanted to cover has now been covered. If the numeric type class hierarchy seems confusing and you'd like to understand it and the ideas behind it better, this guide is for you! https://a-guide-to-the-purescript-numeric-hierarchy.readthedocs.io/en/latest/