【发布时间】:2016-02-16 07:33:46
【问题描述】:
我只是发布代码和编译错误。
module Mov where
import Data.List
import System.IO
mov = do putStr motion
motion :: [Char] -> [Int, Int] -> [Int, Int]
motion [] c ≃ c
motion (i : it) c = if i == 'L' || i == 'l' then putStr ((head c) +1, tail c) : motion it
else if i == 'U' || i == 'u' then putStr (head c, ((tail c) + 1)) : motion
else if i == 'R' || i == 'r' then putStr (((head c) + 1), tail c) : motion
else if i == 'D' || i == 'd' then putStr ((head c), ((tail c) - 1)) : motion it
else "instrução invalida" putStr c
还有编译错误:
mov.hs:10:19:
Illegal type: ‘'[Int, Int]’ Perhaps you intended to use DataKinds
mov.hs:10:33:
Illegal type: ‘'[Int, Int]’ Perhaps you intended to use DataKinds
【问题讨论】:
-
这段代码在很多方面都是错误的——请开始阅读一些基本的haskell语法——比如learnyouahaskell.com
-
[Int,Int]不能存在 - 也许你的意思是(Int,Int)也putStr期望String作为输入 -
我尝试了一个元组 (Int, Int),我得到了相同类型的编译错误。
-
a) 请有礼貌,b) 如果您在论坛上发帖,请尝试写一个有意义的问题 - 您的帖子不包含您已经研究或工作过的信息
-
@baitillus:你的代码(和态度)在很多层面上都是错误的,我真的不知道从哪里开始......但无论如何:它说
[Int, Int]是非法类型,这就是编译错误的全部——[Int, Int]类型是无意义的;当然,您没有提供有关此代码打算做什么的任何见解,也没有提供您可能认为此错误意味着什么,这将有助于您了解您的想法和您的经验水平等,以帮助其他人帮助您。