我似乎无法成功与Fay排序字符串。我意识到,它连接到一个事实,即仙女的不支持类型类,但好像如果不工作一个真正的痛苦...fay:可以对字符串进行排序吗?
import Prelude
main :: Fay()
main = print $ sort ["a", "c", "b"]
输出为:
fay: ghc:
Test.hs:4:16:
No instance for (Ord [Char])
arising from a use of `sort'
Possible fix: add an instance declaration for (Ord [Char])
In the second argument of `($)', namely `sort ["a", "c", "b"]'
In the expression: print $ sort ["a", "c", "b"]
In an equation for `main': main = print $ sort ["a", "c", "b"]
如果我理解正确,我不能定义类型类型的实例,因为Fay不支持类型类型(另外我猜如果可能的话,Fay开发者会这样做)。那么是否有解决方法,或者我必须JS JS做字符串排序?
编辑:从一月克里斯蒂安森的答案似乎正确的:我可以排序使用 “sortBy”,这似乎一见钟情正确:
fay --html-wrapper Sort.hs