- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 prettyprinter
图书馆到prettyprint foo(bar, baz)
,当边距太窄时,我希望它看起来像:
foo(
bar,
baz)
我怎么做?
> import Prettyprinter
> import Prettyprinter.Util
> let commas = punctuate comma
-- 'sep' and 'nest' seem to go well together, but the result lacks the linebreak
> putDocW 10 ("foo" <> parens (nest 2 (sep (commas ["bar", "baz"]))))
foo(bar,
baz)
-- Using 'line'' inside 'nest' almost does the trick
> putDocW 10 ("foo" <> parens (nest 2 (line' <> sep (commas ["bar", "baz"]))))
foo(
bar,
baz)
-- Except 'line'' doesn't seem "mempty" enough
> putDocW 20 ("foo" <> parens (nest 2 (line' <> sep (commas ["bar", "baz"]))))
foo(
bar, baz)
我以为我想要的是
line'
因为提到
mempty
:
line'
is likeline
, but behaves likemempty
if the line break is undone bygroup
(instead ofspace
).
group
撤消”的作用。
line
、
softline
和
softline'
)似乎都没有给出更好的结果。
最佳答案
我不相信这是“正确”的方式,但这里有一个方法:
hcat
[ "prefix"
, nest 2 $ cat
$ "("
: punctuate (flatAlt "," ", ")
[ "first"
, "second"
, "third"
]
, ")"
]
也就是说,将左括号和标点元素的串联卡在前缀之后,根据它们是否折叠,将它们分开有或没有尾随空格,并粘贴在右括号上。
encloseSep
变体在末尾而不是开头添加分隔符,并在
cat
中包含开始分隔符:
encloseSepEnd
:: Doc ann -> Doc ann -> Doc ann -> [Doc ann] -> Doc ann
encloseSepEnd open close sep docs = case docs of
[] -> open <> close
[doc] -> open <> doc <> close
_ -> cat (open : suffixReverse (close : repeat sep) docs)
suffixReverse
:: (Foldable t, Semigroup a)
=> [a] -> t a -> [a]
suffixReverse separators
= snd . foldr go (separators, [])
where
go doc (sep : seps, acc) = (seps, doc <> sep : acc)
hcat
[ "prefix"
, nest 2 $ encloseSepEnd "(" ")" ", "
["first", "second", "third"]
]
除此之外,老实说,我发现我总是必须替换括号函数,例如
parens
用它们单独的部分来达到我想要的结果,以及
group
从不表现得像我希望的那样。
关于haskell - pretty-print : Linebreak on narrow margin, 否则为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66235940/
我想在一个函数中包含一个限制语句,该函数测试在使用 org-narrow-to-subtree 之后缓冲区是否已经缩小到子树。谁能与我分享如何测试收窄条件是否有效?类似于 narrowp。 编辑:我在
static int var[2] __attribute__ ((aligned (8))) = { 0x0255cfa8, 0xfdfcddfc }; 为什么我收到警告:narro
我想做一个像mcmaster.com网站那样的侧边栏菜单。它允许您动态缩小产品范围并切换选项。正如您在图像中看到的,当选择“公制”选项时,所有页面都会根据基于公制的产品、侧边栏以及整个页面进行更改。有
我们阅读了 git narrow clones .假设我们想在极端情况下使用这个新功能最小带宽从大量远程存储库编辑一个文件并推回我们的提交。 唯一的例子是 git clone --no-checkou
我是C++的初学者,对转换有疑问。将int转换为char值时,如果在ASCII表上超过127,会发生什么? 例如, using namespace std; int main() { double d
(Postgres 8.3) 我正在使用 X 100 多列宽的数据库表(遗憾的是我无法更改),其中许多列会通过正常的业务流程不断且非常频繁地更新。 我需要根据异常业务流程更新的 X 中特定列 foo
我想对此进行过滤,以便最终返回的列表中仅包含平均数量大于 350 的部件(因此部件 P3、P4 和 P6)。我尝试使用 *SELECT """"WHERE AVG(spjandq.qty)>350 I
我正在尝试从 sourceforge 编译 hosts3d,它确实编译但生成了几个缩小错误。我不知道如何解决这个问题,但我们将不胜感激任何帮助。我怀疑我可以下载以前版本的编译器,我可能最终会这样做,但
C++ Core Guidelines有一个 narrow如果类型转换更改值,则抛出。看着 microsoft implementation图书馆: // narrow() : a checked v
问题: 我的导航栏看起来一点都不像 http://jquerymobile.com/test/docs/toolbars/footer-persist-a.html 中示例中的导航栏 我做错了什么/有
假设我有一个类型族,我在基本类型中定义了一组方法: interface Foo { Foo a(); Foo b(); ... } 并且Bar扩展了Foo interface Bar
我在我的应用程序中使用此字体时遇到问题。我已经在我的资源中导入了 Arial-Narrow.ttf 文件,并且还在 info.plist 中添加了名称,如下所示 UIAppFonts Ari
假设我有一段 HTML 的结构如下: Loooooooooooooong Short Meeeedium ...我想利用 CSS 获得
我一直在为一个学校元素编码,我遇到了这个问题,我想要一个标题而不是宽泛的标题。我是 Stack Overflow 的新手,我希望我不是在问一个非常愚蠢的问题,但我在事先搜索时没有找到答案。 我的代码是
我正在查看 Bootstrap 站点示例 http://getbootstrap.com/examples/jumbotron-narrow/#当我将鼠标悬停在“关于”或“联系”链接上时,文本周围会出
我正在尝试编写一个简单的无状态 session bean,但我在查找时间中给出的窄引用有问题。我得到了 class cast exeption 我用 eclipse IDE 我的 bean 类 pac
我尝试在启用 gcc 和 C++11 的情况下编译以下代码: unsigned int id = 100; unsigned char array[] = { id % 3, id % 5 }; 我收
#main{ margin-left: auto; margin-right: auto; margin-top: 0; font-family: "Arial Narrow"; position
g++ 4.9.0-O2 -std=c++11 template struct vec3 { T x, y, z; vec3() = default; vec3(const v
我正在使用 prettyprinter 图书馆到prettyprint foo(bar, baz) ,当边距太窄时,我希望它看起来像: foo( bar, baz) 我怎么做? 到目前为止我最
我是一名优秀的程序员,十分优秀!