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
max@sordid ~/work/FS2005 % ls -l | |
total 23952 | |
-rwxr-xr-x+ 1 max staff 12258304 Mar 7 15:31 FSharp.Compiler.Service.dll | |
-rw-r--r--+ 1 max staff 157 Mar 7 15:31 test.fsx | |
max@sordid ~/work/FS2005 % cat test.fsx | |
#r "FSharp.Compiler.Service.dll" | |
open Microsoft.FSharp.Compiler.SimpleSourceCodeServices | |
let scs = SimpleSourceCodeServices() | |
printfn "Hello, world! %A" scs | |
max@sordid ~/work/FS2005 % fsharpc --standalone -I:. -o test.exe test.fsx |
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
// Mock Akka in the absence of artifacts. Don't pay attention to this | |
// part. Oh, and I'm stuck in Akka 1.3.x land, so some of this may | |
// look "retro" to you. | |
trait ActorRef { | |
def !(msg: Any) {} | |
} | |
trait Actor { | |
def self: ActorRef = new ActorRef {} |
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 Foo { | |
def foo(x: Int, y: Int = 10) = x*y | |
lazy val y = foo(x = 20) | |
} | |
// innocuous.scala:3: error: variable definition needs type because 'y' is used as a named argument in its body. | |
// Error occurred in an application involving default arguments. | |
// |
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._ | |
import scalaz.effects._ | |
val a = println("a here").pure[IO] | |
val b = println("b here").pure[IO] | |
val c = a.flatMap(_ => b.flatMap(_ => println("c here").pure[IO])) | |
c.unsafePerformIO // prints 3 lines as expected | |
c.unsafePerformIO // expect 0 lines to be printed, but... | |
c.unsafePerformIO // and again... | |
c.unsafePerformIO // again... |
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
Originally: | |
https://gist.github.com/7565976a89d5da1511ce | |
Hi Donald (and Martin), | |
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I | |
appreciate the tone. This is a Yegge-long response, but given that you and | |
Martin are the two people best-situated to do anything about this, I'd rather | |
err on the side of giving you too much to think about. I realize I'm being very | |
critical of something in which you've invested a great deal (both financially |
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
#!/usr/bin/env perl | |
use strict; | |
use HTTP::Proxy qw/:log/; | |
use Time::HiRes qw/time/; | |
use HTTP::Proxy::BodyFilter::save; | |
my $DIR = '/home/max/Music/Pandora'; | |
$DIR =~ s/\/+$//; | |
die "no dir $DIR" unless -d $DIR; |
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 UglyHacks { | |
implicit def screwEncapsulation(o: AnyRef) = new { | |
private def field(fieldName: String) = { | |
val field = o.getClass.getDeclaredField(fieldName) | |
field.setAccessible(true) | |
field | |
} | |
def shoeHorn(fieldName: String, fieldValue: Any) = field(fieldName).set(o, fieldValue) |
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> def isEven(i: Int): Boolean = { println("checking %d".format(i)); i % 2 == 0 } | |
isEven: (i: Int)Boolean | |
scala> val pf: PartialFunction[Int, Boolean] = { case i if isEven(i) => { println("%d is even".format(i)); true } } | |
pf: PartialFunction[Int,Boolean] = <function1> | |
scala> pf.isDefinedAt(0) | |
checking 0 | |
res0: Boolean = true |
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
1. Dump contents of http://www.w3.org/2003/05/soap-envelope/ to soap12.xsd | |
and put that somewhere alongside the other schemas. | |
2. Run scalaxb, you'll end up with a soap12.scala & company. | |
3. See sample code. Call envXml and get back XML representation of envelope, | |
header, and body all in one. |
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
trait X | |
case class A(i: Int) extends X | |
case class B(i: Int) extends X | |
implicit def int2a(i: Int): A = A(i) | |
implicit def int2b(i: Int): B = B(i) | |
implicit def int2x(i: Int)(implicit multiplier: Int): X = | |
if (System.currentTimeMillis % 100 == 0) A(i * multiplier) else B(i * multiplier) |
NewerOlder