简体   繁体   English

数据构造函数不在 scope - Haskell

[英]Data Constructor not in scope - Haskell

I am new to Haskell so I apologise if this is an obvious mistake to some.我是 Haskell 的新手,所以如果这对某些人来说是一个明显的错误,我深表歉意。 I have been trying to add a tuple to a list of tuples, however I get an errors like Data constructor not in scope: Adelle:: String and Data constructor not in scope: Hello:: String when I input: addRecord tData Hello Adelle into GHCi.我一直在尝试将一个元组添加到元组列表中,但是我收到一个错误,例如Data constructor not in scope: Adelle:: String and Data constructor not in scope: Hello:: String when I input: addRecord tData Hello Adelle into GHCi。

I have done some research and some people suggested to others that their variables have to be lower case, which mine are.我做了一些研究,有些人向其他人建议他们的变量必须是小写的,我的也是。 So I am unsure what is causing the issue.所以我不确定是什么导致了这个问题。 Any help is hugely appreciated.非常感谢任何帮助。

My code is below:我的代码如下:

type Sales = (String, String, Int)

tData :: [Sales]
tData = [("No Lie", "Sean Paul feat. Dua Lipa",  100),
         ("Fear & Delight", "The Correspondents",  120)]

addRecord :: [Sales] -> String -> String -> [Sales]
addRecord dataset songName artist = dataset ++ [(songName, artist, 1)]

You need to put double quotes around your strings:您需要在字符串周围加上双引号:

addRecord tData "Hello" "Adelle"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM