[Haskell-cafe] Re: How many "Haskell Engineer I/II/III"s are there?

Jason Dusek jason.dusek at gmail.com
Fri Feb 12 01:53:42 EST 2010


  I looked at generating C for AVR with JHC. I wanted to see what
  this program became:

    http://github.com/solidsnack/trippy-waves/blob/99ad424a3ed4a21ff6f6a662293d6d21e92d6611/using-jhc/RGB.hs

  The program is relatively simple. It doesn't work, of course (I
  never did get the right FFI bindings figured out) but the
  generated C is suggestive.

    http://github.com/solidsnack/trippy-waves/blob/99ad424a3ed4a21ff6f6a662293d6d21e92d6611/using-jhc/hs.out_code.c

  The generated `main' is very plain:

    static void A_STD
    ftheMain(void)
    {
            jhc_function_inc();
            uintptr_t v10 = ((uintptr_t)DDRB());
            *((uint8_t *)(v10)) = 23;
            uintptr_t v18 = ((uintptr_t)PORTB());
            return *((uint8_t *)(v18)) = 23;
    }

  This is a simple, literal translation of my foreign calls. To
  all appearances, the runtime is entirely bypassed. The
  function `jhc_function_inc()' is a performance counter, set to
  no-op for non-profiling builds as far as I can tell.

  It also doesn't compile but that's because I can't figure out
  how to declare pointers in the FFI; and if I could, then I'd
  have to go through by hand and pull out includes for things
  that aren't available for AVR programming -- <locale.h> and
  such.

--
Jason Dusek


More information about the Haskell-Cafe mailing list