On Fri, Oct 24, 2008 at 01:38:23PM -0700, Dan Piponi wrote:
> I'd like to be able to write something like
> 
> > map zipWith ([1,2,3] >>= printMyInferredType)
> 
> and have the compiler treat 'printMyInferredType' as undefined, but
> also produce the side effect of printing out its inferred type.
> 
> What's the easiest way to simulate this with what we have now?

This will work as long as your type has a typeable instance. You can
modify it to work in an non-io context with unsafePerformIO (as long as
you are aware of the caveats of doing so)



import Data.Typeable

printInferedType :: Typeable a => a -> IO ()
printInferedType x = print (typeOf x)


main = do
    printInferedType ()
    printInferedType "foo"    

-- 
John Meacham - ⑆repetae.net⑆john⑈
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to