I am a newcomer to Haskell and I am trying to build a simple website with a library called Reflex.Dom and the Cascading Style Sheets (CSS) are represented as a Map Text Text
object, that's nice but Haskell is distinguishing between three, nearly-identical objects:
String
Text
[Char]
Certainly, in Python or JavaScript these are the same or nearly the same and functions can be used interchangeably between one object and the other. Not the case in Haskell.
"style" =: pack("color:red")
how about
"style" =: pack("color:red; font-family: Helvetica;")
If I add another style element, I get an error message:
square-01.hs:6:47:
Couldn't match type ‘Text’ with ‘[Char]’
Expected type: String
Actual type: Text
In the second argument of ‘(=:)’, namely ‘pack ("color:red")’
In the second argument of ‘elAttr’, namely
‘("style" =: pack ("color:red"))’
Here is a little bit from Prelude but I don't really get it.
Prelude Reflex.Dom Data.Text Data.Map> "a" =: pack("b")
fromList [("a","b")]
Prelude Reflex.Dom Data.Text Data.Map> :t "a" =: pack("b")
"a" =: pack("b") :: Map [Char] Text
Prelude Reflex.Dom Data.Text Data.Map> "a" =: "b"
fromList [("a","b")]
Prelude Reflex.Dom Data.Text Data.Map> :t "a" =: "b"
"a" =: "b" :: Map [Char] [Char]
Prelude Reflex.Dom Data.Text Data.Map> :t (=:)
(=:) :: k -> a -> Map k a