What's the difference between the “data” and “type” keywords?
问题 The data and type keywords always confuse me. I want to know what is the difference between data and type and how to use them. 回答1: type declares a type synonym . A type synonym is a new name for an existing type. For example, this is how String is defined in the standard library: type String = [Char] String is another name for a list of Char s. GHC will replace all usages of String in your program with [Char] at compile-time. To be clear, a String literally is a list of Char s. It's just an