unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
* How to make sure ghc uses installed packages?
@ 2019-09-16 22:35 Jesse Gibbons
  2019-09-17  0:00 ` John Soo
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Gibbons @ 2019-09-16 22:35 UTC (permalink / raw)
  To: help-guix mailing list

I'm trying Conrad Barski's haskell tutorial[1] but it looks like
runhaskell cannot find a few packages that will be necessary in the
tutorial.
[1]:http://lisperati.com/haskell/
I installed ghc, ghc-random and ghc-regex-compat. I typed up the
program as instructed. Then I ran "runhaskell tutorial.hs" and got this
output:
2 packages in profile
jesse@piranhaplant ~/Documents/haskell$ runhaskell tutorial.hs 

tutorial.hs:2:1: error:
    Could not find module ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.12.0.0)
    Use -v to see a list of the files searched for.
  |
2 | import Text.Regex
  | ^^^^^^^^^^^^^^^^^

tutorial.hs:3:1: error:
    Could not find module ‘System.Random’
    Use -v to see a list of the files searched for.
  |
3 | import System.Random
  | ^^^^^^^^^^^^^^^^^^^^

I searched hackage and hoogle to find which packages I would need to
install, and confirmed I have the correct packages installed, but ghc
can't seem to find them. I even changed the version of ghc and logged
into a terminal to see if I needed a different version. No difference.


Can somebody help me out please?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-16 22:35 How to make sure ghc uses installed packages? Jesse Gibbons
@ 2019-09-17  0:00 ` John Soo
  2019-09-17  1:28   ` Jesse Gibbons
  0 siblings, 1 reply; 8+ messages in thread
From: John Soo @ 2019-09-17  0:00 UTC (permalink / raw)
  To: Jesse Gibbons; +Cc: help-guix mailing list

Hi Jesse,

> Can somebody help me out please?

I can try!

Can get the contents of $GHC_PACKAGE_PATH please? Guix uses this environment variable that is recognized by the ghc toolchain to tell ghc where packages are installed.

What happens if you try to load your file in ghci instead of using runhaskell?

Good luck,

- John

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-17  0:00 ` John Soo
@ 2019-09-17  1:28   ` Jesse Gibbons
  2019-09-17  5:27     ` John Soo
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Gibbons @ 2019-09-17  1:28 UTC (permalink / raw)
  To: John Soo; +Cc: help-guix mailing list

[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]

On Mon, 2019-09-16 at 17:00 -0700, John Soo wrote:
> Hi Jesse,
> 
> > Can somebody help me out please?
> 
> I can try!
> 
> Can get the contents of $GHC_PACKAGE_PATH please? Guix uses this
> environment variable that is recognized by the ghc toolchain to tell
> ghc where packages are installed.
> 
> What happens if you try to load your file in ghci instead of using
> runhaskell?
> 
> Good luck,
> 
> - John
I wrote a script to do that (attached with output), then for each each
of the available versions, removed all ghc, logged into a virtual
terminal, ran the script, then logged out of the virtual terminal. I
did the log in/out because I previously noticed GHC_PACKAGE_PATH did
not change, even when I uninstalled everything, so I suspected it was
linked to a login script.
It appears the required modules were in GHC_PACKAGE_PATH and the
program did not have an error when I used ghc version 8.4.3

I noticed when I installed each successive version of GHC it suggests I
run a script to update the environment variables. I usually ignored it
because I did not have a problem like this before.

Case closed I guess.

[-- Attachment #2: output.txt --]
[-- Type: text/plain, Size: 6523 bytes --]

GHC_PACKAGE_PATH=/home/jesse/.guix-profile/lib/ghc-8.6.5/package.conf.d
runhaskell: 

tutorial.hs:2:1: error:
    Could not find module ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.12.0.0)
    Use -v to see a list of the files searched for.
  |
2 | import Text.Regex
  | ^^^^^^^^^^^^^^^^^

tutorial.hs:3:1: error:
    Could not find module ‘System.Random’
    Use -v to see a list of the files searched for.
  |
3 | import System.Random
  | ^^^^^^^^^^^^^^^^^^^^
ghci: 
GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude Data.List> 
<no location info>: error:
    Could not find module ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.12.0.0)
Prelude Data.List> 
<no location info>: error:
    Could not find module ‘System.Random’
    It is not a module in the current program, or in any known package.
Prelude Data.List> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> 
<interactive>:16:38: error:
    Not in scope: type constructor or class ‘StdGen’

<interactive>:16:54: error:
    Not in scope: type constructor or class ‘StdGen’
Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> 
<interactive>:18:8: error: Empty 'do' block
Prelude Data.List Data.Ord> 
<interactive>:19:2: error:
    • Variable not in scope: putstr :: [Char] -> t
    • Perhaps you meant ‘putStr’ (imported from Prelude)
Prelude Data.List Data.Ord> Leaving GHCi.
GHC_PACKAGE_PATH=/home/jesse/.guix-profile/lib/ghc-8.4.3/ghc-random-1.1.conf.d:/home/jesse/.guix-profile/lib/ghc-8.4.3/ghc-regex-compat-0.95.1.conf.d:/home/jesse/.guix-profile/lib/ghc-8.4.3/package.conf.d
runhaskell: 

tutorial.hs:19:2: error:
    • Variable not in scope: putstr :: [Char] -> t
    • Perhaps you meant ‘putStr’ (imported from Prelude)
   |
19 |  putstr "Hello World! Let's have a picnic! \n"
   |  ^^^^^^
ghci: 
GHCi, version 8.4.3: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude Data.List> Prelude Data.List Text.Regex> Prelude Data.List Text.Regex System.Random> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> Prelude Data.List Text.Regex System.Random Data.Ord> 
<interactive>:18:8: error: Empty 'do' block
Prelude Data.List Text.Regex System.Random Data.Ord> 
<interactive>:19:2: error:
    • Variable not in scope: putstr :: [Char] -> t
    • Perhaps you meant ‘putStr’ (imported from Prelude)
Prelude Data.List Text.Regex System.Random Data.Ord> Leaving GHCi.
GHC_PACKAGE_PATH=/home/jesse/.guix-profile/lib/ghc-8.0.2/package.conf.d
runhaskell: 

tutorial.hs:2:1: error:
    Failed to load interface for ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.9.1.0)
    Use -v to see a list of the files searched for.

tutorial.hs:3:1: error:
    Failed to load interface for ‘System.Random’
    Use -v to see a list of the files searched for.
ghci: 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude Data.List> 
<no location info>: error:
    Could not find module ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.9.1.0)
Prelude Data.List> 
<no location info>: error:
    Could not find module ‘System.Random’
    It is not a module in the current program, or in any known package.
Prelude Data.List> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> 
<interactive>:16:38: error:
    Not in scope: type constructor or class ‘StdGen’

<interactive>:16:54: error:
    Not in scope: type constructor or class ‘StdGen’
Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> 
<interactive>:18:8: error: Empty 'do' block
Prelude Data.List Data.Ord> 
<interactive>:19:2: error:
    • Variable not in scope: putstr :: [Char] -> t
    • Perhaps you meant ‘putStr’ (imported from Prelude)
Prelude Data.List Data.Ord> Leaving GHCi.
GHC_PACKAGE_PATH=/home/jesse/.guix-profile/lib/ghc-7.10.2/package.conf.d
runhaskell: 

tutorial.hs:2:8:
    Could not find module ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.8.1.0)
    Use -v to see a list of the files searched for.

tutorial.hs:3:8:
    Could not find module ‘System.Random’
    Use -v to see a list of the files searched for.
ghci: 
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Prelude> Prelude Data.List> 
<no location info>:
    Could not find module ‘Text.Regex’
    Perhaps you meant Text.Read (from base-4.8.1.0)
Prelude Data.List> 
<no location info>:
    Could not find module ‘System.Random’
    It is not a module in the current program, or in any known package.
Prelude Data.List> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> 
<interactive>:17:38:
    Not in scope: type constructor or class ‘StdGen’

<interactive>:17:54:
    Not in scope: type constructor or class ‘StdGen’
Prelude Data.List Data.Ord> Prelude Data.List Data.Ord> 
<interactive>:19:6: parse error on input ‘=’
Prelude Data.List Data.Ord> 
<interactive>:20:2:
    Not in scope: ‘putstr’
    Perhaps you meant ‘putStr’ (imported from Prelude)
Prelude Data.List Data.Ord> Leaving GHCi.

[-- Attachment #3: record-ghc-package-path --]
[-- Type: text/plain, Size: 187 bytes --]

OUT=output.txt
echo 'GHC_PACKAGE_PATH='$GHC_PACKAGE_PATH >> $OUT
echo "runhaskell: "  >> $OUT
runhaskell tutorial.hs |& cat >> $OUT
echo "ghci: " >> $OUT
ghci < tutorial.hs |& cat >> $OUT

[-- Attachment #4: tutorial.hs --]
[-- Type: text/x-haskell, Size: 514 bytes --]

import Data.List
import Text.Regex
import System.Random
import Data.Ord

type Point = (Float,Float)
type Color = (Int,Int,Int)
type Polygon = [Point]
type Person = [Int]
type Link =[Point]
type Placement = [(Person,Person)]

type EnergyFunction a              = a -> Int
type TemperatureFunction           = Int -> Int -> Float
type TransitionProbabilityFunction = Int -> Int -> Float -> Float
type MotionFunction a              = StdGen -> a -> (StdGen,a)

main = do
 putstr "Hello World! Let's have a picnic! \n"

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-17  1:28   ` Jesse Gibbons
@ 2019-09-17  5:27     ` John Soo
  2019-09-17 12:36       ` Jesse Gibbons
  0 siblings, 1 reply; 8+ messages in thread
From: John Soo @ 2019-09-17  5:27 UTC (permalink / raw)
  To: Jesse Gibbons; +Cc: help-guix mailing list

Hi Jesse,
 
>  GHC_PACKAGE_PATH did
> not change, even when I uninstalled > everything, so I suspected it was
> linked to a login script.

Ok yes. That is the state of affairs right now. The environment variables are sourced in the login profile. You can find the variables using guix package --search-paths -p <path to your profile> and source those if you do install something new. It is a little odd for sure. It feels like the installation transaction is not done almost. Anyways I’m glad that got sorted out. 

- John

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-17  5:27     ` John Soo
@ 2019-09-17 12:36       ` Jesse Gibbons
  2019-09-17 14:09         ` John Soo
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Gibbons @ 2019-09-17 12:36 UTC (permalink / raw)
  To: John Soo; +Cc: help-guix mailing list

On Mon, 2019-09-16 at 22:27 -0700, John Soo wrote:
> Hi Jesse,
>  
> >  GHC_PACKAGE_PATH did
> > not change, even when I uninstalled > everything, so I suspected it
> > was
> > linked to a login script.
> 
> Ok yes. That is the state of affairs right now. The environment
> variables are sourced in the login profile. You can find the
> variables using guix package --search-paths -p <path to your profile>
> and source those if you do install something new. It is a little odd
> for sure. It feels like the installation transaction is not done
> almost. Anyways I’m glad that got sorted out. 
> 
> - John

Why did ghc-random and ghc-regex-compat only work with ghc 8.4.3?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-17 12:36       ` Jesse Gibbons
@ 2019-09-17 14:09         ` John Soo
  2019-09-17 18:21           ` Timothy Sample
  0 siblings, 1 reply; 8+ messages in thread
From: John Soo @ 2019-09-17 14:09 UTC (permalink / raw)
  To: Jesse Gibbons; +Cc: help-guix mailing list

Hi Jesse,

> Why did ghc-random and ghc-regex-compat only work with ghc 8.4.3?

RIght now, most - if not all - ghc packages are built with ghc@8.4.3. GHC
will check the version it was compiled with and refuse to compile if there
is a mismatch between the object file and your project.
Now that I say that, I am not sure I am right. I get version mismatches
compiling xmonad, for instance, when i upgrade ghc to 8.6.
It would be really nice to get more packages up to 8.6. One solution might
be to use a channel with package definitions using your preferred version
of ghc.

One other problem I can think of is that the current ghc is 8.6 but most
ghc-* packages are built with 8.4 so most packages are incompatible with
the default.

- John

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-17 14:09         ` John Soo
@ 2019-09-17 18:21           ` Timothy Sample
  2019-09-17 19:33             ` John Soo
  0 siblings, 1 reply; 8+ messages in thread
From: Timothy Sample @ 2019-09-17 18:21 UTC (permalink / raw)
  To: John Soo; +Cc: help-guix mailing list, Jesse Gibbons

Hi,

John Soo <jsoo1@asu.edu> writes:

> One other problem I can think of is that the current ghc is 8.6 but most
> ghc-* packages are built with 8.4 so most packages are incompatible with
> the default.

I’ve seen a number of bug reports and questions about this.  Maybe we
should rename GHC 8.6 to “ghc-next” until the build system uses it.

Thoughts?


-- Tim

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to make sure ghc uses installed packages?
  2019-09-17 18:21           ` Timothy Sample
@ 2019-09-17 19:33             ` John Soo
  0 siblings, 0 replies; 8+ messages in thread
From: John Soo @ 2019-09-17 19:33 UTC (permalink / raw)
  To: Timothy Sample; +Cc: help-guix mailing list, Jesse Gibbons

Hi Tim,

> Maybe we should rename GHC 8.6 to “ghc-next” until the build system uses it.

Makes sense to me. I tried updating quickcheck for 8.6 and I think we have our work cutout for ourselves... hopefully we can get there soon though!

- John

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-09-17 19:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-16 22:35 How to make sure ghc uses installed packages? Jesse Gibbons
2019-09-17  0:00 ` John Soo
2019-09-17  1:28   ` Jesse Gibbons
2019-09-17  5:27     ` John Soo
2019-09-17 12:36       ` Jesse Gibbons
2019-09-17 14:09         ` John Soo
2019-09-17 18:21           ` Timothy Sample
2019-09-17 19:33             ` John Soo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).