tsc && node main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# lAnGuAgE DataKinds #-} | |
{-# LaNgUaGe FlexibleInstances #-} | |
{-# lAnGuAgE FunctionalDependencies #-} | |
{-# LaNgUaGe KindSignatures #-} | |
{-# lAnGuAgE TypeFamilies #-} | |
{-# LaNgUaGe TypeOperators #-} | |
{-# lAnGuAgE UndecidableInstances #-} | |
module Commit where | |
import Data.Kind (Constraint, Type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE GeneralisedNewtypeDeriving #-} | |
module Data where | |
type UserName = String | |
data DataResult = DataResult String | |
deriving (Eq, Show) | |
class Monad m => Cache m where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find ~/Work -name stack.yaml | xargs grep -o '^resolver: \([^#]*\)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Cancel = void | ((k: (r: void) => void) => void) | |
export const runCancel = (c: Cancel, k: (r: void) => void): void => | |
c ? c(k) : k() | |
export type Fx<H, A> = (handler: H, k: (a: A) => void) => Cancel | |
export type Pure<A> = Fx<{}, A> | |
export const handle = <H0, H1, A>(fx: Fx<H0 & H1, A>, h1: H1): Fx<H0, A> => | |
(h0, k) => fx({ ...h0, ...h1 } as H0 & H1, k) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- a continuation of https://gist.github.com/gelisam/137effb33d2777328d366dcb563d8d13 | |
{-# LANGUAGE FlexibleContexts, FlexibleInstances, GeneralizedNewtypeDeriving, LambdaCase, MultiParamTypeClasses #-} | |
module EIO where | |
import Control.Monad | |
import Data.Void | |
import Test.DocTest | |
import qualified Control.Exception as E | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(cell_update)] | |
use std::fmt::Display; | |
use std::cell::Cell; | |
pub trait IO: Sized { | |
type Output; | |
fn exec(self) -> Self::Output; | |
} | |
pub trait IOExt : IO { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// funciona somente com v3.1.6, essa estrategia de end/continue | |
// era um backdoor para fazer recursao em types, recursao funcionava somente com interfaces | |
// antigamente pela resolucao de tipos ser lazyness e nao acabar fazendo o compiler cair | |
// potencialmente em um looping infinito na resolucao do tipo, por causa disto tem validacao | |
// no compiler agora e codigos nesse estilo sao barrados pelo compiler | |
type Init<T extends any[], TTail extends any[] = TailArray<T>> = CastArray<{ | |
[K in keyof TTail]: T[keyof T & K]; | |
}> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- EXAMPLE THAT WOULD BE WRONG | |
// -- wrongBurgerSpec :: IxBurgerBuilder Ready TopBunOn BurgerSpec | |
// -- wrongBurgerSpec = getEmptyPlate | |
// -- :>>= placeEmptyBun | |
// -- :>>= addKetchup | |
// -- :>>= addCheese -- Can't match PattyOn with BottomBunOn, since we haven't put on the patty, the most important part!!! | |
// -- :>>= addOnions | |
// -- :>>= noLettuce | |
// -- :>>= addTomato | |
// -- :>>= addTopBun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -- OUR AMAZING INDEXED BURGER SPEC FROM READY TO TOP BUN ON | |
// burgerSpec :: IxBurgerBuilder Ready TopBunOn BurgerSpec | |
// burgerSpec = getEmptyPlate | |
// :>>= placeEmptyBun | |
// :>>= addKetchup | |
// :>>= addPatty | |
// :>>= addCheese | |
// :>>= addOnions | |
// :>>= noLettuce | |
// :>>= addTomato |