Parse error on input 'exposing' for Elm - elm

I'm just starting to learn Elm today, and I'm just trying to run a simple 'hello, world!' tutorial which I found online. I'm using a Mac with OS10.12 and I'm sure I've updated Node correctly but I keep getting the following error:
module Main exposing (..)
import Html exposing (text)
main =
text "Hello, World!"
parse error on input ‘exposing’
|
1 | module Main exposing (..)
| ^^^^^^^^
[Finished in 0.3s with exit code 1]
I'm using Sublime text editor and I'm pretty sure I read all the install and setup instructions properly, the problem I'm having is that if I don't include that top line 'module Main exposing (..)' then the build command automatically includes that line and then throws this parsing error. How do I fix this, and why does the builder automatically add a line it doesn't like?

If you don't add a module declaration, Elm will use this one instead:
module Main exposing (..)
Elm expects this module to be in a file called Main.elm. Are you sure that your file is named Main.elm. Make sure you capitalize the name of the file: Main.elm not main.elm.
You can call it however you want...
module Hello exposing (..)
... but then this declaration should be in a file Hello.elm
It could help us, if you could post the contents of your elm-package.json file and the folder structure of the directory you started working in.
If you just want to get started, it might be a good idea to write your first Elm program in the online editor
It takes away a bit of the hassle of setting up a development environment if all you want to do is get to know Elm and decide if you like it.
There is another online editor for Elm. This instance already has the program you were trying to compile inside: https://ellie-app.com/3LBvgqYfGa1/0

Related

"You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file."Webpack, vue.js

I have a problem with images in Vue.js Webpack
My Vue.js template :
(don't pay attention at red-line)
My package.json:
webpack.config.js:
and I am getting this error:
"Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)"
i tried to add url-loader, but its not working. How to fix it?
The main problem here is that your are using Webpack dynamic import with fully dynamic argument. This is not allowed - see the documentation for import() - same limitations described there applies also to a require() where the argument is expression instead of simple static string
You dont need the rquire inside the img tag, if those images are local, just provide the path, relative to your current file, and the name of the image file. That should work.
Also do not use url-loader in these cases, url-loader converts images to base-64 if they are small enough, and that will not work for dynamic stuff most of the time.
You could also try importing all those local images, and then write some logic that will decide which image to to put in the src.
like:
import bike from '#/assets/images/bike.jpg'
//in the tempalte:
<img :src="bike" />
This also works nicely, and it will not confuse vue-loader with dynamic imports in the template... if you have recent es features availabkle you could use dynamic import as well, but that depends on you and your code base...

How do you import a reference to a dart file when you only know the file name? Extension methods and others

To import a file in Dart (using IntelliJ) I will usually use start typing the name of a function, class or variable and select enter. Alternatively I might type the name of the class and press alt+enter on it. This will then give me an option to import the file reference.
For extension methods this doesn't work and sometimes I know the name of the package (file) I want to import but can't remember the name of the function.
Is there a way to use the filename to lookup and insert an import statement with the full package address?
Edit
Unfortunately my originally accepted answer doesn't always work. For example with extension methods. I'm trying to add a reference and it seems impossible to do without typing the full reference to the extension.
Edit2
Found out there is an open issue to fix this
https://github.com/dart-lang/sdk/issues/40365
You can write import 'som...' and ctrl+space for auto-complete and get IntelliJ to make suggestion across all packages imported with pubspec and files across the project. If the file is inside a package, it will automatically insert the full path.

intellij cannot resolve symbol "File"

I have this in my script
import groovy.io.FileType
.....
derp = new File("blah")
The script works but inetillij complains it cant resolve "File" and it suggested I import a totally different wrong library for it (com.jidesoft.icons.IconSet)
I already tried invalidating cache and restarting
How do I get intelllij to import groovy.io.FileType? I cant even find a way to suppress error either it doesnt give me that option
groovy.io.FileType is an enum class. It appears your variable derp would be of type File, not FileType.
You can statically import enums from the FileType class (for example):
import static groovy.io.FileType.*
In my Intellij on Java 8 the File class comes from the java.io package in a .groovy file.

Confused by the way TypeScript uses "require(...)"

I've tried reading several blog posts but TypeScript modules still have me totally confused. In particular, I have used 3 different modules (all installed via npm) and each seems to show totally different behaviour:
(1) I can import and use Angular 2 from npm like this in my .ts:
import {bootstrap, Component, Directive, CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';
Then in my html I have:
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>
This has the following results:
The TypeScript compiler knows to look for the angular2.d.ts file under node_modules, even though I just said "angular2/angular2"
The TypeScript compiler adds "var angular2_1 = require('angular2/angular2'); to the output JavaScript
The browser does not attempt to load the angular 2 JavaScript again despite the presence of the require, it somehow knows it's already loaded it via "angular2.dev.js" in the script tag
(2) The npm D3 module does not have a typescript definition, but I can download the one from DefinitelyTyped and then use it by putting:
/// <reference path="../../typings/tsd.d.ts" />
at the top of my .ts. and
<script src="../node_modules/d3/d3.js"></script>
in my html. It seems that being an old-style module it doesn't need an import statement, and as long as I leave it here the output JavaScript works fine. If I do try to use an import statement immediately after the reference line:
import * as d3 from 'd3';
then as with Angular2 it now adds:
var d3 = require('d3');
to the output JavaScript. However, unlike with the Angular case it doesn't realise it's already loaded the JavaScript via the script tag, and so the browser tries and fails to load a file simply called "d3" from the same directory as the html file, which fails.
(3) The npm Phaser module does include a .d.ts file, in a "typescript" subdirectory of the npm module. This is an old style module ("declare module Phaser"), so it seems I need not use "import.." syntax but instead just:
/// <reference path="../node_modules/phaser/typescript/phaser.d.ts"/>
at the top of my .ts file, as with the D3 example. The TypeScript compiler is happy, but unlike with the D3 example, under some circumstances (I haven't worked out quite what yet, doesn't seem to always happen) it outputs:
var phaser_1 = require('phaser');
in the JavaScript even when I haven't used an import statement. I'm not even using commonjs/requirejs in my phaser project, so "require" isn't even defined, causing failure.
And for completeness, unlike with either the Angular or D3 example, if I try putting an import statement after the reference line:
import * as Phaser from 'Phaser';
even the TypeScript compiler isn't happy. Perhaps in the D3 example the TypeScript compiler is treating the tsd.json or typings folder from DefinitelyTyped in special way, or maybe there is some other reason the import compiles for D3 but not for Phaser.
I have all sorts of questions:
1) What determines whether the TypeScript compiler includes a "require(...)" line in the output JavaScript?
2) Under what circumstances does the TypeScript compiler know where to find an external module in "npm_modules" when using "import", with or without needing a reference line at the top of the file?
3) Under what circumstances does the TypeScript compiler know where to find an ambient module in "typings" when using "import", with or without a "reference" line at the top of the file?
4) Under what circumstances does the TypeScript compiler know where to find an ambient module in "npm_modules" when using "import", with or without a "reference" line at the top of the file??
5) Maybe a commonjs/requirejs question rather than a typescript question, but if the TypeScript compiler does output a "require" line in the JavaScript, what do you do if the source of the JavaScript module is not set up with ES6 module exports?
1 ) I can import and use Angular 2 from npm like this in my .ts:
This is because
angular2 ships with its .d.ts file
The browser doesn't attempt to read require because of magic in angular2.dev.js
The npm D3 module fails && the phaser module fails at runtime
They don't have the magic you get from angular2.dev.js. Use something like webpack or browserify to provide this magic.
Unlike with either the Angular or D3 example, if I try putting an import statement after the reference line: import * as Phaser from 'Phaser';
This is because of how Phaser definition is declared. Apprarently it is missing declare module "Phaser" which is what is provided with d3 see here and angular.

python: from modules import abc.py does not work

I have recently switched from python 2.7 to python 3.2
considering following folder structure:
~/my_program
~/my_program/modules
where *my_program* is the root of the application, containing main script called main.py
*my_program/modules* is used to store all additional classes and subscripts
in python2.x I was able to import any file "module" the same way I do import standard modules
from modules import abc.py
however, while I try to launch the same program in python3.2 I get the error message saying:
File "/my_program/modules/__init__.py" line 1
import abc, def
ImportError: No module named abc
Please advise
It's a good example you are using, because "abc" is in fact a module in the standard library. So in fact, if you in Python 3 do import abc that will work just fine, but you will get the standard library module.
In Python 2, if you had a local module called abc.py, that import abc would import the local module instead. That means you couldn't import the module from the standard library.
In Python 3, this has been changed, and you now need to use the fully qualified name, in your case probably from modules import abc.
Where are you storing the module you created? When I create a module, I do the following:
Create a folder in the lib\sitepackages folder in your python folder ex: myModules
Save a blank python file named init.py in this folder. The file does not have to contain any syntax. Later on, you can set module requirements in this file if you wish.
Save your module into this folder ex: myGamesModule.py
In idle (or whichever python connected IDE you use) type:
from myModules import myGamesModule or from myModules import myGamesModule as myGmMod
That should import your module and then you can call the classes etc ex myGmMod.Player()
I am sure that this is correct, as I have just done it and it was ok.
I have found that sometimes, if I create a blank text file in the module folder and rename it to init.py, it has caused me problems before. I usually just open IDLE and save a init.py file from there into my module folder and then use whichever IDE I use (sublime) to create and save the rest of the files.
Also, for some reason, the text box has disallowed the underscores I am using in this text so where you see init.py, it should be (underscoreunderscore*init*underscoreunderscore.py without any asterix