Skip to content

Instantly share code, notes, and snippets.

View gclaramunt's full-sized avatar

Gabriel Claramunt gclaramunt

View GitHub Profile
@milessabin
milessabin / gist:cadd73b7756fe4097ca0
Last active September 16, 2019 13:44
A new approach to encoding dependently-typed chained implicits, using singleton types ...
object Demo {
// A couple of type classes with type members ...
trait Foo[T] {
type A
}
object Foo {
implicit val fooIS = new Foo[Int] { type A = String }
}
@jessitron
jessitron / haskellyte.md
Created August 1, 2014 16:12
Gershom's Letter to a Young Haskell Enthusiast, condensed. I removed a lot of words, kept the themes, moved a few around a bit.

Letter to a Young Haskell Enthusiast, by Gershom Bazerman.

Condensed from: http://comonad.com/reader/2014/letter-to-a-young-haskell-enthusiast/

The following letter is about tendencies that come with the flush of excitement of learning any new thing. It is written specifically, because if we don't talk specifics, the generalities make no sense. It is a letter full of things I want to remember.

You’ve entered the world of strongly typed functional programming, and it is great. You want to share the great things you’ve learned, and you want to slay all the false statements in the world.

@pchiusano
pchiusano / type-inhabitants.markdown
Last active January 7, 2023 17:23
Reasoning about type inhabitants in Haskell

This is material to go along with a 2014 Boston Haskell talk.

We are going to look at a series of type signatures in Haskell and explore how parametricity (or lack thereof) lets us constrain what a function is allowed to do.

Let's start with a decidedly non-generic function signature. What are the possible implementations of this function which typecheck?

wrangle :: Int -> Int
@puffnfresh
puffnfresh / AlaCarte.hs
Created April 1, 2014 22:46
Coproduct to combine algebras for a free monad interpreter.
module AlaCarte where
-- Control.Monad.Free
data Free f a = Free (f (Free f a)) | Pure a
instance Functor f => Monad (Free f) where
Pure a >>= f = f a
Free r >>= f = Free (fmap (>>= f) r)
return = Pure
@munificent
munificent / gist:9749671
Last active June 23, 2022 04:04
You appear to be creating a new IDE...
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
@softprops
softprops / jvm_tools.md
Last active August 29, 2015 13:57
some ( not all ) helpful tools the jvm provides out of the box
  • hprof a builtin java agent which dumps profiling info at runtime
  • class sharing class file cache used for faster startup times
  • pack200 unpack200 uber packed jars
  • mission control a Profiling, Monitoring, and Diagnostics Tools Suite
  • jstat performance stats tool
  • jhat heap dump browser
  • jmap memory maps
  • jstack prints stack trace of running process
@bitemyapp
bitemyapp / gist:9402223
Last active June 24, 2016 14:25
Getting Scala users moved over

Play Framework vs. the relative messiness of Yesod/Snap/Happstack/Scotty/raw WAI. Clojure has a similar (to Haskell's) story here. I'm understating it here, but this is pretty big. Most web applications are not special snowflakes, a framework to wrap-up common-case nonsense concisely is very valuable. Micro-framework stacks like using WAI directly or Scotty are good to have, but insufficient.

Specialized NLP libraries (in Java, at present) such as for medical lexicons. Might be replicable by being layered on top of existing Haskell NLP libs, but doesn't yet exist to my knowledge. Hardening up libraries like this usually takes a lot of time.

Slick is nicer and easier to get started with than Persistent. Partly due to documentation, partly because Slick isn't silly and embraces relational databases directly, partly because Persistent is just kind of hairy. Supporting MongoDB isn't a plus, it's a minus. Compromises the API anyway.

A migrations library of pretty much any sort at all.

Scala/xml equivalent i

@milessabin
milessabin / gist:5831007
Created June 21, 2013 13:03
Case class members with shapeless 2.0.0-SNAPSHOT.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import shapeless._
import shapeless._
@nuttycom
nuttycom / Functorial
Last active December 18, 2015 08:09
A hypothesis as to what functors, monads, etc. might look like if the value type were not universally quantified, but instead could be restricted by requirement for other typeclass instances. Universal quantification could still be achieved, of course; hence this provides a more flexible generalization of our familiar typeclasses. This grew out …
trait Functorial[F[_], B] {
def map[A](m: F[A])(f: A => B): F[B]
}
trait Monadic[M[_], B] extends Functorial[F, B] {
def point(b: B): M[B]
def flatMap[A](m: M[A])(f: A => M[B]): M[B]
}
trait Traversial[F[_], B] {
import Data.Foldable
import Data.Monoid
pipeline :: [a -> a] -> a -> a
pipeline = appEndo . getDual . foldMap (Dual . Endo)
main = print $ pipeline [(+1), (*10)] 100