Skip to content

Instantly share code, notes, and snippets.

The analogy is comparing writing programs to buying goods:
writing a program with static types is equivalent to buying
with cash, and writing a program with dynamic types is
equivalent to buying with credit.
The "cost" in either case is mental energy and time. When I
write a program with static types I spend a lot of effort up
front, guided by the type system and compiler, to handle edge
cases and generate a totally correct solution. I have to
fully-understand any libraries I'm using and characterize
@non
non / gist:8756312
Created February 1, 2014 18:24
ncursesw formula for homebrew. not sure where this came from but it seemed to work
require 'formula'
class Ncursesw <Formula
#url 'http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz'
#md5 'cce05daf61a64501ef6cd8da1f727ec6'
url 'ftp://invisible-island.net/ncurses/ncurses-5.8.tar.gz'
sha256 '51597f89fd53aa990321954e33e5b4869c4a5ee6137bfa800f98f91d4b6b54b5'
#url 'ftp://invisible-island.net/ncurses/ncurses-5.9.tar.gz'
package demo
case class Wrapper[A](arr: Array[A])
object Wrapper {
def literal[A](as: A*): Wrapper[A] = wrapperMacro
}
object Example {
@non
non / scala-bug-bash-guide.md
Created March 11, 2014 21:47
Basic overview of open issues for bug bash participants. Doesn't currently include links to issues, but every item should have a (tagged) open issue.

Bugs, Features, and Ideas for Future Work

Note that some exotic types and features may need to go into spire-contrib first to see how widely-used they are.

There is a obviously a balance between ultra-minimal and kitchen-sink approaches, although the math community seems to favor kitchen-sink. In general we are happy to accept new functionality provided that it seems to fit into the overall pattern of what's already there.

@non
non / build.sbt
Last active August 29, 2015 13:57
Fun little program to display N digits of Pi in any base (2-36) using Spire.
// this is the build file used to compile piday.scala
name := "piday"
scalaVersion := "2.10.3"
libraryDependencies += "org.spire-math" %% "spire" % "0.7.3"
@non
non / cf.scala
Created March 17, 2014 15:25
First pass at continued fractions in Scala. Still a lot left to be done.
package spire.math
import scala.annotation.tailrec
case class InvalidCFError(msg: String) extends Exception(msg)
object Xyz { type Z = SafeLong }
import Xyz.Z
object Eval {
# i am using capital letters for type variables
#
# i am also probably over-annotating types just to try to be clear what is going on
# assume we have a function type
f1 ^A ^B = ...magic..
# simple pair type
pair ^A = match [^x1: A, ^x2: A]
def genericCosineSimilarity[V, @sp(Double) A](v1: V, v2: V)(implicit ips: InnerProductSpace[V, A], nr: NRoot[A]): A = {
implicit val field = ips.scalar
implicit val nvs = ips.normed
(v1 dot v2) / (v1.norm * v2.norm)
}
sealed trait Order {
def price: Int
}
case class Buy(price: Int) extends Order
case class Sell(price: Int) extends Order
sealed trait ValidTrade[A <: Order, B <: Order]
object Allowed {
@non
non / xyz.scala
Last active August 29, 2015 14:02
Attempt to use kind-projector to support @mandubian's use case as presented here: https://gist.github.com/mandubian/55f8b1fb9f9bec2c0a99
package xyz
import language.higherKinds
import scalaz._
import Scalaz._
import scala.concurrent.Future
// see https://github.com/non/kind-projector for more info about what is going on here
object Test {