Skip to content

Instantly share code, notes, and snippets.

@remysucre
Created November 6, 2017 04:37
Show Gist options
  • Save remysucre/0eae2ee40e4abb4c48a2c8b429eb5569 to your computer and use it in GitHub Desktop.
Save remysucre/0eae2ee40e4abb4c48a2c8b429eb5569 to your computer and use it in GitHub Desktop.
srcloc for bangs
{-# LANGUAGE BangPatterns #-}
module Main where
import Language.Haskell.Exts
import Language.Haskell.Exts.Syntax
import Data.Generics.Uniplate.DataOnly
main :: IO ()
main = do
ParseOk s <- parseFile "/Users/rem/exp/app/Main.hs"
let !locs = [ l | PBangPat l p <- universeBi s] :: [SrcSpanInfo]
print locs
@remysucre
Copy link
Author

Nvm you don't need to -1, the first column is exactly where the bang is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment