Skip to content

Question: Struct monoid - boilerplate #1630

Answered by samhh
maljac asked this question in Q&A
Discussion options

You must be logged in to vote
  1. I don't believe so. TypeScript has no inherent notion of typeclasses so there's a lot of instance-passing like this. On the plus side, this does offer extra flexibility without the need for newtype wrappers.
  2. I think there's a problem before you reach this point, your static configuration is being parsed unnecessarily. Here's another approach to consider in which we don't sacrifice the non-nullability of the default:
declare const defCol: Column
declare const extCol: Option<TTColumn>

const mergeCol = (x: Column) => (y: TTColumn): Column => ({
  ...x,
  field: y.field,
  hidden: pipe(y.hidden, O.getOrElse(constant(x.hidden))),
  layout: pipe(y.layout, O.getOrElse(constant(x.layout))),
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@maljac
Comment options

Answer selected by maljac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants