Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:22:33+00:00 2026-06-02T16:22:33+00:00

I loaded two modules (NecessaryModule1.hs and NecessaryModule2.hs as outlinked in Haskell : loading ALL

  • 0

I loaded two modules (NecessaryModule1.hs and NecessaryModule2.hs as outlinked in Haskell : loading ALL files in current directory path). Now I want to unload NecessaryModule2.hs. I found an ‘unload’ function in System.Plugins.Load however but it did not work in WinGHCi. The error message I got was :

>unload NecessaryModule2

<interactive>:1:1: Not in scope: `unload'

<interactive>:1:8:
    Not in scope: data constructor `NecessaryModule2'

I tried

import System.Plugins.Load

but that did not work. Is there a way to unload modules in the manner described above?

—————————————————————————————

[RESPONSE TO Riccardo]

Hi Riccardo, I tried your suggestion but I could not get it to work in WinGHCi. I had a file NecessaryModule1.hs as follows :

module NecessaryModule1 where

addNumber1 :: Int -> Int -> Int
addNumber1 a b = a + b

I went to the location of the file via the ‘:cd’ command, and then did :

> :module +NecessaryModule1

<no location info>:
    Could not find module `NecessaryModule1':
      it is not a module in the current program, or in any known package.

Is this correct? Thanks [EDIT : see below for correction]

—————————————————————————————

[CORRECTION TO ABOVE]

Just to explain why the above is incorrect (as explained by Riccardo), what needs to be done is the following :

If we have a file NecessaryModule1.hs as follows :

--NecessaryModule1.hs
module NecessaryModule1 where

addNumber1 :: Int -> Int -> Int
addNumber1 a b = a + b

then we do :

> :load NecessaryModule1
[1 of 1] Compiling NecessaryModule1 ( NecessaryModule1.hs, interpreted )
Ok, modules loaded: NecessaryModule1.
> addNumber1 4 5
9
> :module -NecessaryModule1
> addNumber1 4 5

<interactive>:1:1: Not in scope: `addNumber1'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:22:34+00:00Added an answer on June 2, 2026 at 4:22 pm

    Installed modules

    You have to use ghci’s commands in order to load (:module +My.Module) and unload (:module -My.Module) installed modules. You can also use :m instead of :module in order to write less, like this:

    Prelude> :m +Data.List
    Prelude Data.List> sort [3,1,2]
    [1,2,3]
    Prelude Data.List> :m -Data.List
    Prelude> sort [3,1,2]
    
    <interactive>:1:1: Not in scope: `sort'
    

    Remember that the ghci prompt always reminds you the module currently imported: you can have a look at that in order to know what to unload with :m -Module.To.Unload.

    Specific files

    If the module you’re trying to load isn’t installed in the system (e.g. you wrote the source and simply saved the file somewhere), you need to use a different command, :load filename.hs. A quicker way is to pass the path to the file directly as a command-line argument to ghci, e.g ghci filename.hs. If you run winghci and you associated it to the .hs extension, simply double-click the file.

    In both cases you will get a ghci prompt with the specified module correctly loaded AND imported in scope (provided you don’t have get compilation errors instead). As before, you can now use :m [+/-] My.Module to load and unload modules, but please note that this is different from :load because :module assumes you already :loaded what you’re trying to get in/out of scope.

    E.g., if you have test.hs

    module MyModule where
    import Data.List
    
    f x = sort x
    

    you may load it by double-clicking it (on windows with winghci), by typing ghci test.hs in a console, or by loading ghci and typing :load test.hs (beware of relative/absolute paths).

    Another useful ghci command is :reload, which will recompile the module you loaded before. Use it when you change the source file and you want to quickly update the module loaded in ghci.

    Prelude> :load test.hs
    [1 of 1] Compiling MyModule         ( test.hs, interpreted )
    Ok, modules loaded: MyModule.
    *MyModule> let xs = [1,2,3] in sort xs == f xs
    True
    *MyModule> :reload
    Ok, modules loaded: MyModule.
    

    :help will give you a complete list of all available commands.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose I have two modules NecessaryModule1 & NecessaryModule2 (as outlined in the post Haskell
Given two app domain : in the first, Library1 and CommonLibrary are loaded. In
I have two backbone models, loaded from server: var Model = Backbone.Model.extend({}); var SubModel
I need to compare two bitmaps. One bitmap is loaded from a file, the
I've loaded the cucumber.vim files into ftplugin and the other directories per instructions, but
I have a project that consists of a bunch of dynamically loaded modules. Originally,
I have created a modular application. I have two modules, for example Module1 and
I'm currently writing an application that works with modules. The module part is all
I have two files in the same folder, Eval.hs and Data.hs , module in
I have two modules A, B. A has a function f() that is globally

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.