mmark-md / mmark

Strict markdown processor for writers
Other
111 stars 20 forks source link

GHCJS support #54

Closed srid closed 5 years ago

srid commented 6 years ago

Would you open for a PR to support GHCJS?

The yaml dependency doesn't compile on GHCJS.

test/Data/Yaml/IncludeSpec.hs:7:1: warning: [-Wdeprecations]
    Module ‘Data.Yaml’:
      GHCJS is not supported yet (will break at runtime once called).
  |
7 | import           Data.Yaml (ParseException(InvalidYaml))
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[2 of 4] Compiling Data.Yaml.THSpec ( test/Data/Yaml/THSpec.hs, dist/build/spec/spec-tmp/Data/Yaml/THSpec.js_o )
Linking Template Haskell ()
Linking Template Haskell (Data.Yaml.IncludeSpec,ThRunner1)
uncaught exception in Haskell main thread: ReferenceError: h$yaml_parser_initialize is not defined
ReferenceError: h$yaml_parser_initialize is not defined
mrkkrp commented 6 years ago

How do you propose to solve this? Do we have a YAML library written in pure Haskell?

srid commented 6 years ago

I haven't taken a look at how exactly YAML is being used in mmark, but at first glance I'd say by using a different library that is written in pure Haskell. This comes up: https://github.com/haskell-hvr/HsYAML

mrkkrp commented 6 years ago

I’ll take a look.

mrkkrp commented 6 years ago

Hmm, pure YAML implementation is good, but that one lacks Aeson compatibility and parse errors are plain Strings.

srid commented 6 years ago

Time for a myaml library then? :-)

mrkkrp commented 6 years ago

Heh, would be good to have something like HsYAML but with Megaparsec and Aeson-based ;)

srid commented 6 years ago

I don't remember if I already asked you this, but would it be reasonable to make yaml an optional dependency of mmark (so that it can be used in GHCJS today)?

mrkkrp commented 6 years ago

How will it work when yaml is disabled? Should it just ignore YAML blocks then?

srid commented 6 years ago

Yup that’s what I was thinking. Just ignore yaml blocks (or just extract them as raw text).

mrkkrp commented 6 years ago

I think ignoring the blocks would be a better idea because that doesn't lead to a conditional API.

benkolera commented 5 years ago

@srid If you still care about this, I put in a PR #61 which I have working in a WIP obelisk implementation of the 'realworld'/conduit demo app in this commit: https://github.com/qfpl/reflex-realworld-example/commit/e8eb77943a8d20ce946a2fed44b4bffae7c5b975

mrkkrp commented 5 years ago

Implemented in #61.