FilmsSorted :: [Film] -> [Film]
FilmsSorted = reverse.sortBy sortFilm
我收到此错误,不确定如何修复它? (下同)
******。hs:89:1:错误:
无效的类型签名:FilmsSorted ::
应该是::
无效的签名?
答案 0 :(得分:1)
请发布完整示例,例如:
import Data.List (reverse, sortBy)
type Film = ()
FilmsSorted :: [Film] -> [Film]
FilmsSorted = reverse . sortBy sortFilm
sortFilm :: Film -> Film -> Bool
sortFilm = undefined
一个完整的,格式化的错误:
GHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/tommd/.ghci
[1 of 1] Compiling Main ( x.hs, interpreted )
x.hs:4:1: error:
Invalid type signature: FilmsSorted :: ...
Should be of form <variable> :: <type>
|
4 | FilmsSorted :: [Film] -> [Film]
| ^^^^^^^^^^^
Failed, no modules loaded.
此时错误表明您的变量FilmsSorted
在某种程度上是不正确的。正如@Cubic所说,错误是变量必须以小写字母开头。所以试试:
filmsSorted :: ...
filmsSorted = ...