← Back to team overview

kicad-developers team mailing list archive

Re: Haskell Library

 

On Tue, Dec 02, 2014 at 02:26:35PM +0000, Kaspar Emanuel wrote:
> What patch would that be? Something to do with dotted lists?

Nope, simply having all strings in quotes :D

> In Haskell, it seems, s-expression based syntaxes are very common as
> examples in beginner tutorials so I was very happy to have something
> potentially useful, but also feasible, to work on while learning.

Given that IIRC Haskell is based on pattern matching (or was that
Ocaml?) and lists are usually the natural way to implement the
recursive/inductive behaviour on sequence algorithms, it doesn't
surprise me...

However you had to write a parser of some kind; in lisp the sexp
(actually copied from a board file and simply reindented)

(dimension 90.8 (width 0.12) (layer "Dwgs.User")
           (gr_text "90,8" (at 254 100 270) (layer "Dwgs.User")
                    (effects (font (size 2.5 2.5) (thickness 0.25))))
           (feature1 (pts (xy 234 145.4) (xy 253.6 145.400001)))
           (feature2 (pts (xy 234 54.6) (xy 253.6 54.600001)))
           (crossbar (pts (xy 252.2 54.600001) (xy 252.2 145.400001)))
           (arrow1a (pts (xy 252.2 145.400001) (xy 251.61358 144.273498)))
           (arrow1b (pts (xy 252.2 145.400001) (xy 252.78642 144.273498)))
           (arrow2a (pts (xy 252.2 54.600001) (xy 251.61358 55.726504)))
           (arrow2b (pts (xy 252.2 54.600001) (xy 252.78642 55.726504))))

is actually a valid expression and can be passed to the system reader :D
(there still is an incompatibility, the hex timestamps are not tagged as
hex, so they don't parse; however that wouldn't be backward compatible
to fix). That aside almost every book on lisp has a toy implementation
of the system reader (yes, it's *that* important) so in a pinch you
could adapt one of these.

For me the important reason is that since the system reader is matched
to the writer, I can generate footprints in memory as sexp and the
simply PRINT them :D

-- 
Lorenzo Marcantonio
Logos Srl


References