<div><div dir="auto">One way to figure out how to solve this problem is to search Hoogle for the type of function you’re looking for, in this case: [Maybe a] -> [a]</div></div><div dir="auto"><br></div><div dir="auto"><div><a href="https://www.haskell.org/hoogle/?hoogle=%5BMaybe+a%5D+-%3E+a">https://www.haskell.org/hoogle/?hoogle=%5BMaybe+a%5D+-%3E+a</a></div><br></div><div><div dir="auto">You’ll find that such a function exists in Data.Maybe and it is named catMaybes. No need to filter out Nothing separately, this function will do it. </div><div dir="auto"><br></div><div class="gmail_quote"><div dir="ltr">On Wed, Jan 2, 2019 at 20:08 Damien Mattei <<a href="mailto:damien.mattei@gmail.com">damien.mattei@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:large"><div class="m_1265457104528012614gmail-adn m_1265457104528012614gmail-ads"><div class="m_1265457104528012614gmail-gs"><div class="m_1265457104528012614gmail-"><div id="m_1265457104528012614gmail-:279" class="m_1265457104528012614gmail-ii m_1265457104528012614gmail-gt"><div id="m_1265457104528012614gmail-:278" class="m_1265457104528012614gmail-a3s m_1265457104528012614gmail-aXjCH"><div dir="ltr"><div class="gmail_default" style="font-size:large"><div class="gmail_default" style="font-size:large">i had filtered a  
[Maybe Text] type to remove Nothing from the list and now i want to put 
the result in a  [Text] type but the compiler complains about the 
incompatible type :</div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large"> (bd_rows_WDS :: [Only (Maybe Text)]) <- query conn qry_head_WDS (Only (name::String))</div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">-- remove the records having N°BD NULL<br>    let fltWDS :: [Only Text] = Prelude.filter (\(Only a) -><br>                                    case a of<br>                                      Nothing -> False<br>                                      Just a -> True)<br>                 bd_rows_WDS</div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">Prelude> :load UpdateSidonie<br>[1 of 1] Compiling Main             ( UpdateSidonie.hs, interpreted )<br><br>UpdateSidonie.hs:282:33: error:<br>    • Couldn't match type ‘Maybe Text’ with ‘Text’<br>      Expected type: [Only Text]<br>        Actual type: [Only (Maybe Text)]<br>    • In the expression:<br>        Prelude.filter<br>          (\ (Only a)<br>             -> case a of<br>                  Nothing -> False<br>                  Just a -> True)<br>          bd_rows_WDS<br>      In a pattern binding:<br>        fltWDS :: [Only Text]<br>          = Prelude.filter<br>              (\ (Only a)<br>                 -> case a of<br>                      Nothing -> False<br>                      Just a -> True)<br>              bd_rows_WDS<br>      In the expression:<br>        do conn <- connect<br>                     defaultConnectInfo<br>                       {connectHost = "moita", connectUser = "mattei",<br>                        connectPassword = "sidonie2", connectDatabase = "sidonie"}<br>           (rows :: [(Text, Double)]) <- query_<br>                                           conn<br>                                           "SELECT Nom,distance FROM AngularDistance WHERE distance > 0.000278"<br>           (names :: [Only Text]) <- query_<br>                                       conn<br>                                       "SELECT Nom FROM AngularDistance WHERE distance > 0.000278"<br>           let resLstNames = Prelude.map fromOnly names<br>           ....<br>    |<br>282 |     let fltWDS :: [Only Text] = Prelude.filter (\(Only a) -><br>    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^...<br>Failed, no modules loaded.<br></div><div class="gmail_default" style="font-size:large"><br></div><div class="gmail_default" style="font-size:large">how can id do the type conversion,now i'm sure there is no more Nothing values?</div></div></div><div class="m_1265457104528012614gmail-adL">
</div></div></div></div></div></div><div class="m_1265457104528012614gmail-gA m_1265457104528012614gmail-gt m_1265457104528012614gmail-acV"><div class="m_1265457104528012614gmail-gB m_1265457104528012614gmail-xu"><div class="m_1265457104528012614gmail-ip m_1265457104528012614gmail-iq"><div id="m_1265457104528012614gmail-:27a"><table class="m_1265457104528012614gmail-cf m_1265457104528012614gmail-wS"><tbody><tr><td class="m_1265457104528012614gmail-amq"><img id="m_1265457104528012614gmail-:0_24" name="m_1265457104528012614_:0" src="https://plus.google.com/u/0/_/focus/photos/public/AIbEiAIAAABDCK3Mitic7rCiUiILdmNhcmRfcGhvdG8qKGE4MzM3OWQ1ZjJmZGY4MmJjYzIwZmY2YmYyMGQwZDk0NzQ2NTg3MWEwAZ9Fxw-tKAwFrDjeyCEpCYTOo4FL?sz=32" class="m_1265457104528012614gmail-ajn m_1265457104528012614gmail-bofPge"></td><td class="m_1265457104528012614gmail-amr"><br></td></tr></tbody></table></div></div></div></div></div></div>
_______________________________________________<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></div>