Skip to content

Instantly share code, notes, and snippets.

View dewey92's full-sized avatar
🌴

Jihad D. Waspada dewey92

🌴
View GitHub Profile
@ENvironmentSet
ENvironmentSet / st-formal.ts
Last active December 30, 2020 11:13
ST Monad In Typescript
// Sorry for poor naming, this example was intented to explain how to use skolem capturing in practise.
interface Stateful<S, A> {
(state: S): [A, S]
}
function fmap<S, A, B>(f: (a: A) => B): (stateful: Stateful<S, A>) => Stateful<S, B> {
return stateful => state => {
const [a, nextState] = stateful(state);
@konn
konn / Data.Aeson.Generic.DerivingVia.hs
Last active December 7, 2020 21:06
Type-driven safe derivation of ToJSON and FromJSON, using DerivingVia in GHC 8.6 and some type-level hacks
{-# LANGUAGE ConstraintKinds, DataKinds, DeriveGeneric, DerivingVia #-}
{-# LANGUAGE ExplicitNamespaces, FlexibleContexts, FlexibleInstances #-}
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds, ScopedTypeVariables, StandaloneDeriving #-}
{-# LANGUAGE TypeApplications, TypeFamilies, TypeInType, TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wall #-}
module Data.Aeson.Generic.DerivingVia
( StrFun(..), Setting(..), SumEncoding'(..), DefaultOptions, WithOptions(..)
, -- Utility type synonyms to save ticks (') before promoted data constructors
anonymous
anonymous / gist:343672a4f1d3f2b4a84b9f296f2a62b6
Created June 26, 2017 05:33
simon peyton jones papers
https://www.microsoft.com/en-us/research/wp-content/uploads/2017/03/haskell-linear-submitted.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2017/03/demand-jfp-draft.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/12/cardinality-jfp-2.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/trees-that-grow-2.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/levity-1.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/join-points-pldi17.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/dps-submitted.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/bolingbroke-thesis.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/10/wand-book-chapter.pdf
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/10/cont-frac-spj-1984-2.pdf

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@staltz
staltz / introrx.md
Last active June 26, 2024 10:24
The introduction to Reactive Programming you've been missing
@Fristi
Fristi / Aggregate.hs
Last active November 6, 2022 20:50
DDD/Event Sourcing in Haskell. Implemented an aggregate as a type class and type families to couple event, command and error types specific to the aggregate. Errors are returned by using Either (Error e) (Event e). Applying Applicative Functors fits here well to sequentially check if the command suffice.
{-# LANGUAGE TypeFamilies #-}
import Data.Function (on)
import Control.Applicative
data EventData e = EventData {
eventId :: Int,
body :: Event e
}