Running the haskell package turtle's hello world: "Module Turtle appears in multiple packages" error

I found the turtle package and would like to go through the tutorial but I’m struggling a little.

default.nix:

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "name";
  buildInputs = [
    stack
    zlib
  ];
  src = null;
}

hello.hs:

#!/usr/bin/env stack
-- stack --resolver lts-17.9 script
 
                                    -- #!/bin/bash
{-# LANGUAGE OverloadedStrings #-}  --
                                    --
import Turtle                       --
                                    --
main = echo "Hello, world!"         -- echo Hello, world!

.envrc in case it should matter:

use_nix
unset PS1

Here’s what I’m getting:

~/devp/test-turtle ⌚ 15:01:37
$ ./hello.hs
Module Turtle appears in multiple packages:
turtle turtle

And this confuses me. Does anyone here have pointers that could help me?

Figured it out by reading this! I had to add --package turtle:

Updated hello.hs:

#!/usr/bin/env stack
-- stack --resolver lts-17.9 script  --package turtle --no-nix-pure
 
                                    -- #!/bin/bash
{-# LANGUAGE OverloadedStrings #-}  --
                                    --
import Turtle                       --
                                    --
main = echo "Hello, world!"         -- echo Hello, world!

Running it:

~/devp/test-turtle ⌚ 16:37:34
$ ./hello.hs

<no location info>: warning: [-Wmissed-extra-shared-lib]
    libz.so: cannot open shared object file: No such file or directory
    It's OK if you don't want to use symbols from it directly.
    (the package DLL is loaded by the system linker
     which manages dependencies by itself).
Hello, world!
1 Like