Code Monkey home page Code Monkey logo

ghc-tags's People

Contributors

arybczak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ghc-tags's Issues

TemplateHaskell extension not picked up in configuration file

I have a project that uses TemplateHaskell and QuasiQuotes. Extensions are declared in the default-extensions section of the .cabal file (i.e. not as {-# LANGUAGE ... #-} pragmas inside the Haskell files).

When I tried to run ghc-tags -c, I got some errors:

[...].hs:177:67: error:
    parse error on input `|]'

[...].hs:38:18: error:
    parse error on input `$'
    Perhaps you intended to use TemplateHaskell

I created a ghc-tags.yaml, and added TemplateHaskell and QuasiQuotes to the list of extensions that ghc-tags --default produced:

# ghc-tags.yaml
extensions:
# defaults
- BangPatterns
- BlockArguments
- CApiFFI
- ExplicitForAll
- ExplicitNamespaces
- GADTSyntax
- LambdaCase
- MultiWayIf
- NumericUnderscores
- OverloadedLabels
- PatternSynonyms
- TypeApplications
- UnicodeSyntax
# added
- TemplateHaskell
- QuasiQuotes

When I run ghc-tags -c again, the QuasiQuotes error is gone, but I still have the TemplateHaskell error:

[...].hs:38:18: error:
    parse error on input `$'
    Perhaps you intended to use TemplateHaskell

Interestingly enough, if I add {-# LANGUAGE TemplateHaskell #-} at the top of the files producing TemplateHaskell parse errors, then ghc-tags -c runs without errors.

Is the TemplateHaskell extension not being picked up in the ghc-tags.yaml configuration file?

Note: This project is built with GHC 8.10.7, but ghc-tags was installed with GHC 9.2 (because I think that's the only way to install it right?), via ghcup run --ghc 9.2 -- cabal install ghc-tags. I don't know if that could affect this issue, but mentioning it for completeness.

Let `ghc-tags` parse the same file multiple times

Sometimes it's desirable to have two sections in ghc-tags.yaml file for the same file:

source_paths:
  - ouroboros-network-framework/src/Ouroboros/Network/Snocket.hs

cpp_options:
  - '-Dmingw32_HOST_OS'

extensions:
  - BangPatterns
  - ExplicitForAll
  - GADTSyntax
  - CPP

---

source_paths:
  - ouroboros-network-framework/src/Ouroboros/Network/Snocket.hs

extensions:
  - BangPatterns
  - ExplicitForAll
  - GADTSyntax
  - CPP

so that the file is parsed twice, with different cpp options. It seems currently ghc-tags would parse the file once (or I am doing something wrong).

ghc-tags seems to choke on CPP ! negation

I often use CPP like:

#if !MIN_VERSION_simple_cmd_args(0,1,4)
: 

in my code which seems to trip up ghc-tags (I am using 1.5).

I get an error like:

ghc-tags -e

Common.hs:6:0: error:
     error: missing binary operator before token "("
        6 | #if !MIN_VERSION_http_directory(0,1,6)
          | 
  |
6 | #if !MIN_VERSION_http_directory(0,1,6)
  | ^

Common.hs:12:0: error:
 
    error: missing bQiunearry
y. hosp:eMr2aa4it:no.r0h :sb :eerror:f8o
:re 0  :t  o error:ke 
ne r
 "r (o "r 
:U  R meL ir. srh sosir: n: g 9  m:1bi2is0 ns:|ai  rnerror:#ygi  
fob pi !en Mra Iar Nty_o  VroeE prRberSeroIfarOot:Nro _ermh  ittbstoespkfi_eondnrgi e r" be(tic"ont
kaoerr nyy   ( "o0 (p,"e1 
r, a6  t)2 o
4 r    |b   e # f i of r  8e !   M|t I o N#k _ie|Vfn E  
R!"SM(II" ON
 N_ _V |sE 
iR mS 1pI2lO  eN |__ cs  mi9dm #(p|0l i,e#f2_i ,cf!0m M)dMI
_INaN_ r_V gVE sER (RS0SI ,IO 1ON ,N_ 4_h )ht 
tt|tp  p_
 _d di ir re  ec  ct| to
 or ry2 y(4|(0  0,|
,11, ,6 9)# )
|
i
 f   8  !  |M| I N  ^_ 
V# E Ri Sf I |
O! NM
_IsNi_ mVC pEo|lRm
eSm_Io9cOn mN.|d_h(ss 0i:,m#2p1,l6i0e:f)_ 
c0Mm:I d N _error:_ aV|r
EgR s S^( I
0 O, N1_, h4et)rt
rQuery.hs:1:1: error:
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)
po_ rd :i| rme ic^st
soirnyg( 0
b,i1n,aM9ra)yi
 no. ph es|r:a t1^o6
r: b0e:f 
oerror:re
 UtR oL k. eh ns : "e(3r"3r
:or 0: :   m error:is 
s i  n1 g6    b|i  n#eairrfry o MroI:pN e_mrViaEstRsoSirIn OgbN e_bfsioinrmaepr lyte o_okcpemendr (a"0t(,o"2r
, 0b )e 
f o  r e     t o1 k6 e  n|    "# (i|"f 
 
! M I  N  _ V| E
 R S13I63O  N||_ s #iim#fp li!efM_ IcMNmI_dNV__EaVRrESgRIsSO(IN0O_,Nh1_t,st7ip)m_
pdli er _e cc mtdo (r 0y ,( 20 ,, 01|), 
9
) 
     |   |  
^
 1 6   | 
  | #
if   ! M|I
N_3V3E R|SIC OoNm#_msoiinfm. ph!lsMe:I_Nc2_m5Vd:E_Ra0Sr:Ig Oserror:N(_0h
,t1t ,p 7_ )d 
ir  ee cr tr|oorr y:^( 
0m,i1s,s9i
)n
g M ba ii nn|a.rh ys^ :
op2e4r:aURL.hs:1:1: error:
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)
t0o:r  error:be
fo r e   to keernr o"r(:" 
mi s s i ng   b i2n5a r|y  #oipfe r!aMtIoNr_ VbEeRfSoIrOeN _thotktepn_ d"i(r"e
ct o r y (0 , 1 ,264) 
|  # i f  ! M I N _ V E|R S
ION _ s i|m
pl2e5_ c|md _a#rgisf( 0!,M1I,N7_)V
ER S I O N_ h t t p _ d|i r
ect o r y|(
0,214, 6|)
  #  i|f  !^M
IN_VERSION_simple_cCommon.hs:1:1: error:
md    `gcc' failed in phase `C pre-processor'. (Exit code: 1)
_args(0,1,7)
   | ^
Main.hs:1:1: error:
    `gcc' failed in phase `C pre-processor'. (Exit code: 1)

which is quite "interesting". :)

If you want to reproduce this is with https://github.com/juhp/fedora-repoquery but I don't think that particularly matters.

Option `--cabal` to read configuration from a `.cabal` file?

Context: We are considering switching from hs-tags to ghc-tags, just because maintaining hs-tags is a bit burdensome (uses the GHC API, thus, breaks with each new GHC version):

hs-tags has option --cabal to read configuration from the library section of a .cabal file.
I see that ghc-tags requires information such as default-languages and default-extensions to be duplicated in the ghc-tags.yaml configuration file. This is a bit error-prone and contradicts the DRY principle.

Maybe the --cabal option functionality could be ported from hs-tags to ghc-tags.

No tags for projections in record pattern synonyms

E.g. this definition:

{-# LANGUAGE PatternSynonyms #-}

pattern MyJust :: a -> Maybe a
pattern MyJust { theThing } = Just theThing

just produces (with ghc-tags Foo.hs -c) a tag for the MyJust synonym, but not the theThing field:

...
!_TAG_KIND_DESCRIPTION!Haskell	p	/pattern synonym/
...
MyJust	RecordPatternSynonym.hs	4;"	p

NB. Noticed this first for my own tool:

`cabal install ghc-tags` fails with a compilation error

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.10.7

$ cabal --version
cabal-install version 3.4.1.0
$ cabal install ghc-tags
...
Building     ghc-tags-1.3 (exe:ghc-tags)

Failed to build exe:ghc-tags from ghc-tags-1.3.
Build log (
/home/jsynacek/.cabal/logs/ghc-8.10.7/ghc-tags-1.3-e-ghc-tags-366ca059b05819f400ed5936c9ec22dd61ef576344a28846bcccdc210f8158c3.log
):
Configuring executable 'ghc-tags' for ghc-tags-1.3..
Preprocessing executable 'ghc-tags' for ghc-tags-1.3..
Building executable 'ghc-tags' for ghc-tags-1.3..
[ 1 of 17] Compiling GhcTags.Config.Project ( src/GhcTags/Config/Project.hs, dist/build/ghc-tags/ghc-tags-tmp/GhcTags/Config/Project.o )

src/GhcTags/Config/Project.hs:104:32: error:
    • Couldn't match type ‘Data.Aeson.KeyMap.KeyMap Value’
                     with ‘HM.HashMap T.Text v0’
      Expected type: HM.HashMap T.Text v0
        Actual type: Object
    • In the first argument of ‘HM.keys’, namely ‘v’
      In the second argument of ‘($)’, namely ‘HM.keys v’
      In a stmt of a 'do' block: checkUnknownKeys $ HM.keys v
    |
104 |     checkUnknownKeys $ HM.keys v
    |                                ^
cabal: Failed to build exe:ghc-tags from ghc-tags-1.3. See the build log above
for details.

Template Haskell Support - finding field names for Esqueleto/Persistent

Suppose we have the following:

share [ mkPersist sqlSettings
      , mkMigrate "migrateAll"] [persistLowerCase|
  Person
    name String
    age Int Maybe
    deriving Eq Show
  BlogPost
    title String
    authorId PersonId OnDeleteCascade
    deriving Eq Show
  Follow
    follower PersonId OnDeleteCascade
    followed PersonId OnDeleteCascade
    deriving Eq Show
|]

Later we use this schema like so:

 liftIO $ mapM_ (putStrLn . ("Name: " ++) . personName . entityVal) people

It would be highly beneficial for personName to jump to the entity definition file where this is defined

 Person
    name String           <---------tag jump
    age Int Maybe
    deriving Eq Show

It is useful to see what other database fields are available, especially when one is doing lots of database operations in a production environment. Additionally, it allows one to inspect the type without having to create typed holes, etc. One simply jumps to the Entity, sees what is there, and then jumps back to the original query line for modifications.

The alternative is to git grep for things like sql=Person in the case of Esqueleto or to come up with some regex that matches on this

share [ mkPersist sqlSettings
      , mkMigrate "migrateAll"] [persistLowerCase|
  Person

I think tags is the perfect candidate for just jumping to these things, especially since ghc already knows what personName is. It becomes more of a need the more developed a specific database schema becomes (i.e. when one can no longer keep all the tables in ones head at once).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.