[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] New type of expressions containing (error ...) includes noisy implicit parameter
From:       Nicola Gigante <nicola.gigante () gmail ! com>
Date:       2016-02-13 11:58:04
Message-ID: 52695333-71CE-43AC-A6E6-56275864D9AB () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> Il giorno 13 feb 2016, alle ore 10:15, Christopher Allen <cma@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/ \
> <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.

Prelude> :t 1 + 1
1 + 1 :: Num a => a

I suppose that explaining "Num a =>" by saying "it says that the type must be a \
number" is easier because of assonance with the word, but is that really a \
difference?

Note that this situation is much different from the issue about the type of ($):
- Teaching ‘undefined' to beginners is not essential. It's use is waaay less common \
that ($),  and it should be especially for beginners. Partial functions should be \
discouraged  from the start, and maybe a slightly more difficult type can be the \
right way to make people  learn to not use it. It's use comes handy when explaining \
laziness, maybe. But you  could obtain the same effect with a never-ending function, \
which is also theoretically  more affine to the meaning of "bottom".
- The constraint explicitly mentions "CallStack" twice. Exactly like "Num", I think \
it's easy to handwave:  "The 'blahblah =>' part says that the function needs to know \
the ‘call stack', which is what  you see printed when ‘undefined' gets evaluated \
and the program exists". 

So while I agree with you that this type is more difficult to explain, I think it's \
much less of a problem than the new type of ($).

If you don't agree with any of these points please let me know.

Regards,
Nicola


[Attachment #5 (unknown)]

<html><head><meta http-equiv="Content-Type" content="text/html \
charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote \
type="cite" class=""><div class="">Il giorno 13 feb 2016, alle ore 10:15, Christopher \
Allen &lt;<a href="mailto:cma@bitemyapp.com" class="">cma@bitemyapp.com</a>&gt; ha \
scritto:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" \
style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: \
normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: \
start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; \
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="">&gt;<span \
style="font-size: 12.8px;" class="">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.</span></div><div class=""><span style="font-size: 12.8px;" class=""><br \
class=""></span></div><div class=""><span style="font-size: 12.8px;" class="">It is \
unfortunate that the design forces this implementation detail on users trying to \
apply a plain old function.</span></div><div class=""><span style="font-size: \
12.8px;" class=""><br class=""></span></div><div class=""><br class=""></div><div \
class="">I updated my GHC 8.0.1 candidate, got this:</div><div class=""><br \
class=""></div><div class=""><div class="">$ ghci</div><div class="">GHCi, version \
8.0.0.20160204:<span class="Apple-converted-space">&nbsp;</span><a \
href="http://www.haskell.org/ghc/" class="">http://www.haskell.org/ghc/</a><span \
class="Apple-converted-space">&nbsp;</span>&nbsp;:? for help</div><div \
class="">Loaded GHCi configuration from /home/callen/.ghci</div><div \
class="">Prelude&gt; let myList = [1..5 :: Integer]</div><div class="">Prelude&gt; \
let myList' = myList ++ undefined</div><div class="">Prelude&gt; :t myList'</div><div \
class="">myList' :: (?callStack::GHC.Stack.Types.CallStack) =&gt; \
[Integer]</div></div><div class=""><br class=""></div><div class="">&gt;<span \
style="font-size: 12.8px;" class="">&nbsp;changed to use constraint kinds and type \
alias the implicit parameter behind a nicer API.<br class=""></span><br \
class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">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.</div></div></div></blockquote><br class=""></div><div><br \
class=""></div><div>Hi Christopher, I'm following your painful experience preparing \
the book for GHC 8.0,</div><div>and I sympathize with you.</div><div><br \
class=""></div><div>Just a question: how do you manage the type of \
simple</div><div>arithmetic expressions like 1 + 1? I mean, the type contains a \
constraint there.</div><div><br class=""></div><div>Prelude&gt; :t 1 + 1</div><div>1 \
+ 1 :: Num a =&gt; a</div><div><br class=""></div><div>I suppose that explaining "Num \
a =&gt;" by saying "it says that the type must be a number"</div><div>is easier \
because of assonance with the word, but is that really a difference?</div><div><br \
class=""></div><div>Note that this situation is much different from the issue about \
the type of ($):</div><div><div>- Teaching ‘undefined' to beginners is not \
essential. It's use is waaay less common that ($),</div><div>&nbsp; and it should be \
especially for beginners. Partial functions should be discouraged</div><div>&nbsp; \
from the start, and maybe a slightly more difficult type can be the right way to make \
people</div><div>&nbsp; learn to not use it. It's use comes handy when explaining \
laziness, maybe. But you</div><div>&nbsp; could obtain the same effect with a \
never-ending function, which is also theoretically</div><div>&nbsp; more affine to \
the meaning of "bottom".</div></div><div>- The constraint explicitly mentions \
"CallStack" twice. Exactly like "Num", I think it's easy to \
handwave:</div><div>&nbsp; "The 'blahblah =&gt;' part says that the function needs to \
know the ‘call stack', which is what</div><div>&nbsp; you see printed when \
‘undefined' gets evaluated and the program exists".&nbsp;</div><div><br \
class=""></div><div>So while I agree with you that this type is more difficult to \
explain, I think it's much less</div><div>of a problem than the new type of \
($).</div><div><br class=""></div><div>If you don't agree with any of these points \
please let me know.</div><div><br \
class=""></div><div>Regards,</div><div>Nicola</div><div><br class=""></div><br \
class=""><div class=""><br class=""></div><div class=""><br class=""></div><div \
class=""><br class=""></div></body></html>



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic