[Haskell-cafe] isWHNF :: a -> IO Bool ?

Tristan Allwood tora at zonetora.co.uk
Thu Sep 27 08:07:21 EDT 2007


Hi,

Does anyone know if there is a function that tells you if a haskell
value has been forced or not?

e.g. 
isWHNF :: a -> IO Bool

let x = (map succ [0..]) in do
  putStrLn . show (isWHNF x)                -- False
  putStrLn . show . head $ x
  putStrLn . show (isWHNF x)                -- True
  putStrLn . show (isWHNF (Just undefined)) -- True


If not, would it be hard/easy/possible to implement on-top-of or using
GHC?  I'm happy (if it's possible) to have a stab at implementing it
myself, so any pointers to right directions would be helpful.

I'm thinking it could be useful to allow creation of sparse-check [1]
like libraries without needing a separate logic encoding, or things
along those lines / in that area.

Cheers,

Tris

[1] http://www-users.cs.york.ac.uk/~mfn/sparsecheck/index.html#lim

-- 
Tristan Allwood
PhD Student
Department of Computing
Imperial College London


More information about the Haskell-Cafe mailing list