简体   繁体   English

Haskell:HStringTemplate继承示例?

[英]Haskell: HStringTemplate inheritance example?

I'm going a little nuts trying to figure out how to use template inheritance in Haskell's HStringTemplate. 我试着弄清楚如何在Haskell的HStringTemplate中使用模板继承。 Basic template usage is easy enough, but missing something inheritance is concerned. 基本模板的使用很简单,但缺少某些继承。 Can anyone point me in the direction a decent example? 任何人都可以指出我的方向一个体面的例子吗? The document below just isn't complete enough to graduate to more advanced usage. 下面的文档不够完整,无法升级到更高级的用法。

http://www.haskell.org/haskellwiki/HStringTemplate <-- No help!! http://www.haskell.org/haskellwiki/HStringTemplate < - 没有帮助!!

Ok finally figured it out. 好吧终于想通了。 You wouldn't belive how long I've been staring at the Hackage docs, trying to piece this together. 你不会相信我多久盯着Hackage文档,试图把它拼凑起来。 Here's a contrived example, for those of you who follow: 这是一个人为的例子,对于那些关注你的人:

let p = newSTMP "Parent --> $child()$" :: StringTemplate String
let c = newSTMP "Child --> Your content Here." :: StringTemplate String

let grp = groupStringTemplates [("parent", p),("child", c)]

putStrLn $ toString $ fromJust $ getStringTemplate "parent" grp

This prints: 这打印:

Parent --> Child --> Your content Here.

I'll add that I think some of my difficulty has to do with the fact that I'm not all that familiar with Java's StringTemplate. 我要补充一点,我认为我的一些困难与我不熟悉Java的StringTemplate这一事实有关。 I'm still not sure to what degree Haskell's package emulates Java's. 我仍然不确定Haskell的包在多大程度上模仿Java。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM