bryant / punkt

Unsupervised multilingual sentence segmentation.
MIT License
21 stars 5 forks source link

Punkt does not compile with Stack #1

Open rubik opened 9 years ago

rubik commented 9 years ago

While installing with Stack I get the following error:

Configuring punkt-0.1.1...
Building punkt-0.1.1...
Preprocessing library punkt-0.1.1...
[1 of 2] Compiling NLP.Punkt.Match  ( lib/NLP/Punkt/Match.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/NLP/Punkt/Match.o )

lib/NLP/Punkt/Match.hs:24:5:
    Non type-variable argument
      in the constraint: regex-base-0.93.2:Text.Regex.Base.RegexLike.RegexLike
                           Regex b
    (Use FlexibleContexts to permit this)
    When checking that ‘chunk’ has the inferred type
      chunk :: forall b.
               regex-base-0.93.2:Text.Regex.Base.RegexLike.RegexLike Regex b =>
               Regex -> b -> [Either b b]
    In an equation for ‘re_split_impl’:
        re_split_impl re str
          = filter not_blank $ chunk re str
          where
              not_blank xs
                = if xs == Left "" || xs == Right "" then False else True
              chunk re str = maybe [Left str] link $ matchOnceText re str
              link (pre, match, post)
                = Left pre : Right (fst $ match ! 0) : chunk re post

I couldn't try it, but maybe it's just a matter of adding the suggested extension, FlexibleContexts.

bryant commented 8 years ago

Thanks for reporting!

I've created a branch, issue-001 that tentatively fixes this. All it does is include an explicit type signature for chunk. Just to get you going:

$ git checkout https://github.com/bryant/punkt -b issue-001 punkt-001
$ cd punkt-001
$ ... #juststackthings

This looks like a conflict with the type checker and isn't specific to stack. GHC (from 7.10.1 onwards) tries to infer a polymorphic type for the second parameter (str) of re_split_impl.chunk despite the constraint from the top level signature that str unifies with Text.

I've requested for clarification on #ghc, but won't be pushing to master until this is cleared up.

rubik commented 8 years ago

Thanks for explaining the issue! I'll happily wait for clarification, I'm learning Haskell myself.

arademaker commented 4 years ago

I got the. same error using cabal:

cabal sandbox init 
cabal install punkt
...

But how to use the new branch in this setup? Do we have any way to say to cabal to use a branch of the punkt repository?