What does instance mean in Haskell?
If you're interested in explanation of type classes and difference from Java interfaces you should read this post by <❤>. It also explains instances as well.
As for me, I look at instance
as connection between data type and interface. data
contains some information, class
contains methods. data
is about data (sorry for tautology) and class
is about behavior. When you look at data type you don't see what you can do with it, instead you see what it stores. When you look at class
you see what type should be able to do, you don't care what it stores internally. In real programming you actually care about details of implementations and how methods implemented using specific data. So instance
just shows you relation between some data and some behavior — how this behavior implemented using given data.
In case you're interested more in model of type classes then read this blog post: http://www.haskellforall.com/2012/05/scrap-your-type-classes.html
You can look at instances as a values! It might blow your mind if you face such definition first time.
In some dependently type languages instances
are really values that you can pass to other functions. Take a look at this question:
In Idris, is "Eq a" a type, and can I supply a value for it?
In Java, the class system is a way to group similar objects. An instance of a class is an individual object which belongs to that class.
In Haskell, the class system is (roughly speaking) a way to group similar types. (This is the reason we call them "type classes"). An instance of a class is an individual type which belongs to that class. (That is, until you start considering multiparametric type classes).
Incidentally, a Haskell (monoparametric) class somewhat resembles a Java interface and, by extension, a Java class. Or perhaps a Haskell instance resembles Java class. It's better to view this as a coincidence. Approach the term keeping its mathematical origins in mind. A class is just a bunch of things that belong together, and an instance is one of these things.