<div dir="ltr"><div dir="auto">have another look at <div dir="auto"><a href="https://hackage.haskell.org/package/base-4.16.0.0/docs/GHC-Stack.html#v:callStack" target="_blank">https://hackage.haskell.org/packaggetCallStackgetCallStacke/base-4.16.0.0/docs/GHC-Stack.html#v:callStack</a></div><div dir="auto"><br></div><div>You need</div><div>```    <br></div><div>let l = getCallStack callStack<br>print (length l)</div><div>```</div></div><div>the `getCallStack` does not return an "IO" value..<br></div><div dir="auto"><div dir="auto"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 12, 2021, 12:58 Michael Turner <<a href="mailto:michael.eugene.turner@gmail.com" target="_blank">michael.eugene.turner@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The following prints 1, as you'd expect:<br>
-----------------<br>
import GHC.Stack<br>
<br>
foo :: HasCallStack => IO ()<br>
foo = do<br>
   print (length (getCallStack callStack))<br>
<br>
main =<br>
  foo<br>
-------------------<br>
But when I make it this:<br>
...<br>
   l <- getCallStack callStack ;<br>
   print (length l)<br>
<br>
 I get all this:<br>
------------------------------------------<br>
...<br>
    • Couldn't match type ‘[]’ with ‘IO’<br>
      Expected type: IO ([Char], SrcLoc)<br>
        Actual type: [([Char], SrcLoc)]<br>
    • In a stmt of a 'do' block: l <- getCallStack callStack<br>
      In the expression:<br>
        do l <- getCallStack callStack<br>
           print (length l)<br>
      In an equation for ‘foo’:<br>
          foo<br>
            = do l <- getCallStack callStack<br>
                 print (length l)<br>
  |<br>
5 |    l <- getCallStack callStack ;<br>
  |         ^^^^^^^^^^^^^^^^^^^^^^<br>
--------------------------------------------<br>
<br>
What am I not seeing?<br>
<br>
<br>
Regards,<br>
Michael Turner<br>
Executive Director<br>
Project Persephone<br>
1-25-33 Takadanobaba<br>
<br>
Shinjuku-ku Tokyo 169-0075<br>
Mobile: +81 (90) 5203-8682<br>
<a href="mailto:turner@projectpersephone.org" rel="noreferrer" target="_blank">turner@projectpersephone.org</a><br>
<br>
Understand - <a href="http://www.projectpersephone.org/" rel="noreferrer noreferrer" target="_blank">http://www.projectpersephone.org/</a><br>
Join - <a href="http://www.facebook.com/groups/ProjectPersephone/" rel="noreferrer noreferrer" target="_blank">http://www.facebook.com/groups/ProjectPersephone/</a><br>
Donate - <a href="http://www.patreon.com/ProjectPersephone" rel="noreferrer noreferrer" target="_blank">http://www.patreon.com/ProjectPersephone</a><br>
Volunteer - <a href="https://github.com/ProjectPersephone" rel="noreferrer noreferrer" target="_blank">https://github.com/ProjectPersephone</a><br>
<br>
"Love does not consist in gazing at each other, but in looking outward<br>
together in the same direction." -- Antoine de Saint-Exupéry<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" rel="noreferrer" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>