<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 2019-01-03 12:43 AM, Ganesh Sittampalam wrote:<br>
<blockquote type="cite"
cite="mid:32cc4d05-c9ff-da92-e395-f453db0b7ee6@earth.li">If you
did have [Maybe Text] you could use the library function<br>
<br>
catMaybes :: [Maybe a] -> [a]<br>
<br>
to both do the filtering and change the types.<br>
<br>
...<br>
<br>
But in your case you actually have [Only (Maybe Text)] rather than
[Maybe Text] so catMaybes won't work. One option is to use a list
comprehension instead:<br>
<br>
let fltWDS = [Only a | Only (Just a) <- bd_rows_WDS]<br>
</blockquote>
<br>
It probably would be helpful to remove the Only wrapper at this
stage, so this might be even better:<br>
<br>
let fltWDS = [a | Only (Just a) <- bd_rows_WDS]<br>
<br>
The way to do it with catMaybes would be to map with fromOnly first:<br>
<br>
let fltWDS = catMaybes (map fromOnly bd_rows_WDS)<br>
<br>
As Ganesh shows, there's no need for a type annotation after you've
done the query, because the compiler can infer the type [Text] from
the types of the functions that are used. The annotations are
necessary with query only because it's polymorphic and can work with
a wide variety of types.<br>
</body>
</html>