diagrams-latex: configure dependencies

24 views
Skip to first unread message

Igor Moreno Santos

unread,
May 18, 2023, 12:03:26 PM5/18/23
to diagrams-discuss
Hi,

How do I configure dependencies when using diagrams-latex?

In the tutorial, it says: "If you have definitions that should be shared among multiple diagrams (as is common), simply put the definitions in a separate Haskell module in the same directory, and import this module in each diagram block".

But my code has other dependencies. I figured I could maybe try to use the cabal sandbox but that doesn't exist anymore. Any ideas?

Thank you.
Igor

Ryan Yates

unread,
May 18, 2023, 9:47:38 PM5/18/23
to Igor Moreno Santos, diagrams-discuss
It has been a while, but I think one of the options described in `findSandbox` should work to get it to use the correct package-db:




--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diagrams-discuss/b6e4c0ab-8286-401a-971a-4ff6b543b43cn%40googlegroups.com.

Igor Moreno Santos

unread,
May 20, 2023, 12:41:38 PM5/20/23
to diagrams-discuss
Hi,

I'm not sure exactly how to use `findSandbox` to do what I need. I have code that produces a diagram inside a latex file (I'm using diagrams-latex) but this code depends on some libraries so I need to set up the dependencies of the code as I would do in a cabal or stack project.

Thank you.
Igor

Ryan Yates

unread,
May 20, 2023, 9:59:26 PM5/20/23
to Igor Moreno Santos, diagrams-discuss
I was able to get it to work by using the `--package-env` option for `cabal install`:

```
cabal install --lib -fpgf diagrams-builder diagrams-lib diagrams-pgf --package-env=./
```

You can list any additional packages in the list.  This makes a `.ghc.environment.x86_64-linux-9.2.4` file in the current directory which `ghci` and `diagrams-builder` find when I run `pdflatex`.

Let me know if this helps,

Ryan

On Sat, May 20, 2023 at 12:41 PM Igor Moreno Santos <igorm...@gmail.com> wrote:
Hi,

I'm not sure exactly how to use `findSandbox` to do what I need. I have code that produces a diagram inside a latex file (I'm using diagrams-latex) but this code depends on some libraries so I need to set up the dependencies of the code as I would do in a cabal or stack project.

Thank you.
Igor
On Friday, May 19, 2023 at 3:47:38 AM UTC+2 Ryan Yates wrote:
It has been a while, but I think one of the options described in `findSandbox` should work to get it to use the correct package-db:




On Thu, May 18, 2023 at 12:03 PM Igor Moreno Santos <igorm...@gmail.com> wrote:
Hi,

How do I configure dependencies when using diagrams-latex?

In the tutorial, it says: "If you have definitions that should be shared among multiple diagrams (as is common), simply put the definitions in a separate Haskell module in the same directory, and import this module in each diagram block".

But my code has other dependencies. I figured I could maybe try to use the cabal sandbox but that doesn't exist anymore. Any ideas?

Thank you.
Igor

--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/diagrams-discuss/b6e4c0ab-8286-401a-971a-4ff6b543b43cn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.

Igor Moreno Santos

unread,
Jun 1, 2023, 12:27:09 PM6/1/23
to diagrams-discuss
Hi,

Thank you for your help. Indeed what you suggested works for the scenario described but the situation that I have is actually a little different from what I described. I have a codebase I'm developing with stack and this code uses diagrams. I would like to call this code from the latex code. That's why I said I wanted to add other dependencies. But the problem is that cabal doesn't let me add a folder to the list like so:

```
cabal install --lib -fpgf diagrams-builder diagrams-lib diagrams-pgf FOLDER_NAME --package-env=./
```

I could go to the folder and run cabal install

```
cd FOLDER_NAME
cabal install --lib --package-env=FOLDER_WITH_LATEX_CODE
```

but now when I compiled the latex code it doesn't work because I compiled things separately. For example if in my codebase I have

```
c :: _ => QDiagram b V2 n Any
c = circle 1
```

and then in latex I have

```
...
dia = c
```

 it complains saying
 
```
  • Couldn't match expected type: QDiagram PGF V2 Double Any
                  with actual type: diagrams-core-1.5.1:Diagrams.Core.Types.QDiagram
                                      b0 linear-1.22:Linear.V2.V2 n0 Any
```

I'm stuck...

Ryan Yates

unread,
Jun 1, 2023, 9:35:17 PM6/1/23
to Igor Moreno Santos, diagrams-discuss
Hi Igor,

I tried to match your situation a little more closely and was able to build by adding a `cabal.project` file with the path to the folder with the dependency:

```
packages: my-project/
```

In `my-project/` I have `my-project.cabal` that defines a library 'MyLib'.  I can then build with:

```
cabal install --lib -fpgf diagrams-builder diagrams-lib diagrams-pgf MyLib --package-env=./
```

And due to the `cabal.project` file it knows how to resolve `MyLib`.  I could then reference that lib in the diagrams code in the LaTeX file and it would successfully build for me.

Hope this helps!

Ryan

Igor Moreno Santos

unread,
Jun 22, 2023, 8:38:52 AM6/22/23
to Ryan Yates, diagrams-discuss
Amazing! Thank you so much :-)

Igor Moreno



Reply all
Reply to author
Forward
0 new messages