import not working

I go to a directory. I run stack install Safe I start up ghci and get the Prelude prompt. I run import Safe and I get import Safe | ^^^^^^^^^^^ Failed, no modules loaded. I'm once again frustrated. I try to load this hs file {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE NoMonomorphismRestriction #-} import Safe lookupDefault :: Eq a => a -> b -> [(a,b)] -> b lookupDefault k _ (lookup k -> Just s) = s lookupDefault _ d _ = d headTup :: (a, [t]) -> [t] headTup (headMay . snd -> Just n) = [n] headTup _ = [] headNil :: [a] -> [a] headNil (headMay -> Just x) = [x] headNil _ = [] with the same result. What do I need to do? -- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com

How are you invoking ghci? If it's a stack project you can try stack ghci
if you haven't already.
On Fri, 4 Jun 2021 at 21:51, Galaxy Being
I go to a directory. I run
stack install Safe
I start up ghci and get the Prelude prompt. I run
import Safe
and I get
import Safe | ^^^^^^^^^^^ Failed, no modules loaded.
I'm once again frustrated. I try to load this hs file
{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE NoMonomorphismRestriction #-}
import Safe
lookupDefault :: Eq a => a -> b -> [(a,b)] -> b lookupDefault k _ (lookup k -> Just s) = s lookupDefault _ d _ = d
headTup :: (a, [t]) -> [t] headTup (headMay . snd -> Just n) = [n] headTup _ = []
headNil :: [a] -> [a] headNil (headMay -> Just x) = [x] headNil _ = []
with the same result. What do I need to do? -- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

I run ghci with
stack ghci
On Fri, Jun 4, 2021 at 5:19 PM Jesse Rudel
How are you invoking ghci? If it's a stack project you can try stack ghci if you haven't already.
On Fri, 4 Jun 2021 at 21:51, Galaxy Being
wrote: I go to a directory. I run
stack install Safe
I start up ghci and get the Prelude prompt. I run
import Safe
and I get
import Safe | ^^^^^^^^^^^ Failed, no modules loaded.
I'm once again frustrated. I try to load this hs file
{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE NoMonomorphismRestriction #-}
import Safe
lookupDefault :: Eq a => a -> b -> [(a,b)] -> b lookupDefault k _ (lookup k -> Just s) = s lookupDefault _ d _ = d
headTup :: (a, [t]) -> [t] headTup (headMay . snd -> Just n) = [n] headTup _ = []
headNil :: [a] -> [a] headNil (headMay -> Just x) = [x] headNil _ = []
with the same result. What do I need to do? -- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com

Let me reiterate, I'm not creating a stack project formally. I'm just going
to some directory at the command prompt and firing up ghci, which I presume
just uses the global installs. Then I'm creating .hs files in a text editor
and trying to load them at the REPL. How can I install stuff in this
instance?
On Fri, Jun 4, 2021 at 10:47 PM Galaxy Being
I run ghci with
stack ghci
On Fri, Jun 4, 2021 at 5:19 PM Jesse Rudel
wrote: How are you invoking ghci? If it's a stack project you can try stack ghci if you haven't already.
On Fri, 4 Jun 2021 at 21:51, Galaxy Being
wrote: I go to a directory. I run
stack install Safe
I start up ghci and get the Prelude prompt. I run
import Safe
and I get
import Safe | ^^^^^^^^^^^ Failed, no modules loaded.
I'm once again frustrated. I try to load this hs file
{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE NoMonomorphismRestriction #-}
import Safe
lookupDefault :: Eq a => a -> b -> [(a,b)] -> b lookupDefault k _ (lookup k -> Just s) = s lookupDefault _ d _ = d
headTup :: (a, [t]) -> [t] headTup (headMay . snd -> Just n) = [n] headTup _ = []
headNil :: [a] -> [a] headNil (headMay -> Just x) = [x] headNil _ = []
with the same result. What do I need to do? -- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com
-- ⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com

The `stack ghci` command does not load extra packages such as those installed "globally." This is a good thing, IMHO. You can instruct the command to load specific packages using the `--package` option. Example: stack repl --package safe Example using your file: stack repl --package safe GalaxyBeing.hs Note that your email indicates usage of the `Safe` package (uppercase), but that package is deprecated in favor of the `safe` package (lowercase). I mention it in case it is not intentional. * https://hackage.haskell.org/package/safe * https://hackage.haskell.org/package/Safe You may want to create a project that is just for testing. You can then specify which Stack snapshot to use in `stack.yaml` and which packages to use in `package.yaml`. stack new experiment Travis
participants (3)
-
Galaxy Being
-
Jesse Rudel
-
Travis Cardwell