Importing a local swift module - swift

Swift newbie here, using swift 3 on Linux with the package manager.
I have a package Regulate, executable, and a sibling package Utils, intended to be a library. Utils/Sources has a TextReader.swift file, with class TextReader and its init function both public. The Utils directory is a git repo, described in Regulate/Package.swift:
dependencies: [.Package(url: "../Utils", "1.0.0")]
I've tried 3 ways to instantiate a TextReader object in the Regulate program and gotten 3 error messages:
import Utils
...
let reader = TextReader(filename: name)
error: use of unresolved identifier 'TextReader'
import Utils
...
let reader = Utils.TextReader(filename: name)
error: module 'Utils' has no member named 'TextReader'
import class Utils.TextReader
error: no such decl in module
It looks like the library module needs some additional structure to declare its exports, perhaps.
What do I need to do here? Thanks!

D'oh! This looks like a name conflict.
When I use Utils2 instead of Utils, it works fine. With Utils it cloned and built the other module, but apparently went to some system module instead when I referenced it.

Related

Data.Vector module Cannot Be Found

I start a new project library with cabal. here is the .cabal file
cabal-version: 2.4
library
exposed-modules: MyLib
build-depends: base ^>=4.14.3.0
, vector
hs-source-dirs: src
default-language: Haskell2010
I then use some Data.Vector functions inside my code. Here is the MyLib source
module MyLib (someFunc) where
import qualified Data.Vector as V
func :: [a] -> V.Vector a
func a = V.fromList a
But Data.Vector module remains underlined in red and this error is shown inside Vcode:
Could not load module ‘Data.Vector’
It is a member of the hidden package ‘vector-0.13.0.0’.
the func function works when in cabal repl
when I try cabal install vector this error appears:
Wrote tarball sdist to
/home/. .. .tar.gz
Resolving dependencies...
cabal: Cannot build the executables in the package vector because it does not
contain any executables. Check the .cabal file for the package and make sure
that it properly declares the components that you expect.
I don't understand what I am doing wrong? I told I understood the workings of cabal: I import a module as a dependency in .cabal, and I should be able to use it? why VSC does tell me he can't find it?

Unable to import a swift package into my Objective C class that is specified under public headers in SPM

I have a package that is a complete Objective C framework, this contains an include folder with my bridging-header. Now which ever class is exposed using this bridging header to my Swift project, i can't import any module into it. I get module not found error.
Project structure

Why can't I add a package (module) I created in Julia?

I am having trouble installing a module I created in Julia. I am running the Julia plugin under Visual Studio Code. If I run the file below with Ctrl+F5 I get a message
ERROR: LoadError: ArgumentError: Package Utils not found in current path:
- Run `import Pkg; Pkg.add("Utils")` to install the Utils package.
This is the file:
module demo
using Utils
greet() = print("Hello World!")
end # module
If I follow the advice on the error message I get another error message:
ERROR: LoadError: The following package names could not be resolved:
* Utils (not found in project, manifest or registry)
I also tried inserting this line:
import Pkg; Pkg.add(path="C:/Dropbox/Code/Julia/demo/src/Utils.jl")
and got this message (although the path definitely exists):
ERROR: LoadError: Path `C:/Dropbox/Code/Julia/demo/src/Utils.jl` does not exist.
The files demo.jl and Utils.jl are in C:\Dropbox\Code\Julia\demo\src\ and the demo project has been activated as can be seen in the REPL. The OS is Windows 10 Pro.
Any help will be greatly appreciated. Lots of time wasted trying to make this work.
Module and packages are not the same things. In short, packages are modules plus a set of metadata that make it easy for the package to be found and interact well with other packages. See here for a tutorial to write Julia packages:
https://syl1.gitbook.io/julia-language-a-concise-tutorial/language-core/11-developing-julia-packages
In your case, if you want to load a local module, just type include("fileWhereThereIsTheModule.jl") followed by a using Main.MyModule or using .MyModule. Note the dot... without it, Julia would indeed look for a package and to let it find your Demo or Util module you would have to either change an environmental variable or place your module file in certain predefined folders. Using include followed by the "absolute or relative position" of the module you don't have to do either.

Expose a package object's declarations to subpackages in Scala

I have the following packages hierarchy:
rootpackage
---firstpackage
---secondpackage
rootpackage contains a package object.
I know that if a file from firstpackage has package declaration in the form:
package rootpackage.firstpackage
the content of rootpackage package object will not be in the file scope, but with the following declaration it will:
package rootpackage
package firstpackage
How this strange difference is explained? And is there more transparent way to expose the package object's content to subpackages, like importing rootpackage package object content to firstpackage one?
Package object members can be imported in the following way:
import rootpackage.SomeMember

Import declarations in a namespace from external module

I would like use TypeScript.NET in my angular application. I am newbie in typescript and maybe root of problem is simple.
For example I would like to use StringBuilder.
First I install TypeScript via nuget
Add ref to index.html
<script src="source/System/Text/StringBuilder.js"></script>
<script src="source/System/Text/Utility.js"></script>
Here I am confuse, I don’t use any module system (e.g commonJs, amd, etc).
TypeScript.NET nuget add to my project folder dist which constains probably dist version for amd, commonjs etc hence I reference files from source folder.
Now I want to use StringBuilder in my internal module.
module App.Company{
//in internal module
import IVersion = App.IVersion;
import IError = App.IError;
//TypeScript.NET
import StringBuilder from "../../../../source/system/text/stringbuilder";
}
Here I get compilation errror
Import declarations in a namespace cannot reference a module
What is solution?
Second how can simple reference all types from TypeScript.NET?