Skip to content

Instantly share code, notes, and snippets.

View gclaramunt's full-sized avatar

Gabriel Claramunt gclaramunt

View GitHub Profile
19:07 ~/Projects/Kepler_typemacros/sandbox (topic/typemacros)$ scalac Macros.scala
19:07 ~/Projects/Kepler_typemacros/sandbox (topic/typemacros)$ scala -cp .
Welcome to Scala version 2.10.1-20121120-175733-b60f5bcf2c (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.
scala> class C extends AnyRef with Macros.Foo[Int]("2")
defined class C
scala> new C().hello
@paulp
paulp / The Signs of Soundness
Last active June 17, 2021 06:48
The Signs of Soundness
Hello scala, my old friend
I've come to take you home again
Because a feature slowly creeping
left me plagued with doubts and weeping
and the version that was tagged in the repo
just has to go
it lacks the signs of soundness
On sleepless nights I hacked alone
applying ant and other tools of stone
import Data.Foldable
import Data.Monoid
pipeline :: [a -> a] -> a -> a
pipeline = appEndo . getDual . foldMap (Dual . Endo)
main = print $ pipeline [(+1), (*10)] 100
@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] {
@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._
@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

@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
@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:
@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
@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