packages feed

ghcup-0.2.7.0 / lib / GHCup / Prelude / String / QQ.hs

{-# LANGUAGE TemplateHaskellQuotes #-}{-# LANGUAGE QuasiQuotes #-}module GHCup.Prelude.String.QQ  ( s  )whereimport Data.Charimport GHC.Exts                  ( IsString (..) )import Language.Haskell.TH.Quote-- | QuasiQuoter for a non-interpolating ASCII IsString literal.-- The pattern portion is undefined.s :: QuasiQuoters = QuasiQuoter  (\s' -> if all isAscii s'    then (\a -> [|fromString a|]) . trimLeadingNewline . removeCRs $ s'    else fail "Not ascii"  )  (error "Cannot use s as a pattern")  (error "Cannot use s as a type")  (error "Cannot use s as a dec") where  removeCRs = filter (/= '\r')  trimLeadingNewline ('\n' : xs) = xs  trimLeadingNewline xs          = xs