This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.actor._ | |
import scala.concurrent._ | |
import duration._ | |
class EEcho extends Actor { | |
import ExecutionContext.Implicits.global | |
def receive = { | |
case Some(msg:Int) => | |
println("RECV => " + msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package actors.scalaz | |
import scalaz._ | |
import Scalaz._ | |
import akka.actor._ | |
import akka.util.Timeout | |
import akka.pattern.ask | |
import scala.concurrent._ | |
import scala.concurrent.duration._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Chapter26_1 where | |
import Control.Monad.Trans.Reader | |
import Data.Functor.Identity | |
-- Part (2) of my beginnings with Monad Transformers. See Part (1) of my journey with Monad Transformers written here (https://gist.github.com/raygit/e540aacf58e32d5e071d3d1cefb61b96) | |
-- | |
-- I'm trying to understand how this would work. From the package's description | |
-- (https://hackage.haskell.org/package/transformers-0.5.2.0/docs/Control-Monad-Trans-Reader.html), | |
-- i see that: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE InstanceSigs #-} | |
module Chapter26 where | |
import Control.Monad (liftM) | |
newtype MaybeT m a = MaybeT' { runMaybeT :: m (Maybe a) } | |
instance (Functor m) => Functor (MaybeT m) where | |
fmap f (MaybeT' ma) = MaybeT' $ (fmap . fmap) f ma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaz._ | |
import Scalaz._ | |
case class Result(eCode: Int) | |
case class Action(z: Int, f : Int => Int) | |
// Artificially created two "steps" with the intention | |
// combining them later in a composition | |
val step1 = State[Action, Result] { | |
case (a: Action) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<int v> | |
struct Int2Type { | |
enum { value = v }; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
interface Fn<T,R> { | |
R apply(T a); | |
R f(T a); | |
} | |
// Created for the purpose of a class. | |
class AddOneFunction implements Fn<Integer,Integer> { | |
public Integer apply(Integer a) { return f(a); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set t_Co=256 | |
set nu | |
set hlsearch | |
syntax on | |
set tabstop=4 | |
set background=dark | |
let g:solarized_termcolors=256 | |
colorscheme solarized | |
set shiftwidth=4 | |
set expandtab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.locks._ | |
// Doesn't appear to make sense to create an abstraction | |
// to allow users to receive the status of the acquiring or | |
// releasing a lock over an object because ... | |
// | |
trait LockStrategy[L <: Lock] { | |
protected val lck : Lock = null | |
def lock : Unit | |
def unlock : Unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.locks._ | |
trait LockStrategy[L <: Lock] { | |
protected val lck : Lock = null | |
def lock : Unit | |
def unlock : Unit | |
} | |
trait AllowReentrancy extends LockStrategy[ReentrantLock] { | |
override val lck = new ReentrantLock |