[Haskell-cafe] Re: Data constructors versus types
bf3 at telenet.be
Wed Jan 16 16:56:03 EST 2008
Thank you for explaining.
I was wondering if the same syntax could be used somehow (not in
Haskell, in some theoretical language), I mean use an annotation to tell
the compiler that a "type-tag" should be determined at compile time and
not at runtime, otherwise -> error
// Runtime tag, aka data constructor
foo (Int n) = ...
// Compile tag, aka type
foo (>Int< n) = ...
Might not make any sense...
You're talking about O(big)... But wasn't the C language in some way
succesful because on the hardware at that time other much nicer
languages (e.g. LISP) were just way too slow? Or was this just O(n)
IMHO: Shouldn't concepts that are conceptually the same (in this case,
"giving meaning/adding constraints to bits of data" ) at runtime and
compile time look very similar in the language? Most languages require
completely different syntax and code when you want something to be lazy
versus strict. Haskell doesn't, you can just add an annotation if you
want it to be strict, no much rewriting is required. However, if I want
to change a runtime data constructor definition (and code) into a
compiletime type, then I can rewrite all of my code basically. That is
not the case in SCHEME as far as I understand it.
On Wed, 2008-01-16 at 22:20 +0100, Achim Schneider wrote:
> Peter Verswyvelen <bf3 at telenet.be> wrote:
> > I know nothing about theoretical computer science, but I was wondering
> > if it possible to forget about types, and just keep the concept of
> > data constructors, and have an analyzer determine correctness of the
> > code and "staticness" of the data?
> > Basically this is what SCHEME does no? Doesn't SCHEME have static
> > whole program analyzers to remove the overhead of the "symbol tags"
> > and check correctness of a program (Stalin, Petit-Scheme, ...)?
> > What are to pros/contras?
> Basically, it's a matter of taste, and how much of the checking can be
> done at compile-time... which gets quite involved and O(big), if all
> you have is (tagged) lists with type information.
> And, yes, Stalin manages to specialize a -> a functions to Int -> Int
> to make numerical code as fast or faster than C, but so does GHC.
> Plus a GHC build may allow you to get a coffee, Stalin allows you to go
> shopping, watch a movie and then go on vacation.
> That is because, in general, you can't forget about the type of your
> data, you need it in some way or the other to do anything with it.
More information about the Haskell-Cafe