[Haskell-cafe] New type of expressions containing (error ...) includes noisy implicit parameter

Oliver Charles ollie at ocharles.org.uk
Sat Feb 13 17:37:11 UTC 2016


"What's a call stack?"

(I don't know what Chris' target audience is though)

On Sat, 13 Feb 2016 5:18 pm Eric Seidel <eric at seidel.io> wrote:

> Here's what the GHCi session should look like.
>
> > $ ghci
> > GHCi, version 8.0.0.20160204: http://www.haskell.org/ghc/  :? for help
> > Loaded GHCi configuration from /home/callen/.ghci
> > Prelude> let myList = [1..5 :: Integer]
> > Prelude> let myList' = myList ++ undefined
> > Prelude> :t myList'
> > myList' :: HasCallStack => [Integer]
>
> If your readers are using :t they must already know about simple types
> like Integer, [], and, ->, so the new things are HasCallStack and =>.
> This is how I would explain them.
>
>   => is just like -> except the compiler fills in the argument by
>   itself.
>   HasCallStack tells the compiler that the expression needs a call-stack
>   because it might crash. So HasCallStack => [Integer] is a [Integer]
>   that
>   might crash and produce a stack-trace.
>
> I think the call-stacks are much less scary and confusing than
> type-classes in general, which you kind of have to deal with as soon as
> you talk about arithmetic.
>
> Eric
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160213/aea3f263/attachment.html>


More information about the Haskell-Cafe mailing list