Skip to content

Instantly share code, notes, and snippets.

View aeyakovenko's full-sized avatar

anatoly yakovenko aeyakovenko

View GitHub Profile
/**
* we need a placeholder at the start for zero so ##_VA_ARGS__ has something to consume
* then the arguments are pushed out in such a way that 'cnt' ends up with the right count.
*/
#define COUNT_ARGS(...) COUNT_ARGS_(,##__VA_ARGS__,6,5,4,3,2,1,0)
#define COUNT_ARGS_(z,a,b,c,d,e,f,cnt,...) cnt
#define C_ASSERT(test) \
switch(0) {\
case 0:\
{--
$ dist/build/test/test
benchmarking P
time 3.217 s (NaN s .. 3.388 s)
0.998 R² (0.996 R² .. 1.000 R²)
mean 3.058 s (2.935 s .. 3.132 s)
std dev 112.5 ms (0.0 s .. 126.9 ms)
variance introduced by outliers: 19% (moderately inflated)
benchmarking S
module Test where
--impl modules
import Data.Array.Repa.Algorithms.Randomish
import Data.Array.Repa
import Criterion.Main
import System.Environment(getArgs)
main :: IO ()
main = do
val slices: Gen[(Int,Int,List[Int])] = for {
a <- Gen.listOf(Gen.choose(-100,100))
j <- Gen.choose(0, a.length)
k <- Gen.choose(j, a.length)
} yeild(j,k,a)
property("slice") = forAll(slices) { g =>
val (j,k,a) = g
val (p,s,e) = Scala99.slice(j, k, a)
(p ++ s ++ e == a) && (s.length == (k - j))
[info] Loading project definition from /Users/anatolyy/scoogle/project
[info] Set current project to scoogle (in build file:/Users/anatolyy/scoogle/)
[info] Resolving org.scala-lang#scala-library;2.11.8 ...

[info] Resolving org.scala-search#scaps-scala_2.11;0.7-SNAPSHOT ...

[info] Resolving org.scala-search#scaps-scala_2.11;0.7-SNAPSHOT ...

[info] Resolving org.scala-lang#scala-compiler;2.11.8 ...


So I can explicitly define everything via:

  type SchedulerState[X] = StateT[Trampoline, D.SchedulerState, X]
  type SchedulerM[A] = XorT[SchedulerState, String, A]
def bailScheduler[A](msg: String): SchedulerM[A] =
    XorT.left[SchedulerState, String, A](StateT.pure(msg))

But if i try to generalize this i get errors

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" dein
" run
" curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
" sh ./installer.sh ~/.dein # or specify the installation directory
" call dein#install()
if &compatible
set nocompatible
endif
package org.apache.mesos.edsl
import cats.{Applicative,Functor}
import cats.data.{XorT,StateT}
package object control {
type ErrorTStateT[F[_], S, A] = XorT[({type l[X] = StateT[F, S, X]})#l, String, A]
def bail[F[_], S, A](msg: String)(implicit I1: Applicative[F], I2: Functor[({type l[X] = StateT[F, S, X]})#l]): ErrorTStateT[F, S, A] =
XorT.left[({type l[X] = StateT[F, S, X]})#l, String, A](StateT.pure[F, S, String](msg))
> scalastyleGenerateConfig
[success] created: /Users/ayakovenko/cosmos/scalastyle-config.xml
[success] created: /Users/ayakovenko/cosmos/scalastyle-config.xml
[success] created: /Users/ayakovenko/cosmos/scalastyle-config.xml
[success] created: /Users/ayakovenko/cosmos/scalastyle-config.xml
[success] Total time: 1 s, completed Aug 1, 2016 1:11:30 PM
> scalastyle
[info] scalastyle using config /Users/ayakovenko/cosmos/scalastyle-config.xml
[info] scalastyle using config /Users/ayakovenko/cosmos/scalastyle-config.xml
[info] scalastyle using config /Users/ayakovenko/cosmos/scalastyle-config.xml
161. Waiting for source changes... (press enter to interrupt)
[info] Compiling 64 Scala sources to /Users/anatolyy/cosmos/cosmos-server/target/scala-2.11/classes...
[error] /Users/anatolyy/cosmos/cosmos-server/src/main/scala/com/mesosphere/cosmos/Cosmos.scala:43: ambigu
ous implicit values:
[error] both value packageListDecoder in object MediaTypedDecoders of type => com.mesosphere.cosmos.circ
e.MediaTypedDecoder[com.mesosphere.cosmos.rpc.v1.model.ListRequest]
[error] and value packageListVersionsDecoder in object MediaTypedDecoders of type => com.mesosphere.cosm
os.circe.MediaTypedDecoder[com.mesosphere.cosmos.rpc.v1.model.ListVersionsRequest]
[error] match expected type com.mesosphere.cosmos.circe.MediaTypedDecoder[Req]
[error] route(post("package" / "install"), packageInstallHandler)(RequestReaders.standard)