Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted to follow the "Getting Started" instructions, couldn't successfully import MCPrelude. #81

Open
derifatives opened this issue Jan 26, 2021 · 5 comments

Comments

@derifatives
Copy link

I followed the "Getting Started" instructions at https://mightybyte.github.io/monad-challenges/. The cabal install ran for a long time (maybe 20 minutes? I wandered off) but seemed to complete successfully. However, trying to ghci a simple toy file failed to import the prelude:

rif@rifo1:~/tmp/mc/monad-challenges/monad-challenges-code$ cat Set1.hs
{-# LANGUAGE MonadComprehensions #-}
{-# LANGUAGE RebindableSyntax  #-}

module Set1 where

import MCPrelude

fiveRands:: [Integer]
fiveRands = [3, 4, 5]

rif@rifo1:~/tmp/mc/monad-challenges/monad-challenges-code$ ghci Set1.hs
GHCi, version 8.8.4: https://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Set1             ( Set1.hs, interpreted )

Set1.hs:6:1: error:
    Could not find module ‘MCPrelude’
    Perhaps you meant Prelude (from base-4.13.0.0)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
6 | import MCPrelude
  | ^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude> 

Is there maybe some missing piece of newbie instructions here? Do I have to somehow add MCPrelude to a path or something?

@derifatives
Copy link
Author

It's also possible I've done something previously that messed up my system. I don't really understand Haskell install or what is / isn't hermetic.

@georgefst
Copy link

I was just about to open an issue about this. The problem is that the guide uses the old-fashioned way of installing libraries. Cabal has changed a lot in the last few years.

I think the simplest solution (assuming that you're using Cabal 3+, check with cabal -V) would be to create a folder for the Haskell source files you're going to write, then run cabal install --package-env /PATH_TO_YOUR_FOLDER --lib instead of just cabal install. This will create a file called something like .ghc.environment.x86_64-darwin-8.10.3, which will tell calls to ghc and ghci from that folder, where to find MCPrelude.

@mightybyte Should I open a PR modifying/expanding the instructions, or do you have a preferred solution?

@derifatives
Copy link
Author

This does seem to work, thanks!

@georgefst
Copy link

That's a bizarre error @Aster89.

Is there any chance you've tampered with your ghci? Do you have another ghci on your PATH, or have you set an alias? What happens if you run which ghci?

@Aster89
Copy link

Aster89 commented Apr 6, 2021

@georgefst , I had an alias :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants