Any suggestions for a good graph and network library for Haskell ?
I'm looking on functionality something like which networkx library has for Python.
I've found fgl (also see home page) quite easy to work with. I'm not familiar with networkx, so I don't know how it compares.
There's a graph data-structure in the containers package. You can view the interface for it here.
Additionally, you can search through all of the packages available on the haskell-platform or additional packages through Cabal using Hayoo!
It's more than a year old question, but in case someone looks for the lib - the igraph package provides the bindings to all functions about graph properties of the igraph-C library. It won't compile with the igraph-C versions newer than 0.6.5, because the authors don't have time to maintain it, as Nils Schweinsberg said: Pull requests are wellcome. Also not all functions from the original library have the Haskell bindings, but one can write some using the FFI.
fgl is very beautiful library implementing the functional concept of inductive graphs, but it lacks the functionality of the igraph library: You can create directed/undirected weighted/unweighted graphs and have the algorithms implemented taking that into account.
The igraph package could be a very valuable library for the Haskell community if an experienced haskeller took care of it further.
Related
New to Python and come from a statically typed language background. I want type hints for https://lxml.de just for ease of development (mypy flagging issues and suggesting methods would be nice!)
To my knowledge, this is a python 2.0 module and doesn’t have types. Currently I’ve used https://mypy.readthedocs.io/en/stable/stubgen.html to create stub type definitions and filling in “any”-types I’m using with more information, but it’s really hacky. Are there any safer ways to get type hints?
There is an official stubs package for lxml now called lxml-stubs:
$ pip install lxml-stubs
Note, however, that the stubs are still in development and are not 100% complete yet (although very much usable from my experience). These stubs were once part of typeshed, then curated by Jelle Zijlstra after removal and now are developed as part of the lxml project.
If you want the development version of the stubs, install via
$ pip install git+https://github.com/lxml/lxml-stubs.git
(the project's readme installation command is missing the git+ prefix in URL's scheme and won't work).
Recently I have done much more gap filling based on lxml-stubs with some good progress.
Welcome to check out types-lxml if any late comer are still interested. For most people I think lxml.objectify is the only missing piece lacking from the stubs, which is planned immediately after current release.
I’ve used stubgen to create stub type definitions and filling in “any”-types
This is actually the correct approach if it's not lxml; creating template from mypy stubgen is the starting point for many stub files. But lxml is mostly written in Cython, for which stubgen do not have perfect support yet. Besides as OP noted, this is a python 2.0 era module, and author uses function arguments in a quite polymorphous way. There are lots of unique challenges annotating lxml, as lxml is essentially a python interface for libxml and libxslt in its core.
As an example, the support of both unicode and bytes input complicates matter too; this is the same difficulty found when annotating xml.etree bundled with python, but in a much greater magnitude.
I would not call this "hacky", rather it is gradual typing.
You can take a closer look at lxml-stubs repository. From about:
This repository contains external type annotations (see PEP 484) for the lxml package. Such type annotations are normally included in typeshed, but lxml's annotations were frequently problematic and have therefore been deleted from typeshed. In particular, the stubs are incomplete and it has been difficult to provide complete stubs.
Perhaps it will be useful to you
We want to use libOSRM for routing. Currently we are calling its http services. For better performance, I want to call its dynamic library. When reading Haskell FFI, I guess I can compile and links its source (instead of compiled dynamic library) with my Haskell code.
1. Which method is better?
2. How can I do each alternative?
Note that OSRM is full of structs that I am not sure how to import into haskell. c2hsc does not install (cabal raises error!). I do not know how to link the whole source of OSRM, from the other hand.
I prototyped some Haskell bindings going through an API and ABI compatible C wrapper: libosrmc.
Feel free to give it a try and send in pull requests. It's exposing just a small part of the API and is based on OSRM version 5.4; you might need to invest some time. But the overall architecture and ideas still apply. Here are the Haskell bindings.
I recommend thinking twice about going the libosrm/FFI way with Haskell instead of sending HTTP requests: benchmark up-front if it's worth the troubles.
you can look at https://github.com/daniel-j-h/hosrm-qa The project is PoC-only and uses HTTP OSRM API instead of Haskell FFI.
I would like to use a text-based UI in my Haskell program. I found some bindings for the ncurses library (see also hscurses or ncurses, which one to use?). The hscurses and nanocurses packages are just simple wrappers around the C library, while vty isn't very well documented and a bit ugly (for example mixing snake_case and CamelCase).
The ncurses library on Hackage looks much more pretty and provides API which nicely fits Haskell. The problem is that it doesn't seem to implement some crucial features, like resizing or refreshing the windows.
So my question is:
is there any other Haskell text UI library, either ncurses-based or not, which I missed?
if there isn't anyone, is it possible to extend the ncurses Haskell library to at least support window refreshing and resizing? (this should be probably consulted with the project owner, but I need the solution quickly)
EDIT:
I finally used nscurses without windows (and panels) to avoid the troubles with refreshing them. I had problems with output to bottom-right corner of a window (a very similar issue was reported for Python's ncurses binding). I solved it by not writing there :).
Have you looked at vty-ui? It has a very nice user manual with lots of examples. I believe it's essentially a wrapper around vty.
I've used nanoncurses and hscurses succesfully, my hmp3 app has a binding that was the basis for nanocurses.
No matter what you probably will want a nice high level API. hscurses does have a box abstraction at least.
You'd be fine going with hscurses.
There is another good choice for Text-based user interfaces in haskell;
Brick is written by jtdaugherty, the same person that developed vty-ui which is Deprecated now.
The API is Declarative, which is Better for Presenting a language like Haskell.
also the Documentation was great and complete.
I'm in the process of generating a Haskell documentation set for Dash (http://kapeli.com/dash).
I'm trying to index the documentation found at http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/index.html, and there seems to be a complete index at http://www.haskell.org/ghc/docs/7.0-latest/html/libraries/doc-index-All.html.
However, there seem to be a lot of libraries (base, ghc and haskell2010 are some I found), libraries which duplicate the same functions (as far as I can tell).
Which libraries should I index? What would you expect to find in a Haskell documentation browser?
Thanks!
You should cross-reference against base. The other libraries such as haskell2010 only exist to provide stable standards against older versions of the language. ghc is a developer library only, that I wouldn't expect you to be targetting.
I think there are two different issues here.
Which modules to index?
Well, if you manage to index the whole hackage, and keep your system convenient to use with so many functions, that'd be cool and very useful.
Otherwise, you can restrict yourself to the packages in Haskell Platform.
Function duplication
In Haskell modules can re-export entities (functions, types) defined in other modules. This is not specific to base vs haskell2012.
I don't know what interface you provide in your docs browser, but you could display all modules in which the entity is found. This is what Hoogle does: http://www.haskell.org/hoogle/?hoogle=Int (see the first entry there).
I'm creating a OpenCL high-level haskell library. Where's the best path in haskell tree for put it? I think it should be outside of Graphics subtree but I dont know where to put it.
It's based on Jeff Heard OpenCLRaw (He put that one on System.OpenCL.Raw.V10).
Update:
I just started a repository, http://github.com/zhensydow/opencl
Update: Options that I propose (and fomr answers)
System.GPU.OpenCL
Control.Parallel.OpenCL
Foreign.OpenCL
How about putting it in Control.Parallel? The haskell-mpi package uses Control.Parallel.MPI, and there's also the commonly used Control.Parallel.Strategies so it seems like an appropriate prefix.
Shameless plug: I wrote a small script for fun to extract the hierarchical module tree from all packages on Hackage. It might be useful for seeing what hierarchical modules other packages use. I'll clean up the code and release it some time in the future. For now, here's the Hackage tree as of May 2011.