Skip to content

Instantly share code, notes, and snippets.

View nmcb's full-sized avatar

nmc.borst nmcb

View GitHub Profile
object DeBruijn {
sealed trait Nat
sealed trait Z extends Nat
sealed trait S[n <: Nat] extends Nat
sealed trait Fin[n <: Nat]
case class FZ[n <: Nat]() extends Fin[S[n]]
case class FS[n <: Nat](n : Fin[n]) extends Fin[S[n]]
val here : Fin[S[S[Z]]] = FZ()
object LambdaCalculus {
sealed trait Type
case class Arrow[S <: Type, T <: Type]() extends Type
case class Base() extends Type
sealed trait Ctx
case class Nil() extends Ctx
case class Cons[X <: Type, XS <: Ctx]() extends Ctx
@pchiusano
pchiusano / zippy.u
Last active November 11, 2020 07:25
Elementwise ("zippy") traversals ability
-- Ability to range over all the elements of a list
ability Each where
each : [a] -> a
-- Implementation detail - standard early termination ability
ability Abort where abort : x
-- Here's a first usage. `each` lets us traverse multiple lists
-- elementwise, matching up values at corresponding indices.
> handle
let Rule
: Type
= ∀(_Rule : Type) →
∀(One : _Rule) →
∀(Two : _Rule) →
∀(Many : List _Rule → _Rule) →
_Rule
let example
: Rule
namespace RFC where
parseDigit = oneOfChars [?0, ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9]
parseHex = Unipar.satisfy isHexDigit "wasn't a hex digit"
parseCRLF = (ch ?\r Unipar.>> ch ?\n)
type RawHeaders
= RawHeaders (Map Text Text)
type Request
= Request HostName Text RawHeaders
foldRight' ::
(b -> z -> z)
-> (a -> b)
-> z
-> [a]
-> z
foldRight' _ _ z [] =
z
foldRight' k f z (x:xs) =
k (f x) (foldRight' k f z xs)
@johnynek
johnynek / dotty_list.scala
Last active January 12, 2020 13:43
Implementation of linked list using dotty features (opaque type, union types, extension methods, type lambda).
// unfortunately
// opaque type Fix[F[_]] = F[Fix[F]]
// won't work (no recursion in opaque type), but this implementation is safe, but scary due to asInstanceOf
object FixImpl {
type Fix[F[_]]
inline def fix[F[_]](f: F[Fix[F]]): Fix[F] = f.asInstanceOf[Fix[F]]
inline def unfix[F[_]](f: Fix[F]): F[Fix[F]] = f.asInstanceOf[F[Fix[F]]]
}
@vil1
vil1 / 🏳️.md
Last active September 8, 2019 00:05

This is a witch hunt.

When you exclude a relentless innovator from a conference, when this exclusion results in excluding the young woman from North-Africa who was supposed to share the stage with him, it has nothing to do with promoting innovation and inclusivity. It is a witch hunt.

When you bar someone from contributing to a FLOSS project based on alleged aggressive communication without providing any concrete example of the said behavior nor explaining what you did to make this behavior stop before taking such extreme decision, it has nothing to do with making your community a better place. It is a witch hunt.

Witch hunts are bad. Not because they burn people with no fair trial and that some of the burnt people may not have been witches in the first place.

Witch hunts are bad because they burn people. Period.

My LambdaConf experience

I just finished an incredible (and exhausting) week at LambdaConf in Boulder, Colorado. I can say with confidence that it's the best programming conference I've attended, and I'm anxious to be able to attend it again in the future.

Stepping outside my comfort zone

I wouldn't call myself terribly experienced - 28 years old and only 4 years out of college - but I have developed a professional comfort in a few areas:

  • Interacting with F# developers
  • Interacting with C# developers
@timvisee
timvisee / falsehoods-programming-time-list.md
Last active June 6, 2024 13:00
Falsehoods programmers believe about time, in a single list

Falsehoods programmers believe about time

This is a compiled list of falsehoods programmers tend to believe about working with time.

Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.

Falsehoods

  • There are always 24 hours in a day.
  • February is always 28 days long.
  • Any 24-hour period will always begin and end in the same day (or week, or month).