Hello!

New to this list and to BitC. I've grabbed the source in accordance with
http://www.bitc-lang.org/download/index.html
and have been browsing for maybe three hours now :)
If this has been mentioned before, i'd be happy for any links (skimmed
through the last three months mails).


I'm a haskell coder myself, and seeing how bitc seems to be awesome
I'd hate for it to go down any "wrong" paths.
One thing that bother me (and many haskellers) is the fact that the typeclass

> class (Eq a, Show a) => Num a where
>   (+) :: a -> a -> a
>   (*) :: a -> a -> a
>   (-) :: a -> a -> a
>   negate :: a -> a
>   abs :: a -> a
>   signum :: a -> a
>   fromInteger :: Integer -> a

which is equivalent to

> where Ord('a)
> trait Arith('a) {
>     _+_ : fn('a, 'a) -> 'a
>     _-_ : fn('a, 'a) -> 'a
>     _*_ : fn('a, 'a) -> 'a
>     _/_ : fn('a, 'a) -> 'a
>     negate : fn('a) -> 'a
> }

(I assume that implementation-wise it's an all-or-none kind of deal)
Now, getting back to the annoying thing with haskell: The function '+' is taken!
Consider inked list concatenation, this is done with '++' which has
this type signature:

> (++) :: [a] -> [a] -> [a].

But there are many other types for which concatenation makes sense!
For example the in ByteString code it is not uncommon to see
> bs0 `B.append` bs1 `B.append` bs2
where it could have been

> bs0 ++ bs1 ++ bs2

The generalized behaviour desired can be found, but with very
unsatisfying names:
> class Monoid a where
>   mempty :: a
>   mappend :: a -> a -> a
>   mconcat :: [a] -> a



What i propose is a collection of traits instead of 'Numeric' is
something like this (restrictions on 'a removed for brevity):

> trait Additive('a) {
>       _+_     : fn('a, 'a) -> 'a
>       zero    : a
> }

> trait Subtractive('a) {
>       _-_     : fn('a, 'a) -> 'a
>       neg     : fn('a) -> 'a  // maybe declared in its own trait "Negative" :)
> }

> trait Multiplicative('a) {
>       _*_     : fn('a, 'a) -> 'a
>       one     : a
> }

> trait Divisible('a) {
>       _/_     : fn('a, 'a) -> 'a
> }

Then lists and a lot of other types could easily be instances of 'Additive'.


Here's a pretty thorough page on about it:
http://www.haskell.org/haskellwiki/Context_alias


    // Alexander


PS. If someone could tell me how i write and compile a hello world
program, that'd be swell :) DS.
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to