Thursday, May 26, 2016

Using F# modules and types from C#

It's simple to use FSharp modules from C#, but for some reason I always forget exactly how the system works
(maybe too much switching back and forth between Scala/C#/F#/Java...).

Here's some F# snippets and a C# example of how to pull them together. The weird one is C#'s "using static", since the name seems to indicate that it's just pulling in static methods. In addition to pulling in static methods, though, it also pulls in nested types.

Consuming from F# is slightly simpler:

Here's the F# specification for more details.

Wednesday, February 10, 2016

Fun with Shapeless - functions taking arguments converted to functions taking HList's

I'm starting to play with the Shapeless Scala library.

Here's how to take a normal function and turn it into a function that accepts an HList instead of the original arguments.

Sunday, December 27, 2015

Intellij not adding things to the classpath - Exception in thread "main" java.lang.NoSuchMethodError: shapeless.Witness$.mkWitness(Ljava/lang/Object;)Lshapeless/Witness;

Using Intellij? Just added circe (or shapeless, I'm guessing)? Seeing these sorts of exceptions?

Exception in thread "main" java.lang.NoSuchMethodError: shapeless.Witness$.mkWitness(Ljava/lang/Object;)Lshapeless/Witness;
at Example$fresh$macro$73$1.inst$macro$1$lzycompute(PicklingApp.scala:26)
at Example$fresh$macro$73$1.inst$macro$1(PicklingApp.scala:26)
at Example$.delayedEndpoint$Example$1(PicklingApp.scala:26)
at Example$delayedInit$body.apply(PicklingApp.scala:16)
at scala.Function0$class.apply$mcV$sp(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.App$$anonfun$main$1.apply(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35)
at scala.App$class.main(App.scala:76)
at Example$.main(PicklingApp.scala:16)
at Example.main(PicklingApp.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.intellij.rt.execution.application.AppMain.main(

Just restart Intellij. It's become confused about the classpath.