| I could imagine adding two rules to the simplifier:
|
| case unpackCString# "" of  ==> case [] of
| case unpackCString# "xyz" of ==> case (C# 'x': unpackCString# "yz") of
...
| This goes back to an old gripe of mine actually -- we can't get
| at the length of a C string literal at compile time either, which
| would be super useful in rules.
|
| If we had some light primitives for this, that GHC new about (head#,
| length#), that accessed the internal data about what strings are up to,
| that could be useful.

Don, Neil

Can you two be very concrete about what you'd like?  This stuff is very like 
constant folding.  GHC knows about
        1# +# 2#
so it could reasonably know about
        length# "foo"
where
        length# :: CString -> Int
or whatever.


Both Neil's suggestion and the above look do-able.  But I'd like a clear spec 
first.  There is a slight tension between what is "built-in magic" for 
primitive types (in this case CString), and what is general purpose stuff.  I 
don't think there is anything wrong with magic for primitive types, but if 
there is a useful general-purpose mechanism trying to get out, let's liberate 
it.

Simon

_______________________________________________
Glasgow-haskell-users mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to