Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-igraph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-igraph
Commits
0c650a74
Commit
0c650a74
authored
Apr 30, 2018
by
Kai Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
type check during serialization
parent
6ce9fdfd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
3 deletions
+12
-3
haskell-igraph.cabal
haskell-igraph.cabal
+1
-1
IGraph.hs
src/IGraph.hs
+5
-1
Types.hs
src/IGraph/Types.hs
+6
-1
No files found.
haskell-igraph.cabal
View file @
0c650a74
name: haskell-igraph
name: haskell-igraph
version: 0.
5
.0
version: 0.
6
.0
synopsis: Haskell interface of the igraph library.
synopsis: Haskell interface of the igraph library.
description: igraph<"http://igraph.org/c/"> is a library for creating
description: igraph<"http://igraph.org/c/"> is a library for creating
and manipulating large graphs. This package provides the Haskell
and manipulating large graphs. This package provides the Haskell
...
...
src/IGraph.hs
View file @
0c650a74
...
@@ -42,7 +42,7 @@ module IGraph
...
@@ -42,7 +42,7 @@ module IGraph
import
Conduit
import
Conduit
import
Control.Arrow
((
&&&
))
import
Control.Arrow
((
&&&
))
import
Control.Monad
(
forM
,
forM_
,
liftM
,
replicateM
)
import
Control.Monad
(
forM
,
forM_
,
liftM
,
replicateM
,
when
)
import
Control.Monad.Primitive
import
Control.Monad.Primitive
import
Control.Monad.ST
(
runST
)
import
Control.Monad.ST
(
runST
)
import
Data.Conduit.Cereal
import
Data.Conduit.Cereal
...
@@ -71,6 +71,7 @@ data Graph (d :: EdgeType) v e = Graph
...
@@ -71,6 +71,7 @@ data Graph (d :: EdgeType) v e = Graph
instance
(
SingI
d
,
Serialize
v
,
Serialize
e
,
Hashable
v
,
Eq
v
)
instance
(
SingI
d
,
Serialize
v
,
Serialize
e
,
Hashable
v
,
Eq
v
)
=>
Serialize
(
Graph
d
v
e
)
where
=>
Serialize
(
Graph
d
v
e
)
where
put
gr
=
do
put
gr
=
do
put
$
fromSing
(
sing
::
Sing
d
)
put
$
nNodes
gr
put
$
nNodes
gr
go
(
nodeLab
gr
)
(
nNodes
gr
)
0
go
(
nodeLab
gr
)
(
nNodes
gr
)
0
put
$
nEdges
gr
put
$
nEdges
gr
...
@@ -79,6 +80,9 @@ instance (SingI d, Serialize v, Serialize e, Hashable v, Eq v)
...
@@ -79,6 +80,9 @@ instance (SingI d, Serialize v, Serialize e, Hashable v, Eq v)
go
f
n
i
|
i
>=
n
=
return
()
go
f
n
i
|
i
>=
n
=
return
()
|
otherwise
=
put
(
f
i
)
>>
go
f
n
(
i
+
1
)
|
otherwise
=
put
(
f
i
)
>>
go
f
n
(
i
+
1
)
get
=
do
get
=
do
directed
<-
get
when
(
fromSing
(
sing
::
Sing
d
)
/=
directed
)
$
error
"Incorrect graph type"
nn
<-
get
nn
<-
get
nds
<-
replicateM
nn
get
nds
<-
replicateM
nn
get
ne
<-
get
ne
<-
get
...
...
src/IGraph/Types.hs
View file @
0c650a74
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleInstances #-}
...
@@ -15,15 +16,19 @@
...
@@ -15,15 +16,19 @@
module
IGraph.Types
where
module
IGraph.Types
where
import
Data.Serialize
(
Serialize
)
import
Data.Singletons.Prelude
import
Data.Singletons.Prelude
import
Data.Singletons.TH
import
Data.Singletons.TH
import
GHC.Generics
(
Generic
)
$
(
singletons
[
d
|
$
(
singletons
[
d
|
data EdgeType = D
data EdgeType = D
| U
| U
deriving (Show, Read, Eq)
deriving (Show, Read, Eq
, Generic
)
|]
)
|]
)
instance
Serialize
EdgeType
type
Node
=
Int
type
Node
=
Int
type
LNode
a
=
(
Node
,
a
)
type
LNode
a
=
(
Node
,
a
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment