I wonder if it is possible to have a function (somewhat similar to dataToTag# ), for example:
isFunction
or probably equivalent to:
isFunction
which returns True if the value passed as an argument is of type a -> b (or, for that matter, a => b ) at run time for some types a and b , or newtype , whose base type (therefore it is " sees " newtype s, but certainly not data ), without forcing its argument. I have not seen anything like this in GHC.Prim myself, but I may have missed something, or perhaps it is possible using the manual CMM primitive or something like that.
Now that I have been asked a question, I am curious to answer myself ( question Y ), but the original reason I came up with this (question X) is that the complaint usually aligns with seq because it violates eta equivalence, allowing observe the difference between undefined and \_ -> undefined , and I was wondering if it is possible to make a version of seq ( myseq a = if isFunction# a then flip const a else seq a ), which is still "magically polymorphic" (works forall a ) but just leaves the functions alone.
source share