Ambigous Types with Haskell Functional Graph Library

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Ambigous Types with Haskell Functional Graph Library

Joe Schafer
Hey all,

New to Haskell and I'm trying to use the FGL but I keep running into the
same error.

If I load Data.Graph.Inductive.Example and use one of the example
functions such as ucycle I get:

    Ambiguous type variable `gr' in the constraint:
      `Graph gr' arising from a use of `ucycle' at <interactive>:1:0-7
    Probable fix: add a type signature that fixes these type variable(s)

Here's the type of ucycle for reference.

ucycle :: Graph gr => Int -> gr () ()

I'm using GHC 6.10.1 and FGL 5.4.2.2

Thanks,
Joe

Reply | Threaded
Open this post in threaded view
|

Re: Ambigous Types with Haskell Functional Graph Library

Christian Maeder-2
The type constructor variable "gr" can be instantiated with
"Data.Graph.Inductive.Tree.Gr" via a type signature:

Prelude Data.Graph.Inductive.Example> ucycle 5 ::
 Data.Graph.Inductive.Tree.Gr () ()

1:()->[((),2)]
2:()->[((),3)]
3:()->[((),4)]
4:()->[((),5)]
5:()->[((),1)]

HTH Christian

Joe Schafer wrote:

> Hey all,
>
> New to Haskell and I'm trying to use the FGL but I keep running into the
> same error.
>
> If I load Data.Graph.Inductive.Example and use one of the example
> functions such as ucycle I get:
>
>     Ambiguous type variable `gr' in the constraint:
>       `Graph gr' arising from a use of `ucycle' at <interactive>:1:0-7
>     Probable fix: add a type signature that fixes these type variable(s)
>
> Here's the type of ucycle for reference.
>
> ucycle :: Graph gr => Int -> gr () ()
>
> I'm using GHC 6.10.1 and FGL 5.4.2.2
>
> Thanks,
> Joe