[Haskell-beginners] to modify the eagerness level of haskell compiler..

Heinrich Apfelmus apfelmus at quantentunnel.de
Wed Aug 31 09:29:39 CEST 2011


Sunil S Nandihalli wrote:
> the code for the same can be found at https://github.com/sunilnandihalli/is2 it
> is a single main.hs file so compilation is simply
> * ghc main.hs --make*
> thanks,
> Sunil.
> 
> Sunil S Nandihalli wrote:
> 
>> Hi everybody,
>>  May be I am doing it wrong being a beginner.. but here is what I want.. I
>> am trying to debug a stack overflow problem by printing a lot using "trace"
>> commands. But it does not seem to seem to be printing in the expected order.
>> so it has been misleading quiet a bit. Can somebody guide me as to how to
>> modify the laziness of the program or some pointers on how to debug the
>> stack overflow errors.

Woah, your code is way too complicated. I doubt that debugging support 
will help you much.

My recommendation is to use abstract data types and to keep your 
functions much shorter. For instance, what is the type

   Integral a, Integral b => M.Map (Ratio a,Ratio a) b

supposed to mean? Give it a descriptive name

   type Length = Ratio Integer  -- coordinate
   type Node   = Int            -- unique id's for points
   type VoronoiSomething = M.Map (Length, Length) Node

and create many small utility functions that operate on this new 
abstraction.

One thing that strikes out is the repeated test  M.valid . You should 
never need to call that. Likewise, you should never need to write or 
call a function  validTrapeziaMap  if you have made good use of abstract 
data types and the type system.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com




More information about the Beginners mailing list