From lists0 at freea2a.de Wed Jun 15 23:39:03 2022 From: lists0 at freea2a.de (Lists0) Date: Thu, 16 Jun 2022 01:39:03 +0200 Subject: [Haskell-beginners] Invoking ghci with hackage modules Message-ID: <20220616012615.3072c94c@duin> Hi all, a very basic question, that I cannot solve alone: How do I load modules from hackage into ghci ? Say, I have a module arrows.hs : {-# LANGUAGE Arrows #-} module Main where import Control.Arrow import Control.Monad import qualified Control.Category as Cat import Data.List import Data.Maybe import System.Random I get the error in ghci: % ghci arrows.hs GHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( arrows.hs, interpreted ) arrows.hs:9:1: error: Could not find module ‘System.Random’ Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 9 | import System.Random | ^^^^^^^^^^^^^^^^^^^^ Failed, no modules loaded. Prelude> System.Random is in the package "random" from hackage, where the other modules are in the package base. I cannot find a solution in the doku that works :-( Thanks for help! From sylvain at haskus.fr Thu Jun 16 06:52:03 2022 From: sylvain at haskus.fr (Sylvain Henry) Date: Thu, 16 Jun 2022 08:52:03 +0200 Subject: [Haskell-beginners] Invoking ghci with hackage modules In-Reply-To: <20220616012615.3072c94c@duin> References: <20220616012615.3072c94c@duin> Message-ID: <9f110887-8ec7-8d21-30b7-e25bf262e13f@haskus.fr> Hi, With Stack: > stack ghci --resolver=lts-18.28 --package=random arrows.hs You can use Stack's script feature to specify resolver and packages directly in the .hs file. See https://www.wespiser.com/posts/2020-02-02-Command-Line-Haskell.html for some examples. Cheers, Sylvain On 16/06/2022 01:39, Lists0 wrote: > Hi all, > > a very basic question, that I cannot solve alone: > How do I load modules from hackage into ghci ? > Say, I have a module arrows.hs : > > {-# LANGUAGE Arrows #-} > > module Main where > import Control.Arrow > import Control.Monad > import qualified Control.Category as Cat > import Data.List > import Data.Maybe > import System.Random > > > I get the error in ghci: > > % ghci arrows.hs > GHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help > [1 of 1] Compiling Main ( arrows.hs, interpreted ) > > arrows.hs:9:1: error: > Could not find module ‘System.Random’ > Use -v (or `:set -v` in ghci) to see a list of the files searched > for. | > 9 | import System.Random > | ^^^^^^^^^^^^^^^^^^^^ > Failed, no modules loaded. > Prelude> > > > System.Random is in the package "random" from hackage, where the other > modules are in the package base. > > I cannot find a solution in the doku that works :-( > > Thanks for help! > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From yehoshuapw at gmail.com Thu Jun 16 12:21:09 2022 From: yehoshuapw at gmail.com (=?UTF-8?B?15nXlNeV16nXoiDXldec15o=?=) Date: Thu, 16 Jun 2022 15:21:09 +0300 Subject: [Haskell-beginners] Invoking ghci with hackage modules In-Reply-To: <9f110887-8ec7-8d21-30b7-e25bf262e13f@haskus.fr> References: <20220616012615.3072c94c@duin> <9f110887-8ec7-8d21-30b7-e25bf262e13f@haskus.fr> Message-ID: if you're using stack, then indeed, as Sylvain said. if not, this means that the ghci that is being used, and it's relevant haskell does not have "random" installed. so for example if this is the system installed one, install the relevant package with haskell's random too. On Thu, Jun 16, 2022 at 9:55 AM Sylvain Henry wrote: > Hi, > > With Stack: > > > stack ghci --resolver=lts-18.28 --package=random arrows.hs > > You can use Stack's script feature to specify resolver and packages > directly in the .hs file. See > https://www.wespiser.com/posts/2020-02-02-Command-Line-Haskell.html for > some examples. > > Cheers, > Sylvain > > > On 16/06/2022 01:39, Lists0 wrote: > > Hi all, > > > > a very basic question, that I cannot solve alone: > > How do I load modules from hackage into ghci ? > > Say, I have a module arrows.hs : > > > > {-# LANGUAGE Arrows #-} > > > > module Main where > > import Control.Arrow > > import Control.Monad > > import qualified Control.Category as Cat > > import Data.List > > import Data.Maybe > > import System.Random > > > > > > I get the error in ghci: > > > > % ghci arrows.hs > > GHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help > > [1 of 1] Compiling Main ( arrows.hs, interpreted ) > > > > arrows.hs:9:1: error: > > Could not find module ‘System.Random’ > > Use -v (or `:set -v` in ghci) to see a list of the files searched > > for. | > > 9 | import System.Random > > | ^^^^^^^^^^^^^^^^^^^^ > > Failed, no modules loaded. > > Prelude> > > > > > > System.Random is in the package "random" from hackage, where the other > > modules are in the package base. > > > > I cannot find a solution in the doku that works :-( > > > > Thanks for help! > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.jakobi at googlemail.com Thu Jun 16 15:17:50 2022 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Thu, 16 Jun 2022 17:17:50 +0200 Subject: [Haskell-beginners] Invoking ghci with hackage modules In-Reply-To: <20220616012615.3072c94c@duin> References: <20220616012615.3072c94c@duin> Message-ID: With cabal repl, you can specify dependencies on Hackage with --build-depends or -b for short, e.g. cabal repl --build-depends random Am Do., 16. Juni 2022 um 05:19 Uhr schrieb Lists0 : > > > Hi all, > > a very basic question, that I cannot solve alone: > How do I load modules from hackage into ghci ? > Say, I have a module arrows.hs : > > {-# LANGUAGE Arrows #-} > > module Main where > import Control.Arrow > import Control.Monad > import qualified Control.Category as Cat > import Data.List > import Data.Maybe > import System.Random > > > I get the error in ghci: > > % ghci arrows.hs > GHCi, version 8.10.6: https://www.haskell.org/ghc/ :? for help > [1 of 1] Compiling Main ( arrows.hs, interpreted ) > > arrows.hs:9:1: error: > Could not find module ‘System.Random’ > Use -v (or `:set -v` in ghci) to see a list of the files searched > for. | > 9 | import System.Random > | ^^^^^^^^^^^^^^^^^^^^ > Failed, no modules loaded. > Prelude> > > > System.Random is in the package "random" from hackage, where the other > modules are in the package base. > > I cannot find a solution in the doku that works :-( > > Thanks for help! > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners