I was trying to rewrite:
return $ renderHtml $ mconcat $ intersperse " " $ catMaybes links
Which works just fine, into:
return $ renderHtml $ mconcat $ unwords $ catMaybes links
but it is returning:
Couldn't match type ‘Char’
               with ‘blaze-markup-0.7.0.2:Text.Blaze.Internal.MarkupM ()’
Expected type: H.Html
  Actual type: Char
In the second argument of ‘($)’, namely
  ‘mconcat $ unwords $ catMaybes links’
In the second argument of ‘($)’, namely
  ‘renderHtml $ mconcat $ unwords $ catMaybes links’
In a stmt of a 'do' block:
  return $ renderHtml $ mconcat $ unwords $ catMaybes links
I'm not the greatest with Haskell yet, but I thought intersperse " " and unwords where just drop in replacements for one another?
Edit:  Ultimately, I'd like to figure out a way to use unwords... Figuring out why it's giving me the error and how I can work around it is the goal! =)
 
                        
The
unwords :: [String] -> Stringfunction only works on lists ofStrings. What you have is a list of values of typeMarkupM ().The reason why
intersperse :: a -> [a] -> [a]works is that it works of list on any type. WithOverloadedStringspragma the" "value has typeMarkupM(because that type has an instance forIsString). Theinterspersefunction takes a list of these markup values and puts spaces in between them but still returns a list of markup values. Finallymconcatjoins the list into a single value still of typeMarkupM (). With some pseudo data constructor you can imagine the values like this:There is no easy way to get
unwordsto work in this case as you don't have strings and converting to strings would lose you some benefits. Having the markup encapsulated in appropriate wrapper makes sure that you do not produce not well-formed HTML, for example.