Are there additional restrictions on using native code? I installed a 
library with native code using elm-github-install. As far as I can see 
`"native-modules": true` is set in the library but it still cannot find the 
native code, whereas the native code from the http library that is also in 
the project is read.

Simon

On Tuesday, 6 December 2016 23:14:06 UTC+1, Rupert Smith wrote:
>
> On Tuesday, December 6, 2016 at 7:32:49 PM UTC, Rupert Smith wrote:
>>
>> On Tuesday, December 6, 2016 at 5:18:04 PM UTC, Wil C wrote:
>>>
>>> So now, either I write a ports for commonmark.js, or I write it as a 
>>> native module. I asked about it here 
>>> <https://groups.google.com/forum/#!topic/elm-discuss/Kd53qnKY-io> with 
>>> no answers. 
>>>
>>
>> I think if you write it as ports or native, you'll still need to map the 
>> AST between javascript and Elm. As a native module that could be done with 
>> a Decoder or by constructing the Elm AST in native code with Javascript. 
>> Perhaps Decoders are not so bad?
>>
>> I don't think a parser is a side-effect. A parser is a pure function from 
>> String -> Ast, with no side effects.
>>
>
> The thing about ports for something like this is it feels a bit unnatural 
> to invoke the port resulting in a Cmd. Then you'll need a subscription port 
> to get the result back in, and have that pass it to your update function 
> from where you can take it and place it in the model. That doesn't feel 
> like a good way to call a function : String -> Ast.
>
> I'd say the best solution is to implemented your parser in pure Elm. But 
> if that is too much work, just hack together a native module that calls out 
> to commonmark.js. You won't be able to publish your native module to elm 
> packages, but that's ok, perhaps no-one else really wants your markdown 
> with embedded SQL anyway, and if they do there is always 
> elm-github-install. Some time down the road when you really need to share 
> this amazing library, redo it in pure Elm. 
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to