rubik / argon

Monitor cyclomatic complexity in Haskell programs
BSD 3-Clause "New" or "Revised" License
97 stars 8 forks source link

DataKinds is not enabled #11

Closed athanclark closed 9 years ago

athanclark commented 9 years ago

Is this related to how the cyclomatic complexity algorithm is designed? Does DataKinds bork everything because expressions become types? I have no idea how the complexity analysis works, I will read up on it to catch up.

rubik commented 9 years ago

The latest version on Hackage (0.2.0.0) of Argon uses Haskell-Src-Exts to parse the code. The problem with this approach is that one has to tell Haskell-Src-Exts which extensions should be loaded at compile time! This is unfortunate, since one cannot simply enable all extensions, as some extend the syntax in different ways. Argon had a very comprehensive extension list, see: https://github.com/rubik/argon/blob/1f759ab1de4ea3d4f75a24a30dc9a24f75f3aca2/src/Argon/Parser.hs#L19 But, as you have seen, it's not enough.

Fortunately, this has been solved. I managed to replace Haskell-Src-Exts with the GHC API, and now Argon should be able to parse every valid module (one that hasn't syntax errors). The new version is not available yet on Hackage. The only issue blocking the release is #3. It's not really a problem but it would make installation with Stack much easier.

If you try the version from master, it should work. If instead it does not, can you provide the code that Argon cannot parse? I tried with the first snippet at https://www.fpcomplete.com/user/k_bx/playing-with-datakinds and it worked.

athanclark commented 9 years ago

That sounds wonderful :) I've had issues with Haskell-Src-Exts in the past as well - another issue they (actually get right and GHC gets wrong) is with -XMultiParamTypeClasses and contexts - the following is valid:

{-# LANGUAGE MultiParamTypeClasses #-}

foo :: Foo a b => a -> b

But GHC doesn't need the LANGUAGE pragma, while Haskell-Src-Exts does. Anyway, I'm glad you were able to switch over! Are you using hint for the api? Or just raw GHC?

I'll try compiling the master branch, thank you for all your work! This tool is amazing!

rubik commented 9 years ago

I'm glad that you're finding Argon useful! It's actually in a very early stage and can be improved a lot.

As of now I'm using plain GHC API. One major problem is that I'm only sure it works for GHC >=7.10. I've seen in Hint code it's possible to support previous versions, although this requires adding a lot of ugly #if directives. I'm confident that soon Argon will run at least from GHC 7.8 onwards.

P.S. That issue you mention is a weird one! It's odd that GHC does not require the pragma.

rubik commented 9 years ago

I'm closing this as it's working with GHC >= 7.8. If you experience any problems, feel free to reopen or open a new issue altogether.