[Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Immanuel Normann
Hi,

I have a problem with the data constructor NodeMap
Data.Graph.Inductive.NodeMap
of the graph library fgl-5.4.2.3 (also fgl-5.4.2.2):

I cannot access the data constructor NodeMap, as the ghci session shows:

Prelude :m Data.Graph.Inductive.NodeMap
Prelude Data.Graph.Inductive.NodeMap :t NodeMap

interactive:1:0: Not in scope: data constructor `NodeMap'


However, when I load the source directly it works:

Prelude :l Data/Graph/Inductive/NodeMap.hs
[1 of 3] Compiling Data.Graph.Inductive.Graph (
Data/Graph/Inductive/Graph.hs, interpreted )
[2 of 3] Compiling Data.Graph.Inductive.Internal.FiniteMap (
Data/Graph/Inductive/Internal/FiniteMap.hs, interpreted )
[3 of 3] Compiling Data.Graph.Inductive.NodeMap (
Data/Graph/Inductive/NodeMap.hs, interpreted )
Ok, modules loaded: Data.Graph.Inductive.Internal.FiniteMap,
Data.Graph.Inductive.Graph, Data.Graph.Inductive.NodeMap.
*Data.Graph.Inductive.NodeMap :t NodeMap
NodeMap :: (Ord a) = FiniteMap a Node - Int - NodeMap a

Why is that so?

Afterall, my purpose is to get access to the map in a NodeMap and finally to
apply lookup to it. But I don't know how to access the map from a NodeMap
(the map selector isn't accessible either).

Immanuel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Ivan Lazar Miljenovic
Immanuel Normann immanuel.norm...@googlemail.com writes:

 Hi,

 I have a problem with the data constructor NodeMap
 Data.Graph.Inductive.NodeMap
 of the graph library fgl-5.4.2.3 (also fgl-5.4.2.2):

 I cannot access the data constructor NodeMap, as the ghci session shows:

 Prelude :m Data.Graph.Inductive.NodeMap
 Prelude Data.Graph.Inductive.NodeMap :t NodeMap

 interactive:1:0: Not in scope: data constructor `NodeMap'

Well, yes, because you're not meant to.

 However, when I load the source directly it works:

 Prelude :l Data/Graph/Inductive/NodeMap.hs
 [1 of 3] Compiling Data.Graph.Inductive.Graph (
 Data/Graph/Inductive/Graph.hs, interpreted )
 [2 of 3] Compiling Data.Graph.Inductive.Internal.FiniteMap (
 Data/Graph/Inductive/Internal/FiniteMap.hs, interpreted )
 [3 of 3] Compiling Data.Graph.Inductive.NodeMap (
 Data/Graph/Inductive/NodeMap.hs, interpreted )
 Ok, modules loaded: Data.Graph.Inductive.Internal.FiniteMap,
 Data.Graph.Inductive.Graph, Data.Graph.Inductive.NodeMap.
 *Data.Graph.Inductive.NodeMap :t NodeMap
 NodeMap :: (Ord a) = FiniteMap a Node - Int - NodeMap a

 Why is that so?

This works because you're using ghci from within the module, whereas
when you import it you're using only its exposed API.

 Afterall, my purpose is to get access to the map in a NodeMap and finally to
 apply lookup to it. But I don't know how to access the map from a NodeMap
 (the map selector isn't accessible either).

You're not meant to; the point of NodeMap is to serve as a wrapper
around the normal graph types, not for you to use directly (exactly the
same as why the constructor for Map isn't exported).

May I ask, however, why you want to use Data.Graph.Inductive.NodeMap?

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Ivan Lazar Miljenovic
CC-ing haskell-cafe again:

Immanuel Normann immanuel.norm...@googlemail.com writes:

 2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 Immanuel Normann immanuel.norm...@googlemail.com writes:
  Afterall, my purpose is to get access to the map in a NodeMap and finally
 to
  apply lookup to it. But I don't know how to access the map from a NodeMap
  (the map selector isn't accessible either).

 You're not meant to; the point of NodeMap is to serve as a wrapper
 around the normal graph types, not for you to use directly (exactly the
 same as why the constructor for Map isn't exported).

 May I ask, however, why you want to use Data.Graph.Inductive.NodeMap?


 Some of my lnodes in the graph have by construction unique labels and I want
 to lookup the lnode from a graph given only the label of that lnode.

Well, from my understanding NodeMap doesn't do what you want, since it
assumes that _all_ of the node labels are unique.  Furthemore, the way
of using it seems to be analogous of how one would use a State monad
rather than for actual interactive use throughout.

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Ivan Lazar Miljenovic
Once again cc-ing -cafe; Immanuel, can you please do reply to all
rather than just reply in GMail? :p

Immanuel Normann immanuel.norm...@googlemail.com writes:

 2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 CC-ing haskell-cafe again:

 Immanuel Normann immanuel.norm...@googlemail.com writes:

  2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

  Some of my lnodes in the graph have by construction unique labels and I
 want
  to lookup the lnode from a graph given only the label of that lnode.

 Well, from my understanding NodeMap doesn't do what you want, since it
 assumes that _all_ of the node labels are unique


 I wouldn't bother when NodeMap maps also non-unique labels to single nodes,
 because I only lookup nodes with unique labels, e.g. assume my label are of
 the form
 data Label = Unique String | Multi Label

I'm of the suspicion that using NodeMaps in this fashion will have
problem when considering nodes with the same label (even if you don't
explicitly use it for those nodes), as NodeMap seems to assume that node
labels are unique.

For example, mkNode assumes node labels are unique.

 Furthemore, the way of using it seems to be analogous of how one would use a
 State monad
 rather than for actual interactive use throughout.


 Could you elaborate this further, please.

http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun
and
http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun_

If you just want a mapping from labels to nodes, you may be better off
using your own custom Map (and maybe even defining a new graph type that
has such a Map as part of it).

The successor to FGL-5.x (whatever we'll end up calling it) will allow
you to have custom node types rather than using Ints.  However, this
will not work for you in this situation.

The node type is just an _index_ type, analogous to the actual hash
value in a hash{map,array} (as opposed to the value which has the
hashing function applied upon it).  It's there to provide a unique
identifier for a particular node.  Arguably, an abstract type would be
even better as an Int as it will prevent you from doing silly things
like adding node indices together, but that's beside the point.

If you wish to find a node with a specific label, try using something
like gsel: 
http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-Basic.html#v%3Agsel

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FGL problem: cannot acces data constructor NodeMap

2010-07-24 Thread Immanuel Normann
2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 Once again cc-ing -cafe; Immanuel, can you please do reply to all
 rather than just reply in GMail? :p


Oh, yes I forgot - sorry!

Thanks for all the valuable infos :-)

Immanuel


 Immanuel Normann immanuel.norm...@googlemail.com writes:

  2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
 
  CC-ing haskell-cafe again:
 
  Immanuel Normann immanuel.norm...@googlemail.com writes:
 
   2010/7/24 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com
 
   Some of my lnodes in the graph have by construction unique labels and
 I
  want
   to lookup the lnode from a graph given only the label of that lnode.
 
  Well, from my understanding NodeMap doesn't do what you want, since it
  assumes that _all_ of the node labels are unique
 
 
  I wouldn't bother when NodeMap maps also non-unique labels to single
 nodes,
  because I only lookup nodes with unique labels, e.g. assume my label are
 of
  the form
  data Label = Unique String | Multi Label

 I'm of the suspicion that using NodeMaps in this fashion will have
 problem when considering nodes with the same label (even if you don't
 explicitly use it for those nodes), as NodeMap seems to assume that node
 labels are unique.

 For example, mkNode assumes node labels are unique.

  Furthemore, the way of using it seems to be analogous of how one would
 use a
  State monad
  rather than for actual interactive use throughout.
 
 
  Could you elaborate this further, please.


 http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun
 and

 http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-NodeMap.html#v%3Arun_

 If you just want a mapping from labels to nodes, you may be better off
 using your own custom Map (and maybe even defining a new graph type that
 has such a Map as part of it).

 The successor to FGL-5.x (whatever we'll end up calling it) will allow
 you to have custom node types rather than using Ints.  However, this
 will not work for you in this situation.

 The node type is just an _index_ type, analogous to the actual hash
 value in a hash{map,array} (as opposed to the value which has the
 hashing function applied upon it).  It's there to provide a unique
 identifier for a particular node.  Arguably, an abstract type would be
 even better as an Int as it will prevent you from doing silly things
 like adding node indices together, but that's beside the point.

 If you wish to find a node with a specific label, try using something
 like gsel:
 http://hackage.haskell.org/packages/archive/fgl/5.4.2.3/doc/html/Data-Graph-Inductive-Basic.html#v%3Agsel

 --
 Ivan Lazar Miljenovic
 ivan.miljeno...@gmail.com
 IvanMiljenovic.wordpress.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe