У меня есть следующая строка кода, которая при компиляции с помощью GHC работает без сучка и задоринки:
addRDF c (Just (FILE)) = do
(_:file:_) <- getArgs
check <- doesFileExist file
if check then do rdfG <- TLI.readFile file >>= (return . parseN3fromText)
case rdfG of (Left s) -> putStrLn s
(Right g) -> storeRDF c g
else do putStrLn "Specified files does not exist"
Но когда я запускаю ее через процесс сборки клики, она выдает следующую ошибку.
Repository/Adder.hs:46:35:
Unexpected semi-colons in conditional:
if check then do { rdfG <- TLI.readFile file
>>=
(return . parseN3fromText);
case rdfG of {
(Left s) -> putStrLn s
(Right g) -> storeRDF c g } }; else do { putStrLn
"Specified files does not exist" }
Perhaps you meant to use -XDoAndIfThenElse?
Я вижу дополнительную точку с запятой в ошибке, но не понимаю, откуда она взялась.
Вот мой файл конфигурации клики:
cabal-version: >= 1.2
build-type: Simple
library
build-depends:
base,
containers,
HTTP >= 4000.2.2,
directory >= 1.1.0.0,
text >= 0.11.1.13,
swish >= 0.6.5.2
exposed-modules: Repository.Adder, Repository.Configuration
ghc-options: -Wall
executable repository-add
main-is: repository-add.hs
build-depends:
MissingH,
swish >= 0.6.5.2,
split >= 0.1.4.2
ghc-options: -Wall
ОБНОВЛЕНИЕ
С правильным отступом для if
:
addRDF c (Just (FILE)) = do (_:file:_) <- getArgs
check <- doesFileExist file
if check
then do rdfG <- TLI.readFile file >>= (return . parseN3fromText)
case rdfG of (Left s) -> putStrLn s
(Right g) -> storeRDF c g
else do putStrLn "Specified files does not exist"
Теперь я получаю точку с запятой после check
:
Repository/Adder.hs:46:35:
Unexpected semi-colons in conditional:
if check; then do { rdfG <- TLI.readFile file
>>=
(return . parseN3fromText);
case rdfG of {
(Left s) -> putStrLn s
(Right g) -> storeRDF c g } }; else do { putStrLn
"Specified files does not exist" }
Perhaps you meant to use -XDoAndIfThenElse?