Skip to content

Instantly share code, notes, and snippets.

View Terkwood's full-sized avatar
🦑

Terkwood Terkwood

🦑
  • Salesforce
  • Indiana, USA
  • 12:00 (UTC -04:00)
View GitHub Profile
@Terkwood
Terkwood / after-note.tpl
Created October 2, 2021 23:34
show timestamp in emanote
<!-- templates/hooks/after-note.tpl -->
<ema:metadata>
<span class="mr-2 text-right text-gray-600">
<value var="date" />
</span>
</ema:metadata>
@chiroptical
chiroptical / babyShark.hs
Last active February 3, 2023 15:23
Baby shark as a Haskell program
{-# LANGUAGE BlockArguments #-}
module Main where
main :: IO ()
main = do
babyShark
do do do do do do babyShark
do do do do do do babyShark
do do do do do do babyShark

Understanding Comparative Benchmarks

I'm going to do something that I don't normally do, which is to say I'm going to talk about comparative benchmarks. In general, I try to confine performance discussion to absolute metrics as much as possible, or comparisons to other well-defined neutral reference points. This is precisely why Cats Effect's readme mentions a comparison to a fixed thread pool, rather doing comparisons with other asynchronous runtimes like Akka or ZIO. Comparisons in general devolve very quickly into emotional marketing.

But, just once, today we're going to talk about the emotional marketing. In particular, we're going to look at Cats Effect 3 and ZIO 2. Now, for context, as of this writing ZIO 2 has released their first milestone; they have not released a final 2.0 version. This implies straight off the bat that we're comparing apples to oranges a bit, since Cats Effect 3 has been out and in production for months. However, there has been a post going around which cites various compar

@rebeccaskinner
rebeccaskinner / ByteRing.hs
Created June 14, 2021 05:24
RingBuffer In A Byte String
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE ForeignFunctionInterface #-}
module ByteRing where
import Foreign.Ptr
import Foreign.C.Types
import Foreign.C.String
import Foreign.ForeignPtr
import System.Posix.Types
import System.Posix.Internals
@RaasAhsan
RaasAhsan / Lambda.scala
Last active April 21, 2021 11:19
Type-level, untyped lambda calculus in Scala 3
object Lambda extends App {
sealed trait Term
sealed trait Var[I <: Index] extends Term
sealed trait App[T1 <: Term, T2 <: Term] extends Term
sealed trait Abs[T1 <: Term] extends Term
sealed trait If[T1 <: Term, T2 <: Term, T3 <: Term] extends Term
sealed trait Bool[T1 <: Boolean] extends Term
sealed trait Index
@dvanhorn
dvanhorn / linux_transcript.md
Last active January 25, 2021 22:17
problem running indirect function call via ffi

Here's a transcipt of something very similar that seems to result in an infinite loop on Linux. :(

dvanhorn@starburst:small $ cat f.c
int f() {
  return 42;
}

int (*ptr_to_f)() = f;

About variadics in Rust

This is an analysis of how variadic generics could be added to Rust. It's not a proposal so much as a summary of existing work, and a toolbox for creating an eventual proposal.

Introduction

Variadic generics (aka variadic templates, or variadic tuples), are an often-requested feature that would enable traits, functions and data structures to be generic over a variable number of types.

To give a quick example, a Rust function with variadic generics might look like this:

@seratch
seratch / HomeController.scala
Last active March 26, 2023 14:17
Slack app built with Play Framework (Scala)
package controllers
import javax.inject._
import play.api.mvc._
@Singleton
class HomeController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
def index() = Action { implicit request: Request[AnyContent] =>
Ok("Hello World!")
@edmundsmith
edmundsmith / writeup.md
Created July 7, 2019 20:47
Method for Emulating Higher-Kinded Types in Rust

Method for Emulating Higher-Kinded Types in Rust

Intro

I've been fiddling about with an idea lately, looking at how higher-kinded types can be represented in such a way that we can reason with them in Rust here and now, without having to wait a couple years for what would be a significant change to the language and compiler.

There have been multiple discussions on introducing higher-ranked polymorphism into Rust, using Haskell-style Higher-Kinded Types (HKTs) or Scala-looking Generalised Associated Types (GATs). The benefit of higher-ranked polymorphism is to allow higher-level, richer abstractions and pattern expression than just the rank-1 polymorphism we have today.

As an example, currently we can express this type:

use std::collections::HashMap;
use std::fmt;
use std::io;
use std::num::ParseFloatError;
use std::rc::Rc;
/*
Types
*/