Reputation: 59
Having trouble untangling maybe and nullable values in the following:
container <-
unsafePartial
(fromJust <<< toMaybe
<$> DOM.querySelector (DOM.QuerySelector "body")
(DOM.htmlDocumentToParentNode document))
Which gives me the following error:
Could not match type
Maybe
with type
Nullable
while trying to match type Maybe Element
with type Nullable t1
while checking that expression (querySelector (QuerySelector "body"))
(htmlDocumentToParentNode document)
has type t0 (Nullable t1)
in value declaration mainwhere t0 is an unknown type
t1 is an unknown type
I've tried but I can't find my way through the various types being used here (code is originally from here)
Upvotes: 2
Views: 158
Reputation: 4169
I would recommend breaking this up a bit.
Start with
do body <- DOM.querySelector (DOM.QuerySelector "body")
(DOM.htmlDocumentToParentNode document))
?whatNext
Here, ?whatNext
is a typed hole. The compiler will tell you the inferred type of the hole, which should help you to figure out what to replace it with.
Also note that you can simplify things a little by applying unsafePartial
to fromJust
directly, to give a function of type Maybe a -> a
.
Upvotes: 1