'a' is a Char, a single character.
['a','b','c'] is a string, a list-of-Char. This list can also be written as "abc", using double quotes. Its type can be written as String or [Char].
["abc", "de"] is a list of strings. Its type can be written as [String] or [[Char]] (list-of-lists-of-Char).
We could go on, and say that [["abc","de"], ["ef", "abc"]] is a [[String]] (list-of-lists-of-strings) or [[[Char]]].
Your revStr takes as input not a single string, but a list of strings, hence the [[Char]] type. Its output is again a list of strings.
What is the difference between [[Char]] and [Char] in Haskell? - Stack Overflow
If a string is a list of characters, then why doesn't this work?
get first char of a String
plutus pioneer program - Is type String truly equal to type [Char], and is Haskell truly "pure"? - Cardano Stack Exchange
'a' is a Char, a single character.
['a','b','c'] is a string, a list-of-Char. This list can also be written as "abc", using double quotes. Its type can be written as String or [Char].
["abc", "de"] is a list of strings. Its type can be written as [String] or [[Char]] (list-of-lists-of-Char).
We could go on, and say that [["abc","de"], ["ef", "abc"]] is a [[String]] (list-of-lists-of-strings) or [[[Char]]].
Your revStr takes as input not a single string, but a list of strings, hence the [[Char]] type. Its output is again a list of strings.
Charis a character, meaning a single symbol like'A','$'or'3'[Char]is a list of characters, also called a String (note[Char] = String) like['A','$','3'] = "A$3"[[Char]]is a list of lists of characters, (also[[Char]] = [String]). This is essentially a list of Strings like["Hello", "World"]
revStr reverses all Strings (or [Char]) in the provided List, thus its type is a list of Strings
All the code is here (https://github.com/djotaku/adventofcode/blob/800175cb4e0a69cb8d15e88d0727a07e7108fd8d/2016/Day_02/Haskell/solution.hs) if you need to understand what's in findNextNumber, but basically, I have this function:
findNumberRow number directionList = foldl findNextNumber number directionList
If I feed it:
findNumberRow 4 ["R", "L"]
I get the right answer. But if I feed it:
findNumberRow 4 "RL"
I get:
error:
• Couldn't match type ‘Char’ with ‘[Char]’ Expected type: [[Char]] Actual type: [Char] • In the second argument of ‘findNumberRow’, namely ‘"RL"’ In the expression: findNumberRow 4 "RL" In an equation for ‘it’: it = findNumberRow 4 "RL"
Why? I thought "ERIC" was equal to ["E","R","I","C"] in Haskell.
Hey there Im new with Haskell, for a function i need to get the first char out of a String, any Idea how i could do this?