Using Side-Effects to Inspect Data

Published: 1/18/2020
Last edited: 1/26/2020


Trace is a simple pattern which allows for invoking a binary side-effect in composition - normally we want to stay away from side-effects, but here we're exploiting side-effects to very simply augment our composed pipeline:

import {__, pipe, curry} from 'ramda'
const traceSideEffect = curry((fn, a, b) => {
  fn(a, b)
  return b
const trace = traceSideEffect(console.log)
// OR (shameless plug)
// import {trace} from 'xtrace'
const addAndDivide = curry(
  (a, b, c) => pipe(
    trace('a + b'),
    divide(__, c),


Published: 1/18/2020
Last edited: 1/26/2020
Content by brekk
See this page on Github
Built with 💛 by Open Sorcerers
Created with Gatsby using the 😎 foresight starter