This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import scalaz.syntax.bitraverse._ | |
import scalaz.syntax.bitraverse._ | |
scala> import scalaz.std.tuple._ | |
import scalaz.std.tuple._ | |
scala> (List(1,2,3), List("a")).leftMap(_.map(_ + 1)) | |
res0: (List[Int], List[String]) = (List(2, 3, 4),List(a)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun build-package-name (pn d) | |
(if (null d) | |
pn | |
(let ((c (car d))) | |
(if (equal c "scala") | |
pn | |
(build-package-name (concat c "." pn) (cdr d)))))) | |
(defun scala-package-name-from-buffer () | |
(let ((l (reverse (split-string (buffer-file-name) "/")))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This tries to find where the Spec/test of the current buffer lives, | |
and either creates it, or visits it | |
#+begin_src emacs-lisp | |
(defun split-path-of-file (f) | |
"return dirname.filename" (let ((sp (reverse (split-string f "/")))) | |
(cons (mapconcat 'identity (reverse (cdr sp)) "/") (car sp)))) | |
(defun scala-test-file-name (f) | |
(let* ((sp (reverse (split-string f "\\."))) | |
(h (car sp)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> List(BigDecimal(1).some, BigDecimal(13).some, BigDecimal(12).some).sequence.map(_.sum) | |
res14: Option[scala.math.BigDecimal] = Some(26) | |
scala> List(BigDecimal(1).some, None, BigDecimal(12).some).sequence.map(_.sum) | |
res15: Option[scala.math.BigDecimal] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[debug] Waiting for thread run-main to exit | |
[error] (run-main) java.lang.AbstractMethodError: spire.example.RandomForestExample$$anonfun$1.apply(Ljava/lang/Object;)Ljava/lang/Object; | |
java.lang.AbstractMethodError: spire.example.RandomForestExample$$anonfun$1.apply(Ljava/lang/Object;)Ljava/lang/Object; | |
at spire.example.CrossValidation$.loop$1(DataSets.scala:234) | |
at spire.example.CrossValidation$.crossValidate(DataSets.scala:242) | |
at spire.example.CrossValidation$.crossValidateClassification(DataSets.scala:259) | |
at spire.example.RandomForestExample$.testClassification(randomforest.scala:40) | |
at spire.example.RandomForestExample$delayedInit$body.apply(randomforest.scala:24) | |
at scala.Function0$class.apply$mcV$sp(Function0.scala:40) | |
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; scala-mode2 found here: https://github.com/hvesalai/scala-mode2 is much better than the scala mode that comes with scalac | |
(add-to-list 'load-path "~/.emacs.d/scala-mode2/") | |
(require 'scala-mode) | |
; http://www.emacswiki.org/emacs/RainbowDelimiters | |
(add-hook 'scala-mode-hook 'rainbow-delimiters-mode) | |
; I get ensime from git: | |
; https://github.com/aemoncannon/ensime | |
; then run `sbt stage` inside the ensime source directory, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val f : Int => List[Int] = List(_) | |
f: Int => List[Int] = <function1> | |
scala> Stream(1,2,3) traverse f | |
res1: List[scala.collection.immutable.Stream[Int]] = List(Stream(1, ?)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun right-arrow () | |
(interactive) | |
(cond ((looking-back "=") | |
(backward-delete-char 1) (insert "⇒")) | |
((looking-back "-") | |
(backward-delete-char 1) (insert "→")) | |
(t (insert ">")))) | |
(defun left-arrow () | |
(interactive) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait UnapplyMT[TC[_[_[_], _]], N[_], MTNA] { | |
/** the type constructor */ | |
type MT[_[_], _] | |
/** The type that MT is applied to */ | |
type A | |
/** The instance of the type class */ | |
def TC: TC[MT] |