[Haskell-beginners] Beginners Digest, Vol 161, Issue 1
Michael Turner
michael.eugene.turner at gmail.com
Sun Dec 12 15:31:34 UTC 2021
Regards,
Michael Turner
Executive Director
Project Persephone
1-25-33 Takadanobaba
Shinjuku-ku Tokyo 169-0075
Mobile: +81 (90) 5203-8682
turner at projectpersephone.org
Understand - http://www.projectpersephone.org/
Join - http://www.facebook.com/groups/ProjectPersephone/
Donate - http://www.patreon.com/ProjectPersephone
Volunteer - https://github.com/ProjectPersephone
"Love does not consist in gazing at each other, but in looking outward
together in the same direction." -- Antoine de Saint-Exupéry
On Sun, Dec 12, 2021 at 8:48 PM <beginners-request at haskell.org> wrote:
> have another look at
> https://hackage.haskell.org/packaggetCallStackgetCallStacke/base-4.16.0.0/docs/GHC-Stack.html#v:callStack
> <https://hackage.haskell.org/package/base-4.16.0.0/docs/GHC-Stack.html#v:callStack>
I'd been looking at that already, over and over. Still not seeing it.
But your proposed fix does work. Thank you.
> let l = getCallStack callStack
> print (length l)
> ```
> the `getCallStack` does not return an "IO" value..
And yet it's it's somehow an IO value in "print (length (getCallStack
callStack))"?
I just don't get this.
> On Sun, Dec 12, 2021, 12:58 Michael Turner <michael.eugene.turner at gmail.com>
> wrote:
>
> > The following prints 1, as you'd expect:
> > -----------------
> > import GHC.Stack
> >
> > foo :: HasCallStack => IO ()
> > foo = do
> > print (length (getCallStack callStack))
> >
> > main =
> > foo
> > -------------------
> > But when I make it this:
> > ...
> > l <- getCallStack callStack ;
> > print (length l)
> >
> > I get all this:
> > ------------------------------------------
> > ...
> > • Couldn't match type ‘[]’ with ‘IO’
> > Expected type: IO ([Char], SrcLoc)
> > Actual type: [([Char], SrcLoc)]
> > • In a stmt of a 'do' block: l <- getCallStack callStack
> > In the expression:
> > do l <- getCallStack callStack
> > print (length l)
> > In an equation for ‘foo’:
> > foo
> > = do l <- getCallStack callStack
> > print (length l)
> > |
> > 5 | l <- getCallStack callStack ;
> > | ^^^^^^^^^^^^^^^^^^^^^^
> > --------------------------------------------
> >
> > What am I not seeing?
> >
> >
> > Regards,
> > Michael Turner
> > Executive Director
> > Project Persephone
> > 1-25-33 Takadanobaba
> >
> > Shinjuku-ku Tokyo 169-0075
> > Mobile: +81 (90) 5203-8682
> > turner at projectpersephone.org
> >
> > Understand - http://www.projectpersephone.org/
> > Join - http://www.facebook.com/groups/ProjectPersephone/
> > Donate - http://www.patreon.com/ProjectPersephone
> > Volunteer - https://github.com/ProjectPersephone
> >
> > "Love does not consist in gazing at each other, but in looking outward
> > together in the same direction." -- Antoine de Saint-Exupéry
More information about the Beginners
mailing list