Scala blogs aggregated
A minor release of shapeless. The main changes include,
Scrap Your Boilerplate improvements
shapeless is an exploration of type class and dependent type based generic programming in Scala.
A series of articles on the implementation techniques used will appear here and it also has a mailing list.
Permalink
May 14, 2012 01:26 PM
X-Http-Method-Override
header.
Scalatra is a tiny, Sinatra-like web framework for Scala.
Permalink
May 11, 2012 03:05 PM
SIP-18 is a bad idea because it makes awful assumptions about what is in the interest of language newcomers. I have had no shortage of unsolicited advice of how to teach, most of it in layers of wrongness, so I am acutely aware of the sheer quantity of this kind of advice. Please refrain for now. This is only my opinion, because it has been asked of me more than twice.
SIP-18 (and the Scala collections library for that matter) is no different to Haskell’s (dreaded) monomorphism restriction (DMR). The DMR was introduced specifically because of another chronically bold over-estimate of one’s ability to understand the process of learning. It is now an undesired language issue that hinders all users, especially newcomers. In other words, it serves nobody’s interest, hinders everyone’s interest and especially, the interest of those for whom it was meant to serve. You need only spend a short period of time with newcomers to Haskell to be overwhelmed by the prominence of this fact.
I can hear the pragmatists in the background muttering something about trade-offs, not being so extreme and keeping it relevant to the real world and blah blah blah, <insert the usual pragmatist bullshit here>. There is nothing to be traded off when you offer to take $5 from me for the low cost of $10. Now stop it and get your head out of the clouds so I can talk to you sensibly.
Not only does SIP-18 not help newcomers at all, it helps nobody, hinders everybody and especially newcomers. It is not a trade-off, it is not a good idea; it is simply a bold, severely misguided assertion about how learning takes place — it’s not even an approximation. I have seen only scant pseudo-psychology to support its existence, which obviates its predictable failure.
Hopefully, the Scala guys will work this out, but if Scala’s remarkable precision to repeat historical mistakes is anything to go by, I do not hold high hopes.
Thanks for asking.
by Tony Morris at May 11, 2012 03:12 AM
A few days back the Scala IDE team released an early preview of the Scala IDE V2.1 for Eclipse, based on the new milestone (M3) for the upcoming Scala 2.10. This release has all the new features in the Scala IDE M1, plus a few minor changes needed in order to support 2.10.
You can see the Release Notes for M1 to check the new features in the Scala IDE, and the Scala Change Log for what’s new in Scala 2.10. Read more...
by dotta at May 10, 2012 06:02 AM
by Jesper Nordenberg (noreply@blogger.com) at May 09, 2012 10:18 PM
This is a feature release, adding a the full set of useful XPath Axe, string based XPath evaluation - via a popular open source XPath library, useful equality testing, a lot of new documentation and many smaller improvements in syntax and usability.
This version has been built with xsbt 0.11.x and migrated to github. This releases documentation can be found here and provides many examples on how to use Scales Xml.
Scales 0.3 adds the following axe:
This provides all of the XPath 1 and 2 axe (namespace axis excluded).
position() (pos)
pos\_<, pos\_==, pos\_>
last() (last)
last\_<, last\_==, last\_>
Easier to extend and re-use queries and axe
xfilter, xmap, xflatMap
Implementations for all relevant Scales Xml types
XmlComparison type classes provide full details of differences:
Scales 0.3 moves to Sonatype under the organisation org.scalesxml, with support for 2.8.1, 2.8.2, 2.9.1 and 2.9.2. As such add:
libraryDependencies ++= Seq( // just for the core library "org.scalesxml" %% "scales-xml" % "0.3-RC6" // or, use this instead for String based XPaths (Jaxen, also includes the core) "org.scalesxml" %% "scales-jaxen" % "0.3-RC6" )
to your xsbt builds or use scales-xml_2.9.2 as the id when using Maven.
Scales Xml is an alternate xml library for Scala providing a coherent model, querying and manipulation via an XPath like syntax, better performance, highly customisable equality framework and an Iteratee based pull api.
Permalink
May 08, 2012 05:54 AM
buildInfoBuildNumber
. #2
sbt-buildinfo is a plug-in for sbt to generate Scala source from your build definitions.
Permalink
May 08, 2012 03:14 AM
sbt-assembly is a plug-in for Simple Build Tool that creates a single jar of your project including all of its dependencies.
Permalink
May 08, 2012 02:54 AM
--quiet
, --recurse
, --stdin
, --stdout
options to command-line tool
5.f
, 5.d
as floating points, unless in Scala 2.11+ mode
--scalaVersion=<version>
flag to command-line tool
expr[T1, T2][T3, T4]
and g()[String]
syntaxes
Scalariform is a source code formatter for Scala.
Permalink
May 07, 2012 09:20 PM
May 07, 2012 03:18 PM
May 07, 2012 02:11 PM
Small maintenance release, including:
FileNotFoundException
is thrown
(issue #8) -- Martin Konicek
NoSuchElementException
with a message
clearly refering to the missing key (issue #11) -- Jussi Virtanen
If you wish for extra features, feel free to ask.
Configrity is a simple, immutable and flexible Scala API for handling configurations.
Permalink
May 07, 2012 08:02 AM
This substantial contribution by g-eorge handles file of uploads of arbitrary size, as previously supported only for filter plans. See the netty-uploads readme for details.
Migration Note: If you were using the unfiltered-uploads module before, you should now depend on unfiltered-filter-uploads. The former now serves as a base implementation for the filter and netty upload modules.
HttpRequest
object in the older fashion of Unfiltered. This is altered to now only yield the charset, which is a breaking change. If you see a compilation error for a Charset matcher, simply remove the trailing prameter in its parameter list. Unfiltered is a toolkit for servicing HTTP requests in Scala.
Permalink
May 07, 2012 04:47 AM
by Tim Azzopardi (noreply@blogger.com) at May 06, 2012 10:17 PM
flatMap Oslo (May 15, 16) is Norway’s first Scala conference, and the first anywhere to have such exciting light fixtures. (Good speaker lineup, too.)
May 06, 2012 02:39 PM
Java: Call an anonymous PLSQL Block with one input string and one output string parameter and one output cursor (query result) parameter :
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Types;
public class CallPLSQLBlockWithOneInputStringAndOneOutputStringParameter {
// Warning: this is a simple example program : In a long running application,
// exception handlers MUST clean up connections statements and result sets.
public static void main(String[] args) throws SQLException {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
final Connection c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "manager");
String plsql = "" +
" declare " +
" p_id varchar2(20) := null; " +
" begin " +
" p_id := ?; " +
" ? := 'input parameter was = ' || p_id;" +
" end;";
CallableStatement cs = c.prepareCall(plsql);
cs.setString(1, "12345");
cs.registerOutParameter(2, Types.VARCHAR);
cs.execute();
System.out.println("Output parameter was = '" + cs.getObject(2) + "'");
cs.close();
c.close();
}
}
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Types;
import oracle.jdbc.OracleTypes;
public class CallPLSQLBlockWithOneInputStringAndOneOutputStringParameterAndOneOutputCursorParameter {
public static void main(String[] args) throws Exception {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
final Connection c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "manager");
String plsql = "" +
" declare " +
" p_id varchar2(20) := null; " +
" l_rc sys_refcursor;" +
" begin " +
" p_id := ?; " +
" ? := 'input parameter was = ' || p_id;" +
" open l_rc for " +
" select 1 id, 'hello' name from dual " +
" union " +
" select 2, 'peter' from dual; " +
" ? := l_rc;" +
" end;";
CallableStatement cs = c.prepareCall(plsql);
cs.setString(1, "12345");
cs.registerOutParameter(2, Types.VARCHAR);
cs.registerOutParameter(3, OracleTypes.CURSOR);
cs.execute();
System.out.println("Result = " + cs.getObject(2));
ResultSet cursorResultSet = (ResultSet) cs.getObject(3);
while (cursorResultSet.next ())
{
System.out.println (cursorResultSet.getInt(1) + " " + cursorResultSet.getString(2));
}
cs.close();
c.close();
}
}
import java.sql.Array;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Types;
import oracle.jdbc.OracleTypes;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
public class CallPLSQLBlockWithOneInputStringArrayAndOneOutputStringParameterAndOneOutputCursorParameter {
public static void main(String[] args) throws Exception {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
// Warning: this is a simple example program : In a long running application,
// error handlers MUST clean up connections statements and result sets.
final Connection c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "manager");
String plsql = "" +
" declare " +
" p_id string_array := null; " +
" l_rc sys_refcursor;" +
" begin " +
" p_id := ?; " +
" ? := 'input parameter first element was = ' || p_id(1);" +
" open l_rc for select * from table(p_id) ; " +
" ? := l_rc;" +
" end;";
String[] stringArray = new String[]{ "mathew", "mark"};
// MUST CREATE THIS IN ORACLE BEFORE RUNNING
System.out.println("(This should be done once in Oracle)");
c.createStatement().execute("create or replace type string_array is table of varchar2(32)");
ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor( "STRING_ARRAY", c );
Array array_to_pass = new ARRAY( descriptor, c, stringArray );
CallableStatement cs = c.prepareCall(plsql);
cs.setArray( 1, array_to_pass );
cs.registerOutParameter(2, Types.VARCHAR);
cs.registerOutParameter(3, OracleTypes.CURSOR);
cs.execute();
System.out.println("Result = " + cs.getObject(2));
ResultSet cursorResultSet = (ResultSet) cs.getObject(3);
while (cursorResultSet.next ())
{
System.out.println (cursorResultSet.getString(1));
}
cs.close();
c.close();
}
}
import java.sql.Array;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import oracle.jdbc.OracleTypes;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
public class CallPLSQLBlockWithOneInputStructureArrayAndOneOutputStringParameterAndOneOutputCursorParameter {
public static void main(String[] args) throws Exception {
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
// Warning: this is a simple example program : In a long running application,
// error handlers MUST clean up connections statements and result sets.
final Connection c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "manager");
String plsql = "" +
" declare " +
" p_id student_array := null; " +
" l_rc sys_refcursor;" +
" begin " +
" p_id := ?; " +
" ? := 'input parameter first element was = (' || p_id(1).id_num || ', ' || p_id(1).name || ')'; " +
" open l_rc for select * from table(p_id) ; " +
" ? := l_rc;" +
" end;";
// MUST CREATE ORACLE TYPES BEFORE RUNNING
setupOracleTypes(c);
StructDescriptor structDescr = StructDescriptor.createDescriptor("STUDENT", c);
STRUCT s1struct = new STRUCT(structDescr, c, new Object[]{1, "mathew"});
STRUCT s2struct = new STRUCT(structDescr, c, new Object[]{2, "mark"});
ArrayDescriptor arrayDescr = ArrayDescriptor.createDescriptor( "STUDENT_ARRAY", c );
Array array_to_pass = new ARRAY( arrayDescr, c, new Object[]{s1struct, s2struct} );
CallableStatement cs = c.prepareCall(plsql);
cs.setArray( 1, array_to_pass );
cs.registerOutParameter(2, Types.VARCHAR);
cs.registerOutParameter(3, OracleTypes.CURSOR);
cs.execute();
System.out.println("Result = " + cs.getObject(2));
ResultSet cursorResultSet = (R