Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am suls on github.
  • I am suls (https://keybase.io/suls) on keybase.
  • I have a public key ASCUDW2zvp15B8l1g3Mwk62HqsGSIIrJlgNxxlwOmqfRKQo

To claim this, I am signing this object:

@suls
suls / pagination.scala
Last active January 17, 2016 05:02
pagination
object Pagination {
def pagedRequest[F[_], A] (
f: Offset => F[Page[A]],
offset: Offset
) : Process[F, A] = {
Process
.eval(f(offset))
.flatMap { response: Page[A] =>
Process.emitAll(response.results) ++
@suls
suls / gist:124536c26c4a1fef447f
Last active January 15, 2016 05:56
Is there a better way?
def toDateE(s: String) =
\/.fromTryCatchNonFatal {
new org.joda.DateTime(s)
}
def toDateO(s: String) =
toDateE(s).toOption
scala> fooR
res15: scalaz.\/[String,Int] = \/-(1)
scala> def addOne[M[_]: Applicative](in: M[Int]) = in.map(_+1)
warning: there was one feature warning; re-run with -feature for details
addOne: [M[_]](in: M[Int])(implicit evidence$1: scalaz.Applicative[M])M[Int]
scala> addOne(fooR)
<console>:19: error: no type parameters for method addOne: (in: M[Int])(implicit evidence$1: scalaz.Applicative[M])M[Int] exist so that it can be applied to arguments (scalaz.\/[String,Int])
--- because ---
// project/ServiceApiBuild.scala
object ServiceApiBuild {
def idlProject(projectName : String) =
Project(
id = projectName,
base = file(projectName)
)
.settings(name := projectName)
.settings(
@suls
suls / gist:6068364
Created July 24, 2013 06:03
sample sbt task
object Build extends sbt.Build {
lazy val fooUtil = Project(
// ..
)
val sample = TaskKey[Unit]("sample-task")
val sampleTask = sample := {
println("in sample-task")
(unmanagedSourceDirectories in (fooUtil, Compile)) map {(ds: Seq[java.io.File]) =>
[schef.local ~/code/scala ] git clone git://git.assembla.com/scala-ide.git
Initialized empty Git repository in /Users/suls/code/scala/scala-ide/.git/
remote: Counting objects: 7441, done.
remote: Compressing objects: 100% (2621/2621), done.
remote: Total 7441 (delta 4070), reused 6224 (delta 3321)
Receiving objects: 100% (7441/7441), 120.18 MiB | 73 KiB/s, done.
Resolving deltas: 100% (4070/4070), done.
[schef.local ~/code/scala ] cd scala-ide/
[schef.local ~/code/scala/scala-ide (master)]