在一个模块中我有这种类型:
module Verbally (verbally, Currency) where
import Data.String.Utils
data Currency = Currency {
singular :: String,
plural :: String
} deriving (Read, Show)
aud = Currency "Australian Dollar" "Australian Dollars"
bgn = Currency "Lev" "Levs"
在我的第二个(主要)模块中,如下所示:
main = do
args <- getArgs
putStrLn $ verbally (args !! 0) (args !! 1)
我想转换args !! 1到货币。
verbally将Integer和Currency作为参数。
编译错误:
Couldn't match type ‘[Char]’ with ‘Currency’
Expected type: [Currency]
Actual type: [String]
In the first argument of ‘(!!)’, namely ‘args’
In the second argument of ‘verbally’, namely ‘(args !! 1)’
答案 0 :(得分:2)
我不知道verbally
需要什么,但我猜你想要这个:
main = do
args <- getArgs
putStrLn $ verbally $ Currency (args !! 0) (args !! 1)