Skip to content

Instantly share code, notes, and snippets.

View pjrt's full-sized avatar
🤔
Thinking about why Github now has statuses

Pedro Rodriguez Tavarez pjrt

🤔
Thinking about why Github now has statuses
View GitHub Profile
@pjrt
pjrt / TypeclassBox.hs
Last active July 26, 2018 08:55
A Typeclass Box in Haskell. Allows for a single type to represent any type that responds to a typeclass.
{-# LANGUAGE GADTs, ConstraintKinds, FlexibleInstances, RankNTypes #-}
-- Our typeclass with a simple foo :: a -> String func
class Foo a where
foo :: a -> String
-- Our test data types and their instances of Foo
data MyFoo = MyFoo String
data MyBar = MyBar Int
@seanf
seanf / 81-thinkpad-dock.rules
Last active March 20, 2023 10:42
Example ThinkPad docking script for multi-monitor
# Save this file (after modifying ID_VENDOR and ID_MODEL if necessary) as /etc/udev/rules.d/81-thinkpad-dock.rules
# These values seem to work for "ThinkPad Mini Dock Plus Series 3"
SUBSYSTEM=="usb", ACTION=="add|remove", ENV{ID_VENDOR}=="17ef", ENV{ID_MODEL}=="100a", RUN+="/etc/sbin/thinkpad-dock.sh"
@malcolmgreaves
malcolmgreaves / TaggedTypeScalaMacroIdea.md
Last active February 27, 2019 22:29
Idea for a Scala macro to make working with tagged types more ergonomic.

Main Point

Idea for a Scala macro to make working with tagged types more ergonomic.

Explanation

As a user, I want to define two variables:

  • $TYPE : The name of the new type that we are creating.
  • $CONTENT : The actual, underlying content of the new type.

This will define a new type called $TYPE that is a transparent, no-overhead wrapper around a value of type $CONTENT.

@pjrt
pjrt / transitive.hs
Last active March 4, 2019 16:29
Transitive typeclass instances in Haskell
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-}
{-# LANGUAGE FunctionalDependencies, TypeApplications #-}
import Data.Proxy
data User
class MyClass a b | b -> a
instance MyClass Char Int