Skip to content

Instantly share code, notes, and snippets.

@ksaldana1
ksaldana1 / layers.ts
Last active October 4, 2024 16:27
Layer Composition - Effect.ts
import { Context, Effect, Layer, pipe } from "effect";
class Config extends Context.Tag("Config")<
Config,
{
readonly getConfig: Effect.Effect<{
readonly logLevel: string;
readonly connection: string;
}>;
}
@ksaldana1
ksaldana1 / easymotion.json
Created August 23, 2019 16:54
easymotion settings in vscode
{
"vim.easymotion": true,
"vim.easymotionMarkerHeight": 20,
"vim.easymotionMarkerWidthPerChar": 12,
"vim.easymotionMarkerFontSize": "16",
"vim.easymotionMarkerBackgroundColor": "#428aff",
"vim.easymotionMarkerForegroundColorOneChar": "#fffcfc",
"vim.easymotionMarkerForegroundColorTwoChar": "#fffcfc",
"vim.easymotionMarkerFontFamily": "Arial",
"vim.normalModeKeyBindingsNonRecursive": [
@ksaldana1
ksaldana1 / keybase.md
Created April 24, 2023 15:01
keybase.md

Keybase proof

I hereby claim:

  • I am ksaldana1 on github.
  • I am ksaldana (https://keybase.io/ksaldana) on keybase.
  • I have a public key ASBUNkRku9I4HSFgickNwlwMqY1Pr3Qo8ZQa-klYe3bumAo

To claim this, I am signing this object:

Domain Modeling with Tagged Unions in GraphQL, ReasonML, and TypeScript

GraphQL has exploded in popularity since its open-source announcement in 2015. For developers who had spent a lot of time managing data transformations from their back-end infrastructure to match front-end product needs, GraphQL felt like a tremendous step forwards. Gone were the days of hand-writing BFFs to manage problems of over-fetching.

A lot of value proposition arguments around GraphQL have been about over/under fetching, getting the data shape you ask for, etc. But I think GraphQL provides us more than that—it gives us an opportunity to raise the level of abstraction of our domain, and by doing so allow us to write more robust applications that accurately model the problems we face in the real world (changing requirements, one-off issues).

An underappreciated feature of GraphQL is its type system, and in particular features like [union types](https:

type Query {
messages: [Message!]!
}
type Message {
id: ID!
text: String!
author: MessageAuthor!
}
@ksaldana1
ksaldana1 / re_example_4.re
Created March 13, 2020 01:32
re_example_4
module Styles = {
open Css;
let app =
style([
display(`flex),
justifyContent(`center),
alignItems(`center),
flexDirection(`column),
minHeight(`vh(100.0)),
@ksaldana1
ksaldana1 / re_example_fix_2.re
Created March 13, 2020 01:32
re_example_fix_2.re
module Styles = {
open Css;
let app =
style([
display(`flex),
justifyContent(`center),
alignItems(`center),
flexDirection(`column),
minHeight(`vh(100.0)),
@ksaldana1
ksaldana1 / re_example_2.re
Created March 13, 2020 01:30
re_example_2
module Styles = {
open Css;
let app =
style([
display(`flex),
justifyContent(`center),
alignItems(`center),
flexDirection(`column),
minHeight(`vh(100.0)),
@ksaldana1
ksaldana1 / re_example_1_4.re
Created March 13, 2020 01:30
re_example_1.4
[@react.component]
let make = () => {
let query = Query.use(~variables=(), ());
<div className=Styles.app>
{Belt.Array.map(query.messages, message => {
switch (message.author) {
| `User(user) =>
<div> {React.string(user.name ++ ": " ++ message.text)} </div>
| `Guest(guest) =>
<div>
@ksaldana1
ksaldana1 / re_example_1_3.re
Created March 13, 2020 01:29
re_example_1.3
module Styles = {
open Css;
let app =
style([
display(`flex),
justifyContent(`center),
alignItems(`center),
flexDirection(`column),
minHeight(`vh(100.0)),