OCaml: Unbound module from parent directory in toplevel - module

I'm trying to load a module from a parent directory into the top level interpretor.
#load "../Syntax.cmo";;
open Syntax
let foo = bar
Where bar is in Syntax. I have module Syntax in the parent directory. Loading module Syntax does not cause any problems, but the open line throws an error:
Error: Unbound module Syntax
I have also tried removing the open:
#load "../Syntax.cmo";;
let foo = Syntax.bar
But that gives me the same error as Syntax is in the parent directory.
Is there anyway around this?

You shouldn't use relative paths, instead use #directory directive:
#directory "..";;
#load "Syntax.cmo";;
let foo = Syntax.bar;;
Even better, define your library using oasis, or some other high-level tools, and use #require to load your libraries, instead of tackling with low-level directives.

Related

adding css causes failed build with Vue and Filepond

So, I am trying to follow a number of the file pond example and each of them include some form of CSS import (I get it, there is a lot that comes with beauty). However, no matter what I try, Filepond or Pintura (formerly Doka), I get this error in some form:
Compiled with problems:
ERROR in ./node_modules/filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css
Module build failed (from ./node_modules/style-loader/dist/cjs.js):
ValidationError: Invalid options object. Style Loader has been initialized using an options object that does not match the API schema.
- options should be an object:
object { injectType?, attributes?, insert?, base?, esModule?, modules? }
at validate (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/node_modules/schema-utils/dist/validate.js:105:11)
at Object.loader (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/dist/index.js:25:29)
ERROR in ./node_modules/filepond/dist/filepond.min.css
Module build failed (from ./node_modules/style-loader/dist/cjs.js):
ValidationError: Invalid options object. Style Loader has been initialized using an options object that does not match the API schema.
- options should be an object:
object { injectType?, attributes?, insert?, base?, esModule?, modules? }
at validate (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/node_modules/schema-utils/dist/validate.js:105:11)
at Object.loader (/Users/ryanolson/github/realkinkmen/node_modules/style-loader/dist/index.js:25:29)
I have NO IDEA how to fix this as I am not experienced enough with what would be going on. I am guessing it has to do with Webpack and build but no idea what I need to do to fix it. Any help?
I also want to mention this is a Laravel/VueJS/Tailwind stack
The solution is to add the CSS files to the app.css file under /resources/css/app.css
#import 'filepond/dist/filepond.min.css';
#import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.min.css";

Loading Module in Julia

i'm having some trouble loading module in Julia. I have to module that i cant load in my main file.
So my code (i'm trying to make an octree) look like this:
module Node
export node, contains, intersect
mutable struct node
x::Float64
y::Float64
z::Float64
m::Float64
node(x,y,z) = new(x,y,z,0)
end
end # module
and my other module:
module Tree
include("Node.jl")
using .Node
export tree, insert!, subdivide!
mutable struct tree
capacity::Int64
node::node
divided::Bool
tree(capacity, node) = new(capacity, node, false)
end
end
My problem is when i try to import the module in my main file using something like that:
include("Node.jl")
using .Node
include("Tree.jl")
using .Tree
plop=node(0,0,0)
plip=tree(1,plop)
I get the following error:
ERROR: LoadError: MethodError: Cannot `convert` an object of type node to an object of type Main.Tree.Node.node
I understand its due to the using .Node in my tree module which conflict with the same import in the main file but i'm unable to find a workaround.
One solution would probably be to put everything in the same module but i would like to keep thing separated.
Well, you actually just put the two modules in the same module. Or to be more precise, you have a module Node and a module Tree with a submodule Node in it, thus the Main.Tree.Node.node. This happens because you use include("Node.jl") within your Tree module. The include function works as if it copied the text in the Node.jl file and pasted it into the Tree.jl file. Thus, to use the Node module within Tree without creating a submodule you have to add it.
So, I'd recommend you to generate a package for both the Node and Tree modules. This is done by
julia> using Pkg
julia> Pkg.generate("Node")
Generating project Node:
Node/Project.toml
Node/src/Node.jl
and then copy your Node.jl and Tree.jl files to replace the ones that were created.
Then you can look at this question that tells you how to add a local package.
To sum it up you need to
julia> Pkg.develop(path="/Path/to/Node")
julia> Pkg.develop(path="/Path/to/Tree")
then your /Path/to/Tree/src/Tree.jl looks like
module Tree
using Node
[...]
end
and to run your code you can type
julia> using Node, Tree
julia> plop=node(0,0,0)
node(0.0, 0.0, 0.0, 0.0)
julia> plip=tree(1,plop)
tree(1, node(0.0, 0.0, 0.0, 0.0), false)
Note that it will probably tell you that Tree does not have Node in its dependencies. To solve that you might want to have a look at the documentation of Pkg.jl.

Undefined global variable when using QuestaSim

I have a variable defined in foo_const.v which is defined like this in foo_const.v:
localparam NUM_BITS = 32;
Then I have another file foo_const_slice.v which does this:
localparam SLICE_ADDR_BITS = NUM_BITS;
This compiles fine with the vcs command:
vcs -sverilog foo_const.v foo_const_slice.v
But when I try to use QuestaSim:
vlog -work work -sv foo_const.v foo_const_slice.v
I get the following error message:
** Error: foo_const_slice.v(46): (vlog-2730) Undefined variable: 'NUM_BITS'.
The problem is that by default, each file that vlog compiles goes into a separate compilation unit, just like C/C++ and many other languages. By default, vcs concatenates all files together into a single compilation unit.
Although there is a way to change the default (you can look it up in the user manual), the proper way to code this is to put your parameters in a package, and import the package where needed.
Dave

using the add function in a modular project

I have modeled my project in alloy, and I want to separate the run part from the modeled part of my project.
In some fact and predicate I use the add function in cardinality comparison.
Here is an example :
#relation1 = add[ #(relation2), 1]
When the run part and the model part are in the same file all work successfully.
But when I separate them in 2 files, I have the following syntax error :
The name "add" cannot be found.
I thought it needed to open the integer module where there is an add function, so I have opened it it the header of the model part.
But then the runtime ask me to specify the scope of this/Univ.
You must specify a scope for sig "this/Univ"
Here is an example :
first the model in one module
module solo
open util/ordering [A] as chain
//open util/integer
sig A{ b : set B}
fact { all a : A - chain/last | #(a.next.b) = add[ #(a.b), 2]}
sig B{}
then the run part in another module :
module due
open solo
run {#(solo/chain/first.b) = 2 }for 10 B, 5 A
when I call it like this I have the "the name add cannot be found" error.
When I uncomment the integer module opening, I have the "You must specify a scope for sig "this/Univ"" error.
What should I do that to make it works?
If I'm not mistaken + is the union operator and thus can't be used to perform additions.
Which version of alloy are you using ?
I think the add[Int,Int] function was added recently, before it used to be plus[int,int].
You might want to try plus[Int,Int] and see if it solves your problem.
Else it would be nice to have access to your models. Maybe the error comes from elsewhere.

Elm Graphics.Input

I'm trying to run the Elm input examples from this page. Specifically, the Text Field example, and I'm getting an error saying that the Graphics.Input module is missing.
I've got this in a file called Main.elm:
import Graphics.Input as Input
main = let (field, state) = Input.field "Type here!"
in lift2 display field state
display field state =
field `above` asText state
If I run elm-server and navigate to localhost:8000, I get the error
Your browser may not be supported. Are you using a modern browser?
Runtime Error in Main module:
Error: Module 'Graphics.Input' is missing. Compile with --make flag or load missing module in a separate JavaScript file.
The problem may stem from an improper usage of:
Input.field, above
Compiling the project with elm --make Main.elm gives me
elm: Graphics/Input.elm: openFile: does not exist (No such file or directory)
Is there something extra I need to do to install the Graphic.Input?
Additional Notes:
I'm running this on a Debian machine, and installed it using cabal install elm fairly recently (Jun 15 2013). The current version is labeled Elm-0.7.1.1.
If I hop into the chromium JS prompt and poke around, it turns out there's no Elm.Graphics.Input module, but there is an Elm.Input. There isn't a function called field, there's a similar looking one called textField, but it isn't trivially interchangeable.
Running this:
import Input
main = let (field, state) = textField "Type here!"
in lift2 display field state
display field state =
field `above` asText state
gives me the error
Your browser may not be supported. Are you using a modern browser?
Runtime Error in Main module:
TypeError: a is undefined
The problem may stem from an improper usage of:
above
The Graphics.Input package is new in version 0.8. So, since you're running version 0.7, that explains your problem.
0.8 was released somewhat recently, but it's definitely been out longer than June 15th, so you probably just forgot to cabal update before installing it. Running cabal update now and then updating elm to 0.8 should fix your issue.