On Tuesday 28 November 2006 20:50, Alexis Hazell wrote: > let contact = mkelem "stream:stream" [ sattr "xmlns:stream" > "http://etherx.jabber.org/streams", sattr "xmlns" "jabber:client", sattr > "to" "livejournal.com" ] [] :: ArrowXml a => a XmlTree XmlTree > > And got: > > <interactive>:1:14: > Ambiguous type variable `a' in the constraint: > `ArrowXml a' > arising from instantiating a type signature at <interactive>:1:14-194 > Probable fix: add a type signature that fixes these type variable(s) > > i don't understand why i need to specify type signatures when they should > already be in scope?
Is this a result of the monomorphism restriction? > And if i /do/ need to specify the type signatures for > some reason, how do i do so in a manner that works? You need to add a type signature that specifies a specific arrow data type 'a' that is an instance of ArrowXml. There are many instances of ArrowXml provided in HXT, eg LA, IOSArrow, IOSLArrow, etc so try something like: let contact = mkelem "stream:stream" [ sattr "xmlns:stream" "http://etherx.jabber.org/streams", sattr "xmlns" "jabber:client", sattr "to" "livejournal.com" ] [] :: IOSArrow XmlTree XmlTree By the way, once you have the declaration of contact in a source file, and it is being used by a function in which the ArrowXml instance is not ambiguous eg: foo = runX contact the type checker will be able to infer the type and you don't have to include the type signature. Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe