Unable to deserialize lambda

You can’t deserialize an object without the class defining it. This hasn’t changed with lambda expressions. Lambda expressions are a bit more complex as their generated runtime class is not the class which defined it but their defining class is the one holding the code of the lambda’s body and, in case of serializable lambdas, … Read more

Lambda for type expressions in Haskell?

While sclv answered your direct question, I’ll add as an aside that there’s more than one possible meaning for “type-level lambda”. Haskell has a variety of type operators but none really behave as proper lambdas: Type constructors: Abstract type operators that introduce new types. Given a type A and a type constructor F, the function … Read more

What is the difference between a lambda and a method reference at a runtime level?

Getting Started To investigate this we start with the following class: import java.io.Serializable; import java.util.Comparator; public final class Generic { // Bad implementation, only used as an example. public static final Comparator<Integer> COMPARATOR = (a, b) -> (a > b) ? 1 : -1; public static Comparator<Integer> reference() { return (Comparator<Integer> & Serializable) COMPARATOR::compare; } … Read more

How to raise PropertyChanged event without using string name

Added C# 6 Answer In C# 6 (and whatever version of VB comes with Visual Studio 2015) we have the nameof operator which makes things easier than ever. In my original answer below, I use a C# 5 feature (caller info attributes) to handle the common case of “self-changed” notifications. The nameof operator can be … Read more

Proper Currying in C#

EDIT: As noted in comments, this is partial application rather than currying. I wrote a blog post on my understanding of the difference, which folks may find interesting. Well, it’s not particularly different – but I’d separate out the currying part from the “calling DoSomething” part: public static Func<TResult> Apply<TResult, TArg> (Func<TArg, TResult> func, TArg … Read more

Java Lambda expressions [closed]

Oracle already has tutorial up on the topic. It lists several great uses cases. Before I found the link, I was going to say that lambda expressions let you pass “functions” to code. So you can write code more easily that we used to need a whole mess of interfaces/abstract classes for. For example, suppose … Read more