Why is Haskell missing “obvious” Typeclasses

As other answers have pointed out, Haskell tends to use different vocabulary. However, I don’t think they’ve explained the reason for the difference very well. In a language like Java, functions are not “first class citizens”; it’s true that anonymous functions are available in the latest versions, but this style of interface (Collection, Indexable, Interable, … Read more

Is returning IList worse than returning T[] or List?

Maybe this is not directly answering your question, but in .NET 4.5+, I prefer to follow these rules when designing public or protected APIs: do return IEnumerable<T>, if only enumeration is available; do return IReadOnlyCollection<T> if both enumeration and items count are available; do return IReadOnlyList<T>, if enumeration, items count and indexed access are available; … Read more

What does “abstract over” mean?

In algebra, as in everyday concept formation, abstractions are formed by grouping things by some essential characteristics and omitting their specific other characteristics. The abstraction is unified under a single symbol or word denoting the similarities. We say that we abstract over the differences, but this really means we’re integrating by the similarities. For example, … Read more

Meaning of Leaky Abstraction?

Here’s a meatspace example: Automobiles have abstractions for drivers. In its purest form, there’s a steering wheel, accelerator and brake. This abstraction hides a lot of detail about what’s under the hood: engine, cams, timing belt, spark plugs, radiator, etc. The neat thing about this abstraction is that we can replace parts of the implementation … Read more

What is the difference between an interface and a class, and why I should use an interface when I can implement the methods directly in the class?

Interfaces are excellent when you want to create something like it: using System; namespace MyInterfaceExample { public interface IMyLogInterface { //I want to have a specific method that I’ll use in MyLogClass void WriteLog(); } public class MyClass : IMyLogInterface { public void WriteLog() { Console.Write(“MyClass was Logged”); } } public class MyOtherClass : IMyLogInterface … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)