Parse error on input ‘module’ when importing a module
This is the source code of the file Solitaire.hs:
import MergeSort
module Solitaire where
a :: Int
a = 2
MergeSort.hs and Solitaire.hs are in the same directory.
I'm using WinGhci.
The error I'm getting when trying to load Solitaire.hs after changing to its directory and using the command :load Solitaire.hs is:
Solitaire.hs:3:1: error: parse error on input ‘module’
|
3 | module Solitaire where | ^^^^^^
Failed, one module loaded.
*MergeSort>
What's curious is, that just removing the import statement: import MergeSort
removes any error.
haskell compiler-errors
add a comment |
This is the source code of the file Solitaire.hs:
import MergeSort
module Solitaire where
a :: Int
a = 2
MergeSort.hs and Solitaire.hs are in the same directory.
I'm using WinGhci.
The error I'm getting when trying to load Solitaire.hs after changing to its directory and using the command :load Solitaire.hs is:
Solitaire.hs:3:1: error: parse error on input ‘module’
|
3 | module Solitaire where | ^^^^^^
Failed, one module loaded.
*MergeSort>
What's curious is, that just removing the import statement: import MergeSort
removes any error.
haskell compiler-errors
add a comment |
This is the source code of the file Solitaire.hs:
import MergeSort
module Solitaire where
a :: Int
a = 2
MergeSort.hs and Solitaire.hs are in the same directory.
I'm using WinGhci.
The error I'm getting when trying to load Solitaire.hs after changing to its directory and using the command :load Solitaire.hs is:
Solitaire.hs:3:1: error: parse error on input ‘module’
|
3 | module Solitaire where | ^^^^^^
Failed, one module loaded.
*MergeSort>
What's curious is, that just removing the import statement: import MergeSort
removes any error.
haskell compiler-errors
This is the source code of the file Solitaire.hs:
import MergeSort
module Solitaire where
a :: Int
a = 2
MergeSort.hs and Solitaire.hs are in the same directory.
I'm using WinGhci.
The error I'm getting when trying to load Solitaire.hs after changing to its directory and using the command :load Solitaire.hs is:
Solitaire.hs:3:1: error: parse error on input ‘module’
|
3 | module Solitaire where | ^^^^^^
Failed, one module loaded.
*MergeSort>
What's curious is, that just removing the import statement: import MergeSort
removes any error.
haskell compiler-errors
haskell compiler-errors
edited Nov 25 '18 at 19:08
dfeuer
33.2k349132
33.2k349132
asked Nov 25 '18 at 18:44
Andrei TihoanAndrei Tihoan
51
51
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Take a look at the grammar (5.1):
module → module modid [exports] where body
| body
body → { impdecls ; topdecls }
| { impdecls }
| { topdecls }
impdecls → impdecl1 ; … ; impdecln (n ≥ 1)
topdecls → topdecl1 ; … ; topdecln (n ≥ 1)
Also, in Section 5.3:
The entities exported by a module may be brought into scope in another module with an import declaration at the beginning of the module.
As you can see, imports must be inside the module, so your code should be:
module Solitaire where
import MergeSort
a :: Int
a = 2
1
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470725%2fparse-error-on-input-module-when-importing-a-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Take a look at the grammar (5.1):
module → module modid [exports] where body
| body
body → { impdecls ; topdecls }
| { impdecls }
| { topdecls }
impdecls → impdecl1 ; … ; impdecln (n ≥ 1)
topdecls → topdecl1 ; … ; topdecln (n ≥ 1)
Also, in Section 5.3:
The entities exported by a module may be brought into scope in another module with an import declaration at the beginning of the module.
As you can see, imports must be inside the module, so your code should be:
module Solitaire where
import MergeSort
a :: Int
a = 2
1
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
add a comment |
Take a look at the grammar (5.1):
module → module modid [exports] where body
| body
body → { impdecls ; topdecls }
| { impdecls }
| { topdecls }
impdecls → impdecl1 ; … ; impdecln (n ≥ 1)
topdecls → topdecl1 ; … ; topdecln (n ≥ 1)
Also, in Section 5.3:
The entities exported by a module may be brought into scope in another module with an import declaration at the beginning of the module.
As you can see, imports must be inside the module, so your code should be:
module Solitaire where
import MergeSort
a :: Int
a = 2
1
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
add a comment |
Take a look at the grammar (5.1):
module → module modid [exports] where body
| body
body → { impdecls ; topdecls }
| { impdecls }
| { topdecls }
impdecls → impdecl1 ; … ; impdecln (n ≥ 1)
topdecls → topdecl1 ; … ; topdecln (n ≥ 1)
Also, in Section 5.3:
The entities exported by a module may be brought into scope in another module with an import declaration at the beginning of the module.
As you can see, imports must be inside the module, so your code should be:
module Solitaire where
import MergeSort
a :: Int
a = 2
Take a look at the grammar (5.1):
module → module modid [exports] where body
| body
body → { impdecls ; topdecls }
| { impdecls }
| { topdecls }
impdecls → impdecl1 ; … ; impdecln (n ≥ 1)
topdecls → topdecl1 ; … ; topdecln (n ≥ 1)
Also, in Section 5.3:
The entities exported by a module may be brought into scope in another module with an import declaration at the beginning of the module.
As you can see, imports must be inside the module, so your code should be:
module Solitaire where
import MergeSort
a :: Int
a = 2
answered Nov 25 '18 at 18:56
ForceBruForceBru
20.5k83354
20.5k83354
1
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
add a comment |
1
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
1
1
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
Oh, that worked. I was almost certain I tried that. I must've tried it without indenting it properly or something. Thank you for the very much for the detailed response.
– Andrei Tihoan
Nov 25 '18 at 19:07
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
@AndreiTihoan, it's completely optional to indent module contents like that, and in my experience it's rare. The vast majority of Haskell programmers start their imports and top-level definitions in column 0 so they can make the best use of limited horizontal space. But whatever column you start the module contents in is the one you have to put the rest in.
– dfeuer
Nov 25 '18 at 19:11
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
Thanks again @ForceBru. It does actually look better when not indented. Also, thank you for cleaning up my question. It was my first post, and I made it in a bit of a hurry, not realizing my code wasn't properly written under code.
– Andrei Tihoan
Nov 25 '18 at 19:20
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
@AndreiTihoan, you should thank defer for the idea about indentation, not me :D As for question formatting, you can find more information about how and what to post in the Help Centre. Welcome to Stack Overflow!
– ForceBru
Nov 25 '18 at 19:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470725%2fparse-error-on-input-module-when-importing-a-module%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown