No subject


Sun Oct 23 10:51:38 CEST 2011


can arbitrarily pick an instance of the Graph class, but what can I put for the
type parameter that it expects? It should be of the same type as the input array
elements. This doesn't compile:

----- 8< -----
import Data.Graph.Inductive.Graph ( labNodes, mkGraph )
import qualified Data.Graph.Inductive.Tree as T ( Gr )

doSomething ∷ [a] -> [a]
doSomething xs = map snd $ labNodes g
  where xs' = zip [1..] xs
        g = mkGraph xs' [] :: T.Gr a Int
----- 8< -----

amy3.hs:7:21:
    Couldn't match type `a' with `a2'
      `a' is a rigid type variable bound by
          the type signature for doSomething :: [a] -> [a] at amy3.hs:5:1
      `a2' is a rigid type variable bound by
           an expression type signature: T.Gr a2 Int at amy3.hs:7:13
    Expected type: [Data.Graph.Inductive.Graph.LNode a1]
      Actual type: [(Int, a)]
    In the first argument of `mkGraph', namely `xs''
    In the expression: mkGraph xs' [] :: T.Gr a Int
Failed, modules loaded: none.

Thank you in advance for any advice.




More information about the Beginners mailing list