4

私は書き直そうとしていました:

return $ renderHtml $ mconcat $ intersperse " " $ catMaybes links

これは、次のように問題なく機能します。

return $ renderHtml $ mconcat $ unwords $ catMaybes links

しかし、それは戻ってきています:

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

私は Haskell に関してはまだ最高ではありませんが、私は考えintersperse " "ましunwordsた。

編集:最終的には、使用方法を見つけたいと思いますunwords...エラーが発生する理由と、それを回避する方法を理解することが目標です! =)

4

2 に答える 2

2

あなたが持っているものは、使用すれば機能しますLANGUAGE OverloadedStrings

それ以外の場合は、intersperse (text " ")代わりに使用しintersperse " "ます。

例えば:

{-# LANGUAGE OverloadedStrings #-}

import Text.Blaze.Html
import Text.Blaze.Renderer.String
import Data.Maybe
import Data.List
import Data.Monoid

foo links = renderHtml $ mconcat $ intersperse " " $ catMaybes links
于 2015-07-19T07:01:58.527 に答える