Skip to content

Instantly share code, notes, and snippets.

View aeyakovenko's full-sized avatar

anatoly yakovenko aeyakovenko

View GitHub Profile

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

[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 ...

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))
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
{--
$ 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
/**
* 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:\