Could not find module ‘Text.Megaparsec.Char.Lexer’ - parsing

I tried "stack install megaparsec", adding megaparsec and parsec as a dependency in the project.yaml file and running stack build, i tried stack build on all levels of the project folder. Also what's weird is that I can load the module which contains the imports which are marked as problems by VSCode and show the error message and I can also run the functions in said module which make us of the imported stuff but I can't compile the file.
ghci version is 9.0.1
stack version is 2.7.3
cabal-version: 1.12
Error message from terminal
module Parsing where
import Control.Monad (void)
import Data.Void
import Syntax
import Data.Text (Text)
vvvvv these 3 are marked as problems and are the reason I can't compile the file.
import Text.Megaparsec
import Text.Megaparsec.Char
import qualified Text.Megaparsec.Char.Lexer as L
.cabal file
library
exposed-modules:
Example
Lib
Parsing
Print
Semantics
Syntax
other-modules:
Paths_parser
hs-source-dirs:
src
build-depends:
base >=4.7 && <5
, containers
, megaparsec
, parsec
, text
default-language: Haskell2010
executable parser-exe
main-is: Main.hs
other-modules:
Paths_parser
hs-source-dirs:
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, parser
default-language: Haskell2010
test-suite parser-test
type: exitcode-stdio-1.0
main-is: Spec.hs
other-modules:
Paths_parser
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
base >=4.7 && <5
, parser
default-language: Haskell2010

Related

import fuction from package to another package

can you please tell me how can I import a function from poly.py to query.py
this is the directories tree :
my_project
|_dataset
|_execute
|__poly.py
|_search
|__query.py
|_determine
|_optimize
|_transmit
NB : my python version is 3.6.2 > 3.3 so _init.py is unuseful
You need put those files in 1 folder and do import filename or from filename import function

Can not import files in agda

I have installed agda using cabal. I have created a file name Trial.agda in the directory /media/arkaghosh/Important5/programs/Agda with the following content inside it
module Trial where
open import Data.Nat
But when I try to compile it using
agda -c Trial.agda
I get the following error
Failed to find source of module Data.Nat in any of the following
locations:
/media/arkaghosh/Important5/programs/Agda/Data/Nat.agda
/media/arkaghosh/Important5/programs/Agda/Data/Nat.lagda
/home/arkaghosh/.cabal/share/x86_64-linux-ghc-7.10.3/Agda-2.6.0.1/lib/prim/Data/Nat.agda
/home/arkaghosh/.cabal/share/x86_64-linux-ghc-7.10.3/Agda-2.6.0.1/lib/prim/Data/Nat.lagda
when scope checking the declaration
open import Data.Nat
I have seen this question which is similar to mine
Agda: Can't find std-lib when installing with Stack
. But I am unable use the answer to solve my problem.

Run dart script outside of a project folder

I am trying to replace python with dart as a scripting language for my tools. I can create a python file anywhere, import global packages and run it but I can't seem to get this working with dart. Do I always need a pubspec.yaml file to run a dart script?
This is the script I am trying to run:
import 'package:http/http.dart' as http;
main(List<String> args) async{
var res = await http.get('https://example.com');
print(res.headers);
}
This is the error I am getting:
Error: Could not resolve the package 'http' in 'package:http/http.dart'.
test2.dart:1:8: Error: Not found: 'package:http/http.dart'
import 'package:http/http.dart' as http;
^
test2.dart:4:19: Error: Method not found: 'get'.
var res = await http.get('https://example.com');
No, you don't need a pubspec.yaml file to run a program, but it does need to somehow be able to resolve all the imports.
The pubspec.yaml file is used for obtaining the packages (from pub.dev, a git repository, etc.) but not for finding the packages at runtime. The pub program reads the pubspec.yaml file and downloads the packages mentioned in it, and maintains a packages specification file indicating where each package resolves to. By default the packages specification is in a file called .packages in the same directory as the pubspec.yaml file. The Dart runtime normally finds the packages by looking at the .packages package specification file, but there are other ways.
Here are some options:
Put a .packages file in the same directory as the Dart program, or in an ancestor directory.
Use the --packages option to specify the package specification file to use:
dart --packages=/home/username/stuff/mypackagespecfile myprogram.dart
The Dart runtime also has a --package-root option. But I haven't figured out how to make it work.
The import statements use URIs, so import 'file://...'; can also work in some cases.
Use dart2native to compile the program into an executable.
Note: Dart scripts can also start with a hash-bang line:
#!/usr/bin/env dart
import 'package:http/http.dart' as http;
main(List<String> args) async{
var res = await http.get('https://example.com');
print(res.headers);
}
Then you can make the program executable and run it without needing to type in the Dart runtime:
$ chmod a+x myprogram.dart
$ ./myprogram.dart

Flask vs Terminal: how do I manage imports so that I can use codes in both?

I have a Flask project with the following directory structure:
-my_project
- flask_code.py
- module
- submodule
- foo.py
- bar.py
- xyz.py
In flask_code.py, I must import both foo and bar. Therefore, flask_code has the following import statements:
"""flask_code.py"""
from module.foo import *
from module.bar import *
In foo.py, I need to import xyz. I also have implemented a main function in foo for testing, which I usually call from command line. If I write the imports of foo like this:
"""foo.py import 1"""
from module.xyz import *
The flask application runs exactly as expected. But, if I try to run foo.py from command line, I get the following error:
ModuleNotFoundError: No module named 'module'
On the other hand, if I change the imports of foo to:
"""foo.py import 2"""
from xyz import *
the ModuleNotFoundError is not thrown anymore when foo.py is called from command line, which I guess it's expected. But, the flask application can't find module xyz on its own.
Both my_project and module folders have a init.py empty file.
I want to manage these imports so that I can both use the flask application and call the scripts from command line for testing. Thanks in advance!

Where to set the path to the protoc to import standards Protocol Buffers

Where need I to set the path to the protoc to get import standards Protocol Buffers (protobuf), like empty.proto and timestamp.proto in Windows and Dart?
When the protoc is ran:
protoc --dart_out=grpc:lib/src/protos/generated -Iprotos
protos/organization.proto
--plugin=protoc-gen-dart=D:\Users\Samuel\AppData\Roaming\Pub\Cache\bin\protoc-gen-dart.bat
The following error is presented:
google/protobuf/empty.proto: File not found. organization.proto:
Import "google/protobuf/empty.proto" was not found or had errors.
organization.proto:14:27: "google.protobuf.Empty" is not defined.
In IntelliJ Settings on Protobuf Support plugin the path is define where standard protos (*.proto) are:
Additionally this path is define in IntelliJ on Project Structure \ Global Libraries:
The code organization.proto that import google/protobuf/empty.proto to use Empty class :
syntax = "proto3";
package auge.protobuf;
import "google/protobuf/empty.proto";
service OrganizationService {
rpc GetOrganizations (google.protobuf.Empty) returns (OrganizationsResponse) {}
}
IntelliJ analyzer recognizes the import "google/protobuf/empty.proto" and Empty class on IDEA, but protoc can not find.
The environment is:
SO: Windows 7 x64
protoc: libprotoc 3.6.1
Dart: 2.2.0-edge
Say you have /some/path/to/google/protobuf/empty.proto, you need to pass --proto_path=/some/path/to/ so protoc can locate it.
use two dot before protobuf folder path
<Protobuf Include="..\Proto\protobuf.proto" ProtoRoot="Proto" />

Resources