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

Rustom Mody rustompmody at gmail.com
Sat Feb 13 16:54:21 UTC 2016


On Sat, Feb 13, 2016 at 5:28 PM, Nicola Gigante <nicola.gigante at gmail.com>
wrote:

>
> Il giorno 13 feb 2016, alle ore 10:15, Christopher Allen <
> cma at bitemyapp.com> ha scritto:
>
> >subtle difference means that you do need to know about this due to how
> stacks work in GHC. If you use error and then don't also add that
> constraint yourself to your function, youll only see part of the stack.
>
> It is unfortunate that the design forces this implementation detail on
> users trying to apply a plain old function.
>
>
> I updated my GHC 8.0.1 candidate, got this:
>
> $ 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' :: (?callStack::GHC.Stack.Types.CallStack) => [Integer]
>
> > changed to use constraint kinds and type alias the implicit parameter
> behind a nicer API.
>
> Even if this has happened, we're still talking about the fourth chapter
> which is prior to types, typeclasses, constraints - everything. None of
> this means anything to a beginner being shown how to use undefined. The
> book is trying to make sure _anyone_ can learn Haskell, it's not an
> advanced DSLs book that introduces DataKinds.
>
> The implementation is leaking all the way to the fourth chapter of a book
> for complete beginners. Users will not be sympathetic when the
> implementation elides information because the user failed to speak to the
> nasal demons in the correct accent.
>
>
>
> Hi Christopher, I’m following your painful experience preparing the book
> for GHC 8.0,
> and I sympathize with you.
>
> Just a question: how do you manage the type of simple
> arithmetic expressions like 1 + 1? I mean, the type contains a constraint
> there.
>
>
Yeah That nails the problem well enough (for me)
I use the 25 year old gofer <http://blog.languager.org/2014/09/pugofer.html>
with its simple prelude precisely because Num, Eq, Show etc are too
expensive (for me) early in teaching FP
And the simple prelude is the typeclass-free prelude


> Teaching ‘undefined’ to beginners is not essential.
>

Not from where I see.
A very basic feature of my teaching is
- "Stories types tell" (also patterns tell)
- Combined with going between values and types

eg What is the type of 2? Int
Complementarily
Give something whose type is Int? 2

So what is something whose type is a?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160213/cf119f0c/attachment.html>


More information about the Haskell-Cafe mailing list