Vote count:
0
Is there a way to have Haskell expand certain thunks at run time. For example, say I have
--Purposely inefficient code for demonstration
fib 0=0
fib 1=1
fib n=fib n=fib (n-1) + fib (n-2)
goldRatio=fib 100 / fib 101
How could I have it evaluate goldRatio
at compile time. Like for example, with
{-# EVALUATE goldRatio #-}
It would only need to be to weak head form, since Control.Deepseq.force
could handle the rest. I hear template haskell can do this, but I do not know it well.
Note: I am using GHC at the moment.
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire