
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 : (bd_rows_WDS :: [Only (Maybe Text)]) <- query conn qry_head_WDS (Only (name::String)) -- remove the records having N°BD NULL let fltWDS :: [Only Text] = Prelude.filter (\(Only a) -> case a of Nothing -> False Just a -> True) bd_rows_WDS Prelude> :load UpdateSidonie [1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted ) UpdateSidonie.hs:282:33: error: • Couldn't match type ‘Maybe Text’ with ‘Text’ Expected type: [Only Text] Actual type: [Only (Maybe Text)] • In the expression: Prelude.filter (\ (Only a) -> case a of Nothing -> False Just a -> True) bd_rows_WDS In a pattern binding: fltWDS :: [Only Text] = Prelude.filter (\ (Only a) -> case a of Nothing -> False Just a -> True) bd_rows_WDS In the expression: do conn <- connect defaultConnectInfo {connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie"} (rows :: [(Text, Double)]) <- query_ conn "SELECT Nom,distance FROM AngularDistance WHERE distance > 0.000278" (names :: [Only Text]) <- query_ conn "SELECT Nom FROM AngularDistance WHERE distance > 0.000278" let resLstNames = Prelude.map fromOnly names .... | 282 | let fltWDS :: [Only Text] = Prelude.filter (\(Only a) -> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^... Failed, no modules loaded. how can id do the type conversion,now i'm sure there is no more Nothing values?

i repost because it seems that the first post of the year in haskell cafe
ailing list has been lost! i cant't see in the archive of january neither
december....
so here it is again:
On Tue, Jan 1, 2019 at 10:25 AM Damien Mattei
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 :
(bd_rows_WDS :: [Only (Maybe Text)]) <- query conn qry_head_WDS (Only (name::String))
-- remove the records having N°BD NULL let fltWDS :: [Only Text] = Prelude.filter (\(Only a) -> case a of Nothing -> False Just a -> True) bd_rows_WDS
Prelude> :load UpdateSidonie [1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted )
UpdateSidonie.hs:282:33: error: • Couldn't match type ‘Maybe Text’ with ‘Text’ Expected type: [Only Text] Actual type: [Only (Maybe Text)] • In the expression: Prelude.filter (\ (Only a) -> case a of Nothing -> False Just a -> True) bd_rows_WDS In a pattern binding: fltWDS :: [Only Text] = Prelude.filter (\ (Only a) -> case a of Nothing -> False Just a -> True) bd_rows_WDS In the expression: do conn <- connect defaultConnectInfo {connectHost = "moita", connectUser = "mattei", connectPassword = "sidonie2", connectDatabase = "sidonie"} (rows :: [(Text, Double)]) <- query_ conn "SELECT Nom,distance FROM AngularDistance WHERE distance > 0.000278" (names :: [Only Text]) <- query_ conn "SELECT Nom FROM AngularDistance WHERE distance > 0.000278" let resLstNames = Prelude.map fromOnly names .... | 282 | let fltWDS :: [Only Text] = Prelude.filter (\(Only a) -> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^... Failed, no modules loaded.
how can id do the type conversion,now i'm sure there is no more Nothing values?

That's because you still have "Just a" values. Try mapMaybe from Data.Maybe
instead.
On mobile; please excuse any tpyos.
On Thu, 3 Jan. 2019, 1:29 pm Damien Mattei i repost because it seems that the first post of the year in haskell cafe
ailing list has been lost! i cant't see in the archive of january neither
december....
so here it is again: On Tue, Jan 1, 2019 at 10:25 AM Damien Mattei 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 : (bd_rows_WDS :: [Only (Maybe Text)]) <- query conn qry_head_WDS (Only
(name::String)) -- remove the records having N°BD NULL
let fltWDS :: [Only Text] = Prelude.filter (\(Only a) ->
case a of
Nothing -> False
Just a -> True)
bd_rows_WDS Prelude> :load UpdateSidonie
[1 of 1] Compiling Main ( UpdateSidonie.hs, interpreted ) UpdateSidonie.hs:282:33: error:
• Couldn't match type ‘Maybe Text’ with ‘Text’
Expected type: [Only Text]
Actual type: [Only (Maybe Text)]
• In the expression:
Prelude.filter
(\ (Only a)
-> case a of
Nothing -> False
Just a -> True)
bd_rows_WDS
In a pattern binding:
fltWDS :: [Only Text]
= Prelude.filter
(\ (Only a)
-> case a of
Nothing -> False
Just a -> True)
bd_rows_WDS
In the expression:
do conn <- connect
defaultConnectInfo
{connectHost = "moita", connectUser = "mattei",
connectPassword = "sidonie2", connectDatabase =
"sidonie"}
(rows :: [(Text, Double)]) <- query_
conn
"SELECT Nom,distance FROM
AngularDistance WHERE distance > 0.000278"
(names :: [Only Text]) <- query_
conn
"SELECT Nom FROM AngularDistance
WHERE distance > 0.000278"
let resLstNames = Prelude.map fromOnly names
....
|
282 | let fltWDS :: [Only Text] = Prelude.filter (\(Only a) ->
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
Failed, no modules loaded. how can id do the type conversion,now i'm sure there is no more Nothing
values? _______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
participants (3)
-
Damien Mattei
-
Ivan Lazar Miljenovic
-
Jon Fairbairn