Comments (18)
@snowleopard No problem! I'm happy to help!
That's odd, I'll try and refork the repo!
from alga.
@snowleopard looking into this. I built the project and ghci runs fine! cabal new-repl
on the other hand cannot gives the same error but for QuickCheck. Probably it's because i'm unexperienced with the new version of cabal. I'll stick with ghci
from alga.
from alga.
@adicirstei Hi there!
SymmetricRelation
is an instance of the type class Graph
but it cannot be made an instance of Functor
because it is internally represented by Data.Set
which requires the Ord a
constraint.
We can define a function gmap :: Ord b => (a -> b) -> SymmetricRelation a -> SymmetricRelation b
but it's not polymorphic enough to be used as Functor
's fmap
.
In fact, we have Relation.gmap
:
https://github.com/snowleopard/alga/blob/master/src/Algebra/Graph/Relation.hs#L497-L510
So, we can easily add SymmetricRelation.gmap
by wrapping and unwrapping the newtype. Will that work for you?
from alga.
An alternative would be to add Algebra.Graph.Undirected
that would be a simple wrapper around Graph
data type defined in Algebra.Graph
, which is a proper Functor
.
Then we would be able to define the instance Functor UndirectedGraph
.
from alga.
What would involve doing UndirectedGraph
?
from alga.
@adicirstei The simplest way forward is to define a newtype
:
newtype UndirectedGraph a = UndirectedGraph { graph :: Graph a } deriving (Functor, ... )
Then add a custom Eq
instance, and modify a couple of graph algorithms to correctly deal with undirected edges. Most of the API of this module would simply redirect to the inner graph
.
from alga.
from alga.
@adicirstei Would you like to give this a try? I think it would be nice to add Algebra.Graph.Undirected
to the library.
from alga.
If anyone would like to attempt this, we now have Symmetric.Relation
whose API can be followed:
https://hackage.haskell.org/package/algebraic-graphs-0.4/docs/Algebra-Graph-Relation-Symmetric.html
from alga.
@adicirstei are you working on this issue? If not, I'd be glad to give this a try!
EDIT: @snowleopard would this replace this SymmetricRelation? Or would it be just an adapted API to work with the Graph data type?
Also, could you walk me trough how do you use ghci/cabal new-repl? I'm having trouble with some hidden package errors
from alga.
@bolt12 No, this is independent from your symmetric relations work.
The implementation will be quite similar though: just add a newtype Algebra.Graph.Undirected.Graph
wrapping the algebraic data type Graph
and providing an API based on the one you implemented for symmetric relations.
from alga.
Also, could you walk me trough how do you use ghci/cabal new-repl?
For me both ghci
and stack ghci
seem to work.
P.S.: I assigned this issue to you. Thanks for volunteering! :)
from alga.
@snowleopard sorry to bloat this thread with this issue but can you figure out how to solve this?
I reforked the repo and ran ghci on the project root:
from alga.
@bolt12 Not sure how to fix this at the moment. Let's fork this into a new issue.
from alga.
@snowleopard one question: should I use the Symmetric file as base or the Graph one? What would be preferable? Also the Graph one has rewrite rules and other stuff that I don't quite understand, but since it's a newtype I dont think I need to worry about them.
EDIT: I'll base on one file for documentation inspiration and guidance mainly but I'll still follow the SymmetricRelation API! Probably there will be things that would be worth adding from the Graph that aren't in Symmetric like (===), induceJust (?)
from alga.
@bolt12 Yes, in general please follow the API of Symmetric.Relation
.
Don't worry about the rewrite rules for now.
from alga.
I think we can close this now, since the latest version has:
http://hackage.haskell.org/package/algebraic-graphs-0.5/docs/Algebra-Graph-Undirected.html
Thanks @bolt12!
from alga.
Related Issues (20)
- Hackage Release HOT 5
- How to handle goodness inherited from other libraries HOT 2
- Bump upper bound for base-compat for version 0.4 on Hackage HOT 4
- Unable to use ghcid HOT 6
- Algorithms should be in terms of typeclasses not data structures HOT 15
- Acyclic graphs with Int labels HOT 5
- Tests failed to build with QuickCheck 2.14.2
- Multitree HOT 3
- Monoid instance HOT 6
- support for GraphViz "HTML strings" for node or edge labels HOT 1
- Add benchmarks to CI HOT 2
- Supporting different node and edge types HOT 7
- v0.6 fails to build with GHC 8.0 and 8.2 HOT 3
- Doubt about decorating a Graph HOT 4
- Compatibility with mtl-2.3 HOT 2
- Smart constructor for Symbol rather than requiring -XOverloadedLists HOT 1
- Proposal : foldgM HOT 2
- Algebra.Graph.Labelled.AdjacencyMap.edges appears to be broken HOT 2
- Semigroup version of Algebra.Graph.Labelled.AdjacencyMap HOT 7
- Bump "deepseq" dependency bounds to 1.5.0.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alga.