Working to sniff Bluetooth Low Energy with the adafruit sniffer
For more information, see this blog post
Going the python route, as described here
before installing pySerial, did ...
import Control.Monad.Free | |
import Control.Monad.State.Lazy | |
data TerminalOp a = ReadLine (String -> a) | WriteLine String a | |
instance Functor TerminalOp where | |
fmap f (ReadLine g) = ReadLine (f . g) | |
fmap f (WriteLine s a) = WriteLine s (f a) | |
type TerminalIO a = Free TerminalOp a |
sealed trait EdnExpr { | |
def value : Expr | |
def mdata : Map[Expr,Expr] | |
override def equals(other : Any) = other match { | |
case that : EdnExpr => this.value == that.value | |
case _ => false | |
} | |
} | |
type Expr = Any | |
//-- | |
// Clojure's Transducers | |
// (the simpler parts) | |
//-- | |
// References: |
qsort [] = [] | |
qsort (n:xs) = qsort lt ++ [n] ++ qsort gteq where | |
lt = [x | x <- xs, x < n] | |
gteq = [x | x <- xs, x >= n] |
Working to sniff Bluetooth Low Energy with the adafruit sniffer
For more information, see this blog post
Going the python route, as described here
before installing pySerial, did ...
/** This is in reference to @tploecat's blog http://tpolecat.github.io/2015/04/29/f-bounds.html | |
* where he compares F-bounded polymorphism and type classes for implementing "MyType". | |
* | |
* Curiously, the in my mind obvious solution is missing: Use abstract types. | |
* | |
* A lot of this material, including an argument against F-bounded for the use-case | |
* is discussed in: | |
* | |
* Kim B. Bruce, Martin Odersky, Philip Wadler: | |
* A Statically Safe Alternative to Virtual Types. ECOOP 1998: 523-549 |
object TransducerSpecs extends Specification with ScalaCheck { | |
import Process._ | |
import StreamUtils._ | |
"effectful stream transducers" should { | |
def id[I]: Transducer[Nothing, I, I] = | |
transducer.receive1[Nothing, I, I](emit).repeat | |
"perform a simple identity transformation" in prop { xs: List[List[Int]] => | |
val p = emitAll(xs map emitAll).toSource.join |
import spire.algebra._ | |
import spire.implicits._ | |
object Transducer { | |
type RF[R, A] = (R, A) => R | |
def apply[A, B](f: A => B) = | |
new Transducer[B, A] { | |
def apply[R](rf: RF[R, B]): RF[R, A] = (r, a) => rf(r, f(a)) | |
} |
case class Tree[A](root: A, forest: List[Tree[A]]) { | |
def map[B](f: A => B): Tree[B] = | |
coflatMap(t => f(t.copoint)) | |
// categorical dual to canonical "flatMap" | |
def coflatMap[B](f: Tree[A] => B): Tree[B] = { | |
import Tree.unfoldTree | |
unfoldTree(this, (a: Tree[A]) => (f(a), a.forest)) | |
} |
PROGRAMMING WITH EFFECTS | |
Graham Hutton, January 2015 | |
Shall we be pure or impure? | |
The functional programming community divides into two camps: | |
o "Pure" languages, such as Haskell, are based directly | |
upon the mathematical notion of a function as a | |
mapping from arguments to results. |