2

I am writing a short Turtle script in Haskell, running it with Stack:

#!/usr/bin/env stack
-- stack --resolver lts-19.6 script
                                    
{-# LANGUAGE OverloadedStrings #-}  
                                    
import Turtle                       
import Data.Text 

But as soon I added the "Data.Text" import I get this error:

Module Data.Text appears in multiple packages: 
relude text

Not a typo, it really says "relude".

How can I resolve it?

1 Answer 1

1

You can fix this by explicitly specifying which packages you want to use:

#!/usr/bin/env stack
-- stack --resolver lts-19.6 script --package text --package turtle
                                    
{-# LANGUAGE OverloadedStrings #-}  
                                    
import Turtle                       
import Data.Text 

I think by default it exposes all packages in the snapshot, so then there indeed may be multiple packages that provide the same module, which stack cannot resolve by itself.

An alternative solution would be to use PackageImports:

#!/usr/bin/env stack
-- stack --resolver lts-19.6 script
                                    
{-# LANGUAGE OverloadedStrings, PackageImports #-}  
                                    
import Turtle                       
import "text" Data.Text 

Do take a look at the documentation for best practices:

https://docs.haskellstack.org/en/stable/scripts/

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.