Skip to content

Instantly share code, notes, and snippets.

View joshburgess's full-sized avatar
💭
🤔

Josh Burgess joshburgess

💭
🤔
View GitHub Profile
// Trying to simulate do-notation in TypeScript using async/await
// Trying to convert https://codewithstyle.info/advanced-functional-programming-typescript-monads-generators/
// to use async/await. Generators work but aren't type safe because of https://github.com/Microsoft/TypeScript/issues/2983
interface MyPromise<A> {
then<B>(fn: (a: A) => Option<B>): MyPromise<B>
}
export class Option<A> implements MyPromise<A> {
@OliverJAsh
OliverJAsh / foo.ts
Last active June 27, 2018 02:23
Type safe routing with `fp-ts-routing` and `unionize`
import {
end,
int,
lit,
Match,
parse,
Route as RouteBase,
zero
} from "fp-ts-routing";
import { pipe } from "fp-ts/lib/function";
@maddie927
maddie927 / Ref.js
Created May 31, 2018 18:33
react-basic Ref component
"use strict";
var React = require("react");
var ReactDOM = require("react-dom");
exports.makeRef = function(toMaybe) {
var Ref = function(props) {
this.DOMNode = null;
return this;
};
@jship
jship / DictTrick.hs
Last active May 25, 2018 17:35
Small example showing the Dict trick to discover available instances from a GADT
#!/usr/bin/env stack
-- stack --resolver lts-10.8 --install-ghc exec ghci
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
-- A key type for pretend use in looking up a doggo in a database.
newtype Key a = Key { unKey :: String }
@dwhitney
dwhitney / README.md
Last active May 17, 2024 09:25
Quick React Native with PureScript
  1. create-react-native-app purescript-app; cd purescript-app

  2. pulp init --force

  3. pulp build

  4. src/Main.js

var React = require("react");
var RN = require("react-native");

exports.text = function(props){
@Gabriella439
Gabriella439 / package.dhall
Created April 7, 2018 02:45
The Cabal file format encoded as a Dhall type
let Version = ∀(Version : Type) → ∀(v : Text → Version) → Version
in let VersionRange =
∀(VersionRange : Type)
→ ∀(anyVersion : VersionRange)
→ ∀(noVersion : VersionRange)
→ ∀(thisVersion : Version → VersionRange)
→ ∀(notThisVersion : Version → VersionRange)
→ ∀(laterVersion : Version → VersionRange)
→ ∀(earlierVersion : Version → VersionRange)
@carymrobbins
carymrobbins / LensLabels.hs
Created March 16, 2018 21:35
Using labels as lenses with GHC 8
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DeriveGeneric #-}
module LensLabels where
import Prelude
import Control.Lens
import Data.Generics.Labels
import GHC.Generics
@louispan
louispan / ContMonadInterpreter.hs
Last active August 16, 2019 18:03
Continuation monad interpreter
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilyDependencies #-}
-- Example of interpreting using continuation monad instead of the free monad.
module Main where
@rcook
rcook / AWSInfo.hs
Last active April 7, 2023 09:46
AWS via Haskell Part 2 (S3)
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RecordWildCards #-}
module AWSViaHaskell.AWSInfo
( AWSInfo(..)
, LoggingState(..)
, ServiceEndpoint(..)
, getAWSInfo
, withAWS
, withAWS'