Gabriella439 / turtle

Shell programming, Haskell style

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

command with arguments failing.

DrYSG opened this issue · comments

I looked at your tutorial at: https://hackage.haskell.org/package/turtle-1.5.16/docs/Turtle-Tutorial.html

and I don't understand why the echo "mytext" below is failing;

(the lines earlier work).

module Main where

{-# LANGUAGE OverloadedStrings #-}  
                                    
import Turtle                       

main :: IO ()
main = do
    dir  <- pwd            -- DIR=$(pwd) 
    time <- datefile dir   -- TIME=$(date -r $DIR)
    print time             -- echo $TIME
    print dir
    let mytext = Turtle.textToLines "Hello there"
    echo "mytext" -- This line fails
PS D:\CRIME\haskell-call> stack run
Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail
Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail
haskell-call> build (lib + exe)
Preprocessing library for haskell-call-0.1.0.0..
Building library for haskell-call-0.1.0.0..
Preprocessing executable 'haskell-call-exe' for haskell-call-0.1.0.0..
Building executable 'haskell-call-exe' for haskell-call-0.1.0.0..
[2 of 2] Compiling Main

app\Main.hs:13:37: error:
    * Couldn't match expected type `Text' with actual type `[Char]'
    * In the first argument of `textToLines', namely `"Hello there"'
      In the expression: textToLines "Hello there"
      In an equation for `mytext': mytext = textToLines "Hello there"
   |
13 |     let mytext = Turtle.textToLines "Hello there"
   |                                     ^^^^^^^^^^^^^

app\Main.hs:14:10: error:
    * Couldn't match expected type `Line' with actual type `[Char]'
    * In the first argument of `echo', namely `"mytext"'
      In a stmt of a 'do' block: echo "mytext"
      In the expression:
        do dir <- pwd
           time <- datefile dir
           print time
           print dir
           ....
   |
14 |     echo "mytext" -- This line fails
   |          ^^^^^^^^


--  While building package haskell-call-0.1.0.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_3.0.1.0_ghc-8.8.2.exe --builddir=.stack-work\dist\29cc6475 build lib:haskell-call exe:haskell-call-exe --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

@DrYSG: That's also puzzling to me, too. Both of those error messages suggest that the OverloadedStrings language extension is not enabled, but your sample source code does show the extension. Is it possible that the extension was not enabled at the time you ran into that build failure?

@Gabriel439 is this something that might be compiler or stack related? (I am running on win10).

PS D:\CRIME\haskell-call> stack --version
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2
PS D:\CRIME\haskell-call> ghci --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5
PS D:\CRIME\haskell-call>

or maybe I should be doing something in the package.yaml or stack.yaml to enable the OverloadedStrings

name:                haskell-call
version:             0.1.0.0
github:              "githubuser/haskell-call"
license:             BSD3
author:              "Author name here"
maintainer:          "example@example.com"
copyright:           "2020 Author name here"

extra-source-files:
- README.md
- ChangeLog.md

# Metadata used when publishing your package
# synopsis:            Short description of your package
# category:            Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description:         Please see the README on GitHub at <https://github.com/githubuser/haskell-call#readme>

dependencies:
- base >= 4.7 && < 5

library:
  source-dirs: src
  dependencies:
  - turtle 

executables:
  haskell-call-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - haskell-call
    - turtle

tests:
  haskell-call-test:
    main:                Spec.hs
    source-dirs:         test
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
    dependencies:
    - haskell-call
    - turtle

@DrYSG: You shouldn't have to enable the extension in a project-wide file. Enabling the extension within the same module should be enough. If you can publish a branch that I can use to test or a minimal reproducing example it will probably help narrow things down further.

@DrYSG try moving the OverloadedStrings to be on top of the module definition. Like this:

{-# LANGUAGE OverloadedStrings #-} 
module Main where

@santios yes, that fixes it. Thank you.