So basically i fire up the gchi import the graphics library and then go and do this.
Prelude Graphics.Gnuplot.Simple> plotList [] [(1, 1), (2, 2), (3, 3)]
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package filepath-1.3.0.1 ... linking ... done.
Loading package old-locale-1.0.0.5 ... linking ... done.
Loading package time-1.4.0.1 ... linking ... done.
Loading package bytestring-0.10.0.2 ... linking ... done.
Loading package unix-2.6.0.1 ... linking ... done.
Loading package directory-1.2.0.1 ... linking ... done.
Loading package process-1.1.0.2 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package data-accessor-0.2.2.6 ... linking ... done.
Loading package data-accessor-transformers-0.2.1.6 ... linking ... done.
Loading package exceptions-0.6.1 ... linking ... done.
Loading package temporary-1.2.0.3 ... linking ... done.
Loading package utility-ht-0.0.10 ... linking ... done.
Loading package gnuplot-0.5.2.2 ... linking ... done.
All this stuff happens, but no image is shown? Do i have to do some sort of main function call to display or how would i go about actually seeing a picture. Thanks for the advice.
Make sure you have the gnuplot binary installed, and not only the Haskell gnuplot package from hackage. The latter doesn't really check whether you have the necessary binary installed. Depending on your platform, it simply invokes a shell command or uses a pipe and doesn't look for the return type, therefore you don't even get an error.
You can check whether you have gnuplot installed via
$ gnuplot --version
If this doesn't give you a version, you either have yet to install gnuplot, or gnuplot isn't in your path.
Related
I’m trying to build a project in a cabal sandbox that depends on happstack-server, but this package fails to build. Here is the content of .cabal-sandbox/logs/happstack-server-7.4.6.1.log:
Building happstack-server-7.4.6.1...
Preprocessing library happstack-server-7.4.6.1...
[ 1 of 38] Compiling Happstack.Server.Internal.LazyLiner ( src/Happstack/Server/Internal/LazyLiner.hs, dist/dist-sandbox-925bc8f2/build/Happstack/Server/Internal/LazyLiner.o )
[ 2 of 38] Compiling Happstack.Server.Internal.SocketTH ( src/Happstack/Server/Internal/SocketTH.hs, dist/dist-sandbox-925bc8f2/build/Happstack/Server/Internal/SocketTH.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package zlib-0.6.1.1 ... linking ... done.
Loading package xhtml-3000.2.1 ... linking ... done.
Loading package utf8-string-0.3.8 ... linking ... done.
Loading package old-locale-1.0.0.6 ... linking ... done.
Loading package old-time-1.1.0.2 ... linking ... done.
Loading package time-1.4.2 ... linking ... done.
Loading package time-compat-0.1.0.3 ... linking ... done.
Loading package stm-2.4.4.1 ... linking ... done.
Loading package threads-0.5.1.3 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package binary-0.8.2.1 ... linking ... done.
Loading package text-1.2.2.0 ... linking ... done.
Loading package system-filepath-0.4.13.4 ... linking ... done.
Loading package syb-0.6 ... linking ... done.
Loading package unix-2.7.0.1 ... linking ... done.
Loading package network-2.6.2.1 ... linking ... done.
Loading package sendfile-0.7.9 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.3.1 ... linking ... done.
Loading package parsec-3.1.9 ... linking ... done.
Loading package network-uri-2.6.0.3 ... linking ... done.
Loading package transformers-compat-0.5.1.4 ... linking ... done.
Loading package transformers-base-0.4.4 ... linking ... done.
Loading package monad-control-1.0.0.5 ... linking ... done.
Loading package html-1.0.1.2 ... linking ... done.
Loading package filepath-1.3.0.2 ... linking ... done.
Loading package directory-1.2.1.0 ... linking ... done.
Loading package process-1.2.0.0 ... linking ... done.
Loading package hslogger-1.2.9 ... linking ... done.
Loading package extensible-exceptions-0.1.1.4 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package exceptions-0.8.2.1 ... linking ... done.
Loading package blaze-builder-0.4.0.1 ... linking ... done.
Loading package blaze-markup-0.7.0.3 ... linking ... done.
Loading package blaze-html-0.8.1.1 ... linking ... done.
Loading package base64-bytestring-1.0.0.1 ... linking ... done.
ByteCodeLink.lookupCE
During interactive linking, GHCi couldn't find the following symbol:
templatezmhaskell_LanguageziHaskellziTHziSyntax_zdfMonadQzuzdczgzgze_closure
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
glasgow-haskell-bugs#haskell.org
How can I fix this?
▶ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.4
▶ cabal --version
cabal-install version 1.18.1.0
using version 1.18.1.5 of the Cabal library
The problem was due to an older version of template-haskell installed by my OS package manager. This version was taken into account even though I work in a sandbox. I solved the issue by using cabal install --shadow-installed-packages.
Is anyone successfully using hmatrix-0.16.0.4 on OSX 10.9?
I get the following error:
Prelude> import Numeric.LinearAlgebra
Prelude Numeric.LinearAlgebra> let m = (3><4) [1..] :: Matrix Double
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package primitive-0.5.0.1 ... linking ... done.
Loading package vector-0.10.0.1 ... linking ... done.
Loading package bytestring-0.10.0.2 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package binary-0.5.1.1 ... linking ... done.
Loading package old-locale-1.0.0.5 ... linking ... done.
Loading package time-1.4.0.1 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package split-0.2.2 ... linking ... done.
Loading package storable-complex-0.2.1 ... linking ... done.
Loading package hmatrix-0.16.0.4 ... linking ... <interactive>:
lookupSymbol failed in relocateSection (relocate external)
/Users/tba/.cabal/lib/x86_64-osx-ghc-7.6.3/hmatrix-0.16.0.4/libHShmatrix-0.16.0.4.a: unknown symbol `___ieee_divdc3'
ghc: unable to load package `hmatrix-0.16.0.4'
I installed using brew install gsl && cabal install hmatrix.
My ghc version is 7.6.3.
I suspect it should be built with gcc (instead of clang) -- how can I change this?
(GitHub ticket)
I fixed the issue by installing ghc 7.8. It's unfortunate that homebrew's "haskell-platform" is so out of date.
I need to be able to load Haskell modules dynamicaally, and evaluate expressions in the context of dynamically-loaded modules.
Hint does it; the problem is, it doesn't work under GHCi, on Windows at least.
cygwin-bash> ghci HintTest.hs
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main>
Prelude Main> main
[... lots of "Loading package" messages snipped]
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
_debugLn
whilst processing object file
C:\PROGRAM FILES (X86)\HASKELL PLATFORM\2013.2.0.0\lib\ghc-prim-0.3.0.0\HSghc-prim-0.3.0.0.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
I get the same error when using GHC modules directly, as shown in GHC/As a library.
As a compiled program, HintTest runs just fine.
Is there anything that can bee done about this?
I don't ever need to run my program stand-alone; always using GHCi is sufficient. It would also be nice if the program could use GHCi itself as the interpreter and not its own copy of GHC. That is, I'd like to be able to do something like this:
do
context <- loadToGhci "MyModule.hs"
inContext context "MyModule.myFunction 2 5"
and when I return to the REPL, MyModule is magically loaded to it. context is meant to be some kind of monad that carries GHCi state.
Update The same code works on Linux. Perhaps it's a Windows-specific bug in GHC. Can it be worked around?
Update 2
Here's the full log
Prelude Main> main
Loading package array-0.4.0.1 ... linking ... done.
Loading package deepseq-1.3.0.1 ... linking ... done.
Loading package bytestring-0.10.0.2 ... linking ... done.
Loading package Win32-2.3.0.0 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package old-locale-1.0.0.5 ... linking ... done.
Loading package time-1.4.0.1 ... linking ... done.
Loading package syb-0.4.0 ... linking ... done.
Loading package random-1.0.1.1 ... linking ... done.
Loading package filepath-1.3.0.1 ... linking ... done.
Loading package directory-1.2.0.1 ... linking ... done.
Loading package process-1.1.0.2 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package containers-0.5.0.0 ... linking ... done.
Loading package hpc-0.6.0.0 ... linking ... done.
Loading package hoopl-3.9.0.0 ... linking ... done.
Loading package haskell-src-1.0.1.5 ... linking ... done.
Loading package old-time-1.1.0.1 ... linking ... done.
Loading package Cabal-1.16.0 ... linking ... done.
Loading package binary-0.5.1.1 ... linking ... done.
Loading package bin-package-db-0.0.0.0 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package ghc-7.6.3 ... linking ... done.
Loading package extensible-exceptions-0.1.1.4 ... linking ... done.
Loading package MonadCatchIO-mtl-0.3.0.5 ... linking ... done.
Loading package ghc-mtl-1.0.1.2 ... linking ... done.
Loading package ghc-paths-0.1.0.9 ... linking ... done.
Loading package utf8-string-0.3.7 ... linking ... done.
Loading package hint-0.3.3.7 ... linking ... done.
GHCi runtime linker: fatal error: I found a duplicate definition for symbol
_debugLn
whilst processing object file
C:\PROGRAM FILES (X86)\HASKELL PLATFORM\2013.2.0.0\lib\ghc-prim-0.3.0.0\HSghc-prim-0.3.0.0.o
This could be caused by:
* Loading two different object files which export the same symbol
* Specifying the same object file twice on the GHCi command line
* An incorrect `package.conf' entry, causing some object to be
loaded twice.
GHCi cannot safely continue in this situation. Exiting now. Sorry.
You're trying to dynamically load the bytecode interpreter and runtime into the bytecode interpreter and runtime. Whether this works will depend on how the underlying C libraries are linked on your system -- which is very platform dependent.
In particular, C symbols will be duplicated unless special care is taken when linking, when you load the various RTS modules the second time, which will lead to linker errors.
I try to use the Graphalyze library, installed by the standard way cabal install graphalyze. When I import any modules from this package, I face with a trouble.
My project normally loading into WinGHCi, but when I try to use any function, I see:
Loading package bktrees-0.3.1 ... linking ... done.
Loading package filepath-1.3.0.0 ... linking ... done.
Loading package old-time-1.1.0.0 ... linking ... done.
Loading package directory-1.1.0.2 ... linking ... done.
Loading package colour-2.3.3 ... linking ... done.
Loading package dlist-0.5 ... linking ... done.
Loading package polyparse-1.8 ... linking ... done.
Loading package process-1.1.0.1 ... linking ... done.
Loading package temporary-1.1.2.4 ... linking ... done.
Loading package wl-pprint-text-1.1.0.0 ... linking ... done.
Loading package graphviz-2999.16.0.0 ... linking ... done.
Loading package network-2.3.1.0 ... linking ... done.
Loading package HTTP-4000.2.5 ... linking ... done.
Loading package base64-bytestring-1.0.0.1 ... linking ... done.
Loading package blaze-builder-0.3.1.1 ... linking ... done.
Loading package blaze-markup-0.5.1.5 ... linking ... done.
Loading package blaze-html-0.5.1.3 ... linking ... done.
Loading package List-0.5.1 ... linking ... done.
Loading package extensible-exceptions-0.1.1.4 ... linking ... done.
Loading package utf8-string-0.3.7 ... linking ... done.
Loading package hexpat-0.20.3 ... linking ... done.
Loading package syb-0.3.7 ... linking ... done.
Loading package hs-bibutils-5.0 ... linking ... done.
Loading package pretty-1.1.1.0 ... linking ... done.
Loading package json-0.7 ... linking ... done.
Loading package pandoc-types-1.10 ... linking ... done.
Loading package citeproc-hs-0.3.8 ... linking ... done.
Loading package data-default-class-0.0.1 ... linking ... done.
Loading package data-default-instances-base-0.0.1 ... linking ... done.
Loading package data-default-instances-containers-0.0.1 ... linking ... done.
Loading package data-default-instances-dlist-0.0.1 ... linking ... done.
Loading package data-default-instances-old-locale-0.0.1 ... linking ... done.
Loading package data-default-0.5.3 ... linking ... done.
Loading package regex-base-0.93.2 ... linking ... done.
Loading package regex-pcre-builtin-0.94.4.7.8.31 ... linking ... ghc: unable to load package `regex-pcre-builtin-0.94.4.7.8.31'
If I try again without reloading, I see only one string, but on differ library!:
Loading package bktrees-0.3.1 ... linking ... ghc: unable to load package `bktrees-0.3.1'
What is the problem?
I use WinGHCi 1.0.6 and ghc version 7.4.2, in ghci i have the same problem.
Upd: runghc results `HSregex-pcre-builtin-0.94.4.7.8.31.o: unknown symbol __imp__pcre _compile'
I installed my first Haskell package with cabal:
$ cabal install regex-pcre
Could someone post a simple example using pcre regexes so I can figure out what I am supposed to import?
Okay, I figured it out. The module you need is Text.Regex.PCRE. For POSIX regexes, it's Text.Regex.Posix. Here is an example:
ghci>:m +Text.Regex.PCRE
ghci>"heeeee" =~ "hee|he*" :: [[String]]
Loading package array-0.4.0.0 ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package regex-base-0.93.2 ... linking ... done.
Loading package regex-pcre-0.94.4 ... linking ... done.
[["hee"]]
ghci>:m -Text.Regex.PCRE
ghci>:m +Text.Regex.Posix
ghci>"heeeee" =~ "hee|he*" :: [[String]]
Loading package regex-posix-0.95.2 ... linking ... done.
[["heeeee"]]