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 scala.concurrent.duration._ | |
import scala.concurrent.{Await, Future} | |
import scala.language.{higherKinds, postfixOps} | |
import scala.util.{Failure, Success} | |
object ContainerMapper { | |
import scala.concurrent.ExecutionContext.Implicits.global | |
//this is your typeclass signature. M[_] means M is a type 'constructor'. It needs another type (A) to become a type. List[_] vs List[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
object AmTest extends App { | |
val x = List("=", | |
"+", | |
"==", | |
"applyTo", | |
"asInstanceOf", | |
"attr", | |
"charAt", | |
"chars", |
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
List("one", "two", "three") map (_.length) | |
trait Functor[F[_]] { | |
def fmap[A,B](f: A => B, fa:F[A]): F[B] | |
} | |
class ListFunctor extends Functor[List] { | |
def fmap[A,B](f: A => B, fa:List[A]): List[B] = fa match { | |
case Nil => Nil | |
case x::xs => f(x) :: fmap(f, xs) |
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
case class Person(name:String) | |
fmap((_:Person).name, Holder(Person("Harry Potter"))) | |
11: error: could not find implicit value for parameter functor: Functor[Holder] |
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
List -> is a type constructor | |
List[Long] -> is a type |
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
scala> val ar:List[Int] = Nil | |
ar: List[Int] = List() | |
scala> "blah" :: 5 :: 6 :: ar | |
res21: List[Any] = List(blah, 5, 6) | |
//how did I add a String to a List[Int]? | |
//how do you keep the type within the List fixed at Int? | |
//can I only do that at declaration time as opposed to when I call the :: method? | |
//This works: |
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
;; Load the ensime lisp code... | |
(add-to-list 'load-path "ENSIME_ROOT/elisp/") | |
(require 'ensime) | |
;; This step causes the ensime-mode to be started whenever | |
;; scala-mode is started for a buffer. You may have to customize this step | |
;; if you're not using the standard scala mode. | |
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook) | |
;; MINI HOWTO: |
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
Chain INPUT (policy ACCEPT) | |
target prot opt source destination | |
Chain FORWARD (policy ACCEPT) | |
target prot opt source destination | |
Chain OUTPUT (policy ACCEPT) | |
target prot opt source destination |
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
sudo iptables -A CHAIN_NAME |
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
sudo chmod +x /etc/network/if-pre-up.d/iptablesload |
OlderNewer