Skip to content

Instantly share code, notes, and snippets.

View kejace's full-sized avatar

Kristoffer Josefsson kejace

  • NYC / LA and in between
  • X @kejace
View GitHub Profile
@mikesol
mikesol / sketch.dhall
Last active October 3, 2022 19:05
Yet another Dhall-API-protocol proposal
let fold = https://prelude.dhall-lang.org/List/fold
let filter = https://prelude.dhall-lang.org/List/filter
let equal = https://prelude.dhall-lang.org/Natural/equal
let Obj = <User | Pet | List>
let Key = <Id | Type | Name | Pets | Head | Tail>
let Entry = <Int_: Integer | Bool_: Bool | Double_: Double | Text_: Text | Id_: Natural | Type_: Obj | Nil>
let Row = { ptr: Natural, key: Key, val: Entry }
let Db = List Row
@chshersh
chshersh / parser-combinators-vs-parser-generators.md
Last active June 12, 2023 11:06
Per criterion comparison of Parser Generators and Parser Combinators

Legend:

  • ➖ poor (impossible or very hard to achieve)
  • ➕ good (possible but requires some dancing)
  • ✔️ excellent (very easy to achieve/have)

PC stands for parser combinators and PGparser generators.

Property Generators Combinators Description
Power ✔️ LALR ➕ LL(∞) PC can't handle left-recursive grammars (though, there's some article¹...).
@bryc
bryc / YamahaFM.md
Last active May 17, 2024 03:45
Collecting info on Yamaha FM soundchips
--Roughly based on https://github.com/Gabriel439/Haskell-Morte-Library/blob/master/src/Morte/Core.hs by Gabriel Gonzalez et al.
data Expr = Star | Box | Var Int | Lam Int Expr Expr | Pi Int Expr Expr | App Expr Expr deriving (Show, Eq)
subst v e (Var v') | v == v' = e
subst v e (Lam v' ta b ) | v == v' = Lam v' (subst v e ta) b
subst v e (Lam v' ta b ) = Lam v' (subst v e ta) (subst v e b )
subst v e (Pi v' ta tb) | v == v' = Pi v' (subst v e ta) tb
subst v e (Pi v' ta tb) = Pi v' (subst v e ta) (subst v e tb)
subst v e (App f a ) = App (subst v e f ) (subst v e a )
@i-am-tom
i-am-tom / MapRecord.purs
Last active November 9, 2020 20:53
MapRecord for PureScript, with and without comments!
module MapRecordWithComments where
-- | Type-level Tomfoolery. A million thankyous to @kcsongor and his
-- | unparallelled patience with me while I try to figure this stuff
-- | out.
import Prelude (($), (+), (<>), discard, show)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
@danoneata
danoneata / Sudoku.hs
Last active August 20, 2022 01:27
Applicative-based Sudoku solver
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Applicative
import Data.Char
import Data.List (intersperse)
import Data.Monoid hiding (All, Any)
import Data.Foldable hiding (all, any)
import Prelude hiding (all, any)
@alexvandesande
alexvandesande / ethernalsale.js
Last active October 21, 2021 04:40
This is a first draft at what could be a continuous token sale. I just wrote it and haven't tested it but it shows the proof of concept: tokens are continuously generated in any curve desired and sold for the highest bidder. Since there's a maximum token sale speed, this guarantees that sales can't end too quickly. Since the sale always starts f…
pragma solidity ^0.4.2;
contract ethernalSale {
struct order {
uint amount;
address buyer;
}
mapping (uint => order) orderBook;
mapping (address => uint) balanceOf;
@mtesseract
mtesseract / haskell-records.md
Last active March 8, 2023 22:25
Working around Haskell's namespace problem for records

The Problem

Defining records in Haskell causes accessor functions for the record's fields to be defined. There is no seperate namespace for these accessor functions.

The Goal

Be able to

  • use records in Haskell, which share field names.
  • use lenses for accessing these fields
@chriseth
chriseth / async.md
Last active December 26, 2023 09:13
Async Solidity Contracts

Having seen @pirapira's sketch of Bamboo ( https://github.com/pirapira/bamboo/ ), which proposed to add better control about the "smart contract program flow", even across calls, I thought that this should certainly be added to Solidity, and actually, it might even be possible now to a certain degree using inline assembly.

The problem is that with many functions in a contract, it is not always clear which can be called at which stage in the contract's lifetime. Certain smart contracts would be easier to understand if written as follows:

@Icelandjack
Icelandjack / Constraints.org
Last active April 2, 2024 20:22
Type Classes and Constraints

Reddit discussion.

Disclaimer 1: Type classes are great but they are not the right tool for every job. Enjoy some balance and balance to your balance.

Disclaimer 2: I should tidy this up but probably won’t.

Disclaimer 3: Yeah called it, better to be realistic.

Type classes are a language of their own, this is an attempt to document features and give a name to them.