FQL Pipe

I think it will be less verbose if FQL had a Pipe method. Is this in the roadmap?

HI @vasco3, We’re looking onto a redesign of the query language and simplifiy the syntax while preserving it’s composability. We have been looking into using method chaining as a means to reduce the vebosity of FQL, which is in some regards similar to a piping, although not exactly the same.

1 Like

It’s quite possible in JavaScript, even with types. All we need is data-last FQL function signatures. Then we can use pipe from function.ts - fp-ts.

pipe(Var('foo'), Get, Select(['data', 'bar']))

@Bryan_Fauna We can start in JavaScript with fp-ts. Do you know Either? Either map and chain would make FQL super readable and composable :ok_hand:

So I already started. It looks great.

Classic FQL:

  ['data', 'owner'],
  Get(Select(['data', 'thing'], Get(Var('askRef')))),

Pipeable FQL:

  _Select(['data', 'thing']),
  _Select(['data', 'owner']),

// Another example
  _(Var('ask'), _Exists),
  _(Var('ask'), _Get, _Select('ref'), ViewerDelete),

All we need is:

// Pipeable FQL
const _ = pipe;
const _Var = Var;
const _Get = (ref: ExprArg) => Get(ref);
const _GetWithTS = (ts: ExprArg) => (ref: ExprArg) => Get(ref, ts);
const _Select = (path: ExprArg, _default?: ExprArg) => (from: ExprArg) =>
  _default === undefined ? Select(path, from) : Select(path, from, _default);
const _Exists = (ref: ExprArg) => Exists(ref);