Search Results

Search found 972 results on 39 pages for 'scala'.

Page 30/39 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • Composing actors

    - by Brian Heylin
    I've implemented a Listenable/Listener trait that can be added to Actors. I'm wondering if it's possible to attach this style of trait to an actor without it having to explicitly call the listenerHandler method? Also I was expecting to find this functionality in the Akka library. Am I missing something or is there some reason that Akka would not not include this? trait Listenable { this: Actor => private var listeners: List[Actor] = Nil protected def listenerHandler: PartialFunction[Any, Unit] = { case AddListener(who) => listeners = who :: listeners } protected def notifyListeners(event: Any) = { listeners.foreach(_.send(event)) } } class SomeActor extends Actor with Listenable { def receive = listenerHandler orElse { case Start => notifyListeners(Started()) case Stop => notifyListeners(Stopped()) } }

    Read the article

  • How to make ensime work in windows?

    - by Eastsun
    I'm new to emacs and I want to use ensime in Windows. I had a try but it doesn't work. It seems that it doesn't work because there is a *nix format file named "\ensime\bin\server.sh" . Very appreciate if someone give me some tips.

    Read the article

  • Simple subclass mappable class in lift

    - by coubeatczech
    Hi, is there any way how to easy subclass a Mapped class in lift framework? class One extends LongKeyedMapper[One] with IdPK{ object sharedField extend MappedString(this) } class Two extends One[*]{ ... } *and now I can't hint the compiler because One is not defined generic. So this doesn't work, what is the right way?

    Read the article

  • Convert a List of Options to an Option of List using Scalaz

    - by Rafael de F. Ferreira
    The following function transforms a list of Option[T] into a list of Some[T], in the case where all members are Some's, or None, in the case where there is at least one None member. I guess the code is clearer that this explanation: def lo2ol[T](lo: List[Option[T]]): Option[List[T]] = { lo.foldRight[Option[List[T]]](Some(Nil)){(o, ol) => (o, ol) match { case (Some(x), Some(xs)) => Some(x :: xs); case _ => None : Option[List[T]]; }}} I remember seeing somewhere a similar example, but using Scalaz to simplify the code. How would it look like?

    Read the article

  • Function syntax puzzler in scalaz

    - by oxbow_lakes
    Following watching Nick Partidge's presentation on deriving scalaz, I got to looking at this example, which is just awesome: import scalaz._ import Scalaz._ def even(x: Int) : Validation[NonEmptyList[String], Int] = if (x % 2 ==0) x.success else "not even: %d".format(x).wrapNel.fail println( even(3) <|*|> even(5) ) //prints: Failure(NonEmptyList(not even: 3, not even: 5)) I was trying to understand what the <|*|> method was doing, here is the source code: def <|*|>[B](b: M[B])(implicit t: Functor[M], a: Apply[M]): M[(A, B)] = <**>(b, (_: A, _: B)) OK, that is fairly confusing (!) - but it references the <**> method, which is declared thus: def <**>[B, C](b: M[B], z: (A, B) => C)(implicit t: Functor[M], a: Apply[M]): M[C] = a(t.fmap(value, z.curried), b) So I have a few questions: How come the method appears to take a monad of one type parameter (M[B]) but can get passed a Validation (which has two type paremeters)? How does the syntax (_: A, _: B) define the function (A, B) => C which the 2nd method expects? It doesn't even define an output via =>

    Read the article

  • using REST webservices as a datasource for Lift ?

    - by Jeff Bowman
    Is there a way to use a webservice (REST in this case) as the data source for a Lift application? I can find a number of tutorials/examples of using Lift to provide the REST API, but in my case the data is hosted elsewhere and exported as a REST webservice. Pointers to doc are greatly appreciated. Thanks, Jeff

    Read the article

  • Simple extend mappable class in lift

    - by coubeatczech
    Hi, is there any way how to easy subclass a Mapped class in lift framework? class One extends LongKeyedMapper[One] with IdPK{ object sharedField extend MappedString(this) } class Two extends One[*]{ ... } *and now I can't hint the compiler because One is not defined generic. So this doesn't work, what is the right way?

    Read the article

  • Convert Option[Object] to Option[Int] Implicitly

    - by wheaties
    I'm working with legacy Java code which returns java.lang.object. I'm passing it into a function and I'd like to do some implicit conversions as such: implicit def asInt( _in:Option[Object] ) = _in asInstanceOf[ Option[Int] ] implicit def asDouble( _in:Option[Object] = _in asInstanceOf[ Option[Double] ] private def parseEntry( _name:String, _items:Map[String,Object] ) = _name match{ case docName.m_Constants => new Constants( _items get( Constants m_Epsilon ), _items get( Constant m_Rho ), _items get( Constants m_N ) ) Technically it goes on but I keep getting the same errors: expected Int, Option[Object] found. How have I done my implicits wrong? I was hoping it would do the transformation for me instead of me having to write "asInstanceOf" each and every time.

    Read the article

  • PlayDependencyClassLoader does not find application code

    - by jkschneider
    When a third party dependency attempts to load a class defined in a Play application using Class.forName(className, true, Thread.currentThread().getContextClassLoader()); Play will throw a ClassNotFoundException because the context class loader is of type PlayDependencyClassLoader which apparently only contains classes defined in jar dependencies. Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: eventstore.Commit at org.mapdb.SerializerPojo.classForName(SerializerPojo.java:96) at org.mapdb.SerializerPojo$1.deserialize(SerializerPojo.java:74) at org.mapdb.SerializerPojo$1.deserialize(SerializerPojo.java:39) This only occurs when Play is started with play run. Starting Play with play start loads the class correctly. It would be a shame to sacrifice the class hot-swapping because of this behavior. Is there a known workaround?

    Read the article

  • How Can I Check an Object to See its Type and Return A Casted Object

    - by Russ Bradberry
    I have method to which I pass an object. In this method I check it's type and depending on the type I do something with it and return a Long. I have tried every which way I can think of to do this and I always get several compiler errors telling me it expects a certain object but gets another. Can someone please explain to me what I am doing wrong and guide me in the right direction? What I have tried thus far is below: override def getInteger(obj:Object) = { if (obj.isInstanceOf[Object]) null else if (obj.isInstanceOf[Number]) (obj:Number).longValue() else if (obj.isInstanceOf[Boolean]) if (obj:Boolean) 1 else 0 else if (obj.isInstanceOf[String]) if ((obj:String).length == 0 | (obj:String) == "null") null else try { Long.parse(obj:String) } catch { case e: Exception => throw new ValueConverterException("value \"" + obj.toString() + "\" of type " + obj.getClass().getName() + " is not convertible to Long") } }

    Read the article

  • lift `??` construct and maven example

    - by coubeatczech
    Hi, I have browsed lift's MegaProtoUser and encountered this construction: ??("Last Name"). Can anyone explain, what that means? Also, I didn't find a way how to add a custom field into MegaProtoUser. The maven's lift's basic archetype defines another field, but it never shows anywhere. (Version 1.0) Thanks for answering

    Read the article

  • deploying gwt web application on jetty

    - by Azhar
    Hi I am deploying my web application created in Gwt on the jetty. I have used mongodb as my database.After starting the server it starts deploying the weapp.war and gives following error - 694 [main] INFO org.mortbay.log - Extract /usr/share/jetty/webapps/myapp.war to /tmp/Jetty_0_0_0_0_8090_myapp.war__myapp__n6yltk/webapp 3567 [main] WARN org.mortbay.log - failed Startup: java.lang.LinkageError: loader constraint violation: loader (instance of org/mortbay/jetty/webapp/WebAppClassLoader) previously initiated loading for a different type with name "javax/management/MBeanServer" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:634) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:392) at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363) at com.mongodb.DBPortPool$Holder.get(DBPortPool.java:58) at com.mongodb.DBTCPConnector._set(DBTCPConnector.java:458) at com.mongodb.DBTCPConnector.<init>(DBTCPConnector.java:46) at com.mongodb.Mongo.<init>(Mongo.java:137) at com.mongodb.Mongo.<init>(Mongo.java:123)

    Read the article

  • By-Name-Parameters for Constructors

    - by hotzen
    Hello, coming from my other question is there a way to get by-name-parameters for constructors working? I need a way to provide a code-block which is executed on-demand/lazy/by-name inside an object and this code-block must be able to access the class-methods as if the code-block were part of the class. Following Testcase fails: package test class ByNameCons(code: => Unit) { def exec() = { println("pre-code") code println("post-code") } def meth() = println("method") def exec2(code2: => Unit) = { println("pre-code") code2 println("post-code") } } object ByNameCons { def main(args: Array[String]): Unit = { val tst = new ByNameCons { println("foo") meth() // knows meth() as code is part of ByNameCons } tst.exec() // ByName fails (executed right as constructor) println("--------") tst.exec2 { // ByName works println("foo") //meth() // does not know meth() as code is NOT part of ByNameCons } } } Output: foo method pre-code post-code -------- pre-code foo post-code

    Read the article

  • Testing SocketChannel NIO

    - by hotzen
    Hello, I just wrote some NIO-code and wonder how to stress-test my implementation regarding SocketChannel.write(ByteBuffer) not able to write the whole byte-buffer SocketChannel.read(ByteBuffer) reading the data in chunks into ByteBuffer are there some simple linux-utilities like telnet to open a ServerSocket with some buffering-options?

    Read the article

  • Estimate serialization size of objects?

    - by Stefan K.
    In my thesis, I woud like to enhance messaging in a cluster. It's important to log runtime information about how big a message is (should I prefer processing local or remote). I could just find frameoworks about estimating the object memory size based on java instrumentation. I've tested classmexer, which didn't come close to the serialization size and sourceforge SizeOf. In a small testcase, SizeOf was around 10% wrong and 10x faster than serialization. (Still transient breaks the estimation completely and since e.g. ArrayList is transient but is serialized as an Array, it's not easy to patch SizeOf. But I could live with that) On the other hand, 10x faster with 10% error doesn't seem very good. Any ideas how I could do better?

    Read the article

  • How do I get the scalaz IDEA live templates working for the symbolic methods?

    - by oxbow_lakes
    Many of the methods in scalaz have symbolic equivalents, such as forever and 8 (of course, I have this the wrong way round, the symbolic methods really have ASCII equivalents). The project contains a live templates XML file for IDEA so these can be auto-completed, I believe by using the forever+TAB shortcut (in the above instance). I can't figure out how to import this live template into IDEA and actually use it, though. How can I do that?

    Read the article

  • Lift XML Parsing Error

    - by bstevens90
    I know there are other questions on this and I have read through almost all of them and none of them solved my problem. I have inside a home directory: def search(in: NodeSeq) : NodeSeq = { bind("work", in, "docId" -> text("", did = _), "visitId" -> text("", vid = _), "provider" -> text("", prov = _), "emCode" -> text(ecode, ecode = _)) } along with: <lift:home.searchForm form="POST" multipart="true" > <table> <tr> <td>DocId</td> <td>VisitId</td> <td>Provider</td> <td>EanMCode</td> </tr> <tr> <td><work:docId /></td> <td><work:visitId /></td> <td><work:provider /></td> <td><work:emCode /></td> <td><button>Click Me!</button></td> </tr> </table> </lift:home.searchForm> Inside an html page. I have included xmlns:lift="http://liftweb.net/" in default.... I can't find anyway to fix this... I am getting XML Parsing Error: prefix not bound to a namespace Location: http://localhost:8080/ Line Number 29, Column 10: <td><work:docId></work:docId></td> in firefox. I have written similar code and had it working in another app and just cant even find anything im doing different thats not trivial naming... Thanks in advance!

    Read the article

  • implicit parameter definition in class

    - by coubeatczech
    implicit val odkaz = head; def vypis(implicit odkaz:Prvek):String = { odkaz match{ case null => "" case e => e.cislo + " " + e.pocet + "\n" + vypis(e.dalsi) } } ... def main(args:Array[String]){ val q = new MyQueue() // insert some values println(q.vypis) } This method(vypis) is a member of an queue-class so I'll always want to implicity start the recursion from the start of the queue, when calling the method from outside. Is there a way how to write it, that the method from outside calling, there's no paramter, but in inside, there's a parameter - for recursion...? The compiler complains that the parameter is not defined when called from outside

    Read the article

  • trait implementation

    - by Jeriho
    If I have some traits like: trait A {...} trait B extends A{...} trait C1 extends B{...} trait C2 extends A{...} I can write class in two ways (C1 and C2 add same functionality) class Concrete1 extends B with C1 class Concrete2 extends B with C2 What variant is better(efficient)?

    Read the article

  • How to compose a Matcher[Iterable[A]] from a Matcher[A] with specs testing framework

    - by Garrett Rowe
    If I have a Matcher[A] how do create a Matcher[Iterable[A]] that is satisfied only if each element of the Iterable satisfies the original Matcher. class ExampleSpec extends Specification { def allSatisfy[A](m: => Matcher[A]): Matcher[Iterable[A]] = error("TODO") def notAllSatisfy[A](m: => Matcher[A]): Matcher[Iterable[A]] = allSatisfy(m).not "allSatisfy" should { "Pass if all elements satisfy the expectation" in { List(1, 2, 3, 4) must allSatisfy(beLessThan(5)) } "Fail if any elements do not satisfy the expectation" in { List(1, 2, 3, 5) must notAllSatisfy(beLessThan(5)) } } }

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >