1{-# LANGUAGE TemplateHaskell #-}
3module StringsQQ (strings, longstring) where
5import Language.Haskell.TH
6import Language.Haskell.TH.Quote
8import Data.Char (toUpper)
10strings = QuasiQuoter { quotePat = undefined,
11 quoteType = undefined,
12 quoteExp = stringsExp,
13 quoteDec = undefined }
15-- stringE = return . LitE . StringL
17stringsExp :: String -> Q Exp
18stringsExp = foldr (\x xs -> [e| $(x) : $(xs) |]) [e| [] |]
19 . map delta . filter (not . null) . map words . lines
20 where delta [(x:xs)] = [e| ( $(stringE $ x:xs )
21 , $(stringE $ toUpper x : xs ) ) |]
22 delta [xs,ys] = [e| ( $(stringE xs) , $(stringE ys) ) |]
24longstring = QuasiQuoter { quotePat = undefined,
25 quoteType = undefined,
26 quoteExp = longstringExp,
27 quoteDec = undefined }
29longstringExp ('\n':xs) = stringE xs
30longstringExp xs = stringE xs
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list