我打算怎么使用排序?
在Haskell Turtle中,Sort具有类型(函数IO,Monadio io,ord a)=>壳A-> io [a]
。它采用外壳单元的形式的流,将其分为列表,然后将其包装在monadio
上???
这对我来说似乎是违反直觉的。我的初学者眼睛说monadio
仅在与外界互动时才能使用,sort
不需要做。
我本来希望sort
将为(ord a)=>壳A->壳A
,因此非常适合流。
这是软件包作者的监督,还是我不了解应该如何使用sort
?
In Haskell Turtle, sort has the type (Functor io, MonadIO io, Ord a) => Shell a -> io [a]
. It takes a stream in the form of a Shell monad, sorts it into a list, but then wraps it in a MonadIO
???
This seems counter-intuitive to me. My beginner eyes say that a MonadIO
should only be used when interacting with the outside world, which sort
doesn't need to do.
I would have expected sort
to be (Ord a) => Shell a -> Shell a
so it fits into a stream nicely.
Is this an oversight by the package authors, or am I not understanding how sort
should be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
monadio io => io [a]
比shell a
好,因为shell
是monadio
实例和选择
提升列表到shell
s。因此,如果愿意,您可以编写自己的更具体的sort
具有您喜欢的类型,并使用Turtle提供的sort
实现:MonadIO io => io [a]
is better thanShell a
, becauseShell
is aMonadIO
instance andselect
lifts lists toShell
s. So, if you want, you can write your own more specificsort
that has the type you like, implemented with thesort
provided by turtle: