首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Heist-0.13的默认AttrSplices是什么?

Heist-0.13的默认AttrSplices是什么?
EN

Stack Overflow用户
提问于 2013-09-15 15:30:58
回答 1查看 219关注 0票数 1

我正在使用Heist进行一个项目,由于它最近升级到0.13版本,我试用了它,发现原来的HeistConfig改变了很多。

代码语言:javascript
复制
data HeistConfig m = HeistConfig
    { hcInterpretedSplices :: Splices (I.Splice m)
        -- ^ Interpreted splices are the splices that Heist has always had.  They
        -- return a list of nodes and are processed at runtime.
    , hcLoadTimeSplices    :: Splices (I.Splice IO)
        -- ^ Load time splices are like interpreted splices because they return a
        -- list of nodes.  But they are like compiled splices because they are
        -- processed once at load time.  All of Heist's built-in splices should be
        -- used as load time splices.
    , hcCompiledSplices    :: Splices (C.Splice m)
        -- ^ Compiled splices return a DList of Chunks and are processed at load
        -- time to generate a runtime monad action that will be used to render the
        -- template.
    , hcAttributeSplices   :: Splices (AttrSplice m)
        -- ^ Attribute splices are bound to attribute names and return a list of
        -- attributes.
    , hcTemplateLocations  :: [TemplateLocation]
        -- ^ A list of all the locations that Heist should get its templates
    }

所以现在我不能再使用[]作为默认连接,因为有defaultInterpretedSplices和defaultLoadTimeSplices,我发现defaultAttrSplices刚刚错过,那么我应该如何定义它呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-15 20:22:10

我认为没有内置的AttrSplices。您应该能够使用memptyreturn ()或来自Heist.SpliceAPInoSplices之一绑定任何剪接。

Splices sSplicesM s ()的类型别名,它只是一个包装在newtype中的StateSlices s也是Monoid类的实例,所以您可以在这里使用mempty。

代码语言:javascript
复制
newtype SplicesM s a = SplicesM { unSplices :: State (Map Text s) a }
  deriving (Monad, MonadState (Map Text s))

type Splices s = SplicesM s ()

instance Monoid (Splices s) where
  mempty = noSplices
  mappend = unionWithS (\_ b -> b)
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18814101

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档