Tag Info

Hot answers tagged

9

In general, you use higher-rank polymorphism when you want the callee to be able to select the value of a type parameter, rather than the caller. For example: f :: (forall a. Show a => a -> Int) -> (Int, Int) f g = (g "one", g 2) Any function g that I pass to this f must be able to give me an Int from a value of some type, where the only thing g ...


8

In the java world, it is called Runnable. In the C# world, it is called Action. But, there is a better name which nicely fits within a larger view of things. The larger view of things comes later, when you decide that besides your parameterless void functional interface you also need to have similar functional interfaces that accept one, two, or more ...


6

Higher rank polymorphism is extremely useful. In System F (the core language of typed FP languages you're familiar with), this is essential for admitting "typed Church encodings" which is actually how System F does programming. Without these, system F is completely useless. In System F, we define numbers as Nat = forall c. (c -> c) -> c -> c ...


4

Well, you already hinted at the answer. Imperative programming is closer to the metal, so it makes more sense in places (like embedded) where you're working closer to the metal. Nobody would bother programming an Arduino in Haskell (well, except maybe for @JimmyHoffa), though programming one in Scheme is not unheard of. Some other reasons: Computing ...


3

You call the types "similar", but they're only similar to you. Compiler knows nothing of this similarity, so you either need the compiler to learn about it, or alleviate it somehow. Here are some possible solutions that I would consider in this situation: Bite the bullet and list all the cases (aka the quick one) Before considering more involved ...


2

I'm not sure how easy this would be to implement in Scala, but here's how I'd look to structure it in Haskell: To begin I'm going to review a couple of the monads which Haskell and F# provide -- You're probably familiar with them, but I'll review them just to set the stage. In Haskell there is the IO monad which is used for doing IO operations (e.g. web ...


1

NO. And I'm surprised how many people voted otherwise! Paradigm It's Data-Oriented a.k.a. Data-Driven because we are talking about the architecture and not the language it's written in. Architectures are realizations of programming styles or paradigms, which can usually be unadvisably worked around in a given language. Functional? Your comparison to ...



Only top voted, non community-wiki answers of a minimum length are eligible