This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Simplifying apply method

1 reply
ngarthl
Joined: 2009-07-19,
User offline. Last seen 34 weeks 4 days ago.
Hello guys and gals.
I am building an Atom Library using Daniel Spiewak's anti-xml. 
I have built an extension mechanism using the trait found here https://github.com/arktekk/scala-atom/blob/master/src/main/scala/no/arktekk/atom/extension/AtomExtension.scala
The problem is that when I want to compose multiple Extensions the signature kind of explodes.
Is there a more general way to do this?

Best regards
Erlend

PS: I have looked at HList, which will probably work.
ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
Re: Simplifying apply method
In situations like this, I write a code generator, not the code itself.  It's usually pretty easy (except possibly for the build process--depends on your build tool of choice, I guess).
  --Rex

P.S. Most obvious version would go something like:
"def apply[Like,"+types.mkString(", ")+"]("+
types.map(t => t.toLowerCase + ": AtomExtension[Like,"+t+"]").mkString(", ")+
"): AtomExtension[Like,("+types.mkString(", ")+")] = new AtomExtension[Like, "...
but search-and-replace on tokens you leave behind works well also.



On Fri, Jan 13, 2012 at 3:46 AM, Erlend Hamnaberg <ngarthl@gmail.com> wrote:
Hello guys and gals.
I am building an Atom Library using Daniel Spiewak's anti-xml. 
I have built an extension mechanism using the trait found here https://github.com/arktekk/scala-atom/blob/master/src/main/scala/no/arktekk/atom/extension/AtomExtension.scala
The problem is that when I want to compose multiple Extensions the signature kind of explodes.
Is there a more general way to do this?

Best regards
Erlend

PS: I have looked at HList, which will probably work.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland