Search code examples
haskellfunctional-programming

Interfaces in functional programming


In java and c# we have interfaces, what is the equivalent to that in a language like haskell or what is the concept called in functional programming?


Solution

  • There are things like typeclasses, as the other answers say, but even more than that, there's one pervasive interface: a function. Many, many places where an object-oriented program would need some custom interface, a similar functional program can just use a function. eg, map f xs in haskell uses f, where an object-oriented program might use a Strategy or whatever to accomplish the same task.