[GHC] #7036: StableNames in presence of class constraints / monadic functions
GHC
cvs-ghc at haskell.org
Fri Jun 29 19:42:29 CEST 2012
#7036: StableNames in presence of class constraints / monadic functions
---------------------------------+------------------------------------------
Reporter: ifigueroap | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: GHC API | Version: 7.4.2
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by ifigueroap):
Replying to [comment:2 simonpj]:
> You are skating on incredibly thin ice. Haskell in general, and GHC in
particular, makes no claims about pointer equality.
> Any program that relies on it is likely to be fragile.
Indeed, I guess that StableNames is not the right API for my purposes, but
I see it as a good starting point
> For example, you probably expect `f` to be pointer-equal to `f`. And
perhaps to `head [f]`? What about a partial
> application `(f 1)` and `(f 1)`? What about `(f 1)` and `f (2-1)`?
You are correct in that I would expect those cases to be equal. However my
goal is not really "pointer" equality, but an approximation of function
equality.
> Rather than bend the language or compiler out of shape, I'd be inclined
to look at the original goal, and see if it can be done some other way.
One "reasonable" approach (which would be more than good enough for my
purposes) is used in AspectScheme [1] where they 'tag' every closure with
a unique identifier.Their notion of equality is [1]: "Two function
closures are equal if they have the same textual source location and their
environments are identical." In the implementation they use the macro
system to intercept the "lambda" symbol and inject the tag.
I don't know if it is possible to do that in Haskell in a way that is
transparent to the user. I think I could use a wrapper type like
{{{
data MyFun a b = MyFun (a -> b)
}}}
but doing so I lose the language support for defining functions. In the
case of partial application, the new tag could be deterministically
determined from the tag of the applied function, maybe including a 'seed'
along with the function tag.
However I agree maybe it is not possible to do as I expect because it
would break all compiler optimizations -- and I don't really know about
the internals of GHC.
So I guess my request could be rephrased as "is there any way to tag
functions definitions and compare those tags at runtime?" but retaining
normal Haskell syntax??
Thanks!
[1] http://www.cs.brown.edu/~sk/Publications/Papers/Published/dtk-sem-
scope-aspects-ho-lang/paper.pdf
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7036#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list