Variable not in scope in Haskell

Asked 2 years ago, Updated 2 years ago, 91 views

I started Haskell today.

I finished installing from https://www.haskell.org/platform/, and saved the sample code as file.hs.
If you type ghci file.hs on the GHCi screen,

[1 of 1] Compiling Main (file.hs, interpreted)
Ok, modules loaded: Main.
*Main >

where should be printed

Variable not in scope:ghci::t0->b0->c
Variable not in scope: file
Variable not in scope: hs::a->b0

I got an error and couldn't proceed.
I searched online, but I don't know.

Please give me some advice.

haskell

2022-09-30 14:04

1 Answers

I probably typed ghci file.hs directly while waiting for the program to be entered after starting GHCi.

The correct answer is

  • Specify the filename as an option to launch GHCi in the shell.

    $ghci file.hs

Specify the filename as an option to launch GHCi on the shell.

$ghci file.hs

or

  • After starting GHCi, set to :load file.hs.

    Prelude>:load file.hs

After starting GHCi, set to :load file.hs.

Prelude>:load file.hs

That's fine.


2022-09-30 14:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.