我正在研究“向你学习哈斯克尔”,我在研究么半群。在本节中,作者按如下方式定义了树的foldMap方法:
instance F.Foldable Tree where
foldMap f Empty = mempty
foldMap f (Node x l r) = F.foldMap f l `mappend`
f x `mappend`
F.foldMap f r
它工作得很好而且完全是球型的。然而,他接着说:“现在我们的
给出一个Maybe Int,我试着将它mappend到自己。
$let x = Just 55 :: Maybe Int
$mappend x x
<interactive>:126:1:
No instance for (Monoid Int) arising from a use of `mappend'
In the expression: mappend x x
In an equation for `it': it = mappend x x
看着,我看到:
么半群a =>么半群(可能是a)
由于不实现Monoid类型类
大家好,我想在我们的网站上添加微信的分享链接按钮,就像其他的一样:
<a class="skype social-icon" href="https://web.skype.com/share?url=http://example.com&text=I wanted you to see this site" target="_blank" title="Skype"><i class="fa fa-skype fa-lg"></i></a>
&