Skip to content

Instantly share code, notes, and snippets.

module Codec exposing (..)
import Json.Encode as Encode
type alias Listy = { a : List Int, b : Maybe String }
encodeListy : Listy -> Encode.Value
encodeListy obj = Encode.object
[ ("a", Encode.list Encode.int obj.a)
, ("b", Maybe.withDefault Encode.null Encode.string obj.b)
]
import org.http4s._
import org.http4s.client._
import scalaz.concurrent.Task
object TestClient {
def apply(service: Service[Request, Response]) =
Client(
service.map(resp => DisposableResponse(resp, Task(()))),
Task(())
)
// Mostly borrowed from https://github.com/playframework/playframework/blob/a5decc4ec81d311a769208ce007771a1e45b570b/framework/src/play/src/main/scala/play/api/libs/crypto/Crypto.scala
// but with less Inject
import org.atnos.eff._, org.atnos.eff.syntax.eff._, org.atnos.eff.syntax.all._, org.atnos.eff.all._
import scalaz._, Scalaz._
import java.time._
import javax.crypto.{ Cipher, Mac }
import javax.crypto.spec.{ IvParameterSpec, SecretKeySpec }
import org.apache.commons.codec.binary.Hex
[error] BestFirstSearch.scala:279 Failed to format
UNABLE TO FORMAT,
tok=case∙p1
state.length=0
toks.length=3279
deepestYet.length=921
policies=Vector(P:128(D=false), P:410(D=false), P:128(D=false), P:128(D=false))
nextSplits=List(Space:885(cost=0, indents=[], P:887(D=true)), Space:888(cost=1, indents=[2, 2], P:889(D=false)))
splitsAfterPolicy=Decision(case∙p1,List(Space:885(cost=0, indents=[], P:887(D=true)), Space:888(cost=1, indents=[2, 2], P:889(D=false))))
[error] BestFirstSearch.scala:279 Failed to format
@reactormonk
reactormonk / Symbols.md
Last active November 19, 2021 14:06
Scalaz Symbol Guide
Symbol Explanation Hint
\/ Right-leaning Either Split ways, go one way or the other
-\/ Left value of \/ - is on the left side
\/- Right value of \/ - is on the right side
>>= flatMap shove result into
>> flatMap(_ => ..) shove into, but ignore the result
|@| Applicatives into Tuple Scream operator
|+| Append via Monoid + was taken
`> ` fa.map(_ => b)
{-# OPTIONS_GHC -fglasgow-exts #-}
import XMonad
import XMonad.Operations
import XMonad.Actions.Commands
import XMonad.Actions.CycleWS
import XMonad.Actions.DeManage
import qualified XMonad.Actions.DynamicWorkspaces as DW
name := "scala-playground"
version := "0.1-SNAPSHOT"
organization := "org.reactormonk"
scalaVersion := "2.11.1"
resolvers ++= Seq(
"ScalaNLP Maven2" at "http://repo.scalanlp.org/repo",
/* Generated by the Nimrod Compiler v0.9.1 */
/* (c) 2013 Andreas Rumpf */
var Globals = this;
var framePtr = null;
var excHandler = null;
var NTI842 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI808 = {size: 0, kind: 17, base: null, node: null, finalizer: null};
var NTI140 = {size: 0,kind: 28,base: null,node: null,finalizer: null};
@reactormonk
reactormonk / map_score.rb
Created July 23, 2012 22:50
MAP score calculation
class Array
def avp
each_with_index.with_object(correct: 0.0).map {|(element, index), keep|
relevant = block_given? ? yield(element) : element
if relevant
# if the element is relevant (truy or by block)
keep[:correct] += 1
keep[:correct] / (index + 1)
end
}.compact
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.