<div dir="ltr"><div dir="ltr"><br></div>On Thu, 10 Jan 2019 at 19:34, Damien Mattei <<a href="mailto:mattei@oca.eu">mattei@oca.eu</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
i have this definition:<br>
<br>
{-# LANGUAGE FlexibleInstances #-}<br>
<br>
class ConcatenateMaybeString a where<br>
cms :: Maybe String -> a -> Maybe String<br>
<br>
<br>
instance ConcatenateMaybeString (Maybe String) where<br>
cms mf ms =<br>
mf >>= (\f -><br>
ms >>= (\s -><br>
return (f ++ s)))<br>
<br>
<br>
<br>
instance ConcatenateMaybeString String where<br>
cms mf s =<br>
mf >>= (\f -> return (f ++ s))<br>
<br>
when i use it on :<br>
f `cms` ("." ::String) `cms` s<br>
it works<br>
<br>
but not on this:<br>
f `cms` "." `cms` s<br>
<br>
"." is too ambigious to compile:<br>
<br>
*Main> :load UpdateSidonie<br>
[1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted )<br>
<br>
UpdateSidonie.hs:373:43: error:<br>
• Ambiguous type variable ‘a0’ arising from a use of ‘cms’<br>
prevents the constraint ‘(ConcatenateMaybeString<br>
a0)’ from being solved.<br>
Probable fix: use a type annotation to specify what ‘a0’ should be.<br>
These potential instances exist:<br>
instance ConcatenateMaybeString (Maybe String)<br>
-- Defined at UpdateSidonie.hs:169:11<br>
instance ConcatenateMaybeString String<br>
-- Defined at UpdateSidonie.hs:177:11<br>
• In the first argument of ‘cms’, namely ‘f `cms` "."’<br>
In the expression: f `cms` "." `cms` s<br>
In the expression:<br>
let<br>
f = fmap head resBDwords<br>
s = fmap (head . tail) resBDwords<br>
mp = Just "." :: Maybe String<br>
....<br>
in f `cms` "." `cms` s<br>
|<br>
373 | in f `cms` "." `cms` s) ::<br>
Maybe String<br>
| ^^^^^^^^^^^<br>
<br>
UpdateSidonie.hs:373:51: error:<br>
• Ambiguous type variable ‘a0’ arising from the literal ‘"."’<br>
prevents the constraint ‘(Data.String.IsString<br>
a0)’ from being solved.<br>
Probable fix: use a type annotation to specify what ‘a0’ should be.<br>
These potential instances exist:<br>
instance Data.String.IsString Query<br>
-- Defined in ‘Database.MySQL.Simple.Types’<br>
instance Data.String.IsString Tx.Text -- Defined in ‘Data.Text’<br>
instance (a ~ Char) => Data.String.IsString [a]<br>
-- Defined in ‘Data.String’<br>
...plus six instances involving out-of-scope types<br>
(use -fprint-potential-instances to see them all)<br>
• In the second argument of ‘cms’, namely ‘"."’<br>
In the first argument of ‘cms’, namely ‘f `cms` "."’<br>
In the expression: f `cms` "." `cms` s<br>
|<br>
373 | in f `cms` "." `cms` s) ::<br>
Maybe String<br>
| ^^^<br>
Failed, no modules loaded.<br>
Prelude><br>
<br>
<br>
any idea?<br></blockquote><div><br></div><div>Do you have the OverloadedStrings or OverloadedLists LANGUAGE pragmas enabled?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Damien<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Ivan Lazar Miljenovic<br><a href="mailto:Ivan.Miljenovic@gmail.com" target="_blank">Ivan.Miljenovic@gmail.com</a><br><a href="http://IvanMiljenovic.wordpress.com" target="_blank">http://IvanMiljenovic.wordpress.com</a></div></div>