knupfer / haskell-emacs

Write Emacs extensions in Haskell
376 stars 22 forks source link

Marshalling Documentation #38

Closed ExternalReality closed 8 years ago

ExternalReality commented 8 years ago

Is documentation describing the mapping between Haskell types and what they marshal to in elisp and vice versa needed?

knupfer commented 8 years ago

I think yes, it would show the power of our current solution. But it could be a bit tricky to show this mapping, especially with monads involved

Eric notifications@github.com writes:

Is documentation describing the mapping between Haskell types and what they marshal to in elisp and vice versa needed?

--- Reply to this email directly or view it on GitHub: https://github.com/knupfer/haskell-emacs/issues/38

pthariensflame commented 8 years ago

For now:

http://hackage.haskell.org/package/atto-lisp/docs/Data-AttoLisp.html#t:ToLisp and http://hackage.haskell.org/package/atto-lisp/docs/Data-AttoLisp.html#t:FromLisp

knupfer commented 8 years ago

Well, that's not bad, but I think we can better. We have to consider only types that are representable in elisp. Additionally, we can convert some of the elisp types into other elisp types to allow for example hashtables as list of tuples or something like that...

sboosali commented 8 years ago

elisp has several domain-specific primitive types (some overlap):

Programming Types:

• Integer Type: Numbers without fractional parts. • Floating-Point Type: Numbers with fractional parts and with a large range. • Character Type: The representation of letters, numbers and control characters. • Symbol Type: A multi-use object that refers to a function, variable, or property list, and has a unique identity. • Sequence Type: Both lists and arrays are classified as sequences. • Cons Cell Type: Cons cells, and lists (which are made from cons cells). • Array Type: Arrays include strings and vectors. • String Type: An (efficient) array of characters. • Vector Type: One-dimensional arrays. • Char-Table Type: One-dimensional sparse arrays indexed by characters. • Bool-Vector Type: One-dimensional arrays of t or nil. • Hash Table Type: Super-fast lookup tables. • Function Type: A piece of executable code you can call from elsewhere. • Macro Type: A method of expanding an expression into another expression, more fundamental but less pretty. • Primitive Function Type: A function written in C, callable from Lisp. • Byte-Code Type: A function written in Lisp, then compiled. • Autoload Type: A type used for automatically loading seldom-used functions.

Editing Types:

• Buffer Type: The basic object of editing. • Marker Type: A position in a buffer. • Window Type: Buffers are displayed in windows. • Frame Type: Windows subdivide frames. • Terminal Type: A terminal device displays frames. • Window Configuration Type: Recording the way a frame is subdivided. • Frame Configuration Type: Recording the status of all frames. • Process Type: A subprocess of Emacs running on the underlying OS. • Stream Type: Receive or send characters. • Keymap Type: What function a keystroke invokes. • Overlay Type: How an overlay is represented. • Font Type: Fonts for displaying text.

supporting them all might be nice. with perhaps a simpler "view" (like that marshals hashtables into pair lists, as above).

knupfer commented 8 years ago

Thank you sboosali for the overview! At least the programming types will get nearly all marshallable this week (with the exception of the last three of those, not quite sure if they would make any sense for the haskell side).

The editing types are a lot harder and less clear whether they are useful to marshal. The buffer type is somewhat implemented, with the last major update you can write:

do (Buffer txt pnt) <- getBuffer
   putBuffer (T.reverse txt) pnt

so you have control of the contents and the position of point. But what is the sense of say marshalling a font to haskell?

sboosali commented 8 years ago

i had a vague idea of opaque types that you can operate on from haskell via bindings. like "replicateM_ 5 (foreignCall opaqueData)", rather than a loop in elisp, which has communication costs but saves marshaling costs. but if the communication is inter process anyway, that might outweigh the marshalling.

I'm also not familiar with your library (yet... the README is great btw), so what I said might not make sense.

On Wednesday, September 23, 2015, quxbar notifications@github.com wrote:

Thank you sboosali for the overview! At least the programming types will get nearly all marshallable this week (with the exception of the last three of those, not quite sure if they would make any sense for the haskell side).

The editing types are a lot harder and less clear whether they are useful to marshal. The buffer type is somewhat implemented, with the last major update you can write:

do (Buffer txt pnt) <- getBuffer putBuffer (T.reverse txt) pnt

so you have control of the contents and the position of point. But what is the sense of say marshalling a font to haskell?

— Reply to this email directly or view it on GitHub https://github.com/knupfer/haskell-emacs/issues/38#issuecomment-142527122 .

(this message was composed with dictation: charitably interpret typos)Sam Boosalis

sboosali commented 8 years ago

(sorry, reread your comment, still waking up)

yeah being unmarshallable sounds fine.

knupfer commented 8 years ago

So, I've added a bunch of supported elisp types. We've got now:

pthariensflame commented 8 years ago

Why was this closed? I can't find any (new) marshalling docs. :(