bmsherman / haskell-matlab

Matlab bindings and interface for Haskell
Other
13 stars 4 forks source link

Consider changing EngineEvalArg to be an HMap, HList, etc. #16

Open bbarker opened 4 years ago

bbarker commented 4 years ago

The idea is that when writing FFI calls to the Engine, one often ends up calling anyMXArray for most arguments in the argument list to get the type to agree (i.e., everything becomes MAny). Not only is this slightly tedious, but having to maintain these rather-untyped argument lists all over the place seems a bit dangerous. It might be better to have that machinery all in one place: Engine.hsc in this package, rather than user-code.

Of course, as I recall, using HList can also be tedious (at least in Scala - I don't think I've used any of these datatypes in Haskell so far (that I recall), so take this with a grain of salt). And what this suggests is that we'd be leaking HList into the user API.

Why an HMap? It isn't good for ordered arguments, but could replace what is currently being used for VarArgIn (a regular Data.Map).

Maybe use a record to combine these ideas; some pseudo-code:

data EvalArgs = EvalArgs {args:: HList, varargin:: HMap}
bbarker commented 4 years ago

A few suggestions on HList-like options to look into: