94.3k views
4 votes
What is the type of the following Haskell expression: "hello world"

A) (String)
B) [Char]
C) (Char)
D) String

User Jakentus
by
8.3k points

1 Answer

4 votes

Final answer:

The Haskell expression "hello world" is of type B) [Char], which is equivalent to String in Haskell context.

Step-by-step explanation:

The type of the Haskell expression "hello world" is B) [Char]. In Haskell, strings are represented as lists of characters. When you see double quotes around characters, it's Haskell's syntactic sugar for a list of characters. Therefore, the expression is of type [Char], which is synonymous with String in Haskell, though the latter is often used in contexts where the former type signature is expected.

User Philip Regan
by
7.6k points