Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Osheim non

  • Providence / Philly
View GitHub Profile
View gist:8697842
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 Feb 1, 2014
ncursesw formula for homebrew. not sure where this came from but it seemed to work
View gist:8756312
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'
View example.scala
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 Mar 11, 2014
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.
View scala-bug-bash-guide.md

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 Aug 29, 2015
Fun little program to display N digits of Pi in any base (2-36) using Spire.
View build.sbt
// 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 Mar 17, 2014
First pass at continued fractions in Scala. Still a lot left to be done.
View cf.scala
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 {
View gist:11202545
# 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]
View cosine.scala
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)
}
View gist:aba13319c097bced2fb9
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 Aug 29, 2015
Attempt to use kind-projector to support @mandubian's use case as presented here: https://gist.github.com/mandubian/55f8b1fb9f9bec2c0a99
View xyz.scala
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 {