Skip to content

Instantly share code, notes, and snippets.

View nmcb's full-sized avatar

nmc.borst nmcb

View GitHub Profile

On 'Default' Type Class Instances

TLDR Q: How does one idiomatically implement 'default' type class instances in Haskell?

I was playing around with 'default' type class instances in Scala, trying to understand how to program them as "idiomatically functional as possible in that language". And also to understand Scala's rules and (possible) limitations when it comes to type classes. As part of that humble goal I decided to limit myself to Scala the language, i.e. not Scala the language and some-library. And, to understand better whether I was on the right track, I decided to port the example I created to Haskell as well, mainly because I wanted to compare the two implementations. Probably because in Haskell I'm a novice coder at best, I stumbled upon the question above. Because the port in Haskell required all sort of language pragmas, while it seemed quite naturally in Scala.

So what do I mean with 'default' type class instances. Functionally, I want to provide an "extension method" for all typ

@nmcb
nmcb / WhyLeaveLightbendOrTypesafe.md
Last active February 6, 2017 06:02
Q&A With Jamie Allen

From a "technology is the application of scientific knowledge for practical purposes" POV, ordered for convenience, not priority:

  1. Can we, for the purpose of these questions, agree on what my MacBook's ODE tells me is, the meaning of technology?
  2. Has working for lightbend/typesafe changed your view of Commerce?
  3. Has a lifetime of computing technology changed your view of Commerce?
  4. What type of commercially valuable, non-technology purpose did you advocate your customers while at lightbend/typesafe?
  5. What type of commercially valuable, technology purpose did you advocate your customers at lightbend/typesafe?
  6. Why move from a tech distribution company to a (mild) drug distribution company? (No offence intended, I'm a user)
  7. What type of commercially valuable, non-technology purpose do you advocate your customers currently?
  8. What type of commercially valuable, technology purpose do you advocate your customers currently?

EWD621, by E.W Dijkstra [1]


Speech eight to my students, spring 1977

I must make you aware and part of an observation that is scary to the brink of death. Recently I cited, from the rightmost column of the front page of the Saturday addition of the 23rd of April 1977 of the NRC [2], after I had asked who they thought was cited, the following sentence within family circle:

"I'm more interested in the upholding of moral behavior of high standards, than I am in politics."

@nmcb
nmcb / InfinityTheDarkSide.md
Last active June 17, 2019 22:40
One of those days...

Infinity - The Dark Side

Infinity is not a space without limits. It's not beautiful, not magical, it has no answers, just one question. Why? Infinity is a small square cramped room, the sealing so low that you can't standup straight, the walls so near that you are unable to stretch out. Not that you dare to anyways. It's hot in that endless room, humid, decaying, century old, water stained paint curls down from a yellow ceiling, breaks, and falls in flakes down on a rotting, threadbare, yellowish green carpet from which a repugnant smell evaporates, musky and sour. A nauseating yeasty dust hangs in the air, seemingly alive, attacking your nostrils and mouth, cluttering your eyes, your ears, it sticks to your whimpers, while sweat pours from your forehead mixing the dust into a watery clay, a muddy stream, a film of opaque liquid that stings your eyes and strains your vision.

It's dark. Just a tiny flickering flame sputters up from the last bit of a wax candle on top of a wobbly, thin long, copper

A Glorious Accident?

The following pearl is quoted literally from a lengthy conversation of the TV documentary 'A Glorious Accident', or 'A Schitterend Ongeluk' in Dutch. A documentary that run in the 90s on Dutch public television. [1]

The conversation at a certain point was, two hours already, going on between Oliver Sacks, Daniel C. Dennett and Stephen J. Gould, among other eminent scientists, who had been mostly silent for the last 15 minutes or so. The question being discussed was how brains, humans and (possibly) other "wetware" organisms, evolve into having a specific identity. A specific sence of self. At that stage in the conversation the three of them allready agreed with each other that the some form of continues categorization is required as the underlying principle for organisms to have a self or identity; that what defines us individually is the way we categorize our perception of reality. The self, the identity grows on the continuation of that categorizing fueled by accumulating

trait Color
case object Black extends Color
case object White extends Color
type Pair = Tuple2[Color,Color]
case class Urn(b: Int, w: Int) {
require (b >= 0 && w >= 0 && b + w >= 1)
lazy val random = new java.util.Random
private def takeOne(): (Color, Urn) = {
def countOneBits(l: Long) = {
val Hex55 = 0x5555555555555555L
val Hex33 = 0x3333333333333333L
val Hex0F = 0x0F0F0F0F0F0F0F0FL
val Hex01 = 0x0101010101010101L
var x = l - ((l >> 1) & Hex55)
x = (x & Hex33) + ((x >> 2) & Hex33)
x = (x + (x >> 4)) & Hex0F
(x * Hex01) >> 56
}
actor Main
new creat(env: Env) =>
env.out.print("Mon frère")
# Standards & Values (Normen en Waarden)
I have no right to decide on the truth of scientific principles, nor to prescribe in any way the
character of the questions investigated. I may observe the aesthetic value of artistic creations
and assign this value trough written prose, and I should experiment with the limits of forms of
literacy and artistic expression. I may express differences of view with the validity of
economic, historic, religious, or philosophical doctrines and their dogmas as communicated through
written prose. I have a duty to my fellow primates to maintain freedom, to let individuals among
them contribute to the further adventure and the development of the human race.
"Math is composable" --B. Beckmann's Pragmatical argument, at work 2014
"Math is discovered" --P. Wadler's Modus Ponens argument, Lambda Days 2016
"Math is invented" --B. Meliwsky's Composition argument, Lambda Days 2016