sdiehl / write-you-a-haskell

Building a modern functional compiler from first principles. (http://dev.stephendiehl.com/fun/)
MIT License
3.34k stars 256 forks source link

epub format #74

Closed reeze closed 8 years ago

reeze commented 8 years ago

Thank you for you excellect book. Could you generate an epub version of the book, that will be really helpful for portability ;)

sdiehl commented 8 years ago

This was contributed by someone a while back:

https://github.com/sdiehl/write-you-a-haskell/blob/master/Makefile#L48

If you run

$ stac exec make epub

It should generate the file. I haven't really tested this much though.

reeze commented 8 years ago

Thanks!

it seems not working:

➜  write-you-a-haskell git:(master) stack exec make pdf
# pandoc --filter includes.hs -f markdown --template template.latex --latex-engine=xelatex --standalone --toc --toc-depth=2 --mathjax="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments -o WYAH.pdf title.md 0*.md contributing.md
pandoc --filter includes.hs -f markdown --template template.latex --latex-engine=xelatex --standalone --toc --toc-depth=2 --mathjax="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments -o WYAH.pdf title.md 000_introduction.md 001_basics.md 002_parsers.md 003_lambda_calculus.md 004_type_systems.md 005_evaluation.md 006_hindley_milner.md 007_path.md 008_extended_parser.md 009_datatypes.md 010_renamer.md 026_llvm.md
pandoc: Error running filter includes.hs
fd:4: hPutBuf: resource vanished (Broken pipe)
make: *** [pdf] Error 83

➜  write-you-a-haskell git:(master) stack exec make epub
pandoc --filter includes.hs -f markdown --standalone --toc --toc-depth=2 --mathjax="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments --epub-cover-image=img/cover-kindle.jpg -o WYAH.epub title.md 0*.md
pandoc: Error running filter includes.hs
fd:4: hPutBuf: resource vanished (Broken pipe)
make: *** [epub] Error 83

I am not sure what is the problem

sdiehl commented 8 years ago

You'll need to compile includes.hs

$ stack exec ghc includes.hs
sdiehl commented 8 years ago

Were you able to get it to build?

reeze commented 8 years ago

Hi,

➜  write-you-a-haskell git:(master) stack exec ghc includes.hs

includes.hs:4:8:
    Could not find module ‘Control.Monad.State’
    Perhaps you meant
      Control.Monad.ST (from base)
      Control.Monad.ST.Safe (from base)
      Control.Monad.Fix (from base)
    Use -v to see a list of the files searched for.

includes.hs:6:8:
    Could not find module ‘Text.Pandoc’
    Use -v to see a list of the files searched for.

includes.hs:10:8:
    Could not find module ‘Text.Pandoc.JSON’
    Use -v to see a list of the files searched for.

includes.hs:11:8:
    Could not find module ‘Text.Pandoc.Walk’
    Use -v to see a list of the files searched for.

Seems I need to install more libraries.

sdiehl commented 8 years ago

Does running stack build add the libraries you need?

reeze commented 8 years ago

:( I got this:

➜  write-you-a-haskell git:(master) sudo stack build
Password:
base64-bytestring-1.0.0.1: configure
byteable-0.1.1: configure
cereal-0.4.1.1: configure
SHA-1.6.4.2: configure
Progress: 4/97
--  While building package SHA-1.6.4.2 using:
      /Users/reeze/.stack/setup-exe-cache/setup-Simple-Cabal-1.18.1.5-x86_64-osx-ghc-7.8.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.18.1.5/ configure --with-ghc=/usr/local/bin/ghc --user --package-db=clear --package-db=global --package-db=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/pkgdb/ --libdir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/lib --bindir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/bin --datadir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/share --libexecdir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/libexec --sysconfdir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/etc --docdir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/doc/SHA-1.6.4.2 --htmldir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/doc/SHA-1.6.4.2 --haddockdir=/Users/reeze/.stack/snapshots/x86_64-osx/lts-2.22/7.8.4/doc/SHA-1.6.4.2 --constraint=array==0.5.0.0 --constraint=base==4.7.0.2 --constraint=binary==0.7.1.0 --constraint=bytestring==0.10.4.0 --constraint=directory==1.2.1.0
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/reeze/write-you-a-haskell/.stack-work/logs/SHA-1.6.4.2.log

    Configuring SHA-1.6.4.2...
    setup-Simple-Cabal-1.18.1.5-x86_64-osx-ghc-7.8.4: /usr/bin/ar: permission
    denied
reeze commented 8 years ago

Seems related to this: https://github.com/haskell/cabal/issues/2653

reeze commented 8 years ago

I changed ghc to 7.10, it works:

diff --git a/stack.yaml b/stack.yaml
index 2af92ac..55f17a0 100644
--- a/stack.yaml
+++ b/stack.yaml
@@ -1,4 +1,4 @@
-resolver: lts-2.22
+resolver: lts-4.1
 packages:
 - '.'
 extra-deps: []
diff --git a/write-you-a-haskell.cabal b/write-you-a-haskell.cabal
index 4e9f295..1dcaccd 100644
--- a/write-you-a-haskell.cabal
+++ b/write-you-a-haskell.cabal
@@ -11,7 +11,6 @@ cabal-version:       >=1.10
 executable write-you-a-haskell
   main-is:             Main.hs
   build-depends:       
-    base         >= 4.7 && <4.8,
     pretty       >= 1.1 && <1.2,
     containers   >= 0.5 && <0.6,
     transformers >= 0.3 && <0.5,
mseri commented 8 years ago

This should be now fixed on master with PR #75

sdiehl commented 8 years ago

Nice, I'll close.

reeze commented 8 years ago

thanks!