Is it possible from Main.hs to reference my Graph.hs -functions, edgs and vers in data Graphs a?
I want to create a Graph from my Graphs.hs file, fill it with vertices, and connect them with edges. Then from my Main.hs file I want to create a function getEdges that can list all edges for me. Is this possible or am I thinking too much in an OOP-manner? :-(
Below I've added parts of my code to try and illustrate my problems.
**File Graph.hs:**
module Graph(Graph, addVertex, addEdge, connectedVertex) where
type Vertex a = a
type Edge a = (Vertex a, Vertex a)
data Graph a = Graph {
vers :: [Vertex a],
edgs :: [Edge a]
} deriving (Show, Eq, Read)
**File Main.hs:**
-- func1 to func3 is just to illustrate that there is more than one function in main.
module Main(func1, func2, getEdges, paths) where
import Graph
-- getEdges shall return a list of all edges
getEdges :: Eq a => Grap a -> [a]
getEdges g = edgs $ g
-- paths will return true if there is a connection (edges) between vertecies a to b.
paths :: Eq a => Graph a -> a -> a-> Bool
paths = undefined
I would greatly appreciate any help :-)