[Timber] Bindings

Per Lindgren Per.Lindgren at LTU.SE
Mon May 3 01:52:57 EDT 2010


Hi

On May 3, 2010, at 2:54 AM, Andrey Kruglyak wrote:

> Oh, when two name bindings follow one another, this is probably seen as an extreme form of pattern matching, just as when we define a function on more than one line. 

Yes, I think this could be seen as an extreme for overlapping patterns. At least Haskell makes an attempt warning the programmer of such patterns, I do not know if it is left out in timberc deliberately or if it is to be considered a bug. Johan once mentioned this as a hard problem to solve in general, but at least some obvious overlapping patterns should be brought to the programmers attention.

/Per
 




> 
> On the other hand, maybe the compiler should detect that there are no arguments and consider this an error? And what is the correct behavior for:
> 
> A x = z
> B x = z
> 
> (assuming z is a value of the data type D = A Int | B Int)? Should the first line cause an exception if z is B 4, or should  the second line succeed?
> 
> Andrey
> Sent from my iPhone
> 
> On May 3, 2010, at 1:44, Andrey Kruglyak <kruglyak at mac.com> wrote:
> 
>> Hi!
>> 
>> This must be a bug (and one that should be fixed ASAP), not only because it's not how we define bindings (a name can only be bound once), but also because if we separate the two definitions of "temp" we do get a compile error "duplicate variable":
>> 
>> import POSIX
>> 
>> root :: RootType
>> root w = do
>> temp = "12"
>> env = new posix w 
>> temp = "abc"
>> env.stdout.write (show temp)
>> 
>> I hope that Johan can fix it soon.
>> 
>> Regards,
>> Andrey
>> 
>> On May 2, 2010, at 23:41, Per Lindgren wrote:
>> 
>>> Hi
>>> 
>>> Consider:
>>> -------------
>>> module Err1 where
>>> 
>>> import POSIX
>>> 
>>> root :: RootType
>>> root w = do
>>>      env = new posix w 
>>>      temp = "12"
>>>      temp = "abc"
>>>      env.stdout.write (show temp)
>>> 
>>> What is the defined behavior?
>>> 
>>> (The result using timberc is no compiler error and the output "12" when executed. If that is what's intended, then we might be in for some confused programmers. )
>>> 
>>> /Per
>>> 
>>> 
>>> _______________________________________________
>>> Timber mailing list
>>> Timber at haskell.org
>>> http://www.haskell.org/mailman/listinfo/timber
>> 
>> ------------------------------------------------------------------------
>> Andrey Kruglyak
>> PhD student
>> 
>> http://www.andreykruglyak.com
>> 
>> Dept. of Computer Science and Electrical Engineering
>> Lulea University of Technology, Lulea, Sweden
>> T +46 920 49 23 57 (office)
>> T +46 706 16 76 03 (mobile)
>> Office A2314 (A-huset)
>> 
>> _______________________________________________
>> Timber mailing list
>> Timber at haskell.org
>> http://www.haskell.org/mailman/listinfo/timber
> _______________________________________________
> Timber mailing list
> Timber at haskell.org
> http://www.haskell.org/mailman/listinfo/timber



More information about the Timber mailing list