Tag Info

New answers tagged

4

These sorts of concepts are usually easiest to understand with a concrete example. Consider the following excerpt from this Flow API example: Flow(text.split("\\s").toVector). // transform map(line => line.toUpperCase). // print to console (can also use ``foreach(println)``) foreach(transformedLine => ...


13

I am not familiar with the Flow API. The term “lifting” comes from category theory. In programming languages such as Haskell or Scala, a lift function takes a function A => B, and somehow performs magic so that the lifted function F[A] => F[B] can be applied to a functor or monad F[A]. A concrete example using Scala's Seq container: Assume we have a ...


5

The term to lift can of course have different meanings depending on the context. In generic programming it describes the process of abstracting to the next higher level. For example, you could have two pieces of code, one type with int, and the other with float. Lifting this code would mean something like templating the method with a generic type T that ...


2

In Java-like languages, interfaces describe object types, classes describe abstract data types. "Design with interfaces first" is not the same as "design with types first", simply because in a Java-like language classes (and primitives) are also types (but not object types). So, "design with interfaces first" really just means "do OO". However, "design with ...


2

First things first, I don't see how programming to interfaces addresses the expression problem. In short, the expression problem states that you can only add new data or new functions to a datatype (without recompiling) - not both. Programming to most interfaces lets you make new functions that use that interface, but you can't add data to the interface ...


3

A small case study: a pattern matcher in two pseudo-languages, first OO and then functional In OOP, designing interface-first interface IPatternMatcher { bool Match(string toMatch) } The above is the only interface we need, but it doesn't really give us any clues about how to design our implementing types. You will probably want some composites, so ...


1

The data should be provided in the project, but outside the library/binary. That is the data should be provided as part of the source archive the user downloads (unless very large; large data should be provided separately), but they should take no part in the build process. So they'd go in sample or something and the user will load that data just the way ...


2

I found this. The Haskell equivalent is sequence, and Clojure has a something similar in juxt, which takes a list of functions and returns a function that applies them all to a single value. Given the very different names, it does not seem like there is a term for the concept that is widely accepted between languages.


2

It's just called a map. Functions being first-class means they usually aren't any different from any other list element, including in terminology. There's a better way of expressing it, however. You generally don't use Function or Object directly like that, as you're throwing away a lot of type information. Here's a better implementation: def dmap[A, ...


0

Because it is confusing, therefore it is easier to introduce bugs. One of the most famous in C is: if (a = b) instead of if (a == b). With a distinction between expressions and statements, the compiler would have complained. Going on with C, there is a specific form of if whenever it should return a value: pred ? f(x) : g(x)


-1

The if could return a value here because both of the functions also return values. But there are void functions as well, and f and g might have different return types, which would make it unclear what the type of this if would be. In effect, if you ban statements from a programming language, you also ban void methods, strict typing and some more common ...


1

You could also take a look at this Jenkins plugin: https://wiki.jenkins-ci.org/display/JENKINS/Build+Blocker+Plugin. I would recommend re-architecting your app. As a general approach and good practice, I would recommend versioning your projects/components. Each component will depend on a specific version of the other component. In this way you have full ...


7

For a moment, lets head over to Stack Overflow - How slow are Java exceptions? It turns out that the expensive part of throwing exceptions is the population of the stack trace that goes along with the exception. This stack trace is very helpful when debugging problems to try to figure out where things are getting called from. One of the standard questions ...



Top 50 recent answers are included