Giter Site home page Giter Site logo

Comments (18)

bolt12 avatar bolt12 commented on June 17, 2024 1

@snowleopard No problem! I'm happy to help!

That's odd, I'll try and refork the repo!

from alga.

bolt12 avatar bolt12 commented on June 17, 2024 1

@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.

bolt12 avatar bolt12 commented on June 17, 2024 1

from alga.

snowleopard avatar snowleopard commented on June 17, 2024

@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.

snowleopard avatar snowleopard commented on June 17, 2024

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.

adicirstei avatar adicirstei commented on June 17, 2024

What would involve doing UndirectedGraph ?

from alga.

snowleopard avatar snowleopard commented on June 17, 2024

@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.

adicirstei avatar adicirstei commented on June 17, 2024

from alga.

snowleopard avatar snowleopard commented on June 17, 2024

@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.

snowleopard avatar snowleopard commented on June 17, 2024

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.

bolt12 avatar bolt12 commented on June 17, 2024

@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.

snowleopard avatar snowleopard commented on June 17, 2024

@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.

snowleopard avatar snowleopard commented on June 17, 2024

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.

bolt12 avatar bolt12 commented on June 17, 2024

@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:
image

from alga.

snowleopard avatar snowleopard commented on June 17, 2024

@bolt12 Not sure how to fix this at the moment. Let's fork this into a new issue.

from alga.

bolt12 avatar bolt12 commented on June 17, 2024

@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.

snowleopard avatar snowleopard commented on June 17, 2024

@bolt12 Yes, in general please follow the API of Symmetric.Relation.

Don't worry about the rewrite rules for now.

from alga.

snowleopard avatar snowleopard commented on June 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.