[jhc] jhc's development state and an embedded dream

John Meacham john at repetae.net
Sat Feb 11 00:14:30 CET 2012

I do think that jhc is your best shot for getting something like that
to work :) I'd love to hear of your experiences trying and it is also
something I'm interested in.

With the latest 0.8.0 release, I think it will be easier as I have split up the
libraries even more. lib jhc-prim is what you will need to link in,
but beyond that you can
replace the entire library with one designed to be minimal.

Changes that would make it more embeded friendly would be to get rid of Integer
and define data Char = Char Word8. Perhaps get rid of floating point too
depending on your platform. jhc will only link in what is needed so you don't
need to worry about the fact that things are defined you don't need, you just
need to make sure they are not pulled in as dependencies. Like the standard num
class references 'Integer' so you may end up pulling it in when you just want to
do plain math. Or realToFrac talks about Rational which is way too
complicated of
a beast to pull in to an emedded system.

So, a quick tutorial on the steps to target a really odd platform :)

copy lib/jhc to lib/jhc-myplatform

go into jhc-minimal and redefine the standard types like Char,Int to be what
you want.  they are defined in Jhc.Type.Word.  Then start chopping, you don't
need to get rid of everything you don't want, but you may want to replace the
string functions with ones that work on bytestrings of chars by default. and
change the standard numeric classes to not depend on what you don't want. You
also may want to replace the foreign calls with ones to your platforms library
if it doesn't have the full standard C library.

once you have a suitable library, start compiling for it, you may need to tweak
the rts files, you can do so by adding #ifdefs in the files in rts/
but a better way
would be to have a c-sources: field in your jhc-myplatform.yaml file that points
to the rts files that should be used instead.

Hope this helps! of course, there is always a chance your system might
'just work' :)
compile hello world with --tdir /tmp/jhctest then go into /tmp/jhctest
and try to compile
the file it spit out there with your platforms c compiler. :)


On Fri, Feb 10, 2012 at 10:46 AM, Jorge Marques Pelizzoni
<jorge.pelizzoni at gmail.com> wrote:
> Hi, all!
> I bumped into JHC totally by chance and got quite interested. It's
> been a while since I started dreaming of developing embedded real-time
> systems in Haskell subject to somewhat hard memory constraints (from
> 32KB to 128KB RAM).
> Am I wrong in guessing that JHC might be the best shot we have so far
> in that direction? Would it be applicable at all in that scenario?
> JHC's site mentions that the description of development state in JHC's
> Original Page is out of date. Could anyone possibly provide/point to a
> summary of recent developments?
> Thanks in advance. Cheers,
> Jorge.
> 2012/2/10 Daniel Gorín <jcpetruzza at gmail.com>:
>> Hi John,
>> In case it helps, I was able to build jhc from the tarball by changing
>> the line in the Makefile that says
>> options.mkd: src/Options.hs | jhc
>> to just
>> options.mkd: jhc
>> Incidentally, the newest version of the pretty package (e.g., the one
>> that comes with ghc 7.4) defines a Monoid instance for Doc, which
>> conflicts with the one defined in jhc. I just patched the Makefile to
>> use an older version of the package, I don't know what the usual method
>> to deal with this is.
>> Thanks,
>> Daniel
>> On Wed, 2012-02-08 at 15:05 -0800, John Meacham wrote:
>>> Hi, looks like the tarball doesn't include the original files that go
>>> through drift. it shouldn't need them to compile, strange that it
>>> needed them for you.
>>> You can grab the source from darcs to work around the issue. I'll put
>>> up a fixed tarball when I debug the issue.
>>>     John
>>> On Wed, Feb 8, 2012 at 4:04 AM, Daniel Gorín <jcpetruzza at gmail.com> wrote:
>>> > Hi
>>> >
>>> > I wanted to try jhc 0.8. I followed the instructions here [1], but after
>>> > unpacking jhc-0.8.0.tar.gz, configure runs ok but make fails with:
>>> >
>>> > $ make
>>> > perl ./utils/op_raw.prl src/RawFiles src/data/ViaGhc.hs
>>> > src/data/prelude.m4 src/data/targets.ini rts/rts_constants.h
>>> > rts/stableptr.c rts/queue.h src/data/HsFFI.h rts/wsize.h rts/bitarray.h
>>> > ChangeLog src/data/shortchange.txt > src/RawFiles.hs
>>> > make: *** No rule to make target `src/Options.hs', needed by
>>> > `drift_processed/Options.hs'.  Stop.
>>> >
>>> > Any ideas?
>>> >
>>> > Thanks,
>>> > Daniel
>>> >
>>> > [1] http://repetae.net/computer/jhc/building.shtml
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> > jhc mailing list
>>> > jhc at haskell.org
>>> > http://www.haskell.org/mailman/listinfo/jhc
>> _______________________________________________
>> jhc mailing list
>> jhc at haskell.org
>> http://www.haskell.org/mailman/listinfo/jhc
> _______________________________________________
> jhc mailing list
> jhc at haskell.org
> http://www.haskell.org/mailman/listinfo/jhc

More information about the jhc mailing list