The following are appendices from Optics By Example, a comprehensive guide to optics from beginner to advanced! If you like the content below, there's plenty more where that came from; pick up the book!
{-# LANGUAGE AllowAmbiguousTypes #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE DerivingStrategies #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE InstanceSigs #-} | |
{-# LANGUAGE KindSignatures #-} |
#!/usr/bin/env stack | |
-- stack --resolver lts-14.20 --install-ghc runghc --package either --package free | |
{-# LANGUAGE DeriveFunctor #-} | |
module Main | |
where | |
import Control.Applicative.Free | |
import Data.Bifunctor (first) | |
import Data.Either.Combinators (maybeToRight) | |
import Data.Either.Validation |
Most JavaScript developers love making modern applications, with our new language features and latest libraries making our life easier, but has any one ever actually wondered if this ever impacts our users.
We are dealing with abstractions, abstractions are trying to cover a general use case which could not be conforming to yours. Some are over-engineered in ways one can't possibly comprehend, use cases that will never be reached by middle sized applications. Some of these over
At work, I just spent the last few weeks exploring and evaluating every format I could find, and my number one criteria was whether they supported sum types. I was especially interested in schema languages in which I could describe my types and then some standard specifies how to encode them using an on-the-wire format, usually JSON.
- Swagger represents sum types like Scala does, using subtyping. So you have a parent type
EitherIntString
with two subtypesLeft
andRight
represented as{"discriminator": "Left", value: 42}
and{"discriminator": "Right", value": "foo"}
. Unfortunately, unlike in Scala in which the parent type is abstract and cannot be instantiated, in Swagger it looks like the parent type is concrete, so when you specify that your input is anEitherIntString
, you might receive{"discriminator": "EitherIntString"}
instead of one of its two subtypes. - JSON-schema supports unions, which isn't quite the same thing as sum types because
title | author |
---|---|
Glassery |
Oleg Grenrus |
After I have
improved the raw performance
of optika
– a JavaScript optics library,
it's time to make the library (feature-)complete and sound.
Gathering and classifying all possible optic types, gives us a reference point
module MemCache = { | |
type t; | |
[@bs.deriving abstract] | |
type config = {initialState: Js.Json.t}; | |
type conf = Js.Json.t; | |
[@bs.module "graphql-hooks-memcache"] | |
external _createMemCache: config => t = "default"; |
propertyId | agentId | |
---|---|---|
132 | 50000 | |
99 | 50001 | |
105 | 50002 | |
120 | 50002 | |
58 | 50003 | |
46 | 50005 | |
65 | 50006 | |
66 | 50006 | |
118 | 50011 |
buyerNeedId | agentId | |
---|---|---|
293 | 2324 | |
313 | 1531 |