code
stringlengths 5
1.03M
| repo_name
stringlengths 5
90
| path
stringlengths 4
158
| license
stringclasses 15
values | size
int64 5
1.03M
| n_ast_errors
int64 0
53.9k
| ast_max_depth
int64 2
4.17k
| n_whitespaces
int64 0
365k
| n_ast_nodes
int64 3
317k
| n_ast_terminals
int64 1
171k
| n_ast_nonterminals
int64 1
146k
| loc
int64 -1
37.3k
| cycloplexity
int64 -1
1.31k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
{- |
Module : $Header$
Description : Signatures for DL logics, as extension of CASL signatures
Copyright : (c) Klaus Luettich, Uni Bremen 2004
License : GPLv2 or higher, see LICENSE.txt
Maintainer : [email protected]
Stability : provisional
Portability : portable
Signatures for DL logics, as extension of CASL signatures.
-}
module CASL_DL.Sign where
import qualified Data.Map as Map
import Common.Id
import Common.Doc
import Common.DocUtils
import CASL.AS_Basic_CASL
import CASL_DL.AS_CASL_DL
import CASL_DL.Print_AS ()
import Data.List (union, (\\), isPrefixOf)
import Control.Exception
data CASL_DLSign =
CASL_DLSign { annoProperties :: Map.Map SIMPLE_ID PropertyType
, annoPropertySens :: [AnnoAppl]
} deriving (Show, Eq, Ord)
data PropertyType = AnnoProperty
| OntoProperty deriving (Show, Eq, Ord)
data AnnoAppl = AnnoAppl SIMPLE_ID Id AnnoLiteral
deriving (Show, Eq, Ord)
data AnnoLiteral = AL_Term (TERM DL_FORMULA)
| AL_Id Id
deriving (Show, Eq, Ord)
emptyCASL_DLSign :: CASL_DLSign
emptyCASL_DLSign = CASL_DLSign Map.empty []
addCASL_DLSign :: CASL_DLSign -> CASL_DLSign -> CASL_DLSign
addCASL_DLSign a b = a
{ annoProperties =
Map.unionWithKey (throwAnnoError "CASL_DL.Sign.addCASL_DLSign:")
(annoProperties a) (annoProperties b)
, annoPropertySens = union (annoPropertySens a) (annoPropertySens b)
}
throwAnnoError :: String -> SIMPLE_ID
-> PropertyType -> PropertyType -> PropertyType
throwAnnoError s k e1 e2 =
if e1 == e2
then e1
else error $ s ++ " Annotation Properties and Ontology Properties "
++ "must have distinct names! (" ++ show k ++ ")"
diffCASL_DLSign :: CASL_DLSign -> CASL_DLSign -> CASL_DLSign
diffCASL_DLSign a b = a
{ annoProperties = Map.difference (annoProperties a) (annoProperties b)
, annoPropertySens = (annoPropertySens a) \\ (annoPropertySens b)
}
isSubCASL_DLSign :: CASL_DLSign -> CASL_DLSign -> Bool
isSubCASL_DLSign a b =
Map.isSubmapOf (annoProperties a) (annoProperties b) &&
(annoPropertySens a `isSublistOf` annoPropertySens b)
instance Pretty CASL_DLSign where
pretty dlSign = if Map.null $ annoProperties dlSign
then assert (null $ annoPropertySens dlSign) empty
else printPropertyList AnnoProperty
"%OWLAnnoProperties("
$+$
printPropertyList OntoProperty
"%OWLOntologyProperties("
$+$
if null (annoPropertySens dlSign)
then empty
else text "%OWLAnnotations(" <+>
vcat (punctuate (text "; ") $
(map pretty $
annoPropertySens dlSign)) <+>
text ")%"
where propertyList ty = filter (\ (_,x) -> x==ty) $
Map.toList $ annoProperties dlSign
printPropertyList ty str =
case propertyList ty of
[] -> empty
l -> text str <+>
fcat (punctuate comma $
map (pretty . fst) l) <+>
text ")%"
instance Pretty AnnoAppl where
pretty (AnnoAppl rel subj obj) = pretty rel <>
parens (pretty subj<>comma<>pretty obj)
instance Pretty AnnoLiteral where
pretty annoLit = case annoLit of
AL_Term t -> pretty t
AL_Id i -> pretty i
isSublistOf :: (Eq a) => [a] -> [a] -> Bool
isSublistOf ys l = case l of
[] -> null ys
_ : l' -> isPrefixOf ys l || isSublistOf ys l'
|
nevrenato/Hets_Fork
|
CASL_DL/Sign.hs
|
gpl-2.0
| 3,976 | 0 | 18 | 1,404 | 925 | 479 | 446 | 80 | 2 |
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables,
PatternGuards #-}
{-
Copyright (C) 2006-2014 John MacFarlane <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
Module : Text.Pandoc.Writers.LaTeX
Copyright : Copyright (C) 2006-2014 John MacFarlane
License : GNU GPL, version 2 or above
Maintainer : John MacFarlane <[email protected]>
Stability : alpha
Portability : portable
Conversion of 'Pandoc' format into LaTeX.
-}
module Text.Pandoc.Writers.LaTeX ( writeLaTeX ) where
import Text.Pandoc.Definition
import Text.Pandoc.Walk
import Text.Pandoc.Shared
import Text.Pandoc.Writers.Shared
import Text.Pandoc.Options
import Text.Pandoc.Templates
import Text.Printf ( printf )
import Network.URI ( isURI, unEscapeString )
import Data.List ( (\\), isSuffixOf, isInfixOf, stripPrefix,
isPrefixOf, intercalate, intersperse )
import Data.Char ( toLower, isPunctuation, isAscii, isLetter, isDigit, ord )
import Data.Maybe ( fromMaybe )
import Control.Applicative ((<|>))
import Control.Monad.State
import Text.Pandoc.Pretty
import Text.Pandoc.Slides
import Text.Pandoc.Highlighting (highlight, styleToLaTeX,
formatLaTeXInline, formatLaTeXBlock,
toListingsLanguage)
data WriterState =
WriterState { stInNote :: Bool -- true if we're in a note
, stInQuote :: Bool -- true if in a blockquote
, stInMinipage :: Bool -- true if in minipage
, stInHeading :: Bool -- true if in a section heading
, stNotes :: [Doc] -- notes in a minipage
, stOLLevel :: Int -- level of ordered list nesting
, stOptions :: WriterOptions -- writer options, so they don't have to be parameter
, stVerbInNote :: Bool -- true if document has verbatim text in note
, stTable :: Bool -- true if document has a table
, stStrikeout :: Bool -- true if document has strikeout
, stUrl :: Bool -- true if document has visible URL link
, stGraphics :: Bool -- true if document contains images
, stLHS :: Bool -- true if document has literate haskell code
, stBook :: Bool -- true if document uses book or memoir class
, stCsquotes :: Bool -- true if document uses csquotes
, stHighlighting :: Bool -- true if document has highlighted code
, stIncremental :: Bool -- true if beamer lists should be displayed bit by bit
, stInternalLinks :: [String] -- list of internal link targets
, stUsesEuro :: Bool -- true if euro symbol used
}
-- | Convert Pandoc to LaTeX.
writeLaTeX :: WriterOptions -> Pandoc -> String
writeLaTeX options document =
evalState (pandocToLaTeX options document) $
WriterState { stInNote = False, stInQuote = False,
stInMinipage = False, stInHeading = False,
stNotes = [], stOLLevel = 1,
stOptions = options, stVerbInNote = False,
stTable = False, stStrikeout = False,
stUrl = False, stGraphics = False,
stLHS = False, stBook = writerChapters options,
stCsquotes = False, stHighlighting = False,
stIncremental = writerIncremental options,
stInternalLinks = [], stUsesEuro = False }
pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
pandocToLaTeX options (Pandoc meta blocks) = do
-- Strip off final 'references' header if --natbib or --biblatex
let method = writerCiteMethod options
let blocks' = if method == Biblatex || method == Natbib
then case reverse blocks of
(Div (_,["references"],_) _):xs -> reverse xs
_ -> blocks
else blocks
-- see if there are internal links
let isInternalLink (Link _ ('#':xs,_)) = [xs]
isInternalLink _ = []
modify $ \s -> s{ stInternalLinks = query isInternalLink blocks' }
let template = writerTemplate options
-- set stBook depending on documentclass
let bookClasses = ["memoir","book","report","scrreprt","scrbook"]
case lookup "documentclass" (writerVariables options) of
Just x | x `elem` bookClasses -> modify $ \s -> s{stBook = True}
| otherwise -> return ()
Nothing | any (\x -> "\\documentclass" `isPrefixOf` x &&
(any (`isSuffixOf` x) bookClasses))
(lines template) -> modify $ \s -> s{stBook = True}
| otherwise -> return ()
-- check for \usepackage...{csquotes}; if present, we'll use
-- \enquote{...} for smart quotes:
when ("{csquotes}" `isInfixOf` template) $
modify $ \s -> s{stCsquotes = True}
let colwidth = if writerWrapText options
then Just $ writerColumns options
else Nothing
metadata <- metaToJSON options
(fmap (render colwidth) . blockListToLaTeX)
(fmap (render colwidth) . inlineListToLaTeX)
meta
let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
(blocks', [])
else case last blocks' of
Header 1 _ il -> (init blocks', il)
_ -> (blocks', [])
blocks''' <- if writerBeamer options
then toSlides blocks''
else return blocks''
body <- mapM (elementToLaTeX options) $ hierarchicalize blocks'''
(biblioTitle :: String) <- liftM (render colwidth) $ inlineListToLaTeX lastHeader
let main = render colwidth $ vsep body
st <- get
titleMeta <- stringToLaTeX TextString $ stringify $ docTitle meta
authorsMeta <- mapM (stringToLaTeX TextString . stringify) $ docAuthors meta
let context = defField "toc" (writerTableOfContents options) $
defField "toc-depth" (show (writerTOCDepth options -
if stBook st
then 1
else 0)) $
defField "body" main $
defField "title-meta" titleMeta $
defField "author-meta" (intercalate "; " authorsMeta) $
defField "documentclass" (if writerBeamer options
then ("beamer" :: String)
else if stBook st
then "book"
else "article") $
defField "verbatim-in-note" (stVerbInNote st) $
defField "tables" (stTable st) $
defField "strikeout" (stStrikeout st) $
defField "url" (stUrl st) $
defField "numbersections" (writerNumberSections options) $
defField "lhs" (stLHS st) $
defField "graphics" (stGraphics st) $
defField "book-class" (stBook st) $
defField "euro" (stUsesEuro st) $
defField "listings" (writerListings options || stLHS st) $
defField "beamer" (writerBeamer options) $
defField "mainlang" (maybe "" (reverse . takeWhile (/=',') . reverse)
(lookup "lang" $ writerVariables options)) $
(if stHighlighting st
then defField "highlighting-macros" (styleToLaTeX
$ writerHighlightStyle options )
else id) $
(case writerCiteMethod options of
Natbib -> defField "biblio-title" biblioTitle .
defField "natbib" True
Biblatex -> defField "biblio-title" biblioTitle .
defField "biblatex" True
_ -> id) $
metadata
return $ if writerStandalone options
then renderTemplate' template context
else main
-- | Convert Elements to LaTeX
elementToLaTeX :: WriterOptions -> Element -> State WriterState Doc
elementToLaTeX _ (Blk block) = blockToLaTeX block
elementToLaTeX opts (Sec level _ (id',classes,_) title' elements) = do
modify $ \s -> s{stInHeading = True}
header' <- sectionHeader ("unnumbered" `elem` classes) id' level title'
modify $ \s -> s{stInHeading = False}
innerContents <- mapM (elementToLaTeX opts) elements
return $ vsep (header' : innerContents)
data StringContext = TextString
| URLString
| CodeString
deriving (Eq)
-- escape things as needed for LaTeX
stringToLaTeX :: StringContext -> String -> State WriterState String
stringToLaTeX _ [] = return ""
stringToLaTeX ctx (x:xs) = do
opts <- gets stOptions
rest <- stringToLaTeX ctx xs
let ligatures = writerTeXLigatures opts && ctx == TextString
let isUrl = ctx == URLString
when (x == '€') $
modify $ \st -> st{ stUsesEuro = True }
return $
case x of
'€' -> "\\euro{}" ++ rest
'{' -> "\\{" ++ rest
'}' -> "\\}" ++ rest
'$' -> "\\$" ++ rest
'%' -> "\\%" ++ rest
'&' -> "\\&" ++ rest
'_' | not isUrl -> "\\_" ++ rest
'#' -> "\\#" ++ rest
'-' | not isUrl -> case xs of
-- prevent adjacent hyphens from forming ligatures
('-':_) -> "-\\/" ++ rest
_ -> '-' : rest
'~' | not isUrl -> "\\textasciitilde{}" ++ rest
'^' -> "\\^{}" ++ rest
'\\'| isUrl -> '/' : rest -- NB. / works as path sep even on Windows
| otherwise -> "\\textbackslash{}" ++ rest
'|' -> "\\textbar{}" ++ rest
'<' -> "\\textless{}" ++ rest
'>' -> "\\textgreater{}" ++ rest
'[' -> "{[}" ++ rest -- to avoid interpretation as
']' -> "{]}" ++ rest -- optional arguments
'\'' | ctx == CodeString -> "\\textquotesingle{}" ++ rest
'\160' -> "~" ++ rest
'\x2026' -> "\\ldots{}" ++ rest
'\x2018' | ligatures -> "`" ++ rest
'\x2019' | ligatures -> "'" ++ rest
'\x201C' | ligatures -> "``" ++ rest
'\x201D' | ligatures -> "''" ++ rest
'\x2014' | ligatures -> "---" ++ rest
'\x2013' | ligatures -> "--" ++ rest
_ -> x : rest
toLabel :: String -> State WriterState String
toLabel z = go `fmap` stringToLaTeX URLString z
where go [] = ""
go (x:xs)
| (isLetter x || isDigit x) && isAscii x = x:go xs
| elem x ("-+=:;." :: String) = x:go xs
| otherwise = "ux" ++ printf "%x" (ord x) ++ go xs
-- | Puts contents into LaTeX command.
inCmd :: String -> Doc -> Doc
inCmd cmd contents = char '\\' <> text cmd <> braces contents
toSlides :: [Block] -> State WriterState [Block]
toSlides bs = do
opts <- gets stOptions
let slideLevel = fromMaybe (getSlideLevel bs) $ writerSlideLevel opts
let bs' = prepSlides slideLevel bs
concat `fmap` (mapM (elementToBeamer slideLevel) $ hierarchicalize bs')
elementToBeamer :: Int -> Element -> State WriterState [Block]
elementToBeamer _slideLevel (Blk b) = return [b]
elementToBeamer slideLevel (Sec lvl _num (ident,classes,kvs) tit elts)
| lvl > slideLevel = do
bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
return $ Para ( RawInline "latex" "\\begin{block}{"
: tit ++ [RawInline "latex" "}"] )
: bs ++ [RawBlock "latex" "\\end{block}"]
| lvl < slideLevel = do
bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
return $ (Header lvl (ident,classes,kvs) tit) : bs
| otherwise = do -- lvl == slideLevel
-- note: [fragile] is required or verbatim breaks
let hasCodeBlock (CodeBlock _ _) = [True]
hasCodeBlock _ = []
let hasCode (Code _ _) = [True]
hasCode _ = []
opts <- gets stOptions
let fragile = not $ null $ query hasCodeBlock elts ++
if writerListings opts
then query hasCode elts
else []
let allowframebreaks = "allowframebreaks" `elem` classes
let optionslist = ["fragile" | fragile] ++
["allowframebreaks" | allowframebreaks]
let options = if null optionslist
then ""
else "[" ++ intercalate "," optionslist ++ "]"
let slideStart = Para $ RawInline "latex" ("\\begin{frame}" ++ options) :
if tit == [Str "\0"] -- marker for hrule
then []
else (RawInline "latex" "{") : tit ++ [RawInline "latex" "}"]
let slideEnd = RawBlock "latex" "\\end{frame}"
-- now carve up slide into blocks if there are sections inside
bs <- concat `fmap` mapM (elementToBeamer slideLevel) elts
return $ slideStart : bs ++ [slideEnd]
isListBlock :: Block -> Bool
isListBlock (BulletList _) = True
isListBlock (OrderedList _ _) = True
isListBlock (DefinitionList _) = True
isListBlock _ = False
isLineBreakOrSpace :: Inline -> Bool
isLineBreakOrSpace LineBreak = True
isLineBreakOrSpace Space = True
isLineBreakOrSpace _ = False
-- | Convert Pandoc block element to LaTeX.
blockToLaTeX :: Block -- ^ Block to convert
-> State WriterState Doc
blockToLaTeX Null = return empty
blockToLaTeX (Div (identifier,classes,_) bs) = do
beamer <- writerBeamer `fmap` gets stOptions
ref <- toLabel identifier
let linkAnchor = if null identifier
then empty
else "\\hyperdef{}" <> braces (text ref) <> "{}"
contents <- blockListToLaTeX bs
if beamer && "notes" `elem` classes -- speaker notes
then return $ "\\note" <> braces contents
else return (linkAnchor $$ contents)
blockToLaTeX (Plain lst) =
inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
-- title beginning with fig: indicates that the image is a figure
blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
inNote <- gets stInNote
capt <- inlineListToLaTeX txt
img <- inlineToLaTeX (Image txt (src,tit))
return $ if inNote
-- can't have figures in notes
then "\\begin{center}" $$ img $+$ capt $$ "\\end{center}"
else "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
("\\caption" <> braces capt) $$ "\\end{figure}"
-- . . . indicates pause in beamer slides
blockToLaTeX (Para [Str ".",Space,Str ".",Space,Str "."]) = do
beamer <- writerBeamer `fmap` gets stOptions
if beamer
then blockToLaTeX (RawBlock "latex" "\\pause")
else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."]
blockToLaTeX (Para lst) =
inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
blockToLaTeX (BlockQuote lst) = do
beamer <- writerBeamer `fmap` gets stOptions
case lst of
[b] | beamer && isListBlock b -> do
oldIncremental <- gets stIncremental
modify $ \s -> s{ stIncremental = not oldIncremental }
result <- blockToLaTeX b
modify $ \s -> s{ stIncremental = oldIncremental }
return result
_ -> do
oldInQuote <- gets stInQuote
modify (\s -> s{stInQuote = True})
contents <- blockListToLaTeX lst
modify (\s -> s{stInQuote = oldInQuote})
return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
opts <- gets stOptions
ref <- toLabel identifier
let linkAnchor = if null identifier
then empty
else "\\hyperdef{}" <> braces (text ref) <>
braces ("\\label" <> braces (text ref))
let lhsCodeBlock = do
modify $ \s -> s{ stLHS = True }
return $ flush (linkAnchor $$ "\\begin{code}" $$ text str $$
"\\end{code}") $$ cr
let rawCodeBlock = do
st <- get
env <- if stInNote st
then modify (\s -> s{ stVerbInNote = True }) >>
return "Verbatim"
else return "verbatim"
return $ flush (linkAnchor $$ text ("\\begin{" ++ env ++ "}") $$
text str $$ text ("\\end{" ++ env ++ "}")) <> cr
let listingsCodeBlock = do
st <- get
let params = if writerListings (stOptions st)
then (case getListingsLanguage classes of
Just l -> [ "language=" ++ l ]
Nothing -> []) ++
[ "numbers=left" | "numberLines" `elem` classes
|| "number" `elem` classes
|| "number-lines" `elem` classes ] ++
[ (if key == "startFrom"
then "firstnumber"
else key) ++ "=" ++ attr |
(key,attr) <- keyvalAttr ] ++
(if identifier == ""
then []
else [ "label=" ++ ref ])
else []
printParams
| null params = empty
| otherwise = brackets $ hcat (intersperse ", " (map text params))
return $ flush ("\\begin{lstlisting}" <> printParams $$ text str $$
"\\end{lstlisting}") $$ cr
let highlightedCodeBlock =
case highlight formatLaTeXBlock ("",classes,keyvalAttr) str of
Nothing -> rawCodeBlock
Just h -> modify (\st -> st{ stHighlighting = True }) >>
return (flush $ linkAnchor $$ text h)
case () of
_ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes &&
"literate" `elem` classes -> lhsCodeBlock
| writerListings opts -> listingsCodeBlock
| writerHighlight opts && not (null classes) -> highlightedCodeBlock
| otherwise -> rawCodeBlock
blockToLaTeX (RawBlock f x)
| f == Format "latex" || f == Format "tex"
= return $ text x
| otherwise = return empty
blockToLaTeX (BulletList []) = return empty -- otherwise latex error
blockToLaTeX (BulletList lst) = do
incremental <- gets stIncremental
let inc = if incremental then "[<+->]" else ""
items <- mapM listItemToLaTeX lst
let spacing = if isTightList lst
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
else empty
return $ text ("\\begin{itemize}" ++ inc) $$ spacing $$ vcat items $$
"\\end{itemize}"
blockToLaTeX (OrderedList _ []) = return empty -- otherwise latex error
blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
st <- get
let inc = if stIncremental st then "[<+->]" else ""
let oldlevel = stOLLevel st
put $ st {stOLLevel = oldlevel + 1}
items <- mapM listItemToLaTeX lst
modify (\s -> s {stOLLevel = oldlevel})
let tostyle x = case numstyle of
Decimal -> "\\arabic" <> braces x
UpperRoman -> "\\Roman" <> braces x
LowerRoman -> "\\roman" <> braces x
UpperAlpha -> "\\Alph" <> braces x
LowerAlpha -> "\\alph" <> braces x
Example -> "\\arabic" <> braces x
DefaultStyle -> "\\arabic" <> braces x
let todelim x = case numdelim of
OneParen -> x <> ")"
TwoParens -> parens x
Period -> x <> "."
_ -> x <> "."
let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)
let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim
then empty
else "\\def" <> "\\label" <> enum <>
braces (todelim $ tostyle enum)
let resetcounter = if start == 1 || oldlevel > 4
then empty
else "\\setcounter" <> braces enum <>
braces (text $ show $ start - 1)
let spacing = if isTightList lst
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
else empty
return $ text ("\\begin{enumerate}" ++ inc)
$$ stylecommand
$$ resetcounter
$$ spacing
$$ vcat items
$$ "\\end{enumerate}"
blockToLaTeX (DefinitionList []) = return empty
blockToLaTeX (DefinitionList lst) = do
incremental <- gets stIncremental
let inc = if incremental then "[<+->]" else ""
items <- mapM defListItemToLaTeX lst
let spacing = if all isTightList (map snd lst)
then text "\\itemsep1pt\\parskip0pt\\parsep0pt"
else empty
return $ text ("\\begin{description}" ++ inc) $$ spacing $$ vcat items $$
"\\end{description}"
blockToLaTeX HorizontalRule = return $
"\\begin{center}\\rule{0.5\\linewidth}{\\linethickness}\\end{center}"
blockToLaTeX (Header level (id',classes,_) lst) = do
modify $ \s -> s{stInHeading = True}
hdr <- sectionHeader ("unnumbered" `elem` classes) id' level lst
modify $ \s -> s{stInHeading = False}
return hdr
blockToLaTeX (Table caption aligns widths heads rows) = do
headers <- if all null heads
then return empty
else ($$ "\\midrule\n") `fmap`
(tableRowToLaTeX True aligns widths) heads
let endhead = if all null heads
then empty
else text "\\endhead"
captionText <- inlineListToLaTeX caption
let capt = if isEmpty captionText
then empty
else text "\\caption" <> braces captionText
<> "\\tabularnewline\n\\toprule\n"
<> headers
<> "\\endfirsthead"
rows' <- mapM (tableRowToLaTeX False aligns widths) rows
let colDescriptors = text $ concat $ map toColDescriptor aligns
modify $ \s -> s{ stTable = True }
return $ "\\begin{longtable}[c]" <>
braces ("@{}" <> colDescriptors <> "@{}")
-- the @{} removes extra space at beginning and end
$$ capt
$$ "\\toprule"
$$ headers
$$ endhead
$$ vcat rows'
$$ "\\bottomrule"
$$ "\\end{longtable}"
toColDescriptor :: Alignment -> String
toColDescriptor align =
case align of
AlignLeft -> "l"
AlignRight -> "r"
AlignCenter -> "c"
AlignDefault -> "l"
blockListToLaTeX :: [Block] -> State WriterState Doc
blockListToLaTeX lst = vsep `fmap` mapM blockToLaTeX lst
tableRowToLaTeX :: Bool
-> [Alignment]
-> [Double]
-> [[Block]]
-> State WriterState Doc
tableRowToLaTeX header aligns widths cols = do
-- scale factor compensates for extra space between columns
-- so the whole table isn't larger than columnwidth
let scaleFactor = 0.97 ** fromIntegral (length aligns)
let widths' = map (scaleFactor *) widths
cells <- mapM (tableCellToLaTeX header) $ zip3 widths' aligns cols
return $ hsep (intersperse "&" cells) <> "\\tabularnewline"
-- For simple latex tables (without minipages or parboxes),
-- we need to go to some lengths to get line breaks working:
-- as LineBreak bs = \vtop{\hbox{\strut as}\hbox{\strut bs}}.
fixLineBreaks :: Block -> Block
fixLineBreaks (Para ils) = Para $ fixLineBreaks' ils
fixLineBreaks (Plain ils) = Plain $ fixLineBreaks' ils
fixLineBreaks x = x
fixLineBreaks' :: [Inline] -> [Inline]
fixLineBreaks' ils = case splitBy (== LineBreak) ils of
[] -> []
[xs] -> xs
chunks -> RawInline "tex" "\\vtop{" :
concatMap tohbox chunks ++
[RawInline "tex" "}"]
where tohbox ys = RawInline "tex" "\\hbox{\\strut " : ys ++
[RawInline "tex" "}"]
-- We also change display math to inline math, since display
-- math breaks in simple tables.
displayMathToInline :: Inline -> Inline
displayMathToInline (Math DisplayMath x) = Math InlineMath x
displayMathToInline x = x
tableCellToLaTeX :: Bool -> (Double, Alignment, [Block])
-> State WriterState Doc
tableCellToLaTeX _ (0, _, blocks) =
blockListToLaTeX $ walk fixLineBreaks $ walk displayMathToInline blocks
tableCellToLaTeX header (width, align, blocks) = do
modify $ \st -> st{ stInMinipage = True, stNotes = [] }
cellContents <- blockListToLaTeX blocks
notes <- gets stNotes
modify $ \st -> st{ stInMinipage = False, stNotes = [] }
let valign = text $ if header then "[b]" else "[t]"
let halign = case align of
AlignLeft -> "\\raggedright"
AlignRight -> "\\raggedleft"
AlignCenter -> "\\centering"
AlignDefault -> "\\raggedright"
return $ ("\\begin{minipage}" <> valign <>
braces (text (printf "%.2f\\columnwidth" width)) <>
(halign <> "\\strut" <> cr <> cellContents <> cr) <>
"\\strut\\end{minipage}")
$$ case notes of
[] -> empty
ns -> (case length ns of
n | n > 1 -> "\\addtocounter" <>
braces "footnote" <>
braces (text $ show $ 1 - n)
| otherwise -> empty)
$$
vcat (intersperse
("\\addtocounter" <> braces "footnote" <> braces "1")
$ map (\x -> "\\footnotetext" <> braces x)
$ reverse ns)
listItemToLaTeX :: [Block] -> State WriterState Doc
listItemToLaTeX lst
-- we need to put some text before a header if it's the first
-- element in an item. This will look ugly in LaTeX regardless, but
-- this will keep the typesetter from throwing an error.
| ((Header _ _ _) :_) <- lst =
blockListToLaTeX lst >>= return . (text "\\item ~" $$) . (nest 2)
| otherwise = blockListToLaTeX lst >>= return . (text "\\item" $$) .
(nest 2)
defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
defListItemToLaTeX (term, defs) = do
term' <- inlineListToLaTeX term
-- put braces around term if it contains an internal link,
-- since otherwise we get bad bracket interactions: \item[\hyperref[..]
let isInternalLink (Link _ ('#':_,_)) = True
isInternalLink _ = False
let term'' = if any isInternalLink term
then braces term'
else term'
def' <- liftM vsep $ mapM blockListToLaTeX defs
return $ case defs of
(((Header _ _ _) : _) : _) ->
"\\item" <> brackets term'' <> " ~ " $$ def'
_ ->
"\\item" <> brackets term'' $$ def'
-- | Craft the section header, inserting the secton reference, if supplied.
sectionHeader :: Bool -- True for unnumbered
-> [Char]
-> Int
-> [Inline]
-> State WriterState Doc
sectionHeader unnumbered ref level lst = do
txt <- inlineListToLaTeX lst
lab <- text `fmap` toLabel ref
plain <- stringToLaTeX TextString $ foldl (++) "" $ map stringify lst
let noNote (Note _) = Str ""
noNote x = x
let lstNoNotes = walk noNote lst
txtNoNotes <- inlineListToLaTeX lstNoNotes
let star = if unnumbered then text "*" else empty
-- footnotes in sections don't work (except for starred variants)
-- unless you specify an optional argument:
-- \section[mysec]{mysec\footnote{blah}}
optional <- if unnumbered || lstNoNotes == lst
then return empty
else do
return $ brackets txtNoNotes
let contents = if render Nothing txt == plain
then braces txt
else braces (text "\\texorpdfstring"
<> braces txt
<> braces (text plain))
let stuffing = star <> optional <> contents
book <- gets stBook
opts <- gets stOptions
let level' = if book || writerChapters opts then level - 1 else level
internalLinks <- gets stInternalLinks
let refLabel x = (if ref `elem` internalLinks
then text "\\hyperdef"
<> braces empty
<> braces lab
<> braces x
else x)
let headerWith x y = refLabel $ text x <> y <>
if null ref
then empty
else text "\\label" <> braces lab
let sectionType = case level' of
0 | writerBeamer opts -> "part"
| otherwise -> "chapter"
1 -> "section"
2 -> "subsection"
3 -> "subsubsection"
4 -> "paragraph"
5 -> "subparagraph"
_ -> ""
inQuote <- gets stInQuote
let prefix = if inQuote && level' >= 4
then text "\\mbox{}%"
-- needed for \paragraph, \subparagraph in quote environment
-- see http://tex.stackexchange.com/questions/169830/
else empty
return $ if level' > 5
then txt
else prefix $$
headerWith ('\\':sectionType) stuffing
$$ if unnumbered
then "\\addcontentsline{toc}" <>
braces (text sectionType) <>
braces txtNoNotes
else empty
-- | Convert list of inline elements to LaTeX.
inlineListToLaTeX :: [Inline] -- ^ Inlines to convert
-> State WriterState Doc
inlineListToLaTeX lst =
mapM inlineToLaTeX (fixBreaks $ fixLineInitialSpaces lst)
>>= return . hcat
-- nonbreaking spaces (~) in LaTeX don't work after line breaks,
-- so we turn nbsps after hard breaks to \hspace commands.
-- this is mostly used in verse.
where fixLineInitialSpaces [] = []
fixLineInitialSpaces (LineBreak : Str s@('\160':_) : xs) =
LineBreak : fixNbsps s ++ fixLineInitialSpaces xs
fixLineInitialSpaces (x:xs) = x : fixLineInitialSpaces xs
fixNbsps s = let (ys,zs) = span (=='\160') s
in replicate (length ys) hspace ++ [Str zs]
hspace = RawInline "latex" "\\hspace*{0.333em}"
-- linebreaks after blank lines cause problems:
fixBreaks [] = []
fixBreaks ys@(LineBreak : LineBreak : _) =
case span (== LineBreak) ys of
(lbs, rest) -> RawInline "latex"
("\\\\[" ++ show (length lbs) ++
"\\baselineskip]") : fixBreaks rest
fixBreaks (y:ys) = y : fixBreaks ys
isQuoted :: Inline -> Bool
isQuoted (Quoted _ _) = True
isQuoted _ = False
-- | Convert inline element to LaTeX
inlineToLaTeX :: Inline -- ^ Inline to convert
-> State WriterState Doc
inlineToLaTeX (Span (id',classes,_) ils) = do
let noEmph = "csl-no-emph" `elem` classes
let noStrong = "csl-no-strong" `elem` classes
let noSmallCaps = "csl-no-smallcaps" `elem` classes
ref <- toLabel id'
let linkAnchor = if null id'
then empty
else "\\hyperdef{}" <> braces (text ref) <> "{}"
fmap (linkAnchor <>)
((if noEmph then inCmd "textup" else id) .
(if noStrong then inCmd "textnormal" else id) .
(if noSmallCaps then inCmd "textnormal" else id) .
(if not (noEmph || noStrong || noSmallCaps)
then braces
else id)) `fmap` inlineListToLaTeX ils
inlineToLaTeX (Emph lst) =
inlineListToLaTeX lst >>= return . inCmd "emph"
inlineToLaTeX (Strong lst) =
inlineListToLaTeX lst >>= return . inCmd "textbf"
inlineToLaTeX (Strikeout lst) = do
-- we need to protect VERB in an mbox or we get an error
-- see #1294
contents <- inlineListToLaTeX $ protectCode lst
modify $ \s -> s{ stStrikeout = True }
return $ inCmd "sout" contents
inlineToLaTeX (Superscript lst) =
inlineListToLaTeX lst >>= return . inCmd "textsuperscript"
inlineToLaTeX (Subscript lst) = do
inlineListToLaTeX lst >>= return . inCmd "textsubscript"
inlineToLaTeX (SmallCaps lst) =
inlineListToLaTeX lst >>= return . inCmd "textsc"
inlineToLaTeX (Cite cits lst) = do
st <- get
let opts = stOptions st
case writerCiteMethod opts of
Natbib -> citationsToNatbib cits
Biblatex -> citationsToBiblatex cits
_ -> inlineListToLaTeX lst
inlineToLaTeX (Code (_,classes,_) str) = do
opts <- gets stOptions
case () of
_ | writerListings opts -> listingsCode
| writerHighlight opts && not (null classes) -> highlightCode
| otherwise -> rawCode
where listingsCode = do
inNote <- gets stInNote
when inNote $ modify $ \s -> s{ stVerbInNote = True }
let chr = case "!\"&'()*,-./:;?@_" \\ str of
(c:_) -> c
[] -> '!'
return $ text $ "\\lstinline" ++ [chr] ++ str ++ [chr]
highlightCode = do
case highlight formatLaTeXInline ("",classes,[]) str of
Nothing -> rawCode
Just h -> modify (\st -> st{ stHighlighting = True }) >>
return (text h)
rawCode = liftM (text . (\s -> "\\texttt{" ++ escapeSpaces s ++ "}"))
$ stringToLaTeX CodeString str
where
escapeSpaces = concatMap (\c -> if c == ' ' then "\\ " else [c])
inlineToLaTeX (Quoted qt lst) = do
contents <- inlineListToLaTeX lst
csquotes <- liftM stCsquotes get
opts <- gets stOptions
if csquotes
then return $ "\\enquote" <> braces contents
else do
let s1 = if (not (null lst)) && (isQuoted (head lst))
then "\\,"
else empty
let s2 = if (not (null lst)) && (isQuoted (last lst))
then "\\,"
else empty
let inner = s1 <> contents <> s2
return $ case qt of
DoubleQuote ->
if writerTeXLigatures opts
then text "``" <> inner <> text "''"
else char '\x201C' <> inner <> char '\x201D'
SingleQuote ->
if writerTeXLigatures opts
then char '`' <> inner <> char '\''
else char '\x2018' <> inner <> char '\x2019'
inlineToLaTeX (Str str) = liftM text $ stringToLaTeX TextString str
inlineToLaTeX (Math InlineMath str) =
return $ "\\(" <> text str <> "\\)"
inlineToLaTeX (Math DisplayMath str) =
return $ "\\[" <> text str <> "\\]"
inlineToLaTeX (RawInline f str)
| f == Format "latex" || f == Format "tex"
= return $ text str
| otherwise = return empty
inlineToLaTeX (LineBreak) = return "\\\\"
inlineToLaTeX Space = return space
inlineToLaTeX (Link txt ('#':ident, _)) = do
contents <- inlineListToLaTeX txt
lab <- toLabel ident
return $ text "\\hyperref" <> brackets (text lab) <> braces contents
inlineToLaTeX (Link txt (src, _)) =
case txt of
[Str x] | escapeURI x == src -> -- autolink
do modify $ \s -> s{ stUrl = True }
src' <- stringToLaTeX URLString src
return $ text $ "\\url{" ++ src' ++ "}"
[Str x] | Just rest <- stripPrefix "mailto:" src,
escapeURI x == rest -> -- email autolink
do modify $ \s -> s{ stUrl = True }
src' <- stringToLaTeX URLString src
contents <- inlineListToLaTeX txt
return $ "\\href" <> braces (text src') <>
braces ("\\nolinkurl" <> braces contents)
_ -> do contents <- inlineListToLaTeX txt
src' <- stringToLaTeX URLString src
return $ text ("\\href{" ++ src' ++ "}{") <>
contents <> char '}'
inlineToLaTeX (Image _ (source, _)) = do
modify $ \s -> s{ stGraphics = True }
let source' = if isURI source
then source
else unEscapeString source
source'' <- stringToLaTeX URLString source'
inHeading <- gets stInHeading
return $
(if inHeading then "\\protect\\includegraphics" else "\\includegraphics")
<> braces (text source'')
inlineToLaTeX (Note contents) = do
inMinipage <- gets stInMinipage
modify (\s -> s{stInNote = True})
contents' <- blockListToLaTeX contents
modify (\s -> s {stInNote = False})
let optnl = case reverse contents of
(CodeBlock _ _ : _) -> cr
_ -> empty
let noteContents = nest 2 contents' <> optnl
opts <- gets stOptions
-- in beamer slides, display footnote from current overlay forward
let beamerMark = if writerBeamer opts
then text "<.->"
else empty
modify $ \st -> st{ stNotes = noteContents : stNotes st }
return $
if inMinipage
then "\\footnotemark{}"
-- note: a \n before } needed when note ends with a Verbatim environment
else "\\footnote" <> beamerMark <> braces noteContents
protectCode :: [Inline] -> [Inline]
protectCode [] = []
protectCode (x@(Code ("",[],[]) _) : xs) = x : protectCode xs
protectCode (x@(Code _ _) : xs) = ltx "\\mbox{" : x : ltx "}" : xs
where ltx = RawInline (Format "latex")
protectCode (x : xs) = x : protectCode xs
citationsToNatbib :: [Citation] -> State WriterState Doc
citationsToNatbib (one:[])
= citeCommand c p s k
where
Citation { citationId = k
, citationPrefix = p
, citationSuffix = s
, citationMode = m
}
= one
c = case m of
AuthorInText -> "citet"
SuppressAuthor -> "citeyearpar"
NormalCitation -> "citep"
citationsToNatbib cits
| noPrefix (tail cits) && noSuffix (init cits) && ismode NormalCitation cits
= citeCommand "citep" p s ks
where
noPrefix = all (null . citationPrefix)
noSuffix = all (null . citationSuffix)
ismode m = all (((==) m) . citationMode)
p = citationPrefix $ head $ cits
s = citationSuffix $ last $ cits
ks = intercalate ", " $ map citationId cits
citationsToNatbib (c:cs) | citationMode c == AuthorInText = do
author <- citeCommand "citeauthor" [] [] (citationId c)
cits <- citationsToNatbib (c { citationMode = SuppressAuthor } : cs)
return $ author <+> cits
citationsToNatbib cits = do
cits' <- mapM convertOne cits
return $ text "\\citetext{" <> foldl combineTwo empty cits' <> text "}"
where
combineTwo a b | isEmpty a = b
| otherwise = a <> text "; " <> b
convertOne Citation { citationId = k
, citationPrefix = p
, citationSuffix = s
, citationMode = m
}
= case m of
AuthorInText -> citeCommand "citealt" p s k
SuppressAuthor -> citeCommand "citeyear" p s k
NormalCitation -> citeCommand "citealp" p s k
citeCommand :: String -> [Inline] -> [Inline] -> String -> State WriterState Doc
citeCommand c p s k = do
args <- citeArguments p s k
return $ text ("\\" ++ c) <> args
citeArguments :: [Inline] -> [Inline] -> String -> State WriterState Doc
citeArguments p s k = do
let s' = case s of
(Str (x:[]) : r) | isPunctuation x -> dropWhile (== Space) r
(Str (x:xs) : r) | isPunctuation x -> Str xs : r
_ -> s
pdoc <- inlineListToLaTeX p
sdoc <- inlineListToLaTeX s'
let optargs = case (isEmpty pdoc, isEmpty sdoc) of
(True, True ) -> empty
(True, False) -> brackets sdoc
(_ , _ ) -> brackets pdoc <> brackets sdoc
return $ optargs <> braces (text k)
citationsToBiblatex :: [Citation] -> State WriterState Doc
citationsToBiblatex (one:[])
= citeCommand cmd p s k
where
Citation { citationId = k
, citationPrefix = p
, citationSuffix = s
, citationMode = m
} = one
cmd = case m of
SuppressAuthor -> "autocite*"
AuthorInText -> "textcite"
NormalCitation -> "autocite"
citationsToBiblatex (c:cs) = do
args <- mapM convertOne (c:cs)
return $ text cmd <> foldl (<>) empty args
where
cmd = case citationMode c of
AuthorInText -> "\\textcites"
_ -> "\\autocites"
convertOne Citation { citationId = k
, citationPrefix = p
, citationSuffix = s
}
= citeArguments p s k
citationsToBiblatex _ = return empty
-- Determine listings language from list of class attributes.
getListingsLanguage :: [String] -> Maybe String
getListingsLanguage [] = Nothing
getListingsLanguage (x:xs) = toListingsLanguage x <|> getListingsLanguage xs
|
sapek/pandoc
|
src/Text/Pandoc/Writers/LaTeX.hs
|
gpl-2.0
| 42,870 | 0 | 36 | 15,059 | 11,507 | 5,770 | 5,737 | 840 | 33 |
{-# LANGUAGE PatternGuards #-}
{-
Copyright (C) 2014 Jesse Rosenthal <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
Module : Text.TeXMath.Readers.OMML
Copyright : Copyright (C) 2014 Jesse Rosenthal
License : GNU GPL, version 2 or above
Maintainer : Jesse Rosenthal <[email protected]>
Stability : alpha
Portability : portable
Types and functions for conversion of OMML into TeXMath 'Exp's.
-}
module Text.TeXMath.Readers.OMML (readOMML) where
import Text.XML.Light
import Data.Maybe (isJust, mapMaybe, fromMaybe)
import Data.List (intercalate)
import Data.Char (isDigit)
import Text.TeXMath.Types
import Text.TeXMath.Shared (fixTree, getSpaceWidth, getOperator)
import Text.TeXMath.Unicode.ToTeX (getSymbolType)
import Control.Applicative ((<$>))
-- As we constuct from the bottom up, this situation can occur.
readOMML :: String -> Either String [Exp]
readOMML s | Just e <- parseXMLDoc s =
case elemToOMML e of
Just exs -> Right $ map fixTree $ unGroup exs
Nothing -> Left "xml file was not an <m:oMathPara> or <m:oMath> element."
readOMML _ = Left "Couldn't parse OMML file"
unGroup :: [Exp] -> [Exp]
unGroup [EGrouped exps] = exps
unGroup exps = exps
elemToOMML :: Element -> Maybe [Exp]
elemToOMML element | isElem "m" "oMathPara" element = do
let expList = mapMaybe elemToOMML (elChildren element)
return $ map (\l -> if length l == 1 then (head l) else EGrouped l) expList
elemToOMML element | isElem "m" "oMath" element =
Just $ concat $ mapMaybe (elemToExps) (elChildren element)
elemToOMML _ = Nothing
isElem :: String -> String -> Element -> Bool
isElem prefix name element =
let qp = fromMaybe "" (qPrefix (elName element))
in
qName (elName element) == name &&
qp == prefix
hasElemName:: String -> String -> QName -> Bool
hasElemName prefix name qn =
let qp = fromMaybe "" (qPrefix qn)
in
qName qn == name &&
qp == prefix
data OMathRunElem = TextRun String
| LnBrk
| Tab
deriving Show
data OMathRunTextStyle = NoStyle
| Normal
| Styled { oMathScript :: Maybe OMathTextScript
, oMathStyle :: Maybe OMathTextStyle }
deriving Show
data OMathTextScript = ORoman
| OScript
| OFraktur
| ODoubleStruck
| OSansSerif
| OMonospace
deriving (Show, Eq)
data OMathTextStyle = OPlain
| OBold
| OItalic
| OBoldItalic
deriving (Show, Eq)
elemToBase :: Element -> Maybe Exp
elemToBase element | isElem "m" "e" element = do
bs <- elemToBases element
return $ case bs of
(e : []) -> e
exps -> EGrouped exps
elemToBase _ = Nothing
elemToBases :: Element -> Maybe [Exp]
elemToBases element | isElem "m" "e" element =
return $ concat $ mapMaybe elemToExps' (elChildren element)
elemToBases _ = Nothing
-- TODO: The right way to do this is to use the ampersand to break the
-- text lines into multiple columns. That's tricky, though, and this
-- will get us most of the way for the time being.
filterAmpersand :: Exp -> Exp
filterAmpersand (EIdentifier s) = EIdentifier (filter ('&' /=) s)
filterAmpersand (EText tt s) = EText tt (filter ('&' /=) s)
filterAmpersand (EStyled tt exps) = EStyled tt (map filterAmpersand exps)
filterAmpersand (EGrouped exps) = EGrouped (map filterAmpersand exps)
filterAmpersand e = e
elemToOMathRunTextStyle :: Element -> OMathRunTextStyle
elemToOMathRunTextStyle element
| Just mrPr <- filterChildName (hasElemName"m" "rPr") element
, Just _ <- filterChildName (hasElemName"m" "nor") mrPr =
Normal
| Just mrPr <- filterChildName (hasElemName"m" "rPr") element =
let scr =
case
filterChildName (hasElemName"m" "scr") mrPr >>=
findAttrBy (hasElemName"m" "val")
of
Just "roman" -> Just ORoman
Just "script" -> Just OScript
Just "fraktur" -> Just OFraktur
Just "double-struck" -> Just ODoubleStruck
Just "sans-serif" -> Just OSansSerif
Just "monospace" -> Just OMonospace
_ -> Nothing
sty =
case
filterChildName (hasElemName"m" "sty") mrPr >>=
findAttrBy (hasElemName"m" "val")
of
Just "p" -> Just OPlain
Just "b" -> Just OBold
Just "i" -> Just OItalic
Just "bi" -> Just OBoldItalic
_ -> Nothing
in
Styled { oMathScript = scr, oMathStyle = sty }
| otherwise = NoStyle
elemToOMathRunElem :: Element -> Maybe OMathRunElem
elemToOMathRunElem element
| isElem "w" "t" element
|| isElem "m" "t" element
|| isElem "w" "delText" element = Just $ TextRun $ strContent element
| isElem "w" "br" element = Just LnBrk
| isElem "w" "tab" element = Just Tab
| otherwise = Nothing
elemToOMathRunElems :: Element -> Maybe [OMathRunElem]
elemToOMathRunElems element
| isElem "w" "r" element
|| isElem "m" "r" element =
Just $ mapMaybe (elemToOMathRunElem) (elChildren element)
elemToOMathRunElems _ = Nothing
----- And now the TeXMath Creation
oMathRunElemToString :: OMathRunElem -> String
oMathRunElemToString (TextRun s) = s
oMathRunElemToString (LnBrk) = ['\n']
oMathRunElemToString (Tab) = ['\t']
oMathRunElemsToString :: [OMathRunElem] -> String
oMathRunElemsToString = concatMap oMathRunElemToString
oMathRunTextStyleToTextType :: OMathRunTextStyle -> Maybe TextType
oMathRunTextStyleToTextType (Normal) = Just $ TextNormal
oMathRunTextStyleToTextType (NoStyle) = Nothing
oMathRunTextStyleToTextType (Styled scr sty)
| Just OBold <- sty
, Just OSansSerif <- scr =
Just $ TextSansSerifBold
| Just OBoldItalic <- sty
, Just OSansSerif <- scr =
Just $ TextSansSerifBoldItalic
| Just OBold <- sty
, Just OScript <- scr =
Just $ TextBoldScript
| Just OBold <- sty
, Just OFraktur <- scr =
Just $ TextBoldFraktur
| Just OItalic <- sty
, Just OSansSerif <- scr =
Just $ TextSansSerifItalic
| Just OBold <- sty =
Just $ TextBold
| Just OItalic <- sty =
Just $ TextItalic
| Just OMonospace <- scr =
Just $ TextMonospace
| Just OSansSerif <- scr =
Just $ TextSansSerif
| Just ODoubleStruck <- scr =
Just $ TextDoubleStruck
| Just OScript <- scr =
Just $ TextScript
| Just OFraktur <- scr =
Just $ TextFraktur
| Just OBoldItalic <- sty =
Just $ TextBoldItalic
| otherwise = Nothing
elemToExps :: Element -> Maybe [Exp]
elemToExps element = unGroup <$> elemToExps' element
elemToExps' :: Element -> Maybe [Exp]
elemToExps' element | isElem "m" "acc" element = do
let chr = filterChildName (hasElemName "m" "accPr") element >>=
filterChildName (hasElemName "m" "chr") >>=
findAttrBy (hasElemName "m" "val") >>=
Just . head
chr' = case chr of
Just c -> c
Nothing -> '^' -- default to hat.
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
return $ [EOver False baseExp (ESymbol Accent [chr'])]
elemToExps' element | isElem "m" "bar" element = do
pos <- filterChildName (hasElemName "m" "barPr") element >>=
filterChildName (hasElemName "m" "pos") >>=
findAttrBy (hasElemName "m" "val")
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
case pos of
"top" -> Just [EOver False baseExp (ESymbol Accent "\175")]
"bot" -> Just [EUnder False baseExp (ESymbol Accent "\818")]
_ -> Nothing
elemToExps' element | isElem "m" "box" element = do
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
return [baseExp]
elemToExps' element | isElem "m" "borderBox" element = do
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
return [EBoxed baseExp]
elemToExps' element | isElem "m" "d" element =
let baseExps = mapMaybe
elemToBases
(elChildren element)
inDelimExps = map (map Right) baseExps
dPr = filterChildName (hasElemName "m" "dPr") element
begChr = dPr >>=
filterChildName (hasElemName "m" "begChr") >>=
findAttrBy (hasElemName "m" "val") >>=
(\c -> if null c then (Just ' ') else (Just $ head c))
sepChr = dPr >>=
filterChildName (hasElemName "m" "sepChr") >>=
findAttrBy (hasElemName "m" "val") >>=
(\c -> if null c then (Just ' ') else (Just $ head c))
endChr = dPr >>=
filterChildName (hasElemName "m" "endChr") >>=
findAttrBy (hasElemName "m" "val") >>=
(\c -> if null c then (Just ' ') else (Just $ head c))
beg = fromMaybe '(' begChr
end = fromMaybe ')' endChr
sep = fromMaybe '|' sepChr
exps = intercalate [Left [sep]] inDelimExps
in
Just [EDelimited [beg] [end] exps]
elemToExps' element | isElem "m" "eqArr" element =
let expLst = mapMaybe elemToBases (elChildren element)
expLst' = map (\es -> [map filterAmpersand es]) expLst
in
return [EArray [] expLst']
elemToExps' element | isElem "m" "f" element = do
num <- filterChildName (hasElemName "m" "num") element
den <- filterChildName (hasElemName "m" "den") element
let numExp = EGrouped $ concat $ mapMaybe (elemToExps) (elChildren num)
denExp = EGrouped $ concat $ mapMaybe (elemToExps) (elChildren den)
return $ [EFraction NormalFrac numExp denExp]
elemToExps' element | isElem "m" "func" element = do
fName <- filterChildName (hasElemName "m" "fName") element
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
-- We need a string for the fname, but omml gives it to us as a
-- series of oMath elems. We're going to filter out the oMathRuns,
-- which should work for us most of the time.
let fnameString = concatMap expToString $
concat $ mapMaybe (elemToExps) (elChildren fName)
return [EMathOperator fnameString, baseExp]
elemToExps' element | isElem "m" "groupChr" element = do
let gPr = filterChildName (hasElemName "m" "groupChrPr") element
chr = gPr >>=
filterChildName (hasElemName "m" "chr") >>=
findAttrBy (hasElemName "m" "val")
pos = gPr >>=
filterChildName (hasElemName "m" "pos") >>=
findAttrBy (hasElemName "m" "val")
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
case pos of
Just "top" ->
let chr' = case chr of
Just (c:_) -> c
_ -> '\65079' -- default to overbrace
in
return [EOver False baseExp (ESymbol Accent [chr'])]
Just "bot" ->
let chr' = case chr of
Just (c:_) -> c
_ -> '\65080' -- default to underbrace
in
return [EUnder False baseExp (ESymbol Accent [chr'])]
_ -> Nothing
elemToExps' element | isElem "m" "limLow" element = do
baseExp <- filterChildName (hasElemName "m" "e") element
>>= elemToBase
limExp <- filterChildName (hasElemName "m" "lim") element
>>= (\e -> Just $ concat $ mapMaybe (elemToExps) (elChildren e))
>>= (return . EGrouped)
return [EUnder True baseExp limExp]
elemToExps' element | isElem "m" "limUpp" element = do
baseExp <- filterChildName (hasElemName "m" "e") element
>>= elemToBase
limExp <- filterChildName (hasElemName "m" "lim") element
>>= (\e -> Just $ concat $ mapMaybe (elemToExps) (elChildren e))
>>= (return . EGrouped)
return [EOver True limExp baseExp]
elemToExps' element | isElem "m" "m" element =
let rows = filterChildrenName (hasElemName "m" "mr") element
rowExps = map
(\mr -> mapMaybe
elemToBases
(elChildren mr))
rows
in
return [EArray [AlignCenter] rowExps]
elemToExps' element | isElem "m" "nary" element = do
let naryPr = filterChildName (hasElemName "m" "naryPr") element
naryChr = naryPr >>=
filterChildName (hasElemName "m" "chr") >>=
findAttrBy (hasElemName "m" "val")
opChr = case naryChr of
Just (c:_) -> c
_ -> '\8747' -- default to integral
limLoc = naryPr >>=
filterChildName (hasElemName "m" "limLoc") >>=
findAttrBy (hasElemName "m" "val")
subExps <- filterChildName (hasElemName "m" "sub") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
supExps <- filterChildName (hasElemName "m" "sup") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
case limLoc of
Just "undOvr" -> return [EUnderover True
(ESymbol Op [opChr])
(EGrouped subExps)
(EGrouped supExps)
, baseExp]
_ -> return [ESubsup
(ESymbol Op [opChr])
(EGrouped subExps)
(EGrouped supExps)
, baseExp]
elemToExps' element | isElem "m" "phant" element = do
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
return [EPhantom baseExp]
elemToExps' element | isElem "m" "rad" element = do
degExps <- filterChildName (hasElemName "m" "deg") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
return $ case degExps of
[] -> [ESqrt baseExp]
ds -> [ERoot (EGrouped ds) baseExp]
elemToExps' element | isElem "m" "sPre" element = do
subExps <- filterChildName (hasElemName "m" "sub") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
supExps <- filterChildName (hasElemName "m" "sup") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
return [ESubsup
(EIdentifier "")
(EGrouped subExps)
(EGrouped supExps)
, baseExp]
elemToExps' element | isElem "m" "sSub" element = do
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
subExps <- filterChildName (hasElemName "m" "sub") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
return [ESub baseExp (EGrouped subExps)]
elemToExps' element | isElem "m" "sSubSup" element = do
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
subExps <- filterChildName (hasElemName "m" "sub") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
supExps <- filterChildName (hasElemName "m" "sup") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
return [ESubsup baseExp (EGrouped subExps) (EGrouped supExps)]
elemToExps' element | isElem "m" "sSup" element = do
baseExp <- filterChildName (hasElemName "m" "e") element >>=
elemToBase
supExps <- filterChildName (hasElemName "m" "sup") element >>=
(\e -> return $ concat $ mapMaybe (elemToExps) (elChildren e))
return [ESuper baseExp (EGrouped supExps)]
elemToExps' element | isElem "m" "r" element = do
let mrPr = filterChildName (hasElemName "m" "rPr") element
lit = mrPr >>=
filterChildName (hasElemName "m" "lit") >>=
findAttrBy (hasElemName "m" "val")
txtSty = elemToOMathRunTextStyle element
mrElems <- elemToOMathRunElems element
return $ case oMathRunTextStyleToTextType txtSty of
Nothing -> interpretString $ oMathRunElemsToString mrElems
Just textType ->
case lit of
Just "on" ->
[EText textType (oMathRunElemsToString mrElems)]
_ ->
[EStyled textType $ interpretString $ oMathRunElemsToString mrElems]
elemToExps' _ = Nothing
interpretChar :: Char -> Exp
interpretChar c | isDigit c = ENumber [c]
interpretChar c = case getSymbolType c of
Alpha -> EIdentifier [c]
Ord | isDigit c -> ENumber [c]
| otherwise -> case getSpaceWidth c of
Just x -> ESpace x
Nothing -> ESymbol Ord [c]
symType -> ESymbol symType [c]
interpretString :: String -> [Exp]
interpretString [c] = [interpretChar c]
interpretString s
| all isDigit s = [ENumber s]
| isJust (getOperator (EMathOperator s))
= [EMathOperator s]
| otherwise =
case map interpretChar s of
xs | all isIdentifierOrSpace xs -> [EText TextNormal s]
| otherwise -> xs
where isIdentifierOrSpace (EIdentifier _) = True
isIdentifierOrSpace (ESpace _) = True
isIdentifierOrSpace _ = False
expToString :: Exp -> String
expToString (ENumber s) = s
expToString (EIdentifier s) = s
expToString (EMathOperator s) = s
expToString (ESymbol _ s) = s
expToString (EText _ s) = s
expToString (EGrouped exps) = concatMap expToString exps
expToString (EStyled _ exps) = concatMap expToString exps
expToString _ = ""
|
timtylin/scholdoc-texmath
|
src/Text/TeXMath/Readers/OMML.hs
|
gpl-2.0
| 18,428 | 0 | 20 | 5,230 | 5,522 | 2,666 | 2,856 | 393 | 16 |
{-# LANGUAGE NoImplicitPrelude, RankNTypes #-}
module Lamdu.GUI.RedundantAnnotations
( markAnnotationsToDisplay
) where
import Control.Lens (Lens')
import qualified Control.Lens as Lens
import Control.Lens.Operators
import qualified Lamdu.GUI.ExpressionGui.Types as T
import qualified Lamdu.Sugar.Lens as SugarLens
import Lamdu.Sugar.Types
import Prelude.Compat
showAnn :: Lens' (Payload m0 T.Payload) T.ShowAnnotation
showAnn = plData . T.plShowAnnotation
dontShowEval :: Expression name m T.Payload -> Expression name m T.Payload
dontShowEval = rPayload . showAnn . T.showInEvalMode .~ T.EvalModeShowNothing
dontShowAnnotation :: Expression name m T.Payload -> Expression name m T.Payload
dontShowAnnotation = rPayload . showAnn .~ T.neverShowAnnotations
forceShowType :: Expression name m T.Payload -> Expression name m T.Payload
forceShowType =
rPayload . showAnn %~
(T.showExpanded .~ True) .
(T.showInEvalMode .~ T.EvalModeShowType)
forceShowTypeOrEval :: Expression name m T.Payload -> Expression name m T.Payload
forceShowTypeOrEval =
rPayload . showAnn %~
(T.showExpanded .~ True) .
(T.showInEvalMode .~ T.EvalModeShowEval)
markAnnotationsToDisplay ::
Expression name m T.Payload ->
Expression name m T.Payload
markAnnotationsToDisplay (Expression oldBody pl) =
case newBody of
BodyLiteral LiteralNum {} ->
Expression newBody pl & dontShowAnnotation
BodyLiteral LiteralText {}->
Expression newBody pl & dontShowAnnotation
BodyLiteral LiteralBytes {} ->
Expression newBody pl & dontShowEval
BodyRecord _ ->
Expression newBody pl & dontShowAnnotation
BodyLam _ ->
Expression newBody pl & dontShowAnnotation
BodyGetVar (GetParam Param { _pBinderMode = LightLambda }) ->
Expression newBody pl
BodyGetVar (GetParam Param { _pBinderMode = NormalBinder }) ->
Expression newBody pl & dontShowAnnotation
BodyGetVar (GetBinder BinderVar { _bvForm = GetDefinition }) ->
Expression newBody pl
BodyGetVar (GetBinder BinderVar { _bvForm = GetLet }) ->
Expression newBody pl & dontShowAnnotation
BodyFromNom _ ->
Expression (newBody <&> dontShowEval) pl
BodyToNom _ ->
Expression (newBody <&> dontShowEval) pl
BodyInject _ ->
Expression newBody pl & dontShowEval
BodyGetVar (GetParamsRecord _) ->
Expression newBody pl
BodyGetField _ ->
Expression newBody pl
BodyApply app ->
Expression (BodyApply (app & aFunc %~ dontShowAnnotation)) pl
BodyHole hole ->
Expression (BodyHole hole') pl & forceShowType
where
hole' = hole & holeMArg . Lens._Just . haExpr %~ forceShowTypeOrEval
BodyCase cas ->
Expression (BodyCase cas') pl
where
cas' =
cas
-- cKind contains the scrutinee which is not always
-- visible (for case alts that aren't lambdas), so
-- maybe we do want to show the annotation
& cKind . Lens.mapped %~ dontShowAnnotation
& cAlts . Lens.mapped . Lens.mapped %~
(rBody . _BodyLam . lamBinder . bBody . bbContent .
SugarLens.binderContentExpr %~ dontShowAnnotation) .
(rPayload . showAnn . T.funcApplyLimit .~ T.AtMostOneFuncApply)
where
newBody = oldBody <&> markAnnotationsToDisplay
|
da-x/lamdu
|
Lamdu/GUI/RedundantAnnotations.hs
|
gpl-3.0
| 3,484 | 0 | 18 | 892 | 892 | 452 | 440 | -1 | -1 |
{-# LANGUAGE NoImplicitPrelude, FlexibleInstances, UndecidableInstances #-}
module Control.MonadA(MonadA) where
import Prelude.Compat
class (Monad m, Applicative m) => MonadA m
instance (Monad m, Applicative m) => MonadA m
|
rvion/lamdu
|
bottlelib/Control/MonadA.hs
|
gpl-3.0
| 225 | 0 | 6 | 29 | 61 | 33 | 28 | -1 | -1 |
module Main where
import Control.Monad
import Data.Vector.Storable (fromList)
import Numeric.Units.Dimensional.Prelude (nano, meter,
(*~))
-- import Pipes
-- import qualified Pipes.Prelude as P
import Hkl
import Prelude hiding (lookup)
main :: IO ()
main = do
let sample = Sample "test" (Orthorhombic
(1.05394 *~ nano meter)
(0.25560 *~ nano meter)
(1.49050 *~ nano meter))
(Parameter "ux" (-89.8821) (Range (-180) 180))
(Parameter "uy" 0.1733 (Range (-180) 180))
(Parameter "uz" (-84.0081) (Range (-180) 180))
let geometry = Geometry Uhv (Source (0.0672929 *~ nano meter))
(fromList [0.1794, -160.0013, 21.1381, 0.5194])
(Just [ Parameter "mu" 0.1794 (Range (-180) 180)
, Parameter "omega" (-160.0013) (Range (-180) 180)
, Parameter "delta" 21.1381 (Range (-180) 180)
, Parameter "gamma" 0.5194 (Range (-180) 180)])
let detector = ZeroD
-- compute the pseudo axes values
pseudoAxes <- compute geometry detector sample
print pseudoAxes
-- solve a pseudo axis problem for the given engine
let engine = Engine "hkl" [ Parameter "h" 4.0 (Range (-1.0) 1.0)
, Parameter "k" 1.0 (Range (-1.0) 1.0)
, Parameter "l" 0.3 (Range (-1.0) 1.0)
]
(Mode "zaxis" [])
print =<< solve geometry detector sample engine
-- let from = fromList [0, 0, 1 :: Double]
-- let to = fromList [0, 1, 1 :: Double]
-- runEffect $ fromToPipe 20 from to
-- >-> P.print
-- -- solve a trajectory with Pipes
-- runEffect $ fromToPipe 10000 from to
-- >-> enginesTrajectoryPipe engine
-- >-> solveTrajPipe factory geometry detector sample
-- >-> P.print
-- -- >-> P.drain
return ()
|
picca/hkl
|
contrib/haskell/src/ghkl.hs
|
gpl-3.0
| 2,043 | 0 | 18 | 743 | 525 | 280 | 245 | 31 | 1 |
{-# LANGUAGE ExistentialQuantification #-}
-- Module : Network.Metric.Internal
-- Copyright : (c) 2012-2015 Brendan Hay <[email protected]>
-- License : This Source Code Form is subject to the terms of
-- the Mozilla Public License, v. 2.0.
-- A copy of the MPL can be found in the LICENSE file or
-- you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : experimental
-- Portability : non-portable (GHC extensions)
module Network.Metric.Internal (
-- * Exported Types
Handle(..)
, Host
, Group
, Bucket
, Metric(..)
-- * Existential Types
, AnyMeasurable(..)
, AnySink(..)
-- * Exported Type Classes
, Measurable(..)
, Encodable(..)
, Sink(..)
-- * General Functions
, key
-- * Socket Handle Functions
, fOpen
, hOpen
, hClose
, hPush
-- * Re-exports
, S.HostName
, S.PortNumber
) where
import Control.Monad (liftM, unless)
import Data.Typeable (Typeable)
import Data.Word (Word16)
import Text.Printf (printf)
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BL
import qualified Network.Socket as S
import qualified Network.Socket.ByteString.Lazy as SBL
-- | Socket handle
data Handle = Handle S.Socket S.SockAddr deriving (Show)
-- | Metric host
type Host = BS.ByteString
-- | Metric group
type Group = BS.ByteString
-- | Metric bucket
type Bucket = BS.ByteString
data Metric
= Counter Group Bucket Integer
| Timer Group Bucket Double
| Gauge Group Bucket Double
deriving (Show, Eq)
-- | Measure a type for a collection of metrics
class Measurable a where
-- | Convert a measurable instance from a host into a list of metrics
measure :: a -> [Metric]
-- | Metric value to be encoded
class (Show a, Typeable a) => Encodable a where
-- | Encode the value as a bytestring
encode :: a -> BS.ByteString
-- | Sink resource to write metrics to
class Sink a where
-- | Write a metric to the sink.
push :: Measurable b => a -> b -> IO ()
-- | Close the sink - subsequent writes will throw an error.
close :: a -> IO ()
-- | Any instance of the Measurable type class
data AnyMeasurable = forall a. Measurable a => AnyMeasurable a
-- | Any instance of the Sink type class
data AnySink = forall a. Sink a => AnySink a
instance Measurable AnyMeasurable where
measure (AnyMeasurable m) = measure m
instance Measurable Metric where
measure = flip (:) []
instance Encodable Int where
encode = BS.pack . show
instance Encodable Integer where
encode = BS.pack . show
instance Encodable Double where
encode = BS.pack . printf "%.8f"
instance Encodable String where
encode = BS.pack
-- | Existential sink instance
instance Sink AnySink where
push (AnySink s) = push s
close (AnySink s) = close s
-- | Combine a Host, Group and Bucket into a single key
key :: Maybe Host -> Group -> Bucket -> BS.ByteString
key (Just h) g b = BS.intercalate "." [h, g, b]
key Nothing g b = BS.intercalate "." [g, b]
-- | Helper to curry a constructor function for a sink
fOpen :: Sink a
=> (Handle -> a)
-> S.SocketType
-> S.HostName
-> S.PortNumber
-> IO AnySink
fOpen ctor typ host port = liftM (AnySink . ctor) (hOpen typ host port)
-- | Create a new socket handle (in a disconnected state) for UDP communication
hOpen :: S.SocketType -> S.HostName -> S.PortNumber -> IO Handle
hOpen typ host port = do
(addr:_) <- S.getAddrInfo Nothing (Just host) (Just . show . p2w $ port)
sock <- S.socket (S.addrFamily addr) typ S.defaultProtocol
return $ Handle sock (S.addrAddress addr)
where
p2w :: S.PortNumber -> Word16
p2w = fromIntegral
-- | Close a socket handle
hClose :: Handle -> IO ()
hClose (Handle sock _) = S.sClose sock
-- | Direct access for writing a bytestring to a socket handle
hPush :: Handle -> BL.ByteString -> IO ()
hPush (Handle sock addr) bstr | BL.null bstr = return ()
| otherwise = do
S.sIsConnected sock >>= \b -> unless b $ S.connect sock addr
_ <- SBL.send sock bstr
return ()
|
brendanhay/network-metrics
|
src/Network/Metric/Internal.hs
|
mpl-2.0
| 4,392 | 0 | 12 | 1,184 | 1,063 | 583 | 480 | 85 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-duplicate-exports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- |
-- Module : Network.Google.Resource.Analytics.Management.ProFiles.Patch
-- Copyright : (c) 2015-2016 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an existing view (profile). This method supports patch
-- semantics.
--
-- /See:/ <https://developers.google.com/analytics/ Google Analytics API Reference> for @analytics.management.profiles.patch@.
module Network.Google.Resource.Analytics.Management.ProFiles.Patch
(
-- * REST Resource
ManagementProFilesPatchResource
-- * Creating a Request
, managementProFilesPatch
, ManagementProFilesPatch
-- * Request Lenses
, mpfpWebPropertyId
, mpfpProFileId
, mpfpPayload
, mpfpAccountId
) where
import Network.Google.Analytics.Types
import Network.Google.Prelude
-- | A resource alias for @analytics.management.profiles.patch@ method which the
-- 'ManagementProFilesPatch' request conforms to.
type ManagementProFilesPatchResource =
"analytics" :>
"v3" :>
"management" :>
"accounts" :>
Capture "accountId" Text :>
"webproperties" :>
Capture "webPropertyId" Text :>
"profiles" :>
Capture "profileId" Text :>
QueryParam "alt" AltJSON :>
ReqBody '[JSON] ProFile :> Patch '[JSON] ProFile
-- | Updates an existing view (profile). This method supports patch
-- semantics.
--
-- /See:/ 'managementProFilesPatch' smart constructor.
data ManagementProFilesPatch =
ManagementProFilesPatch'
{ _mpfpWebPropertyId :: !Text
, _mpfpProFileId :: !Text
, _mpfpPayload :: !ProFile
, _mpfpAccountId :: !Text
}
deriving (Eq, Show, Data, Typeable, Generic)
-- | Creates a value of 'ManagementProFilesPatch' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'mpfpWebPropertyId'
--
-- * 'mpfpProFileId'
--
-- * 'mpfpPayload'
--
-- * 'mpfpAccountId'
managementProFilesPatch
:: Text -- ^ 'mpfpWebPropertyId'
-> Text -- ^ 'mpfpProFileId'
-> ProFile -- ^ 'mpfpPayload'
-> Text -- ^ 'mpfpAccountId'
-> ManagementProFilesPatch
managementProFilesPatch pMpfpWebPropertyId_ pMpfpProFileId_ pMpfpPayload_ pMpfpAccountId_ =
ManagementProFilesPatch'
{ _mpfpWebPropertyId = pMpfpWebPropertyId_
, _mpfpProFileId = pMpfpProFileId_
, _mpfpPayload = pMpfpPayload_
, _mpfpAccountId = pMpfpAccountId_
}
-- | Web property ID to which the view (profile) belongs
mpfpWebPropertyId :: Lens' ManagementProFilesPatch Text
mpfpWebPropertyId
= lens _mpfpWebPropertyId
(\ s a -> s{_mpfpWebPropertyId = a})
-- | ID of the view (profile) to be updated.
mpfpProFileId :: Lens' ManagementProFilesPatch Text
mpfpProFileId
= lens _mpfpProFileId
(\ s a -> s{_mpfpProFileId = a})
-- | Multipart request metadata.
mpfpPayload :: Lens' ManagementProFilesPatch ProFile
mpfpPayload
= lens _mpfpPayload (\ s a -> s{_mpfpPayload = a})
-- | Account ID to which the view (profile) belongs
mpfpAccountId :: Lens' ManagementProFilesPatch Text
mpfpAccountId
= lens _mpfpAccountId
(\ s a -> s{_mpfpAccountId = a})
instance GoogleRequest ManagementProFilesPatch where
type Rs ManagementProFilesPatch = ProFile
type Scopes ManagementProFilesPatch =
'["https://www.googleapis.com/auth/analytics.edit"]
requestClient ManagementProFilesPatch'{..}
= go _mpfpAccountId _mpfpWebPropertyId _mpfpProFileId
(Just AltJSON)
_mpfpPayload
analyticsService
where go
= buildClient
(Proxy :: Proxy ManagementProFilesPatchResource)
mempty
|
brendanhay/gogol
|
gogol-analytics/gen/Network/Google/Resource/Analytics/Management/ProFiles/Patch.hs
|
mpl-2.0
| 4,399 | 0 | 18 | 1,005 | 547 | 325 | 222 | 90 | 1 |
module MakeUpper where
import Data.Char
makeUpperCase :: [Char] -> [Char]
makeUpperCase = map toUpper
|
ice1000/OI-codes
|
codewars/101-200/makeuppercase.hs
|
agpl-3.0
| 104 | 0 | 6 | 16 | 32 | 19 | 13 | 4 | 1 |
lucky :: Int -> String
lucky 7 = "Lucky number seven!"
lucky x = "Sorry, you're out of luck, pal!"
factorial :: Int -> Int
factorial 0 = 1
factorial n = n * factorial (n - 1)
addVectors :: (Double, Double) -> (Double, Double) -> (Double, Double)
addVectors (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)
first :: (a, b, c) -> a
first (x, _, _) = x
second :: (a, b, c) -> b
second (_, y, _) = y
third :: (a, b, c) -> c
third (_, _, z) = z
head' :: [a] -> a
head' [] = error "Can't call head on an empty list, fool!"
head' (x:_) = x
head'2 :: [a] -> a
head'2 xs =
case xs of
[] -> error "No head for empty lists!"
(x:_) -> x
tell :: (Show a) => [a] -> String
tell [] = "The list is empty"
tell (x:[]) = "The list has one element: " ++ show x
tell (x:y:[]) = "The list has two elements: " ++ show x ++ " and " ++ show y
tell (x:y:_) = "The list is long. The first two elements are: " ++ show x ++ " and " ++ show y
badAdd :: (Num a) => [a] -> a
badAdd [x,y,z] = x + y + z
firstLetter :: String -> String
firstLetter "" = "Emtpy string, whoops!"
firstLetter all@(x:xs) = "The first letter of " ++ all ++ " is " ++ [x]
bmiTell :: Double -> Double -> String
bmiTell weight height
| bmi <= skinny = "You're underweight, you emo, you!"
| bmi <= normal = "You're supposedly normal. Pfft, I bet you're ugly!"
| bmi <= fat = "You're fat! Lose some weight, fatty!"
| otherwise = "You're a whale, congratulations!"
where (bmi, skinny, normal, fat) = (weight / height ^ 2, 18.5, 25.0, 30.0)
max' :: (Ord a) => a -> a -> a
max' a b
| a <= b = b
| otherwise = a
myCompare :: (Ord a) => a -> a -> Ordering
a `myCompare` b
| a == b = EQ
| a < b = LT
| otherwise = GT
badGreeting :: String
badGreeting = "Oh! Pfft. It's you."
niceGreeting :: String
niceGreeting = "Hello! So very nice to see you,"
greet :: String -> String
greet "Juan" = niceGreeting ++ " Juan!"
greet "Fernando" = niceGreeting ++ " Fernando!"
greet name = badGreeting ++ " " ++ name
initials :: String -> String -> String
initials firstname lastname = [f] ++ ". " ++ [l] ++ "."
where (f:_) = firstname
(l:_) = lastname
initials2 :: String -> String -> String
initials2 (f:_) (l:_) = [f] ++ ". " ++ [l] ++ "."
calcBmis :: [(Double, Double)] -> [Double]
calcBmis [] = []
calcBmis ((weight, height):xs) = bmi:calcBmis xs
where bmi = weight / height ^ 2
calcBmis2 :: [(Double, Double)] -> [Double]
calcBmis2 xs = [bmi w h| (w, h) <- xs]
where bmi w h = w / h ^ 2
cylinder :: Double -> Double -> Double
cylinder r h =
let sideArea = 2 * pi * r * h
topArea = pi * r ^ 2
in sideArea + 2 * topArea
calcBmis3 :: [(Double, Double)] -> [Double]
calcBmis3 xs = [bmi | (w, h) <- xs, let bmi = w / h ^ 2, bmi > 25.0]
describeList :: [a] -> String
describeList ls = "The list is " ++ case ls of
[] -> "empty."
[x] -> "a singleton list."
xs -> "a longer list."
describeList2 :: [a] -> String
describeList2 ls = "The list is " ++ what ls
where what [] = "empty."
what [x] = "a singleton list."
what xs = "a longer list."
sum' :: (Num a) => [a] -> a
sum' xs = foldl (\acc x -> acc + x) 0 xs
|
alexliew/learn_you_a_haskell
|
code/syntax.hs
|
unlicense
| 3,124 | 0 | 11 | 765 | 1,416 | 758 | 658 | 88 | 3 |
-- Exercises: Some Instances
-- Copied from: https://github.com/johnchandlerburnham/haskellbook/blob/master/26/MaybeT.hs
-- StateT
import Control.Monad.Trans
newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) }
instance (Functor m) => Functor (MaybeT m) where
fmap f (MaybeT ma) = MaybeT $ (fmap . fmap) f ma
instance (Applicative m) => Applicative (MaybeT m) where
pure x = MaybeT (pure (pure x))
MaybeT fab <*> MaybeT fa = MaybeT $ fmap (<*>) fab <*> fa
instance (Monad m) => Monad (MaybeT m) where
return = pure
MaybeT ma >>= f = MaybeT $ do
v <- ma
case v of
Nothing -> return Nothing
Just a -> runMaybeT $ f a
-- 1. MaybeT
instance MonadTrans MaybeT where
lift ma = MaybeT $ fmap Just ma
instance (MonadIO m) => MonadIO (MaybeT m) where
liftIO = lift . liftIO
|
dmp1ce/Haskell-Programming-Exercises
|
Chapter 26/Exercises: Some Instances.hs
|
unlicense
| 811 | 0 | 13 | 179 | 310 | 158 | 152 | 18 | 0 |
-- |Utility functions for STM.
module System.IO.FileSync.STM.Utils where
import Control.Concurrent (forkIO)
import Control.Concurrent.STM.TMVar
import Control.Concurrent.STM.TVar
import Control.Concurrent.STM.TQueue
import Data.Foldable (traverse_)
import Control.Monad.IO.Class (MonadIO(..))
import Control.Monad.Loops (whileJust)
import Control.Monad.STM
-- |Abstract type for a limit on the number of concurrent tasks.
-- This is a semaphore that might have an infinite value (no limit).
newtype TaskLimit = TaskLimit (TVar (Maybe Int))
-- |Descreases a task limit by 1, if it exists. If the value is already at
-- 0, the function blocks.
addTask :: TaskLimit -> STM ()
addTask (TaskLimit v) = do
v' <- readTVar v
case v' of Nothing -> return ()
Just v'' -> if v'' <= 0 then retry
else writeTVar v (fmap (subtract 1) v')
-- |Increases a value by one. A semaphore's "signal"-
removeTask :: TaskLimit -> STM ()
removeTask (TaskLimit l) = modifyTVar' l (fmap (+1))
-- |Performs an IO action, taking into account a TaskLimit, i.e.
-- blocking while it is @<=0@ and then temporarily decrementing it.
--
-- Note: this does not spawn a new thread.
withTaskLimit :: MonadIO m => TaskLimit -> m a -> m a
withTaskLimit lock m = do liftIO $ atomically $ addTask lock
res <- m
liftIO $ atomically $ removeTask lock
return res
-- |Reads all elements of a queue.
readWholeQueue :: TQueue a -> STM [a]
readWholeQueue q = whileJust (tryReadTQueue q) return
-- |Executes a collection of actions with a thread pool,
-- gathering the results in a qeue.
--
-- The function blocks until all actions have finished.
-- Ordering of the results is not guaranteed;
-- they are inserted as each task finishes.
--
-- This function is morally identical to 'Control.Parallel.Strategies.parMap'
-- in Control.Parallel.Strategies, with the difference that it takes
-- an @a -> IO b@ instead of @a -> b@.
parMapSTM :: (a -> IO b)
-- ^The function which is to be applied to each element
-- of the input.
-> [a]
-- ^Input data.
-> IO [b]
parMapSTM f inp = do
remaining <- atomically $ newTVar $ length inp
results <- atomically newTQueue
traverse_ (f' remaining results) inp
atomically (readTVar remaining >>= check . (<=0))
atomically (readWholeQueue results)
where
f' remaining results n =
forkIO (do result <- f n
atomically (writeTQueue results result
>> modifyTVar remaining (subtract 1)))
|
jtapolczai/FileSync
|
System/IO/FileSync/STM/Utils.hs
|
apache-2.0
| 2,663 | 0 | 16 | 683 | 561 | 296 | 265 | 38 | 3 |
{-# LANGUAGE OverloadedStrings #-}
module ID.Opts
( IDOpts(..)
, options
, execParser
) where
import Options.Applicative
data IDOpts = IDOpts
{ optConfig :: FilePath
} deriving (Show)
idOpts :: Parser IDOpts
idOpts = IDOpts
<$> strOption ( short 'c' <> long "config" <> metavar "CONFIG_FILE"
<> help "This is the location of the configuration file for ID options.")
options :: ParserInfo IDOpts
options = info (helper <*> idOpts)
( fullDesc
<> progDesc "Evolves web pages."
<> header "intelligent-design: designing web pages through evolution.")
|
erochest/intelligent-design
|
src/ID/Opts.hs
|
apache-2.0
| 683 | 0 | 11 | 220 | 138 | 74 | 64 | 18 | 1 |
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module PopVox.Types.Contrib
( Amount
, ContribInfo
, ContribEntry(..)
, ContribIndex
, ContribIndex'
) where
import Control.Applicative
import Data.Aeson
import Data.Aeson.Types (defaultOptions)
import Data.Csv hiding ((.:))
import qualified Data.Csv as CSV
import Data.Hashable
import qualified Data.HashSet as S
import Data.Monoid
import qualified Data.Text as T
import qualified Data.Text.Lazy.Builder as B
import GHC.Generics
import PopVox.Types.Common
type Amount = Double
type DistrictName = T.Text
type ContribInfo = (First DistrictName, Sum Amount)
type ContribInfo' = (Maybe DistrictName, Amount)
type ContribIndex = HashIndex ContribEntry ContribInfo
type ContribIndex' = HashIndex ContribEntry ContribInfo'
data ContribEntry
= Candidate
{ contribYear :: !Year
, contribParty :: !Party
}
| Committee
{ contribYear :: !Year
}
| StateLevel
{ contribYear :: !Year
, stateCode :: !T.Text
}
deriving (Show, Eq, Ord, Generic)
instance Hashable ContribEntry
last2 :: [a] -> [a]
last2 [] = []
last2 xs@[_] = xs
last2 xs@[_, _] = xs
last2 (_:xs) = last2 xs
instance ColumnHead ContribEntry where
columnBuilder (Candidate y p) = mconcat [ columnBuilder p
, B.fromString (last2 $ show y)
]
columnBuilder (Committee y) = mconcat [ ""
, B.fromString (last2 $ show y)
]
columnBuilder (StateLevel y st) = mconcat [ B.fromText st
, B.fromString (last2 $ show y)
]
stateCodes :: S.HashSet T.Text
stateCodes = S.fromList [ "AL" , "AK" , "AZ" , "AR" , "CA" , "CO"
, "CT" , "DE" , "DC" , "FL" , "GA" , "HI"
, "ID" , "IL" , "IN" , "IA" , "KS" , "KY"
, "LA" , "ME" , "MD" , "MA" , "MI" , "MN"
, "MS" , "MO" , "MT" , "NE" , "NV" , "NH"
, "NJ" , "NM" , "NY" , "NC" , "ND" , "OH"
, "OK" , "OR" , "PA" , "RI" , "SC" , "SD"
, "TN" , "TX" , "UT" , "VT" , "VA" , "WA"
, "WV" , "WI" , "WY"
]
instance FromNamedRecord ContribEntry where
parseNamedRecord m = do
rtype <- defaulting "CAND" <$> (m CSV..: "recipient_type" :: Parser T.Text)
case rtype of
"CAND" -> Candidate <$> m CSV..: "cycle"
<*> m CSV..: "recipient_party"
"COMM" -> Committee <$> m CSV..: "cycle"
r | r `S.member` stateCodes -> StateLevel <$> m CSV..: "cycle"
<*> pure r
| otherwise -> fail $ "Invalid recipient_type: " ++ T.unpack r
where
defaulting d v | T.null v = d
| otherwise = v
instance ToNamedRecord ContribEntry where
toNamedRecord (Candidate y p) =
namedRecord [ "recipient_type" CSV..= ("CAND" :: T.Text)
, "recipient_party" CSV..= toField p
, "cycle" CSV..= toField y
]
toNamedRecord (Committee y) =
namedRecord [ "recipient_type" CSV..= ("COMM" :: T.Text)
, "cycle" CSV..= toField y
]
toNamedRecord (StateLevel y st) =
namedRecord [ "recipient_type" CSV..= st
, "cycle" CSV..= toField y
]
instance ToJSON ContribEntry where
toJSON = genericToJSON defaultOptions
|
erochest/popvox-scrape
|
src/PopVox/Types/Contrib.hs
|
apache-2.0
| 4,069 | 0 | 14 | 1,719 | 1,013 | 565 | 448 | 95 | 1 |
-- Copyright 2020-2021 Google LLC
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
{-# LANGUAGE TypeApplications #-}
module SNumberLiterals where
import Data.SNumber (SNumber)
import DependentLiterals (valueOf)
import Kinds.Integer (Integer(..))
import Numeric.Natural (Natural)
x0 :: SNumber Natural ('Pos 0)
x0 = 0
x1 :: SNumber Natural ('Pos 4096)
x1 = 4096
x2 :: SNumber Natural ('Pos 77)
x2 = valueOf @77
x3 :: SNumber Natural ('Pos 77)
x3 = valueOf @('Pos 77)
x4 :: SNumber Int ('Pos 0)
x4 = 0
x5 :: SNumber Int ('Neg 4)
x5 = -4
x6 :: SNumber Int ('Neg 77)
x6 = valueOf @('Neg 77)
x7 :: SNumber Word ('Pos 7)
x7 = 7
x8 :: SNumber Prelude.Integer ('Neg 44)
x8 = -44
|
google/hs-dependent-literals
|
dependent-literals-plugin/tests/SNumberLiterals.hs
|
apache-2.0
| 1,193 | 0 | 9 | 217 | 304 | 168 | 136 | -1 | -1 |
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
-- ^ Common API definitions
module Api.Common where
import Data.Text (Text, unpack)
import Servant
import Types.Common
type GetMultiple = QueryParams "include" Text
:> QueryParam "where" Text
:> QueryParams "sort" Text
:> QueryParam "page" Int
:> QueryParam "per_page" Int
:> Get '[JSON] (Headers '[ Header "X-Page" String
, Header "X-Total-Count" String
, Header "X-Page-Count" String
, Header "X-Per-Page" String
, Header "Link" String
] [Record])
type GetSingle = Capture "id" Text :> Get '[JSON] (Headers '[Header "ETag" String] Record)
type HeadNoContent = Verb 'HEAD 204
type OptionsNoContent = Verb 'OPTIONS 204
-- |
-- Generic API description
type GenericApi =
-- get
GetMultiple
:<|> Header "If-None-Match" Text :> GetSingle
-- delete
:<|> Capture "id" Text :> DeleteNoContent '[JSON] NoContent
-- create
:<|> ReqBody '[JSON] (ApiData Record) :> PostCreated '[JSON] (Headers '[Header "Location" String, Header "Link" String] (ApiData ApiResult))
-- update (replace)
:<|> Capture "id" Text :> ReqBody '[JSON] Record :> Put '[JSON] Record
:<|> ReqBody '[JSON] [Record] :> Put '[JSON] [ApiResult]
-- update (modify)
:<|> Capture "id" Text :> ReqBody '[JSON] Record :> Patch '[JSON] Record
:<|> ReqBody '[JSON] [Record] :> Patch '[JSON] [ApiResult]
-- options
:<|> Capture "id" Text :> OptionsNoContent '[JSON] (Headers '[Header "Access-Control-Allow-Methods" String] NoContent)
:<|> OptionsNoContent '[JSON] (Headers '[Header "Access-Control-Allow-Methods" String] NoContent)
type ApiGetMultipleLink = [Text] -> Maybe Text -> [Text] -> Maybe Int -> Maybe Int -> String
perPageDefault :: Int
perPageDefault = 50
mkLink1
:: (MkLink endpoint ~ (a -> x), HasLink endpoint, ToHttpApiData x, IsElem endpoint api)
=> Proxy api -> Proxy endpoint -> a -> String
mkLink1 api method = mkPath . safeLink api method
mkLink2
:: (MkLink endpoint ~ (a -> b -> x)
,HasLink endpoint
,ToHttpApiData x
,IsElem endpoint api)
=> Proxy api -> Proxy endpoint -> a -> b -> String
mkLink2 api method a = mkPath . safeLink api method a
mkLink3
:: (MkLink endpoint ~ (a -> b -> c -> x)
,HasLink endpoint
,ToHttpApiData x
,IsElem endpoint api)
=> Proxy api -> Proxy endpoint -> a -> b -> c -> String
mkLink3 api method a b = mkPath . safeLink api method a b
mkLink4
:: (MkLink endpoint ~ (a -> b -> c -> d -> x)
,HasLink endpoint
,ToHttpApiData x
,IsElem endpoint api)
=> Proxy api -> Proxy endpoint -> a -> b -> c -> d -> String
mkLink4 api method a b c = mkPath . safeLink api method a b c
mkLink5
:: (MkLink endpoint ~ (a -> b -> c -> d -> e -> x)
,HasLink endpoint
,ToHttpApiData x
,IsElem endpoint api)
=> Proxy api -> Proxy endpoint -> a -> b -> c -> d -> e -> String
mkLink5 api method a b c d = mkPath . safeLink api method a b c d
mkLink6
:: (MkLink endpoint ~ (a -> b -> c -> d -> e -> f -> x)
,HasLink endpoint
,ToHttpApiData x
,IsElem endpoint api)
=> Proxy api -> Proxy endpoint -> a -> b -> c -> d -> e -> f -> String
mkLink6 api method a b c d e = mkPath . safeLink api method a b c d e
mkPath :: ToHttpApiData a => a -> String
mkPath = ("/" ++) . unpack . toUrlPiece
|
gabesoft/kapi
|
src/Api/Common.hs
|
bsd-3-clause
| 3,690 | 0 | 29 | 997 | 1,310 | 667 | 643 | 79 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeOperators #-}
module Ivory.OS.Posix.Tower.Signal where
import Ivory.Language
import Ivory.Tower
import Ivory.OS.Posix.Tower.EventLoop
data Watcher = Watcher
{ watcherName :: String
, watcherDefs :: (forall s. Ivory (AllocEffects s) ()) -> ModuleDef
, watcherInit :: forall eff. Ivory eff ()
}
instance Signalable Watcher where
signalName = watcherName
signalHandler = watcherDefs
signalInit = watcherInit
signalNumber = error "no signal numbers defined for Watcher"
data IOEventMask
= ReadOnly
| WriteOnly
| ReadWrite
watchIO :: String
-> Sint32
-> IOEventMask
-> (ChanOutput ('Stored ITime) -> Ref 'Global ('Struct "ev_io") -> Monitor e ())
-> Tower e ()
watchIO name fd eventmask mon = do
sig <- signal (Watcher name defs $ call_ start $ procPtr $ cb $ return ()) (us 0)
towerModule m
monitor name $ do
monitorModuleDef $ depend m
mon sig $ addrOf global_watcher
where
cb :: (forall s1. Ivory (AllocEffects s1) ()) -> Def ('[Ref s2 ('Struct "ev_loop"), Ref s3 ('Struct "ev_io"), Sint32] ':-> ())
cb action = proc (name ++ "_callback") $ \ _loop _watcher _events -> body $
noReturn action
global_watcher = area (name ++ "_watcher") Nothing
start = voidProc (name ++ "_start") $ \ cbPtr -> body $ do
call_ ev_io_init (addrOf global_watcher) cbPtr fd $
case eventmask of
ReadOnly -> ev_READ
WriteOnly -> ev_WRITE
ReadWrite -> ev_READ .| ev_WRITE
default_loop <- call ev_default_loop 0
call_ ev_io_start default_loop (addrOf global_watcher)
m = package name $ do
uses_libev
defMemArea global_watcher
incl start
-- FIXME: fd might not be an `extern` expression
inclSym fd
defs :: (forall s. Ivory (AllocEffects s) ()) -> ModuleDef
defs action = do
depend m
private $ do
incl $ cb action
|
GaloisInc/ivory-tower-posix
|
src/Ivory/OS/Posix/Tower/Signal.hs
|
bsd-3-clause
| 1,932 | 0 | 16 | 454 | 650 | 327 | 323 | 53 | 3 |
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE LambdaCase #-}
module River.Core.Evaluate (
evaluateProgram
, Value(..)
, RuntimeError(..)
) where
import Control.Spoon (spoon)
import Data.Int (Int64)
import Data.Map (Map)
import qualified Data.Map as Map
import River.Bifunctor
import River.Core.Primitive
import River.Core.Syntax
data RuntimeError n a =
DivisionByZero !a ![n] !(Tail Prim n a)
| LetArityMismatch !a ![n] ![Value n a]
| LambdaArityMismatch !a ![n] ![Value n a]
| UnboundVariable !a !n
| UnboundFunction !a !n
| ArithError !a !Prim ![Value n a]
| DivideByZero !a !Prim ![Value n a]
| InvalidPrimApp !a !Prim ![Value n a]
| CannotIfNonBool !a !(Value n a)
| CannotCallNonLambda !a !n !(Value n a) ![Value n a]
deriving (Eq, Ord, Show, Functor)
data Value n a =
VInt64 !Int64
| VLambda ![n] !(Term () Prim n a)
deriving (Eq, Ord, Show, Functor)
evaluateProgram :: Ord n => Program () Prim n a -> Either (RuntimeError n a) [Value n a]
evaluateProgram = \case
Program _ tm ->
evaluateTerm Map.empty tm
evaluateTerm :: Ord n => Map n (Value n a) -> Term () Prim n a -> Either (RuntimeError n a) [Value n a]
evaluateTerm env0 = \case
Return _ tl ->
evaluateTail env0 tl
If a () i0 t e -> do
i <- evaluateAtom env0 i0
case i of
VInt64 0 ->
evaluateTerm env0 e
VInt64 _ ->
evaluateTerm env0 t
_ ->
Left $ CannotIfNonBool a i
Let a ns tl tm -> do
vs <- evaluateTail env0 tl
if length ns /= length vs then
Left $ LetArityMismatch a ns vs
else
let
env =
Map.fromList (zip ns vs) `Map.union` env0
in
evaluateTerm env tm
LetRec _ (Bindings _ bs) tm ->
let
env1 =
Map.fromList $
fmap (second evaluateBinding) bs
env =
env1 `Map.union`
env0
in
evaluateTerm env tm
evaluateBinding :: Binding () Prim n a -> Value n a
evaluateBinding = \case
Lambda _ ns tm ->
VLambda ns tm
evaluateTail :: Ord n => Map n (Value n a) -> Tail Prim n a -> Either (RuntimeError n a) [Value n a]
evaluateTail env = \case
Copy _ xs ->
traverse (evaluateAtom env) xs
Call a n xs -> do
vs <- traverse (evaluateAtom env) xs
evaluateCall env a n vs
Prim a p xs ->
evaluatePrim a p =<< traverse (evaluateAtom env) xs
evaluateCall ::
Ord n =>
Map n (Value n a) ->
a ->
n ->
[Value n a] ->
Either (RuntimeError n a) [Value n a]
evaluateCall env0 a n vs =
case Map.lookup n env0 of
Nothing ->
Left $ UnboundFunction a n
Just (VLambda ns tm) ->
-- TODO this is the same as a Let above, maybe extract?
if length ns /= length vs then
Left $ LambdaArityMismatch a ns vs
else
let
env =
Map.fromList (zip ns vs) `Map.union` env0
in
evaluateTerm env tm
Just v ->
Left $ CannotCallNonLambda a n v vs
evaluateAtom :: Ord n => Map n (Value n a) -> Atom n a -> Either (RuntimeError n a) (Value n a)
evaluateAtom env = \case
Immediate _ x ->
pure . VInt64 $ fromInteger x
Variable a n ->
case Map.lookup n env of
Nothing ->
Left $ UnboundVariable a n
Just v ->
pure v
evaluatePrim :: a -> Prim -> [Value n a] -> Either (RuntimeError n a) [Value n a]
evaluatePrim a p xs =
case (p, xs) of
(Neg, [VInt64 x]) ->
pure [ VInt64 $ -x ]
(Add, [VInt64 x, VInt64 y]) ->
pure [ VInt64 $ x + y ]
(Sub, [VInt64 x, VInt64 y]) ->
pure [ VInt64 $ x - y ]
(Mul, [VInt64 x, VInt64 y]) ->
pure [ VInt64 $ x * y ]
(Div, [_, VInt64 0]) ->
Left $ DivideByZero a p xs
(Mod, [_, VInt64 0]) ->
Left $ DivideByZero a p xs
(Div, [VInt64 x, VInt64 y]) ->
case spoon $ quot x y of
Nothing ->
-- TODO would be good to be more specific, maybe it's not so hard to
-- TODO detect what kind of error we'll have
Left $ ArithError a p xs
Just d ->
pure [ VInt64 d ]
(Mod, [VInt64 x, VInt64 y]) ->
case spoon $ rem x y of
Nothing ->
Left $ ArithError a p xs
Just m ->
pure [ VInt64 m ]
(prim, [VInt64 x, VInt64 y])
| Just cmp <- takeIntCmp prim
->
if cmp x y then
pure [ VInt64 1 ]
else
pure [ VInt64 0 ]
_ ->
Left $ InvalidPrimApp a p xs
takeIntCmp :: Prim -> Maybe (Int64 -> Int64 -> Bool)
takeIntCmp = \case
Eq ->
Just (==)
Ne ->
Just (/=)
Lt ->
Just (<)
Le ->
Just (<=)
Gt ->
Just (>)
Ge ->
Just (>=)
_ ->
Nothing
|
jystic/river
|
src/River/Core/Evaluate.hs
|
bsd-3-clause
| 4,710 | 0 | 18 | 1,571 | 1,957 | 967 | 990 | 218 | 13 |
{-# LANGUAGE DeriveDataTypeable, DeriveGeneric,
MultiParamTypeClasses, FlexibleInstances
#-}
module FOmega.Syntax where
import Data.Typeable (Typeable)
import GHC.Generics (Generic)
import Insomnia.Common.Literal
import Insomnia.Common.SampleParameters
import Unbound.Generics.LocallyNameless
import {-# SOURCE #-} FOmega.Pretty (ppType, ppTerm, ppKind, ppCommand)
import Insomnia.Pretty (Pretty(..))
-- | There will be some stylized records that have predefined field
-- names distinct from what a user may write.
data Field =
FVal
| FType
| FSig
-- data type definition fields
| FDataOut
| FDataIn
-- data type constructor field
| FCon !String
-- integer indexed field
| FTuple !Int
-- user defined record fields
| FUser !String
deriving (Show, Eq, Ord, Typeable, Generic)
data Kind =
KType
| KArr !Kind !Kind
deriving (Show, Eq, Typeable, Generic)
type TyVar = Name Type
-- TODO: Maybe use a (βη)-normalized representation?
data Type =
TV !TyVar
| TLam !(Bind (TyVar, Embed Kind) Type)
| TApp !Type !Type
| TForall !(Bind (TyVar, Embed Kind) Type)
| TFix !(Bind (TyVar, Embed Kind) Type)
| TExist !ExistPack
| TRecord ![(Field, Type)] -- TRecord [] is the unit type
| TSum ![(Field, Type)] -- TSum [] is the void type
| TArr !Type !Type
| TDist !Type -- probability distribution monad
deriving (Show, Typeable, Generic)
type ExistPack = Bind (TyVar, Embed Kind) Type
type Var = Name Term
data Term =
V !Var
| L !Literal
| Lam !(Bind (Var, Embed Type) Term)
| App !Term !Term
| Let !(Bind (Var, Embed Term) Term)
| PLam !(Bind (TyVar, Embed Kind) Term)
| PApp !Term !Type
| Record ![(Field, Term)] -- Record [] is the unit value
| Proj !Term !Field
| Pack !Type !Term !ExistPack
| Unpack !(Bind (TyVar, Var, Embed Term) Term) -- let unpack <α, x> = e₁ in e₂
| Return !Term
| LetSample !(Bind (Var, Embed Term) Term)
| LetRec !(Bind RecBindings Term)
| Memo !Term
| Assume !Type
| Inj !Field !Term !Type
| Case !Term ![Clause] !DefaultClause
| Roll !Type !Term !(Bind TyVar Type) -- roll μ..., m as δ.T
| Unroll !Type !Term !(Bind TyVar Type) -- unroll μ..., m as δ.T
deriving (Show, Typeable, Generic)
data Command =
LetC !(Bind (Var, Embed Term) Command)
| UnpackC !(Bind (TyVar, Var, Embed Term) Command)
| BindC !(Bind (Var, Embed Command) Command)
| ReturnC !Term
| EffectC !PrimitiveCommand !Term
deriving (Show, Typeable, Generic)
data PrimitiveCommand =
SamplePC SampleParameters
| PrintPC
deriving (Show, Typeable, Generic)
infixl 6 `Proj`
data Clause = Clause !Field !(Bind Var Term)
deriving (Show, Typeable, Generic)
newtype DefaultClause = DefaultClause (Either CaseMatchFailure Term)
deriving (Show, Typeable, Generic)
newtype CaseMatchFailure = CaseMatchFailure Type
deriving (Show, Typeable, Generic)
-- terms should be values
type RecBindings = Rec [(Var, Embed Type, Embed Term)]
-- * Alpha equivalence and Substitution
instance Alpha Field
instance Alpha Kind
instance Alpha Type
instance Alpha Term
instance Alpha Clause
instance Alpha DefaultClause
instance Alpha CaseMatchFailure
instance Alpha Command
instance Alpha PrimitiveCommand
instance Subst Type Type where
isvar (TV a) = Just (SubstName a)
isvar _ = Nothing
-- no types inside kinds
instance Subst Type Kind where
subst _ _ = id
substs _ = id
instance Subst Type Field where
subst _ _ = id
substs _ = id
instance Subst Type Literal where
subst _ _ = id
substs _ = id
instance Subst Type Clause
instance Subst Type DefaultClause
instance Subst Type CaseMatchFailure
instance Subst Type Term
instance Subst Type Command
instance Subst Term Term where
isvar (V a) = Just (SubstName a)
isvar _ = Nothing
instance Subst Term Clause
instance Subst Term DefaultClause
instance Subst Term CaseMatchFailure
instance Subst Term Type where
subst _ _ = id
substs _ = id
instance Subst Term Field where
subst _ _ = id
substs _ = id
instance Subst Term Kind where
subst _ _ = id
substs _ = id
instance Subst Term Literal where
subst _ _ = id
substs _ = id
instance Subst Term Command
instance Subst b PrimitiveCommand where
subst _ _ = id
substs _ = id
-- * Pretty printing
instance Pretty Kind where pp = ppKind
instance Pretty Type where pp = ppType
instance Pretty Term where pp = ppTerm
instance Pretty Command where pp = ppCommand
-- * Utilities
kArrs :: [Kind] -> Kind -> Kind
kArrs [] = id
kArrs (k:ks) = KArr k . kArrs ks
intT :: Type
intT = TV (s2n "Int")
realT :: Type
realT = TV (s2n "Real")
tLams :: [(TyVar, Kind)] -> Type -> Type
tLams [] = id
tLams ((tv,k):tvks) =
TLam . bind (tv, embed k) . tLams tvks
tLams' :: [(TyVar, Embed Kind)] -> Type -> Type
tLams' [] = id
tLams' (tvk:tvks) =
TLam . bind tvk . tLams' tvks
tForalls :: [(TyVar, Kind)] -> Type -> Type
tForalls [] = id
tForalls ((tv,k):tvks) =
TForall . bind (tv, embed k) . tForalls tvks
tExists :: [(TyVar, Kind)] -> Type -> Type
tExists [] = id
tExists ((tv,k):tvks) =
TExist . bind (tv, embed k) . tExists tvks
tExists' :: [(TyVar, Embed Kind)] -> Type -> Type
tExists' [] = id
tExists' (tvk:tvks) =
TExist . bind tvk . tExists' tvks
tApps :: Type -> [Type] -> Type
tApps = flip tApps'
where
tApps' [] = id
tApps' (t:ts) = tApps' ts . (`TApp` t)
tArrs :: [Type] -> Type -> Type
tArrs [] = id
tArrs (t:ts) = (t `TArr`) . tArrs ts
tupleT :: [Type] -> Type
tupleT ts =
let fts = zipWith (\t i -> (FTuple i, t)) ts [0..]
in TRecord fts
lams :: [(Var, Type)] -> Term -> Term
lams [] = id
lams ((v,t):vts) =
Lam . bind (v, embed t) . lams vts
lams' :: [(Var, Embed Type)] -> Term -> Term
lams' [] = id
lams' (vt:vts) =
Lam . bind vt . lams' vts
pLams :: [(TyVar, Kind)] -> Term -> Term
pLams [] = id
pLams ((tv,k):tvks) =
PLam . bind (tv, embed k) . pLams tvks
pLams' :: [(TyVar, Embed Kind)] -> Term -> Term
pLams' [] = id
pLams' (tvk:tvks) =
PLam . bind tvk . pLams' tvks
pApps :: Term -> [Type] -> Term
pApps = flip pApps'
where
pApps' [] = id
pApps' (t:ts) = pApps' ts . (`PApp` t)
apps :: Term -> [Term] -> Term
apps = flip apps'
where
apps' [] = id
apps' (m:ms) = apps' ms . (`App` m)
-- | packs τs, e as αs.τ' defined as
-- packs ε, e as ·.τ ≙ e
-- packs τ:τs, e as α,αs.τ' ≙ pack τ, (packs τs, e as αs.τ'[τ/α]) as α.∃αs.τ'
packs :: [Type] -> Term -> ([(TyVar, Embed Kind)], Type) -> Term
packs taus_ m_ (tvks_, tbody_) =
go taus_ tvks_ tbody_ m_
where
go [] [] _t m = m
go (tau:taus) (tvk@(tv,_k):tvks') tbody m =
let m' = go taus tvks' (subst tv tau tbody) m
t' = tExists' tvks' tbody
in Pack tau m' (bind tvk t')
go _ _ _ _ = error "expected lists of equal length"
-- | unpacksM αs x defined as
-- unpacksM · x ≙ (m.n. let x = m in n, ·)
-- unpacksM (α,αs) x ≙ (m.n. let ⟨α,x′⟩ = m in h (x′) in n, (x′,xs′))
-- where (h,xs′) = unpacksM αs x
-- That is, it returns a pair of a term with a hole for the subject and the body,
-- and the set of locally fresh variables derived from x that stand for the intermediate
-- terms.
unpacksM :: LFresh m => [TyVar] -> Var -> m ((Term -> Term -> Term), [AnyName])
unpacksM [] x = return ((\e1 ebody -> Let $ bind (x, embed e1) ebody),
[])
unpacksM (tv:tvs) x = do
x1 <- lfresh x
let avd = [AnyName x1]
(rest, avd') <- avoid avd (unpacksM tvs x)
return ((\e1 -> Unpack . bind (tv, x1, embed e1) . rest (V x1)),
avd ++ avd')
unpacksCM :: LFresh m => [TyVar] -> Var -> m ((Term -> Command -> Command), [AnyName])
unpacksCM [] x = return ((\e1 cbody -> LetC $ bind (x, embed e1) cbody),
[])
unpacksCM (tv:tvs) x = do
x1 <- lfresh x
let avd = [AnyName x1]
(rest, avd') <- avoid avd (unpacksCM tvs x)
return ((\e1 -> UnpackC . bind (tv, x1, embed e1) . rest (V x1)),
avd ++ avd')
unpacks :: LFresh m => [TyVar] -> Var -> Term -> Term -> m Term
unpacks tvs x e1 ebody = do
(rest, _) <- unpacksM tvs x
return $ rest e1 ebody
-- | @workUnderExists (∃αs:κs.τ) m h@ returns the term
-- let
-- ⟨αs,x⟩ = m
-- in
-- pack ⟨αs, n⟩ as ∃αs:κs.σ
-- where (n, σ) = h αs τ
workUnderExists :: LFresh m
=> Bind [(TyVar, Embed Kind)] Type
-> Term
-> ([(TyVar, Embed Kind)] -> Type -> m (Term, Type))
-> m Term
workUnderExists bnd subj h =
lunbind bnd $ \(tvks, tp) -> do
let tvs = map fst tvks
x <- lfresh (s2n "x")
(unpacker, _) <- unpacksM tvs x
(body, sigma) <- h tvks tp
return $ unpacker subj $ packs (map TV tvs) body (tvks, sigma)
-- | lets · m ≙ m
-- | lets x=m, bs ≙ let x = m in lets bs m
lets :: [(Var, Term)] -> Term -> Term
lets [] = id
lets ((v,m):vs) = Let . bind (v, embed m) . lets vs
-- | tuple [m0, …, mk] = { #0 = m0, …, #k = mk }
tuple :: [Term] -> Term
tuple ms =
let ims = zipWith (\m i -> (FTuple i, m)) ms [0..]
in Record ims
unitT :: Type
unitT = TRecord []
unitVal :: Term
unitVal = Record []
voidT :: Type
voidT = TSum []
-- | λε:⋆. { Nil : {} | Cons : { #0 : τ; #1 : (listT τ) } }
listSumT :: Type
listSumT =
let
ve = s2n "ε"
e = TV ve
in
TLam $ bind (ve, embed KType)
$ TSum [(FUser "Nil", unitT)
, (FUser "Cons", tupleT [e, listT `TApp` e])]
-- μ (δ : ⋆→⋆) . λ (α : ⋆) . { Nil : {} | Cons : { #0 : α; #1 : δ α } }
listT :: Type
listT =
let
vd = s2n "δ"
va = s2n "α"
d = TV vd
a = TV va
body = TSum [(FUser "Nil", unitT)
, (FUser "Cons", tupleT [a, d `TApp` a])]
l = TLam $ bind (va, embed KType) body
in
TFix $ bind (vd, embed (KType `KArr` KType)) l
-- | construct: Λε:⋆ . roll (listT ε) (Inj Nil [] (listSumT ε)) as α.(α ε)
nilListVal :: Term
nilListVal =
let
ve = s2n "ε"
va = s2n "α"
e = TV ve
a = TV va
inj = Inj (FUser "Nil") unitVal (listSumT `TApp` e)
ctx = bind va (a `TApp` e)
in PLam $ bind (ve, embed KType)
$ Roll (listT `TApp` e) inj ctx
-- | construct: Λ ε:⋆. λ p : (ε, listT ε) . roll (listT ε) (Inj Cons p (listSumT ε)) as α.(α ε)
consListVal :: Term
consListVal =
let
ve = s2n "ε"
va = s2n "α"
vp = s2n "p"
e = TV ve
a = TV va
p = V vp
pt = tupleT [e, listT `TApp` e]
inj = Inj (FUser "Cons") p (listSumT `TApp` e)
ctx = bind va (a `TApp` e)
in PLam $ bind (ve, embed KType)
$ Lam $ bind (vp, embed pt)
$ Roll (listT `TApp` e) inj ctx
-- | Given a list of fields and a single field, return it
selectField :: [(Field, a)] -> Field -> Maybe a
selectField fvs_ f = (go fvs_)
where
go [] = Nothing
go ((f',v):fvs) | f == f' = return v
| otherwise = go fvs
|
lambdageek/insomnia
|
src/FOmega/Syntax.hs
|
bsd-3-clause
| 10,942 | 0 | 15 | 2,803 | 4,262 | 2,244 | 2,018 | 416 | 3 |
{-# LANGUAGE
FlexibleContexts
#-}
module Main where
import Build
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NE
import Data.Tree (Tree (..))
import Data.Trie.List as L
import Data.Trie.Map as M
import Data.Trie.HashMap as HM
import Data.Tree.Knuth.Forest as K
import Data.Trie.Knuth as K
import Data.Trie.Class as TC
import qualified Data.Map as Map
import qualified Data.HashMap.Lazy as HMap
import Criterion.Main
import Control.Monad.State
deleteMany :: ( Trie NonEmpty Int c
) => Int -> c Int a -> c Int a
deleteMany top xs =
foldr
(\p -> TC.delete $ buildMiddleQuery top)
xs
[1..top]
insertMany :: ( Trie NonEmpty Int c
) => Int -> c Int Int -> c Int Int
insertMany top xs =
foldr
(\p -> TC.insert (buildMiddleQuery top) 0)
xs
[1..top]
main = defaultMain
[ bgroup "delete"
[ bench "ListTrie" $ whnf (deleteMany 100) (genListTrie 100)
, bench "MapTrie" $ whnf (deleteMany 100) (genMapTrie 100)
, bench "HashMapTrie" $ whnf (deleteMany 100) (genHashMapTrie 100)
, bench "KnuthTrie" $ whnf (deleteMany 100) (genKnuthTrie 100)
]
, bgroup "insert"
[ bench "ListTrie" $ whnf (insertMany 100) (genListTrie 100)
, bench "MapTrie1" $ whnf (insertMany 100) (genMapTrie 100)
, bench "HashMapTrie" $ whnf (insertMany 100) (genHashMapTrie 100)
, bench "KnuthTrie" $ whnf (insertMany 100) (genKnuthTrie 100)
]
]
|
athanclark/tries
|
bench/Main.hs
|
bsd-3-clause
| 1,576 | 0 | 12 | 443 | 517 | 283 | 234 | 42 | 1 |
-----------------------------------------------------------------------------
-- |
-- Module : Application.DevAdmin.Job
-- Copyright : (c) 2011-2013 Ian-Woo Kim
--
-- License : BSD3
-- Maintainer : Ian-Woo Kim <[email protected]>
-- Stability : experimental
-- Portability : GHC
--
-----------------------------------------------------------------------------
module Application.DevAdmin.Job where
import Control.Applicative
import Control.Monad (when)
import System.Directory
import System.Exit
import System.FilePath
import System.Process
import Text.StringTemplate
import Text.StringTemplate.Helpers
--
import Application.DevAdmin.Config
import Application.DevAdmin.Project
import Application.DevAdmin.VersionCheck
--
import Paths_devadmin
-- | git clone
gitCloneJob :: BuildConfiguration -> String -> IO ()
gitCloneJob bc name = do
putStrLn $ "git clone : " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc)
excode <- system $ "git clone " ++ (bc_gitrepobase bc </> name <.> "git")
case excode of
ExitSuccess -> do
when (bc_ispushable bc) $ do
setCurrentDirectory (dir </> bc_srcbase bc </> name)
system $ "git remote add github " ++ (bc_gitrepobase bc </> name <.> "git")
return ()
-- system $ "git push github master"
-- putStrLn "Successful. Press any key."
-- c <- getLine
-- if (not.null $ c)
-- then return ()
-- else return ()
ExitFailure 1 -> do
error "Not successful. Press any key."
-- c <- getLine
-- if (not.null $ c)
-- then return ()
-- else return ()
_ -> do
error "Not successful. Press any key."
-- c <- getLine
-- if (not.null $ c)
-- then return ()
-- else return ()
setCurrentDirectory dir
return ()
-- | git push for a project
gitPushJob :: BuildConfiguration -> String -> IO ()
gitPushJob bc name = do
putStrLn $ "git push : " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
system $ "git push github master"
return ()
-- | git pull for a project
gitPullJob :: BuildConfiguration -> String -> IO ()
gitPullJob bc name = do
putStrLn $ "git pull : " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
system $ "git pull github master"
return ()
-- |
showJob :: BuildConfiguration -> String -> IO ()
showJob _bc name = do
putStrLn $ "currently working on " ++ name
-- | need to be generalized
cabalInstallJob :: BuildConfiguration -> Maybe String -> String -> IO ()
cabalInstallJob bc mopt name = do
putStrLn $ "update : " ++ name
system $ "ghc-pkg --force unregister " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
let cmd = "cabal install " ++ (maybe "" id mopt)
putStrLn $ " Command : " ++ cmd
excode <- system cmd
case excode of
ExitSuccess -> do
putStrLn "successful installation"
putStrLn "-----------------------"
ExitFailure ecd -> error $ "not successful installation of " ++ name
++ " with exit code " ++ show ecd
setCurrentDirectory dir
-- return ()
-- |
haddockJob :: BuildConfiguration -> String -> IO ()
haddockJob bc name = do
putStrLn $ "haddock : " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
system $ "cabal install --enable-documentation"
system $ "cabal haddock --hyperlink-source"
system $ "cabal copy"
-- versioncheck bc
setCurrentDirectory dir
return ()
-- |
cabalCleanJob :: BuildConfiguration -> String -> IO ()
cabalCleanJob bc name = do
putStrLn $ "cleaning : " ++ name
system $ "ghc-pkg --force unregister " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
excode <- system $ "cabal clean"
case excode of
ExitSuccess -> do
putStrLn "successful clean"
putStrLn "-----------------------"
ExitFailure ecd -> error $ "not successful installation of " ++ name
++ " with exit code " ++ show ecd
-- return ()
-- |
gitDiffJob :: BuildConfiguration -> String -> IO ()
gitDiffJob bc name = do
putStrLn $ "git diff : " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
excode <- system $ "git diff"
case excode of
ExitSuccess -> do
putStrLn "some change happened. would you proceed to the next? (Y/N)"
c <- getLine
if (not.null $ c) && (head c == 'y' || head c == 'Y')
then return ()
else gitDiffJob bc name
ExitFailure 1 -> return ()
_ -> error $ "do not know what to do in whatsnew job " ++ name
return ()
-- |
haddockSandBoxJob :: FilePath -> BuildConfiguration -> String -> IO ()
haddockSandBoxJob fp bc name = do
putStrLn $ "haddock : " ++ name
dir <- getCurrentDirectory
setCurrentDirectory (dir </> bc_srcbase bc </> name)
system $ "cabal-dev install --enable-documentation --sandbox="++ fp
system $ "cabal-dev haddock --hyperlink-source --sandbox=" ++ fp
system $ "cabal-dev copy --sandbox=" ++ fp
-- versioncheck bc
return ()
-- | make an index file for each package
updateHtml :: FilePath -> BuildConfiguration -> ProjectConfiguration -> IO ()
updateHtml fp bc pc = do
let projects = pc_projects pc
tmpldir <- (</> "template") <$> getDataDir
templates <- directoryGroup tmpldir
progbodystr <- mapM (progbody fp bc) projects >>= return . concat
let str = renderTemplateGroup
templates
[ ("body" , progbodystr) ]
"proghtml.html"
writeFile (fp </> "share" </> "doc" </> "index.html") str
progbody :: FilePath -> BuildConfiguration -> Project -> IO String
progbody fp bc (ProgProj prjname) = do
prjnameversion <- getProjNameWithVersion bc prjname
tmpldir <- (</> "template") <$> getDataDir
templates <- directoryGroup tmpldir
let str = renderTemplateGroup
templates
[ ("progindexhtml", prjnameversion
</> "html/index.html")
, ("progname", prjnameversion) ]
"progbody.html"
return str
progbody _ _ _ = error "no match error in progbody"
{-
-- |
darcsPushJob :: BuildConfiguration -> String -> IO ()
darcsPushJob bc name = do
putStrLn $ "darcs push : " ++ name
setCurrentDirectory ((bc_progbase bc) </> name)
system $ "darcs push"
return ()
-- |
darcsPullJob :: BuildConfiguration -> String -> IO ()
darcsPullJob bc name = do
putStrLn $ "darcs pull : " ++ name
setCurrentDirectory (bc_progbase bc </> name)
system $ "darcs pull"
return ()
-}
{-
-- |
hoogleJob :: BuildConfiguration -> String -> IO ()
hoogleJob bc name = do
putStrLn $ "hoogle : " ++ name
setCurrentDirectory ((bc_srcbase bc) </> name)
system $ "cabal haddock --hoogle"
let hooglefile = (bc_srcbase bc) </> name </> "dist/doc/html" </> name </> name ++ ".txt"
b <- doesFileExist hooglefile
if b
then copyFile hooglefile ((bc_hoogleDatabase bc) </> name ++ ".txt")
else putStrLn $ "no such file : " ++ hooglefile
return ()
-}
-- |
{-
bridgeJob :: BuildConfiguration -> String -> IO ()
bridgeJob bc name = do
putStrLn $ "bridge : " ++ name
let progdir = bc_progbase bc </> name
bridgedir = bc_bridgebase bc </> name ++ "_bridge"
bridgedarcs = bridgedir </> name
bridgegit = bridgedir </> name ++ "_git"
gitdir = bc_gitbase bc </> name ++ "_git"
setCurrentDirectory ((bc_progbase bc) </> name)
system $ "darcs push " ++ bridgedarcs
setCurrentDirectory (bc_bridgebase bc)
system $ "darcs-fastconvert sync " ++ (name ++ "_bridge") ++ " git"
setCurrentDirectory gitdir
system $ "git checkout master"
system $ "git pull " ++ bridgegit
system $ "git push github master"
return ()
createBridgeJob :: BuildConfiguration -> String -> IO ()
createBridgeJob bc name = do
putStrLn $ "create bridge : " ++ name
let progdir = bc_progbase bc </> name
bridgedir = bc_bridgebase bc </> name ++ "_bridge"
bridgedarcs = bridgedir </> name
bridgegit = bridgedir </> name ++ "_git"
gitdir = bc_gitbase bc </> name ++ "_git"
-- setCurrentDirectory ((bc_progbase bc) </> name)
-- system $ "darcs push " ++ bridgedarcs
setCurrentDirectory (bc_bridgebase bc)
system $ "darcs-fastconvert create-bridge " ++ progdir
setCurrentDirectory (bc_gitbase bc)
system $ "git clone " ++ bridgegit
setCurrentDirectory bridgegit
system $ "git remote add github [email protected]:wavewave/" ++ name ++ ".git"
putStrLn $ "please make " ++ name ++ " on github. Did you do?"
x <- getLine
if head x == 'y' || head x == 'Y'
then system "git push github master " >> return ()
else putStrLn "later, please do git push github master "
{-
system $ "git pull " ++ bridgegit
system $ "git push github master" -}
return ()
-}
{-
darcsGetJob :: BuildConfiguration -> String -> IO ()
darcsGetJob bc name = do
putStrLn $ "darcs get : " ++ name
setCurrentDirectory (bc_progbase bc)
excode <- system $ "darcs get " ++ ((bc_darcsrepobase bc) </> name)
case excode of
ExitSuccess -> do
putStrLn "some change happened. would you proceed to the next? (Y/N)"
c <- getLine
if (not.null $ c) && (head c == 'y' || head c == 'Y')
then return ()
else darcsWhatsnewJob bc name
ExitFailure 1 -> return ()
_ -> error $ "do not know what to do in whatsnew job " ++ name
return ()
-}
|
wavewave/devadmin
|
lib/Application/DevAdmin/Job.hs
|
bsd-3-clause
| 9,696 | 0 | 19 | 2,416 | 1,554 | 755 | 799 | 136 | 4 |
{-|
This modules defines the 'QueryArr' arrow, which is an arrow that represents
selecting data from a database, and composing multiple queries together.
-}
module Opaleye.QueryArr where
import Prelude hiding (id)
import qualified Opaleye.Internal.Unpackspec as U
import qualified Opaleye.Internal.Tag as Tag
import Opaleye.Internal.Tag (Tag)
import qualified Opaleye.Internal.PrimQuery as PQ
import qualified Database.HaskellDB.PrimQuery as HPQ
import qualified Control.Arrow as A
import Control.Arrow ((&&&), (***), arr)
import qualified Control.Category as C
import Control.Category ((<<<), id)
import Control.Applicative (Applicative, pure, (<*>))
import qualified Data.Profunctor as P
import qualified Data.Profunctor.Product as PP
newtype QueryArr a b = QueryArr ((a, PQ.PrimQuery, Tag) -> (b, PQ.PrimQuery, Tag))
type Query = QueryArr ()
simpleQueryArr :: ((a, Tag) -> (b, PQ.PrimQuery, Tag)) -> QueryArr a b
simpleQueryArr f = QueryArr g
where g (a0, primQuery, t0) = (a1, PQ.times primQuery primQuery', t1)
where (a1, primQuery', t1) = f (a0, t0)
runQueryArr :: QueryArr a b -> (a, PQ.PrimQuery, Tag) -> (b, PQ.PrimQuery, Tag)
runQueryArr (QueryArr f) = f
runSimpleQueryArr :: QueryArr a b -> (a, Tag) -> (b, PQ.PrimQuery, Tag)
runSimpleQueryArr f (a, t) = runQueryArr f (a, PQ.Unit, t)
runQueryArrUnpack :: U.Unpackspec a b
-> Query a -> (PQ.PrimQuery, [HPQ.PrimExpr])
runQueryArrUnpack unpackspec q = (primQ, primExprs)
where (columns, primQ, _) = runSimpleQueryArr q ((), Tag.start)
f pe = ([pe], pe)
primExprs :: [HPQ.PrimExpr]
(primExprs, _) = U.runUnpackspec unpackspec f columns
first3 :: (a1 -> b) -> (a1, a2, a3) -> (b, a2, a3)
first3 f (a1, a2, a3) = (f a1, a2, a3)
instance C.Category QueryArr where
id = QueryArr id
QueryArr f . QueryArr g = QueryArr (f . g)
instance A.Arrow QueryArr where
arr f = QueryArr (first3 f)
first f = QueryArr g
where g ((b, d), primQ, t0) = ((c, d), primQ', t1)
where (c, primQ', t1) = runQueryArr f (b, primQ, t0)
instance Functor (QueryArr a) where
fmap f = (arr f <<<)
instance Applicative (QueryArr a) where
pure = arr . const
f <*> g = arr (uncurry ($)) <<< (f &&& g)
instance P.Profunctor QueryArr where
dimap f g a = arr g <<< a <<< arr f
instance PP.ProductProfunctor QueryArr where
empty = id
(***!) = (***)
|
k0001/haskell-opaleye
|
Opaleye/QueryArr.hs
|
bsd-3-clause
| 2,429 | 0 | 11 | 520 | 930 | 540 | 390 | 51 | 1 |
{-# LANGUAGE NoImplicitPrelude #-}
-- |
-- Module: $HEADER$
-- Description: TODO
-- Copyright: (c) 2016, Peter Trško
-- License: BSD3
--
-- Maintainer: [email protected]
-- Stability: experimental
-- Portability: NoImplicitPrelude
--
-- TODO
module DataAnalysis.Encode
( module DataAnalysis.Encode.Class
, module DataAnalysis.Encode.Aeson
, encodeFile
)
where
import Data.Function ((.))
import System.IO (FilePath, IO)
import qualified Data.ByteString.Lazy as Lazy.ByteString (writeFile)
import DataAnalysis.Encode.Class
import DataAnalysis.Encode.Aeson hiding
( aesonEncodeToBuilderWith
, aesonEncodeWith
)
encodeFile
:: Encode e a
=> proxy e
-> (EncodingParams e)
-> FilePath
-> a
-> IO ()
encodeFile proxy opts fileName =
Lazy.ByteString.writeFile fileName . encodeWith proxy opts
|
trskop/data-analysis
|
src/DataAnalysis/Encode.hs
|
bsd-3-clause
| 875 | 0 | 11 | 184 | 170 | 104 | 66 | 21 | 1 |
-- |JavaScript's syntax.
module BrownPLT.JavaScript.Syntax(Expression(..),CaseClause(..),Statement(..),
InfixOp(..),CatchClause(..),VarDecl(..),JavaScript(..),
AssignOp(..),Id(..),PrefixOp(..),Prop(..),
ForInit(..),ForInInit(..),unId
, UnaryAssignOp (..)
, LValue (..)
, unJavaScript
, SourcePos
, isIterationStmt
) where
import Text.Parsec.Pos(initialPos,SourcePos) -- used by data JavaScript
import Data.Generics(Data,Typeable)
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
import Data.Default
data JavaScript a
-- |A script in <script> ... </script> tags. This may seem a little silly,
-- but the Flapjax analogue has an inline variant and attribute-inline
-- variant.
= Script a [Statement a]
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
instance Default a => Default (JavaScript a) where
def = Script def []
-- | extracts statements from a JavaScript type
unJavaScript :: JavaScript a -> [Statement a]
unJavaScript (Script _ stmts) = stmts
instance Default SourcePos where
def = initialPos ""
data Id a = Id a String
deriving (Show,Eq,Ord,Data,Typeable,Functor,Foldable,Traversable)
unId :: Id a -> String
unId (Id _ s) = s
-- http://developer.mozilla.org/en/docs/
-- Core_JavaScript_1.5_Reference:Operators:Operator_Precedence
data InfixOp = OpLT | OpLEq | OpGT | OpGEq | OpIn | OpInstanceof | OpEq | OpNEq
| OpStrictEq | OpStrictNEq | OpLAnd | OpLOr
| OpMul | OpDiv | OpMod | OpSub | OpLShift | OpSpRShift
| OpZfRShift | OpBAnd | OpBXor | OpBOr | OpAdd
deriving (Show,Data,Typeable,Eq,Ord,Enum)
data AssignOp = OpAssign | OpAssignAdd | OpAssignSub | OpAssignMul | OpAssignDiv
| OpAssignMod | OpAssignLShift | OpAssignSpRShift | OpAssignZfRShift
| OpAssignBAnd | OpAssignBXor | OpAssignBOr
deriving (Show,Data,Typeable,Eq,Ord)
data UnaryAssignOp
= PrefixInc | PrefixDec | PostfixInc | PostfixDec
deriving (Show, Data, Typeable, Eq, Ord)
data PrefixOp = PrefixLNot | PrefixBNot | PrefixPlus
| PrefixMinus | PrefixTypeof | PrefixVoid | PrefixDelete
deriving (Show,Data,Typeable,Eq,Ord)
data Prop a
= PropId a (Id a) | PropString a String | PropNum a Integer
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data LValue a
= LVar a String
| LDot a (Expression a) String
| LBracket a (Expression a) (Expression a)
deriving (Show, Eq, Ord, Data, Typeable, Functor,Foldable,Traversable)
data Expression a
= StringLit a String
| RegexpLit a String Bool {- global? -} Bool {- case-insensitive? -}
| NumLit a Double
| IntLit a Int
| BoolLit a Bool
| NullLit a
| ArrayLit a [Expression a]
| ObjectLit a [(Prop a, Expression a)]
| ThisRef a
| VarRef a (Id a)
| DotRef a (Expression a) (Id a)
| BracketRef a (Expression a) {- container -} (Expression a) {- key -}
| NewExpr a (Expression a) {- constructor -} [Expression a]
| PrefixExpr a PrefixOp (Expression a)
| UnaryAssignExpr a UnaryAssignOp (LValue a)
| InfixExpr a InfixOp (Expression a) (Expression a)
| CondExpr a (Expression a) (Expression a) (Expression a)
| AssignExpr a AssignOp (LValue a) (Expression a)
| ParenExpr a (Expression a)
| ListExpr a [Expression a]
| CallExpr a (Expression a) [Expression a]
--funcexprs are optionally named
| FuncExpr a (Maybe (Id a)) [(Id a)] (Statement a)
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data CaseClause a
= CaseClause a (Expression a) [Statement a]
| CaseDefault a [Statement a]
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data CatchClause a
= CatchClause a (Id a) (Statement a)
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data VarDecl a
= VarDecl a (Id a) (Maybe (Expression a))
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data ForInit a
= NoInit
| VarInit [VarDecl a]
| ExprInit (Expression a)
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data ForInInit a
= ForInVar (Id a)
| ForInLVal (LValue a)
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
data Statement a
= BlockStmt a [Statement a]
| EmptyStmt a
| ExprStmt a (Expression a)
| IfStmt a (Expression a) (Statement a) (Statement a)
| IfSingleStmt a (Expression a) (Statement a)
| SwitchStmt a (Expression a) [CaseClause a]
| WhileStmt a (Expression a) (Statement a)
| DoWhileStmt a (Statement a) (Expression a)
| BreakStmt a (Maybe (Id a))
| ContinueStmt a (Maybe (Id a))
| LabelledStmt a (Id a) (Statement a)
| ForInStmt a (ForInInit a) (Expression a) (Statement a)
| ForStmt a (ForInit a)
(Maybe (Expression a)) -- test
(Maybe (Expression a)) -- increment
(Statement a) -- body
| TryStmt a (Statement a) {-body-} (Maybe (CatchClause a))
(Maybe (Statement a)) {-finally-}
| ThrowStmt a (Expression a)
| ReturnStmt a (Maybe (Expression a))
| WithStmt a (Expression a) (Statement a)
| VarDeclStmt a [VarDecl a]
| FunctionStmt a (Id a) {-name-} [(Id a)] {-args-} (Statement a) {-body-}
deriving (Show,Data,Typeable,Eq,Ord,Functor,Foldable,Traversable)
isIterationStmt :: Statement a -> Bool
isIterationStmt s = case s of
WhileStmt _ _ _ -> True
DoWhileStmt _ _ _ -> True
ForStmt _ _ _ _ _ -> True
ForInStmt _ _ _ _ -> True
_ -> False
|
brownplt/webbits
|
src/BrownPLT/JavaScript/Syntax.hs
|
bsd-3-clause
| 5,469 | 0 | 10 | 1,106 | 2,078 | 1,146 | 932 | 125 | 5 |
module Rules.Unit where
import Derivation
import Goal
import Rules.Utils
import Tactic
import Term
-- H >> unit = unit in U(i)
-- Uses: UNIT_EQ
unitEQ :: PrlTactic
unitEQ (Goal ctx t) =
case t of
Eq Unit Unit (Uni i) -> return $ Result
{ resultGoals = []
, resultEvidence = \d -> case d of
[] -> UNIT_EQ
_ -> error "UNIT.EQ: Invalid evidence!"
}
_ -> fail "UNIT.EQ does not apply."
-- H >> unit
-- Uses: UNIT_INTRO
unitINTRO :: PrlTactic
unitINTRO (Goal ctx t) =
case t of
Unit -> return $ Result
{ resultGoals = []
, resultEvidence = \d -> case d of
[] -> UNIT_INTRO
_ -> error "UNIT.INTRO: Invalid evidence!"
}
_ -> fail "UNIT.INTRO does not apply."
-- H >> tt = tt in unit
-- Uses: TT_EQ
unitTTEQ :: PrlTactic
unitTTEQ (Goal ctx t) =
case t of
Eq TT TT Unit -> return $ Result
{ resultGoals = []
, resultEvidence = \d -> case d of
[] -> TT_EQ
_ -> error "UNIT.TTEQ: Invalid evidence!"
}
_ -> fail "UNIT.TTEQ does not apply."
|
thsutton/cha
|
lib/Rules/Unit.hs
|
bsd-3-clause
| 1,196 | 0 | 15 | 452 | 307 | 165 | 142 | 33 | 3 |
module Main where
import Codec.Picture (writePng, generateImage)
import Codec.Picture.Types (PixelRGB8(..))
import Data.Bits ((.|.))
import Data.Char (toLower)
import Data.Fixed (mod')
import Data.List (splitAt, length, intersect)
import Data.Vector ((!), Vector, fromList)
import Numeric (readHex)
import Options.Applicative
import System.Environment (getArgs)
import System.Exit (die)
data Options = Options
{ hash :: String
, size :: Int
, output :: String
}
background :: PixelRGB8
background =
PixelRGB8 (fromIntegral 240) (fromIntegral 240) (fromIntegral 240)
main :: IO ()
main =
execParser opts >>= generator
where
opts = info (helper <*> options)
( fullDesc
<> progDesc "Generate identicons"
<> header "hidenticon - an identicon generator" )
options :: Parser Options
options = Options
<$> strOption
( long "hash"
<> metavar "HASH"
<> help "Hash to generate identicon" )
<*> option auto
( long "size"
<> short 's'
<> help "Size of the identicon" )
<*> strOption
( long "output"
<> metavar "OUTPUT"
<> short 'o'
<> help "Name of the output file" )
validHash :: String -> Bool
validHash hash =
Data.List.length hash > 15 &&
(Data.List.intersect hash ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'] == hash)
generator :: Options -> IO ()
generator (Options hash size output) =
let
decodedHash =
fromList $ map (\c -> hexToInt [c]) hash
hueValue =
let
x = hexToInt $ snd $ splitAt (length hash - 7) hash
max = hexToInt "fffffff"
in
fromIntegral x / fromIntegral max
baseMargin =
floor $ fromIntegral size * 0.08
cell =
floor $ fromIntegral (size - baseMargin * 2) / 5
margin =
floor $ fromIntegral (size - cell * 5) / 2
hash' =
map toLower hash
in
do if validHash hash' then
imageCreator decodedHash hueValue cell margin size output
else
die "Invalid hash"
imageCreator :: Vector Int -> Float -> Int -> Int -> Int -> String -> IO ()
imageCreator hash hue cell margin size path =
writePng path $
generateImage
(pixelRenderer hash hue cell margin)
size size
pixelRenderer :: Vector Int -> Float -> Int -> Int -> Int -> Int -> PixelRGB8
pixelRenderer hash hue cell margin x y
| x < margin = background
| x > margin + 5 * cell = background
| y < margin = background
| y > margin + 5 * cell = background
| otherwise = (quadrantColor hash hue) $ quadrant cell margin (x, y)
hsl2rgb :: Float -> PixelRGB8
hsl2rgb h =
let
s = 0.5
b = 0.7
h' :: Float
h' = h * 6
b2 = if (b < 0.5) then b else 1.0 - b
s' = s * b2
b' = b + s'
s'' = s' * 2
b'' = b' - s''
vec =
Data.Vector.fromList
[ b'
, b' - h' `mod'` 1 * s' * 2
, b''
, b''
, b'' + h' `mod'` 1 * s''
, b'' + s''
]
h'' = toInteger $ floor h'
cr = fromIntegral $ h'' `mod` 6
cg = fromIntegral $ (h'' .|. 16) `mod` 6
cb = fromIntegral $ (h'' .|. 8) `mod` 6
in
PixelRGB8
(fromIntegral $ floor ((vec ! cr) * 255))
(fromIntegral $ floor ((vec ! cg) * 255))
(fromIntegral $ floor ((vec ! cb) * 255))
hexToInt :: String -> Int
hexToInt ss =
case readHex ss of
[] -> 0
[(x, _)] -> x
quadrant :: Int -> Int -> (Int, Int) -> (Int, Int)
quadrant cell margin (x, y) =
let
f x' = floor $ fromIntegral (x' - x' `rem` cell) / (fromIntegral cell)
normalize x' =
case x' of
3 -> 1
4 -> 0
_ -> x'
in
( normalize (f (x - margin - 1))
, (f (y - margin - 1))
)
quadrantColor :: Vector Int -> Float -> (Int, Int) -> PixelRGB8
quadrantColor hash hue (x, y) =
let
place x y =
(10 - 5 * x) + y
color =
case (hash ! (place x y)) `mod` 2 of
0 -> hsl2rgb hue
_ -> background
in
color
|
sgillis/hidenticon
|
src/Main.hs
|
bsd-3-clause
| 3,988 | 0 | 17 | 1,225 | 1,564 | 831 | 733 | 133 | 3 |
module Entity.Id where
import qualified GameData.Entity as E
invalidId :: Int
invalidId = -1
entityId :: E.Entity -> Int
entityId E.Player {E.playerId = id} = id
entityId E.Enemy {E.enemyId = id} = id
entityId E.Star {E.starId = id} = id
entityId E.Platform {E.platformId = id} = id
setEntityId :: E.Entity -> Int -> E.Entity
setEntityId [email protected] {} id = p {E.playerId = id}
setEntityId [email protected] {} id = e {E.enemyId = id}
setEntityId [email protected] {} id = s {E.starId = id}
setEntityId [email protected] {} id = p {E.platformId = id}
|
dan-t/layers
|
src/Entity/Id.hs
|
bsd-3-clause
| 570 | 0 | 8 | 132 | 254 | 140 | 114 | 14 | 1 |
{-# LANGUAGE FlexibleInstances
, BangPatterns
, MagicHash
, ScopedTypeVariables
, TypeFamilies
, UndecidableInstances
, OverlappingInstances
, DeriveDataTypeable
, MultiParamTypeClasses
, NamedFieldPuns
, RankNTypes
#-}
{-# OPTIONS_HADDOCK prune #-}
#define MODNAME Intel.Cnc
-- This file is simple here to dispatch to the appropriate scheduler implementation.
#ifndef CNC_SCHEDULER
#warning "Cnc.hs -- CNC_SCHEDULER unset, defaulting to scheduler 7 "
#define CNC_SCHEDULER 7
#endif
#if CNC_SCHEDULER == 3
#include "Cnc3.hs"
#elif CNC_SCHEDULER == 4
#include "Cnc4.hs"
#elif CNC_SCHEDULER == 5
#include "Cnc5.hs"
#elif CNC_SCHEDULER == 6
#include "Cnc6.hs"
#elif CNC_SCHEDULER == 7
#include "Cnc7.hs"
#elif CNC_SCHEDULER == 8
#include "Cnc8.hs"
#elif CNC_SCHEDULER == 9
#include "Cnc9.hs"
#elif CNC_SCHEDULER == 10
#include "Cnc10.hs"
#elif CNC_SCHEDULER == 11
#include "Cnc11.hs"
-- TEMP:
#elif CNC_SCHEDULER == 99
#include "Cnc10ver1.hs"
#else
#error "Cnc.hs -- CNC_SCHEDULER is not set to a support scheduler: {3,4,5,6,7,8,10,11}"
#endif
|
rrnewton/Haskell-CnC
|
Intel/Cnc.hs
|
bsd-3-clause
| 1,075 | 0 | 2 | 170 | 14 | 13 | 1 | 12 | 0 |
{-# LANGUAGE OverloadedStrings #-}
module Handlers.Subscriber where
import Control.Monad.IO.Class
import Data.Aeson (decode)
import Data.Text.Lazy (Text)
import qualified Database.MySQL.Base as Mysql
import Database.Subscriber
import Network.HTTP.Types.Status
import Types.Subscriber
import Web.Scotty
import Web.Scotty.Internal.Types (ActionT)
import Data.Pool (Pool, tryWithResource)
showSubscribers :: Pool Mysql.MySQLConn -> ActionM ()
showSubscribers dbPool = do
subscribers <- liftIO (tryWithResource dbPool listSubscriber)
json subscribers
showSubscriber :: Pool Mysql.MySQLConn -> ActionM ()
showSubscriber dbPool = do
idSubscriber <- param "id" :: ActionM Integer
subscriber <- liftIO (tryWithResource dbPool $ fetchSubscriber idSubscriber)
json subscriber
deleteSubscribers :: Pool Mysql.MySQLConn -> ActionM ()
deleteSubscribers dbPool = do
idSubscriber <- param "id" :: ActionM Integer
liftIO $ tryWithResource dbPool $ deleteSubscriber idSubscriber
status ok200
addSubscriber :: Pool Mysql.MySQLConn -> ActionM ()
addSubscriber dbPool = do
subscriber <- parseSubscriber
liftIO $ tryWithResource dbPool $ insertSubscriber subscriber
json subscriber
status created201
-- Parse the request body into the Subscriber
parseSubscriber :: ActionT Text IO (Maybe Subscriber)
parseSubscriber = do
b <- body
return (decode b :: Maybe Subscriber)
|
ArekCzarnik/Uthenga
|
src/Handlers/Subscriber.hs
|
bsd-3-clause
| 1,383 | 0 | 11 | 196 | 392 | 195 | 197 | 36 | 1 |
-- http://adventofcode.com/2016/day/19
module Day_19 where
import Data.Sequence as S
type Elfs = S.Seq Int
main :: IO ()
main = do
print ("Part 1", part 1) -- 1830117
print ("Part 2", part 2) -- 1417887
part :: Int -> Elfs
part n = until ((1==) . S.length) (rotate . (if n == 1 then popNext
else popOpposite)) $ elfs
elfs :: Elfs
elfs = S.fromList [1..3012210]
popOpposite :: Elfs -> Elfs
popOpposite xs = S.deleteAt index xs
where
index = S.length xs `div` 2
popNext :: Elfs -> Elfs
popNext = S.deleteAt 1
rotate :: Elfs -> Elfs
rotate xs = S.drop 1 xs >< S.take 1 xs
|
MaxwellBo/Advent_Of_Code_2016
|
Day_19.hs
|
bsd-3-clause
| 642 | 0 | 11 | 181 | 247 | 133 | 114 | 19 | 2 |
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
import GHC.TypeLits
import Data.Type.Bool
infixl 8 &
x & f = f x
-- | Type for person construction
data PersonC (i :: [Symbol]) =
PersonC { firstNameC :: String
, lastNameC :: String
, locationC :: String
}
-- | Unparametrized type after construction
data Person =
Person { firstName :: !String
, lastName :: !String
, location :: !String
}
-- | Setters
setFirstName :: String -> PersonC i -> PersonC ("firstName" ': i)
setFirstName x pc = pc {firstNameC=x}
setLastName :: String -> PersonC i -> PersonC ("lastName" ': i)
setLastName x pc = pc {lastNameC=x}
setLocation :: String -> PersonC i -> PersonC ("location" ': i)
setLocation x pc = pc {locationC=x}
-- | Type of least defined Person, ⊥
type PersonCBottom = PersonC '[]
personCBottom :: PersonC '[]
personCBottom = PersonC undefined undefined undefined
-- | Equivalence class of greatest-defined Persons
class PersonCTop a where
makePerson :: a -> Person
instance (["firstName", "lastName", "location"] :< i ~ True) => PersonCTop (PersonC i) where
makePerson PersonC{..} = Person firstNameC lastNameC locationC
-- | Ordering relation of subset inclusion
type family (ls :: [Symbol]) :< (rs :: [Symbol]) where
(l ': ls) :< rs = Elem l rs && (ls :< rs)
('[]) :< rs = True
type family Elem (ls :: Symbol) (rs :: [Symbol]) where
Elem l '[] = False
Elem l (l ':rs) = True
Elem l (r ':rs) = Elem l rs
-- Now, our typesafe constructors in action!:
-- | The following typechecks:
me1 :: Person
me1 = makePerson $ personCBottom
& setFirstName "Sean"
& setLastName "Lee"
& setLocation "Brooklyn"
-- | As does this: (different order)
me2 :: Person
me2 = makePerson $ personCBottom
& setLocation "Brooklyn"
& setLastName "Lee"
& setFirstName "Sean"
-- | And this: (non-increasing updates)
me3 :: Person
me3 = makePerson $ personCBottom
& setFirstName "Sean"
& setLastName "Lee"
& setLocation "Queens"
& setLocation "just kidding Brooklyn"
-- | But not this, as expected, because we forgot to define locationC!
-- me :: Person
-- me = makePerson $ personCBottom
-- & setFirstName "Sean"
-- & setLastName "Lee"
|
sleexyz/haskell-fun
|
TypeSafeComposableConstructors.hs
|
bsd-3-clause
| 2,457 | 0 | 9 | 523 | 644 | 355 | 289 | 62 | 1 |
{-# LANGUAGE DeriveGeneric #-}
module TPar.Server.Types where
import Control.Distributed.Process
import Data.Binary
import Data.Time.Clock
import System.Exit
import GHC.Generics
import TPar.Rpc
import TPar.JobMatch
import TPar.Types
import TPar.SubPubStream
import TPar.ProcessPipe
-- | A channel which should be used by a 'Worker' to indicate that a job has
-- been started. It provides a 'SendPort' which will be called by the server to indicate that any atomic watches have been established and that the job can proceed.
type JobStartedNotify = RpcSendPort (SubPubSource ProcessOutput ExitCode) ()
-- | A channel which should be used by a 'Worker' to indicate that a job has
-- finished.
type JobFinishedChan = SendPort (UTCTime, ExitCode)
data ServerIface =
ServerIface { protocolVersion :: ProtocolVersion
, serverPid :: ProcessId
, enqueueJob :: RpcSendPort (JobRequest, Maybe JobStartingNotify) JobId
, requestJob :: RpcSendPort () (Job, JobStartedNotify, JobFinishedChan)
, killJobs :: RpcSendPort JobMatch [Job]
, getQueueStatus :: RpcSendPort JobMatch [Job]
, rerunJobs :: RpcSendPort JobMatch [Job]
}
deriving (Generic)
instance Binary ServerIface
type ProtocolVersion = Int
currentProtocolVersion :: ProtocolVersion
currentProtocolVersion = 5
{- $ the-story
Starting a job (in the general case with an atomic monitor) happens as follows,
1. An 'enqueueJob' request is sent to the server. This request carries a
'JobStartingNotify' which will be used to guarantee that the job doesn't start
before the monitor is established.
2. The server places the job on the queue in the 'Queued' state.
3. A worker sends a 'requestJob' request to the server, the job is de-queued,
moved to 'Starting' state, and sent to the worker.
4. The worker creates a (paused) 'SubPubSource' for the job and notifies the
server with the 'JobStartedNotify'. The worker then waits on the result of the
'SubPubSource'.
5. The server notifies the job originator of the 'SubPubSource' with the
'JobStartingNotify' included in the 'enqueueJob' request.
6. The originator subscribes to the 'SubPubSource' and returns a confirmation to
the server.
7. The server starts the 'SubPubSource', moves the job to the 'Running' state,
and waits for notification on the 'JobFinishedChan'.
8. Optional: The server may kill the job due to a 'killJobs' request. In this
case the worker process running the job is asked to exit and the job is moved to
the 'Killed' state.
9. The worker eventually finishes the job and notifies the server on the
'JobFinishedChan'.
10. The server moves the job to either 'Failed' or 'Finished' state.
-}
|
bgamari/tpar
|
TPar/Server/Types.hs
|
bsd-3-clause
| 2,774 | 0 | 11 | 564 | 236 | 141 | 95 | 27 | 1 |
{-# LANGUAGE CPP, NondecreasingIndentation, TupleSections, RecordWildCards #-}
{-# OPTIONS_GHC -fno-cse #-}
--
-- (c) The University of Glasgow 2002-2006
--
-- -fno-cse is needed for GLOBAL_VAR's to behave properly
-- | The dynamic linker for GHCi.
--
-- This module deals with the top-level issues of dynamic linking,
-- calling the object-code linker and the byte-code linker where
-- necessary.
module Linker ( getHValue, showLinkerState,
linkExpr, linkDecls, unload, withExtendedLinkEnv,
extendLinkEnv, deleteFromLinkEnv,
extendLoadedPkgs,
linkPackages,initDynLinker,linkModule,
linkCmdLineLibs,
-- Saving/restoring globals
PersistentLinkerState, saveLinkerGlobals, restoreLinkerGlobals
) where
#include "HsVersions.h"
import GHCi
import GHCi.RemoteTypes
import LoadIface
import ByteCodeLink
import ByteCodeAsm
import ByteCodeTypes
import TcRnMonad
import Packages
import DriverPhases
import Finder
import HscTypes
import Name
import NameEnv
import NameSet
import UniqFM
import Module
import ListSetOps
import DynFlags
import BasicTypes
import Outputable
import Panic
import Util
import ErrUtils
import SrcLoc
import qualified Maybes
import UniqSet
import FastString
import Platform
import SysTools
-- Standard libraries
import Control.Monad
import Control.Applicative((<|>))
import Data.IORef
import Data.List
import Data.Maybe
import Control.Concurrent.MVar
import System.FilePath
import System.Directory
import Exception
{- **********************************************************************
The Linker's state
********************************************************************* -}
{-
The persistent linker state *must* match the actual state of the
C dynamic linker at all times, so we keep it in a private global variable.
The global IORef used for PersistentLinkerState actually contains another MVar.
The reason for this is that we want to allow another loaded copy of the GHC
library to side-effect the PLS and for those changes to be reflected here.
The PersistentLinkerState maps Names to actual closures (for
interpreted code only), for use during linking.
-}
GLOBAL_VAR_M(v_PersistentLinkerState, newMVar (panic "Dynamic linker not initialised"), MVar PersistentLinkerState)
GLOBAL_VAR(v_InitLinkerDone, False, Bool) -- Set True when dynamic linker is initialised
modifyPLS_ :: (PersistentLinkerState -> IO PersistentLinkerState) -> IO ()
modifyPLS_ f = readIORef v_PersistentLinkerState >>= flip modifyMVar_ f
modifyPLS :: (PersistentLinkerState -> IO (PersistentLinkerState, a)) -> IO a
modifyPLS f = readIORef v_PersistentLinkerState >>= flip modifyMVar f
data PersistentLinkerState
= PersistentLinkerState {
-- Current global mapping from Names to their true values
closure_env :: ClosureEnv,
-- The current global mapping from RdrNames of DataCons to
-- info table addresses.
-- When a new Unlinked is linked into the running image, or an existing
-- module in the image is replaced, the itbl_env must be updated
-- appropriately.
itbl_env :: !ItblEnv,
-- The currently loaded interpreted modules (home package)
bcos_loaded :: ![Linkable],
-- And the currently-loaded compiled modules (home package)
objs_loaded :: ![Linkable],
-- The currently-loaded packages; always object code
-- Held, as usual, in dependency order; though I am not sure if
-- that is really important
pkgs_loaded :: ![UnitId],
-- we need to remember the name of previous temporary DLL/.so
-- libraries so we can link them (see #10322)
temp_sos :: ![(FilePath, String)] }
emptyPLS :: DynFlags -> PersistentLinkerState
emptyPLS _ = PersistentLinkerState {
closure_env = emptyNameEnv,
itbl_env = emptyNameEnv,
pkgs_loaded = init_pkgs,
bcos_loaded = [],
objs_loaded = [],
temp_sos = [] }
-- Packages that don't need loading, because the compiler
-- shares them with the interpreted program.
--
-- The linker's symbol table is populated with RTS symbols using an
-- explicit list. See rts/Linker.c for details.
where init_pkgs = [rtsUnitId]
extendLoadedPkgs :: [UnitId] -> IO ()
extendLoadedPkgs pkgs =
modifyPLS_ $ \s ->
return s{ pkgs_loaded = pkgs ++ pkgs_loaded s }
extendLinkEnv :: [(Name,ForeignHValue)] -> IO ()
extendLinkEnv new_bindings =
modifyPLS_ $ \pls -> do
let ce = closure_env pls
let new_ce = extendClosureEnv ce new_bindings
return pls{ closure_env = new_ce }
deleteFromLinkEnv :: [Name] -> IO ()
deleteFromLinkEnv to_remove =
modifyPLS_ $ \pls -> do
let ce = closure_env pls
let new_ce = delListFromNameEnv ce to_remove
return pls{ closure_env = new_ce }
-- | Get the 'HValue' associated with the given name.
--
-- May cause loading the module that contains the name.
--
-- Throws a 'ProgramError' if loading fails or the name cannot be found.
getHValue :: HscEnv -> Name -> IO ForeignHValue
getHValue hsc_env name = do
initDynLinker hsc_env
pls <- modifyPLS $ \pls -> do
if (isExternalName name) then do
(pls', ok) <- linkDependencies hsc_env pls noSrcSpan
[nameModule name]
if (failed ok) then throwGhcExceptionIO (ProgramError "")
else return (pls', pls')
else
return (pls, pls)
case lookupNameEnv (closure_env pls) name of
Just (_,aa) -> return aa
Nothing
-> ASSERT2(isExternalName name, ppr name)
do let sym_to_find = nameToCLabel name "closure"
m <- lookupClosure hsc_env (unpackFS sym_to_find)
case m of
Just hvref -> mkFinalizedHValue hsc_env hvref
Nothing -> linkFail "ByteCodeLink.lookupCE"
(unpackFS sym_to_find)
linkDependencies :: HscEnv -> PersistentLinkerState
-> SrcSpan -> [Module]
-> IO (PersistentLinkerState, SuccessFlag)
linkDependencies hsc_env pls span needed_mods = do
-- initDynLinker (hsc_dflags hsc_env)
let hpt = hsc_HPT hsc_env
dflags = hsc_dflags hsc_env
-- The interpreter and dynamic linker can only handle object code built
-- the "normal" way, i.e. no non-std ways like profiling or ticky-ticky.
-- So here we check the build tag: if we're building a non-standard way
-- then we need to find & link object files built the "normal" way.
maybe_normal_osuf <- checkNonStdWay dflags span
-- Find what packages and linkables are required
(lnks, pkgs) <- getLinkDeps hsc_env hpt pls
maybe_normal_osuf span needed_mods
-- Link the packages and modules required
pls1 <- linkPackages' hsc_env pkgs pls
linkModules hsc_env pls1 lnks
-- | Temporarily extend the linker state.
withExtendedLinkEnv :: (ExceptionMonad m) =>
[(Name,ForeignHValue)] -> m a -> m a
withExtendedLinkEnv new_env action
= gbracket (liftIO $ extendLinkEnv new_env)
(\_ -> reset_old_env)
(\_ -> action)
where
-- Remember that the linker state might be side-effected
-- during the execution of the IO action, and we don't want to
-- lose those changes (we might have linked a new module or
-- package), so the reset action only removes the names we
-- added earlier.
reset_old_env = liftIO $ do
modifyPLS_ $ \pls ->
let cur = closure_env pls
new = delListFromNameEnv cur (map fst new_env)
in return pls{ closure_env = new }
-- | Display the persistent linker state.
showLinkerState :: DynFlags -> IO ()
showLinkerState dflags
= do pls <- readIORef v_PersistentLinkerState >>= readMVar
log_action dflags dflags NoReason SevDump noSrcSpan defaultDumpStyle
(vcat [text "----- Linker state -----",
text "Pkgs:" <+> ppr (pkgs_loaded pls),
text "Objs:" <+> ppr (objs_loaded pls),
text "BCOs:" <+> ppr (bcos_loaded pls)])
{- **********************************************************************
Initialisation
********************************************************************* -}
-- | Initialise the dynamic linker. This entails
--
-- a) Calling the C initialisation procedure,
--
-- b) Loading any packages specified on the command line,
--
-- c) Loading any packages specified on the command line, now held in the
-- @-l@ options in @v_Opt_l@,
--
-- d) Loading any @.o\/.dll@ files specified on the command line, now held
-- in @ldInputs@,
--
-- e) Loading any MacOS frameworks.
--
-- NOTE: This function is idempotent; if called more than once, it does
-- nothing. This is useful in Template Haskell, where we call it before
-- trying to link.
--
initDynLinker :: HscEnv -> IO ()
initDynLinker hsc_env =
modifyPLS_ $ \pls0 -> do
done <- readIORef v_InitLinkerDone
if done then return pls0
else do writeIORef v_InitLinkerDone True
reallyInitDynLinker hsc_env
reallyInitDynLinker :: HscEnv -> IO PersistentLinkerState
reallyInitDynLinker hsc_env = do
-- Initialise the linker state
let dflags = hsc_dflags hsc_env
pls0 = emptyPLS dflags
-- (a) initialise the C dynamic linker
initObjLinker hsc_env
-- (b) Load packages from the command-line (Note [preload packages])
pls <- linkPackages' hsc_env (preloadPackages (pkgState dflags)) pls0
-- steps (c), (d) and (e)
linkCmdLineLibs' hsc_env pls
linkCmdLineLibs :: HscEnv -> IO ()
linkCmdLineLibs hsc_env = do
initDynLinker hsc_env
modifyPLS_ $ \pls -> do
linkCmdLineLibs' hsc_env pls
linkCmdLineLibs' :: HscEnv -> PersistentLinkerState -> IO PersistentLinkerState
linkCmdLineLibs' hsc_env pls =
do
let dflags@(DynFlags { ldInputs = cmdline_ld_inputs
, libraryPaths = lib_paths}) = hsc_dflags hsc_env
-- (c) Link libraries from the command-line
let minus_ls = [ lib | Option ('-':'l':lib) <- cmdline_ld_inputs ]
libspecs <- mapM (locateLib hsc_env False lib_paths) minus_ls
-- (d) Link .o files from the command-line
classified_ld_inputs <- mapM (classifyLdInput dflags)
[ f | FileOption _ f <- cmdline_ld_inputs ]
-- (e) Link any MacOS frameworks
let platform = targetPlatform dflags
let (framework_paths, frameworks) =
if platformUsesFrameworks platform
then (frameworkPaths dflags, cmdlineFrameworks dflags)
else ([],[])
-- Finally do (c),(d),(e)
let cmdline_lib_specs = catMaybes classified_ld_inputs
++ libspecs
++ map Framework frameworks
if null cmdline_lib_specs then return pls
else do
-- Add directories to library search paths
let all_paths = let paths = framework_paths
++ lib_paths
++ [ takeDirectory dll | DLLPath dll <- libspecs ]
in nub $ map normalise paths
pathCache <- mapM (addLibrarySearchPath hsc_env) all_paths
pls1 <- foldM (preloadLib hsc_env lib_paths framework_paths) pls
cmdline_lib_specs
maybePutStr dflags "final link ... "
ok <- resolveObjs hsc_env
-- DLLs are loaded, reset the search paths
mapM_ (removeLibrarySearchPath hsc_env) $ reverse pathCache
if succeeded ok then maybePutStrLn dflags "done"
else throwGhcExceptionIO (ProgramError "linking extra libraries/objects failed")
return pls1
{- Note [preload packages]
Why do we need to preload packages from the command line? This is an
explanation copied from #2437:
I tried to implement the suggestion from #3560, thinking it would be
easy, but there are two reasons we link in packages eagerly when they
are mentioned on the command line:
* So that you can link in extra object files or libraries that
depend on the packages. e.g. ghc -package foo -lbar where bar is a
C library that depends on something in foo. So we could link in
foo eagerly if and only if there are extra C libs or objects to
link in, but....
* Haskell code can depend on a C function exported by a package, and
the normal dependency tracking that TH uses can't know about these
dependencies. The test ghcilink004 relies on this, for example.
I conclude that we need two -package flags: one that says "this is a
package I want to make available", and one that says "this is a
package I want to link in eagerly". Would that be too complicated for
users?
-}
classifyLdInput :: DynFlags -> FilePath -> IO (Maybe LibrarySpec)
classifyLdInput dflags f
| isObjectFilename platform f = return (Just (Object f))
| isDynLibFilename platform f = return (Just (DLLPath f))
| otherwise = do
log_action dflags dflags NoReason SevInfo noSrcSpan defaultUserStyle
(text ("Warning: ignoring unrecognised input `" ++ f ++ "'"))
return Nothing
where platform = targetPlatform dflags
preloadLib
:: HscEnv -> [String] -> [String] -> PersistentLinkerState
-> LibrarySpec -> IO PersistentLinkerState
preloadLib hsc_env lib_paths framework_paths pls lib_spec = do
maybePutStr dflags ("Loading object " ++ showLS lib_spec ++ " ... ")
case lib_spec of
Object static_ish -> do
(b, pls1) <- preload_static lib_paths static_ish
maybePutStrLn dflags (if b then "done" else "not found")
return pls1
Archive static_ish -> do
b <- preload_static_archive lib_paths static_ish
maybePutStrLn dflags (if b then "done" else "not found")
return pls
DLL dll_unadorned -> do
maybe_errstr <- loadDLL hsc_env (mkSOName platform dll_unadorned)
case maybe_errstr of
Nothing -> maybePutStrLn dflags "done"
Just mm | platformOS platform /= OSDarwin ->
preloadFailed mm lib_paths lib_spec
Just mm | otherwise -> do
-- As a backup, on Darwin, try to also load a .so file
-- since (apparently) some things install that way - see
-- ticket #8770.
let libfile = ("lib" ++ dll_unadorned) <.> "so"
err2 <- loadDLL hsc_env libfile
case err2 of
Nothing -> maybePutStrLn dflags "done"
Just _ -> preloadFailed mm lib_paths lib_spec
return pls
DLLPath dll_path -> do
do maybe_errstr <- loadDLL hsc_env dll_path
case maybe_errstr of
Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm lib_paths lib_spec
return pls
Framework framework ->
if platformUsesFrameworks (targetPlatform dflags)
then do maybe_errstr <- loadFramework hsc_env framework_paths framework
case maybe_errstr of
Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm framework_paths lib_spec
return pls
else panic "preloadLib Framework"
where
dflags = hsc_dflags hsc_env
platform = targetPlatform dflags
preloadFailed :: String -> [String] -> LibrarySpec -> IO ()
preloadFailed sys_errmsg paths spec
= do maybePutStr dflags "failed.\n"
throwGhcExceptionIO $
CmdLineError (
"user specified .o/.so/.DLL could not be loaded ("
++ sys_errmsg ++ ")\nWhilst trying to load: "
++ showLS spec ++ "\nAdditional directories searched:"
++ (if null paths then " (none)" else
intercalate "\n" (map (" "++) paths)))
-- Not interested in the paths in the static case.
preload_static _paths name
= do b <- doesFileExist name
if not b then return (False, pls)
else if dynamicGhc
then do pls1 <- dynLoadObjs hsc_env pls [name]
return (True, pls1)
else do loadObj hsc_env name
return (True, pls)
preload_static_archive _paths name
= do b <- doesFileExist name
if not b then return False
else do if dynamicGhc
then panic "Loading archives not supported"
else loadArchive hsc_env name
return True
{- **********************************************************************
Link a byte-code expression
********************************************************************* -}
-- | Link a single expression, /including/ first linking packages and
-- modules that this expression depends on.
--
-- Raises an IO exception ('ProgramError') if it can't find a compiled
-- version of the dependents to link.
--
linkExpr :: HscEnv -> SrcSpan -> UnlinkedBCO -> IO ForeignHValue
linkExpr hsc_env span root_ul_bco
= do {
-- Initialise the linker (if it's not been done already)
; initDynLinker hsc_env
-- Take lock for the actual work.
; modifyPLS $ \pls0 -> do {
-- Link the packages and modules required
; (pls, ok) <- linkDependencies hsc_env pls0 span needed_mods
; if failed ok then
throwGhcExceptionIO (ProgramError "")
else do {
-- Link the expression itself
let ie = itbl_env pls
ce = closure_env pls
-- Link the necessary packages and linkables
; let nobreakarray = error "no break array"
bco_ix = mkNameEnv [(unlinkedBCOName root_ul_bco, 0)]
; resolved <- linkBCO hsc_env ie ce bco_ix nobreakarray root_ul_bco
; [root_hvref] <- createBCOs hsc_env [resolved]
; fhv <- mkFinalizedHValue hsc_env root_hvref
; return (pls, fhv)
}}}
where
free_names = nameSetElems (bcoFreeNames root_ul_bco)
needed_mods :: [Module]
needed_mods = [ nameModule n | n <- free_names,
isExternalName n, -- Names from other modules
not (isWiredInName n) -- Exclude wired-in names
] -- (see note below)
-- Exclude wired-in names because we may not have read
-- their interface files, so getLinkDeps will fail
-- All wired-in names are in the base package, which we link
-- by default, so we can safely ignore them here.
dieWith :: DynFlags -> SrcSpan -> MsgDoc -> IO a
dieWith dflags span msg = throwGhcExceptionIO (ProgramError (showSDoc dflags (mkLocMessage SevFatal span msg)))
checkNonStdWay :: DynFlags -> SrcSpan -> IO (Maybe FilePath)
checkNonStdWay dflags srcspan
| gopt Opt_ExternalInterpreter dflags = return Nothing
-- with -fexternal-interpreter we load the .o files, whatever way
-- they were built. If they were built for a non-std way, then
-- we will use the appropriate variant of the iserv binary to load them.
| interpWays == haskellWays = return Nothing
-- Only if we are compiling with the same ways as GHC is built
-- with, can we dynamically load those object files. (see #3604)
| objectSuf dflags == normalObjectSuffix && not (null haskellWays)
= failNonStd dflags srcspan
| otherwise = return (Just (interpTag ++ "o"))
where
haskellWays = filter (not . wayRTSOnly) (ways dflags)
interpTag = case mkBuildTag interpWays of
"" -> ""
tag -> tag ++ "_"
normalObjectSuffix :: String
normalObjectSuffix = phaseInputExt StopLn
failNonStd :: DynFlags -> SrcSpan -> IO (Maybe FilePath)
failNonStd dflags srcspan = dieWith dflags srcspan $
text "Cannot load" <+> compWay <+>
text "objects when GHC is built" <+> ghciWay $$
text "To fix this, either:" $$
text " (1) Use -fexternal-interprter, or" $$
text " (2) Build the program twice: once" <+>
ghciWay <> text ", and then" $$
text " with" <+> compWay <+>
text "using -osuf to set a different object file suffix."
where compWay
| WayDyn `elem` ways dflags = text "-dynamic"
| WayProf `elem` ways dflags = text "-prof"
| otherwise = text "normal"
ghciWay
| dynamicGhc = text "with -dynamic"
| rtsIsProfiled = text "with -prof"
| otherwise = text "the normal way"
getLinkDeps :: HscEnv -> HomePackageTable
-> PersistentLinkerState
-> Maybe FilePath -- replace object suffices?
-> SrcSpan -- for error messages
-> [Module] -- If you need these
-> IO ([Linkable], [UnitId]) -- ... then link these first
-- Fails with an IO exception if it can't find enough files
getLinkDeps hsc_env hpt pls replace_osuf span mods
-- Find all the packages and linkables that a set of modules depends on
= do {
-- 1. Find the dependent home-pkg-modules/packages from each iface
-- (omitting modules from the interactive package, which is already linked)
; (mods_s, pkgs_s) <- follow_deps (filterOut isInteractiveModule mods)
emptyUniqSet emptyUniqSet;
; let {
-- 2. Exclude ones already linked
-- Main reason: avoid findModule calls in get_linkable
mods_needed = mods_s `minusList` linked_mods ;
pkgs_needed = pkgs_s `minusList` pkgs_loaded pls ;
linked_mods = map (moduleName.linkableModule)
(objs_loaded pls ++ bcos_loaded pls) }
-- 3. For each dependent module, find its linkable
-- This will either be in the HPT or (in the case of one-shot
-- compilation) we may need to use maybe_getFileLinkable
; let { osuf = objectSuf dflags }
; lnks_needed <- mapM (get_linkable osuf) mods_needed
; return (lnks_needed, pkgs_needed) }
where
dflags = hsc_dflags hsc_env
this_pkg = thisPackage dflags
-- The ModIface contains the transitive closure of the module dependencies
-- within the current package, *except* for boot modules: if we encounter
-- a boot module, we have to find its real interface and discover the
-- dependencies of that. Hence we need to traverse the dependency
-- tree recursively. See bug #936, testcase ghci/prog007.
follow_deps :: [Module] -- modules to follow
-> UniqSet ModuleName -- accum. module dependencies
-> UniqSet UnitId -- accum. package dependencies
-> IO ([ModuleName], [UnitId]) -- result
follow_deps [] acc_mods acc_pkgs
= return (uniqSetToList acc_mods, uniqSetToList acc_pkgs)
follow_deps (mod:mods) acc_mods acc_pkgs
= do
mb_iface <- initIfaceCheck hsc_env $
loadInterface msg mod (ImportByUser False)
iface <- case mb_iface of
Maybes.Failed err -> throwGhcExceptionIO (ProgramError (showSDoc dflags err))
Maybes.Succeeded iface -> return iface
when (mi_boot iface) $ link_boot_mod_error mod
let
pkg = moduleUnitId mod
deps = mi_deps iface
pkg_deps = dep_pkgs deps
(boot_deps, mod_deps) = partitionWith is_boot (dep_mods deps)
where is_boot (m,True) = Left m
is_boot (m,False) = Right m
boot_deps' = filter (not . (`elementOfUniqSet` acc_mods)) boot_deps
acc_mods' = addListToUniqSet acc_mods (moduleName mod : mod_deps)
acc_pkgs' = addListToUniqSet acc_pkgs $ map fst pkg_deps
--
if pkg /= this_pkg
then follow_deps mods acc_mods (addOneToUniqSet acc_pkgs' pkg)
else follow_deps (map (mkModule this_pkg) boot_deps' ++ mods)
acc_mods' acc_pkgs'
where
msg = text "need to link module" <+> ppr mod <+>
text "due to use of Template Haskell"
link_boot_mod_error mod =
throwGhcExceptionIO (ProgramError (showSDoc dflags (
text "module" <+> ppr mod <+>
text "cannot be linked; it is only available as a boot module")))
no_obj :: Outputable a => a -> IO b
no_obj mod = dieWith dflags span $
text "cannot find object file for module " <>
quotes (ppr mod) $$
while_linking_expr
while_linking_expr = text "while linking an interpreted expression"
-- This one is a build-system bug
get_linkable osuf mod_name -- A home-package module
| Just mod_info <- lookupUFM hpt mod_name
= adjust_linkable (Maybes.expectJust "getLinkDeps" (hm_linkable mod_info))
| otherwise
= do -- It's not in the HPT because we are in one shot mode,
-- so use the Finder to get a ModLocation...
mb_stuff <- findHomeModule hsc_env mod_name
case mb_stuff of
Found loc mod -> found loc mod
_ -> no_obj mod_name
where
found loc mod = do {
-- ...and then find the linkable for it
mb_lnk <- findObjectLinkableMaybe mod loc ;
case mb_lnk of {
Nothing -> no_obj mod ;
Just lnk -> adjust_linkable lnk
}}
adjust_linkable lnk
| Just new_osuf <- replace_osuf = do
new_uls <- mapM (adjust_ul new_osuf)
(linkableUnlinked lnk)
return lnk{ linkableUnlinked=new_uls }
| otherwise =
return lnk
adjust_ul new_osuf (DotO file) = do
MASSERT(osuf `isSuffixOf` file)
let file_base = fromJust (stripExtension osuf file)
new_file = file_base <.> new_osuf
ok <- doesFileExist new_file
if (not ok)
then dieWith dflags span $
text "cannot find object file "
<> quotes (text new_file) $$ while_linking_expr
else return (DotO new_file)
adjust_ul _ (DotA fp) = panic ("adjust_ul DotA " ++ show fp)
adjust_ul _ (DotDLL fp) = panic ("adjust_ul DotDLL " ++ show fp)
adjust_ul _ l@(BCOs {}) = return l
{- **********************************************************************
Loading a Decls statement
********************************************************************* -}
linkDecls :: HscEnv -> SrcSpan -> CompiledByteCode -> IO ()
linkDecls hsc_env span cbc@CompiledByteCode{..} = do
-- Initialise the linker (if it's not been done already)
initDynLinker hsc_env
-- Take lock for the actual work.
modifyPLS $ \pls0 -> do
-- Link the packages and modules required
(pls, ok) <- linkDependencies hsc_env pls0 span needed_mods
if failed ok
then throwGhcExceptionIO (ProgramError "")
else do
-- Link the expression itself
let ie = plusNameEnv (itbl_env pls) bc_itbls
ce = closure_env pls
-- Link the necessary packages and linkables
new_bindings <- linkSomeBCOs hsc_env ie ce [cbc]
nms_fhvs <- makeForeignNamedHValueRefs hsc_env new_bindings
let pls2 = pls { closure_env = extendClosureEnv ce nms_fhvs
, itbl_env = ie }
return (pls2, ())
where
free_names = concatMap (nameSetElems . bcoFreeNames) bc_bcos
needed_mods :: [Module]
needed_mods = [ nameModule n | n <- free_names,
isExternalName n, -- Names from other modules
not (isWiredInName n) -- Exclude wired-in names
] -- (see note below)
-- Exclude wired-in names because we may not have read
-- their interface files, so getLinkDeps will fail
-- All wired-in names are in the base package, which we link
-- by default, so we can safely ignore them here.
{- **********************************************************************
Loading a single module
********************************************************************* -}
linkModule :: HscEnv -> Module -> IO ()
linkModule hsc_env mod = do
initDynLinker hsc_env
modifyPLS_ $ \pls -> do
(pls', ok) <- linkDependencies hsc_env pls noSrcSpan [mod]
if (failed ok) then throwGhcExceptionIO (ProgramError "could not link module")
else return pls'
{- **********************************************************************
Link some linkables
The linkables may consist of a mixture of
byte-code modules and object modules
********************************************************************* -}
linkModules :: HscEnv -> PersistentLinkerState -> [Linkable]
-> IO (PersistentLinkerState, SuccessFlag)
linkModules hsc_env pls linkables
= mask_ $ do -- don't want to be interrupted by ^C in here
let (objs, bcos) = partition isObjectLinkable
(concatMap partitionLinkable linkables)
-- Load objects first; they can't depend on BCOs
(pls1, ok_flag) <- dynLinkObjs hsc_env pls objs
if failed ok_flag then
return (pls1, Failed)
else do
pls2 <- dynLinkBCOs hsc_env pls1 bcos
return (pls2, Succeeded)
-- HACK to support f-x-dynamic in the interpreter; no other purpose
partitionLinkable :: Linkable -> [Linkable]
partitionLinkable li
= let li_uls = linkableUnlinked li
li_uls_obj = filter isObject li_uls
li_uls_bco = filter isInterpretable li_uls
in
case (li_uls_obj, li_uls_bco) of
(_:_, _:_) -> [li {linkableUnlinked=li_uls_obj},
li {linkableUnlinked=li_uls_bco}]
_ -> [li]
findModuleLinkable_maybe :: [Linkable] -> Module -> Maybe Linkable
findModuleLinkable_maybe lis mod
= case [LM time nm us | LM time nm us <- lis, nm == mod] of
[] -> Nothing
[li] -> Just li
_ -> pprPanic "findModuleLinkable" (ppr mod)
linkableInSet :: Linkable -> [Linkable] -> Bool
linkableInSet l objs_loaded =
case findModuleLinkable_maybe objs_loaded (linkableModule l) of
Nothing -> False
Just m -> linkableTime l == linkableTime m
{- **********************************************************************
The object-code linker
********************************************************************* -}
dynLinkObjs :: HscEnv -> PersistentLinkerState -> [Linkable]
-> IO (PersistentLinkerState, SuccessFlag)
dynLinkObjs hsc_env pls objs = do
-- Load the object files and link them
let (objs_loaded', new_objs) = rmDupLinkables (objs_loaded pls) objs
pls1 = pls { objs_loaded = objs_loaded' }
unlinkeds = concatMap linkableUnlinked new_objs
wanted_objs = map nameOfObject unlinkeds
if interpreterDynamic (hsc_dflags hsc_env)
then do pls2 <- dynLoadObjs hsc_env pls1 wanted_objs
return (pls2, Succeeded)
else do mapM_ (loadObj hsc_env) wanted_objs
-- Link them all together
ok <- resolveObjs hsc_env
-- If resolving failed, unload all our
-- object modules and carry on
if succeeded ok then do
return (pls1, Succeeded)
else do
pls2 <- unload_wkr hsc_env [] pls1
return (pls2, Failed)
dynLoadObjs :: HscEnv -> PersistentLinkerState -> [FilePath]
-> IO PersistentLinkerState
dynLoadObjs _ pls [] = return pls
dynLoadObjs hsc_env pls objs = do
let dflags = hsc_dflags hsc_env
let platform = targetPlatform dflags
let minus_ls = [ lib | Option ('-':'l':lib) <- ldInputs dflags ]
let minus_big_ls = [ lib | Option ('-':'L':lib) <- ldInputs dflags ]
(soFile, libPath , libName) <- newTempLibName dflags (soExt platform)
let
dflags2 = dflags {
-- We don't want the original ldInputs in
-- (they're already linked in), but we do want
-- to link against previous dynLoadObjs
-- libraries if there were any, so that the linker
-- can resolve dependencies when it loads this
-- library.
ldInputs =
concatMap
(\(lp, l) ->
[ Option ("-L" ++ lp)
, Option ("-Wl,-rpath")
, Option ("-Wl," ++ lp)
, Option ("-l" ++ l)
])
(temp_sos pls)
++ concatMap
(\lp ->
[ Option ("-L" ++ lp)
, Option ("-Wl,-rpath")
, Option ("-Wl," ++ lp)
])
minus_big_ls
++ map (\l -> Option ("-l" ++ l)) minus_ls,
-- Add -l options and -L options from dflags.
--
-- When running TH for a non-dynamic way, we still
-- need to make -l flags to link against the dynamic
-- libraries, so we need to add WayDyn to ways.
--
-- Even if we're e.g. profiling, we still want
-- the vanilla dynamic libraries, so we set the
-- ways / build tag to be just WayDyn.
ways = [WayDyn],
buildTag = mkBuildTag [WayDyn],
outputFile = Just soFile
}
-- link all "loaded packages" so symbols in those can be resolved
-- Note: We are loading packages with local scope, so to see the
-- symbols in this link we must link all loaded packages again.
linkDynLib dflags2 objs (pkgs_loaded pls)
consIORef (filesToNotIntermediateClean dflags) soFile
m <- loadDLL hsc_env soFile
case m of
Nothing -> return pls { temp_sos = (libPath, libName) : temp_sos pls }
Just err -> panic ("Loading temp shared object failed: " ++ err)
rmDupLinkables :: [Linkable] -- Already loaded
-> [Linkable] -- New linkables
-> ([Linkable], -- New loaded set (including new ones)
[Linkable]) -- New linkables (excluding dups)
rmDupLinkables already ls
= go already [] ls
where
go already extras [] = (already, extras)
go already extras (l:ls)
| linkableInSet l already = go already extras ls
| otherwise = go (l:already) (l:extras) ls
{- **********************************************************************
The byte-code linker
********************************************************************* -}
dynLinkBCOs :: HscEnv -> PersistentLinkerState -> [Linkable]
-> IO PersistentLinkerState
dynLinkBCOs hsc_env pls bcos = do
let (bcos_loaded', new_bcos) = rmDupLinkables (bcos_loaded pls) bcos
pls1 = pls { bcos_loaded = bcos_loaded' }
unlinkeds :: [Unlinked]
unlinkeds = concatMap linkableUnlinked new_bcos
cbcs :: [CompiledByteCode]
cbcs = map byteCodeOfObject unlinkeds
ies = map bc_itbls cbcs
gce = closure_env pls
final_ie = foldr plusNameEnv (itbl_env pls) ies
names_and_refs <- linkSomeBCOs hsc_env final_ie gce cbcs
-- We only want to add the external ones to the ClosureEnv
let (to_add, to_drop) = partition (isExternalName.fst) names_and_refs
-- Immediately release any HValueRefs we're not going to add
freeHValueRefs hsc_env (map snd to_drop)
-- Wrap finalizers on the ones we want to keep
new_binds <- makeForeignNamedHValueRefs hsc_env to_add
return pls1 { closure_env = extendClosureEnv gce new_binds,
itbl_env = final_ie }
-- Link a bunch of BCOs and return references to their values
linkSomeBCOs :: HscEnv
-> ItblEnv
-> ClosureEnv
-> [CompiledByteCode]
-> IO [(Name,HValueRef)]
-- The returned HValueRefs are associated 1-1 with
-- the incoming unlinked BCOs. Each gives the
-- value of the corresponding unlinked BCO
linkSomeBCOs hsc_env ie ce mods = foldr fun do_link mods []
where
fun CompiledByteCode{..} inner accum =
case bc_breaks of
Nothing -> inner ((panic "linkSomeBCOs: no break array", bc_bcos) : accum)
Just mb -> withForeignRef (modBreaks_flags mb) $ \breakarray ->
inner ((breakarray, bc_bcos) : accum)
do_link [] = return []
do_link mods = do
let flat = [ (breakarray, bco) | (breakarray, bcos) <- mods, bco <- bcos ]
names = map (unlinkedBCOName . snd) flat
bco_ix = mkNameEnv (zip names [0..])
resolved <- sequence [ linkBCO hsc_env ie ce bco_ix breakarray bco
| (breakarray, bco) <- flat ]
hvrefs <- createBCOs hsc_env resolved
return (zip names hvrefs)
-- | Useful to apply to the result of 'linkSomeBCOs'
makeForeignNamedHValueRefs
:: HscEnv -> [(Name,HValueRef)] -> IO [(Name,ForeignHValue)]
makeForeignNamedHValueRefs hsc_env bindings =
mapM (\(n, hvref) -> (n,) <$> mkFinalizedHValue hsc_env hvref) bindings
{- **********************************************************************
Unload some object modules
********************************************************************* -}
-- ---------------------------------------------------------------------------
-- | Unloading old objects ready for a new compilation sweep.
--
-- The compilation manager provides us with a list of linkables that it
-- considers \"stable\", i.e. won't be recompiled this time around. For
-- each of the modules current linked in memory,
--
-- * if the linkable is stable (and it's the same one -- the user may have
-- recompiled the module on the side), we keep it,
--
-- * otherwise, we unload it.
--
-- * we also implicitly unload all temporary bindings at this point.
--
unload :: HscEnv
-> [Linkable] -- ^ The linkables to *keep*.
-> IO ()
unload hsc_env linkables
= mask_ $ do -- mask, so we're safe from Ctrl-C in here
-- Initialise the linker (if it's not been done already)
initDynLinker hsc_env
new_pls
<- modifyPLS $ \pls -> do
pls1 <- unload_wkr hsc_env linkables pls
return (pls1, pls1)
let dflags = hsc_dflags hsc_env
debugTraceMsg dflags 3 $
text "unload: retaining objs" <+> ppr (objs_loaded new_pls)
debugTraceMsg dflags 3 $
text "unload: retaining bcos" <+> ppr (bcos_loaded new_pls)
return ()
unload_wkr :: HscEnv
-> [Linkable] -- stable linkables
-> PersistentLinkerState
-> IO PersistentLinkerState
-- Does the core unload business
-- (the wrapper blocks exceptions and deals with the PLS get and put)
unload_wkr hsc_env keep_linkables pls = do
let (objs_to_keep, bcos_to_keep) = partition isObjectLinkable keep_linkables
discard keep l = not (linkableInSet l keep)
(objs_to_unload, remaining_objs_loaded) =
partition (discard objs_to_keep) (objs_loaded pls)
(bcos_to_unload, remaining_bcos_loaded) =
partition (discard bcos_to_keep) (bcos_loaded pls)
mapM_ unloadObjs objs_to_unload
mapM_ unloadObjs bcos_to_unload
-- If we unloaded any object files at all, we need to purge the cache
-- of lookupSymbol results.
when (not (null (objs_to_unload ++
filter (not . null . linkableObjs) bcos_to_unload))) $
purgeLookupSymbolCache hsc_env
let bcos_retained = map linkableModule remaining_bcos_loaded
-- Note that we want to remove all *local*
-- (i.e. non-isExternal) names too (these are the
-- temporary bindings from the command line).
keep_name (n,_) = isExternalName n &&
nameModule n `elem` bcos_retained
itbl_env' = filterNameEnv keep_name (itbl_env pls)
closure_env' = filterNameEnv keep_name (closure_env pls)
new_pls = pls { itbl_env = itbl_env',
closure_env = closure_env',
bcos_loaded = remaining_bcos_loaded,
objs_loaded = remaining_objs_loaded }
return new_pls
where
unloadObjs :: Linkable -> IO ()
unloadObjs lnk
| dynamicGhc = return ()
-- We don't do any cleanup when linking objects with the
-- dynamic linker. Doing so introduces extra complexity for
-- not much benefit.
| otherwise
= mapM_ (unloadObj hsc_env) [f | DotO f <- linkableUnlinked lnk]
-- The components of a BCO linkable may contain
-- dot-o files. Which is very confusing.
--
-- But the BCO parts can be unlinked just by
-- letting go of them (plus of course depopulating
-- the symbol table which is done in the main body)
{- **********************************************************************
Loading packages
********************************************************************* -}
data LibrarySpec
= Object FilePath -- Full path name of a .o file, including trailing .o
-- For dynamic objects only, try to find the object
-- file in all the directories specified in
-- v_Library_paths before giving up.
| Archive FilePath -- Full path name of a .a file, including trailing .a
| DLL String -- "Unadorned" name of a .DLL/.so
-- e.g. On unix "qt" denotes "libqt.so"
-- On Windows "burble" denotes "burble.DLL" or "libburble.dll"
-- loadDLL is platform-specific and adds the lib/.so/.DLL
-- suffixes platform-dependently
| DLLPath FilePath -- Absolute or relative pathname to a dynamic library
-- (ends with .dll or .so).
| Framework String -- Only used for darwin, but does no harm
-- If this package is already part of the GHCi binary, we'll already
-- have the right DLLs for this package loaded, so don't try to
-- load them again.
--
-- But on Win32 we must load them 'again'; doing so is a harmless no-op
-- as far as the loader is concerned, but it does initialise the list
-- of DLL handles that rts/Linker.c maintains, and that in turn is
-- used by lookupSymbol. So we must call addDLL for each library
-- just to get the DLL handle into the list.
partOfGHCi :: [PackageName]
partOfGHCi
| isWindowsHost || isDarwinHost = []
| otherwise = map (PackageName . mkFastString)
["base", "template-haskell", "editline"]
showLS :: LibrarySpec -> String
showLS (Object nm) = "(static) " ++ nm
showLS (Archive nm) = "(static archive) " ++ nm
showLS (DLL nm) = "(dynamic) " ++ nm
showLS (DLLPath nm) = "(dynamic) " ++ nm
showLS (Framework nm) = "(framework) " ++ nm
-- | Link exactly the specified packages, and their dependents (unless of
-- course they are already linked). The dependents are linked
-- automatically, and it doesn't matter what order you specify the input
-- packages.
--
linkPackages :: HscEnv -> [UnitId] -> IO ()
-- NOTE: in fact, since each module tracks all the packages it depends on,
-- we don't really need to use the package-config dependencies.
--
-- However we do need the package-config stuff (to find aux libs etc),
-- and following them lets us load libraries in the right order, which
-- perhaps makes the error message a bit more localised if we get a link
-- failure. So the dependency walking code is still here.
linkPackages hsc_env new_pkgs = do
-- It's probably not safe to try to load packages concurrently, so we take
-- a lock.
initDynLinker hsc_env
modifyPLS_ $ \pls -> do
linkPackages' hsc_env new_pkgs pls
linkPackages' :: HscEnv -> [UnitId] -> PersistentLinkerState
-> IO PersistentLinkerState
linkPackages' hsc_env new_pks pls = do
pkgs' <- link (pkgs_loaded pls) new_pks
return $! pls { pkgs_loaded = pkgs' }
where
dflags = hsc_dflags hsc_env
link :: [UnitId] -> [UnitId] -> IO [UnitId]
link pkgs new_pkgs =
foldM link_one pkgs new_pkgs
link_one pkgs new_pkg
| new_pkg `elem` pkgs -- Already linked
= return pkgs
| Just pkg_cfg <- lookupPackage dflags new_pkg
= do { -- Link dependents first
pkgs' <- link pkgs (depends pkg_cfg)
-- Now link the package itself
; linkPackage hsc_env pkg_cfg
; return (new_pkg : pkgs') }
| otherwise
= throwGhcExceptionIO (CmdLineError ("unknown package: " ++ unitIdString new_pkg))
linkPackage :: HscEnv -> PackageConfig -> IO ()
linkPackage hsc_env pkg
= do
let dflags = hsc_dflags hsc_env
platform = targetPlatform dflags
dirs | interpreterDynamic dflags = Packages.libraryDynDirs pkg
| otherwise = Packages.libraryDirs pkg
let hs_libs = Packages.hsLibraries pkg
-- The FFI GHCi import lib isn't needed as
-- compiler/ghci/Linker.hs + rts/Linker.c link the
-- interpreted references to FFI to the compiled FFI.
-- We therefore filter it out so that we don't get
-- duplicate symbol errors.
hs_libs' = filter ("HSffi" /=) hs_libs
-- Because of slight differences between the GHC dynamic linker and
-- the native system linker some packages have to link with a
-- different list of libraries when using GHCi. Examples include: libs
-- that are actually gnu ld scripts, and the possibility that the .a
-- libs do not exactly match the .so/.dll equivalents. So if the
-- package file provides an "extra-ghci-libraries" field then we use
-- that instead of the "extra-libraries" field.
extra_libs =
(if null (Packages.extraGHCiLibraries pkg)
then Packages.extraLibraries pkg
else Packages.extraGHCiLibraries pkg)
++ [ lib | '-':'l':lib <- Packages.ldOptions pkg ]
hs_classifieds <- mapM (locateLib hsc_env True dirs) hs_libs'
extra_classifieds <- mapM (locateLib hsc_env False dirs) extra_libs
let classifieds = hs_classifieds ++ extra_classifieds
-- Complication: all the .so's must be loaded before any of the .o's.
let known_dlls = [ dll | DLLPath dll <- classifieds ]
dlls = [ dll | DLL dll <- classifieds ]
objs = [ obj | Object obj <- classifieds ]
archs = [ arch | Archive arch <- classifieds ]
-- Add directories to library search paths
let dll_paths = map takeDirectory known_dlls
all_paths = nub $ map normalise $ dll_paths ++ dirs
pathCache <- mapM (addLibrarySearchPath hsc_env) all_paths
maybePutStr dflags
("Loading package " ++ sourcePackageIdString pkg ++ " ... ")
-- See comments with partOfGHCi
when (packageName pkg `notElem` partOfGHCi) $ do
loadFrameworks hsc_env platform pkg
mapM_ (load_dyn hsc_env)
(known_dlls ++ map (mkSOName platform) dlls)
-- After loading all the DLLs, we can load the static objects.
-- Ordering isn't important here, because we do one final link
-- step to resolve everything.
mapM_ (loadObj hsc_env) objs
mapM_ (loadArchive hsc_env) archs
maybePutStr dflags "linking ... "
ok <- resolveObjs hsc_env
-- DLLs are loaded, reset the search paths
-- Import libraries will be loaded via loadArchive so only
-- reset the DLL search path after all archives are loaded
-- as well.
mapM_ (removeLibrarySearchPath hsc_env) $ reverse pathCache
if succeeded ok
then maybePutStrLn dflags "done."
else let errmsg = "unable to load package `"
++ sourcePackageIdString pkg ++ "'"
in throwGhcExceptionIO (InstallationError errmsg)
-- we have already searched the filesystem; the strings passed to load_dyn
-- can be passed directly to loadDLL. They are either fully-qualified
-- ("/usr/lib/libfoo.so"), or unqualified ("libfoo.so"). In the latter case,
-- loadDLL is going to search the system paths to find the library.
--
load_dyn :: HscEnv -> FilePath -> IO ()
load_dyn hsc_env dll = do
r <- loadDLL hsc_env dll
case r of
Nothing -> return ()
Just err -> throwGhcExceptionIO (CmdLineError ("can't load .so/.DLL for: "
++ dll ++ " (" ++ err ++ ")" ))
loadFrameworks :: HscEnv -> Platform -> PackageConfig -> IO ()
loadFrameworks hsc_env platform pkg
= when (platformUsesFrameworks platform) $ mapM_ load frameworks
where
fw_dirs = Packages.frameworkDirs pkg
frameworks = Packages.frameworks pkg
load fw = do r <- loadFramework hsc_env fw_dirs fw
case r of
Nothing -> return ()
Just err -> throwGhcExceptionIO (CmdLineError ("can't load framework: "
++ fw ++ " (" ++ err ++ ")" ))
-- Try to find an object file for a given library in the given paths.
-- If it isn't present, we assume that addDLL in the RTS can find it,
-- which generally means that it should be a dynamic library in the
-- standard system search path.
-- For GHCi we tend to prefer dynamic libraries over static ones as
-- they are easier to load and manage, have less overhead.
locateLib :: HscEnv -> Bool -> [FilePath] -> String -> IO LibrarySpec
locateLib hsc_env is_hs dirs lib
| not is_hs
-- For non-Haskell libraries (e.g. gmp, iconv):
-- first look in library-dirs for a dynamic library (libfoo.so)
-- then look in library-dirs for a static library (libfoo.a)
-- then look in library-dirs and inplace GCC for a dynamic library (libfoo.so)
-- then check for system dynamic libraries (e.g. kernel32.dll on windows)
-- then try looking for import libraries on Windows (.dll.a, .lib)
-- then try "gcc --print-file-name" to search gcc's search path
-- then look in library-dirs and inplace GCC for a static library (libfoo.a)
-- for a dynamic library (#5289)
-- otherwise, assume loadDLL can find it
--
= findDll `orElse`
findSysDll `orElse`
tryImpLib `orElse`
tryGcc `orElse`
findArchive `orElse`
assumeDll
| loading_dynamic_hs_libs -- search for .so libraries first.
= findHSDll `orElse`
findDynObject `orElse`
assumeDll
| loading_profiled_hs_libs -- only a libHSfoo_p.a archive will do.
= findArchive `orElse`
assumeDll
| otherwise
-- HSfoo.o is the best, but only works for the normal way
-- libHSfoo.a is the backup option.
= findObject `orElse`
findArchive `orElse`
assumeDll
where
dflags = hsc_dflags hsc_env
obj_file = lib <.> "o"
dyn_obj_file = lib <.> "dyn_o"
arch_file = "lib" ++ lib ++ lib_tag <.> "a"
lib_tag = if is_hs && loading_profiled_hs_libs then "_p" else ""
loading_profiled_hs_libs = interpreterProfiled dflags
loading_dynamic_hs_libs = interpreterDynamic dflags
import_libs = [lib <.> "lib", "lib" ++ lib <.> "lib", "lib" ++ lib <.> "dll.a"]
hs_dyn_lib_name = lib ++ '-':programName dflags ++ projectVersion dflags
hs_dyn_lib_file = mkHsSOName platform hs_dyn_lib_name
so_name = mkSOName platform lib
lib_so_name = "lib" ++ so_name
dyn_lib_file = case (arch, os) of
(ArchX86_64, OSSolaris2) -> "64" </> so_name
_ -> so_name
findObject = liftM (fmap Object) $ findFile dirs obj_file
findDynObject = liftM (fmap Object) $ findFile dirs dyn_obj_file
findArchive = let local = liftM (fmap Archive) $ findFile dirs arch_file
linked = liftM (fmap Archive) $ searchForLibUsingGcc dflags arch_file dirs
in liftM2 (<|>) local linked
findHSDll = liftM (fmap DLLPath) $ findFile dirs hs_dyn_lib_file
findDll = liftM (fmap DLLPath) $ findFile dirs dyn_lib_file
findSysDll = fmap (fmap $ DLL . takeFileName) $ findSystemLibrary hsc_env so_name
tryGcc = let short = liftM (fmap DLLPath) $ searchForLibUsingGcc dflags so_name dirs
full = liftM (fmap DLLPath) $ searchForLibUsingGcc dflags lib_so_name dirs
in liftM2 (<|>) short full
tryImpLib = case os of
OSMinGW32 -> let check name = liftM (fmap Archive) $ searchForLibUsingGcc dflags name dirs
in apply (map check import_libs)
_ -> return Nothing
assumeDll = return (DLL lib)
infixr `orElse`
f `orElse` g = f >>= maybe g return
apply [] = return Nothing
apply (x:xs) = do x' <- x
if isJust x'
then return x'
else apply xs
platform = targetPlatform dflags
arch = platformArch platform
os = platformOS platform
searchForLibUsingGcc :: DynFlags -> String -> [FilePath] -> IO (Maybe FilePath)
searchForLibUsingGcc dflags so dirs = do
-- GCC does not seem to extend the library search path (using -L) when using
-- --print-file-name. So instead pass it a new base location.
str <- askCc dflags (map (FileOption "-B") dirs
++ [Option "--print-file-name", Option so])
let file = case lines str of
[] -> ""
l:_ -> l
if (file == so)
then return Nothing
else return (Just file)
-- ----------------------------------------------------------------------------
-- Loading a dynamic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
-- Darwin / MacOS X only: load a framework
-- a framework is a dynamic library packaged inside a directory of the same
-- name. They are searched for in different paths than normal libraries.
loadFramework :: HscEnv -> [FilePath] -> FilePath -> IO (Maybe String)
loadFramework hsc_env extraPaths rootname
= do { either_dir <- tryIO getHomeDirectory
; let homeFrameworkPath = case either_dir of
Left _ -> []
Right dir -> [dir </> "Library/Frameworks"]
ps = extraPaths ++ homeFrameworkPath ++ defaultFrameworkPaths
; mb_fwk <- findFile ps fwk_file
; case mb_fwk of
Just fwk_path -> loadDLL hsc_env fwk_path
Nothing -> return (Just "not found") }
-- Tried all our known library paths, but dlopen()
-- has no built-in paths for frameworks: give up
where
fwk_file = rootname <.> "framework" </> rootname
-- sorry for the hardcoded paths, I hope they won't change anytime soon:
defaultFrameworkPaths = ["/Library/Frameworks", "/System/Library/Frameworks"]
{- **********************************************************************
Helper functions
********************************************************************* -}
maybePutStr :: DynFlags -> String -> IO ()
maybePutStr dflags s
= when (verbosity dflags > 1) $
do let act = log_action dflags
act dflags
NoReason
SevInteractive
noSrcSpan
defaultUserStyle
(text s)
maybePutStrLn :: DynFlags -> String -> IO ()
maybePutStrLn dflags s = maybePutStr dflags (s ++ "\n")
{- **********************************************************************
Tunneling global variables into new instance of GHC library
********************************************************************* -}
saveLinkerGlobals :: IO (MVar PersistentLinkerState, Bool)
saveLinkerGlobals = liftM2 (,) (readIORef v_PersistentLinkerState) (readIORef v_InitLinkerDone)
restoreLinkerGlobals :: (MVar PersistentLinkerState, Bool) -> IO ()
restoreLinkerGlobals (pls, ild) = do
writeIORef v_PersistentLinkerState pls
writeIORef v_InitLinkerDone ild
|
GaloisInc/halvm-ghc
|
compiler/ghci/Linker.hs
|
bsd-3-clause
| 57,881 | 6 | 24 | 17,672 | 10,576 | 5,399 | 5,177 | -1 | -1 |
module Parlindromize (simple, kmp) where
isPalindrome :: String -> Bool
isPalindrome s = s == (reverse s)
simple :: String -> Int
simple [] = 0
simple xxs@(x:xs)
| isPalindrome xxs = length xxs
| otherwise = 2 + simple xs
matches :: Eq a => [a] -> [a] -> [Int]
matches ws = map length . filter (endswith ws) . inits
inits :: [a] -> [[a]]
inits xs = inits' (init xs) [xs]
inits' :: [a] -> [[a]] -> [[a]]
inits' [] ys = []:ys
inits' xs ys = inits' (init xs) (xs:ys)
endswith = undefined
kmp :: String -> String -> [Int]
kmp = undefined
bm :: String -> String -> [Int]
bm = undefined
|
everyevery/programming_study
|
algospot/palindromize/palindromize.hs
|
mit
| 594 | 0 | 9 | 130 | 322 | 171 | 151 | 20 | 1 |
module Network.Types where
-----------------------------------------------------------------------------
-- |
-- Module : Network.Types
-- Copyright : (c) Commiters
-- License : The same as `nmcli` - http://manpages.ubuntu.com/manpages/maverick/man1/nmcli.1.html
--
-- Maintainer : massyl, ardumont
-- Stability : experimental
-- Portability : unportable
-- Dependency : nmcli (network-manager package in debian-based platform - http://www.gnome.org/projects/NetworkManager/)
--
-- Definition types.
--
-----------------------------------------------------------------------------
import Control.Monad.Error
import Control.Monad.Writer (WriterT)
type WifiMonad w a = WriterT w IO a
type SSID = String
type Signal = Integer
type Wifi = (SSID, Signal)
type Log = String
type Output = String
type Psk = String
-- | A CLI command to connect or scan wifi
type CLICommand = String
-- | A command is either to scan wifi or to connect to one.
data Command = Scan { scan :: CLICommand }
| Connect { connect :: SSID -> CLICommand }
| Create { create :: SSID -> Psk -> CLICommand }
instance Show Command where
show (Scan _) = "Scan wifi"
show (Connect _) = "Connect to an elected Wifi..."
show (Create _) = "Create a new wifi entry..."
-- ####### Error
data CommandError = BadCommand String
| NoWifiAvailable
| ScanWifiError
| KnownWifiError
| ConnectionError String
| ConnectionCreationError String
| EmptySSID String
| Default String
deriving Eq
instance Show CommandError where
show NoWifiAvailable = "No known wifi available!"
show ScanWifiError = "Scan wifi error."
show KnownWifiError = "List known wifi error."
show (BadCommand cmd) = "'" ++ cmd ++ "' is not a valid command."
show (ConnectionError wifiSSID) = "Error during connection to '" ++ wifiSSID ++ "'."
show (ConnectionCreationError wifiSSID) = "Error during wifi creation connection to '" ++ wifiSSID ++ "'."
show (EmptySSID wifiSSID) = "Empty SSID '" ++ wifiSSID ++ "'."
show (Default msg) = msg
instance Error CommandError where
noMsg = Default "An error has occured."
strMsg = Default
type ThrowsError = Either CommandError
|
ardumont/hWifi
|
Network/Types.hs
|
gpl-2.0
| 2,411 | 0 | 10 | 636 | 407 | 235 | 172 | 40 | 0 |
module Foo where
class Monad a => <resolved>Foo a where
baz :: a -> String
|
carymrobbins/intellij-haskforce
|
tests/gold/resolve/Class00002/Foo.hs
|
apache-2.0
| 78 | 2 | 7 | 18 | 36 | 18 | 18 | -1 | -1 |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd">
<helpset version="2.0" xml:lang="da-DK">
<title>>Run Applications | ZAP Extensions</title>
<maps>
<homeID>top</homeID>
<mapref location="map.jhm"/>
</maps>
<view>
<name>TOC</name>
<label>Contents</label>
<type>org.zaproxy.zap.extension.help.ZapTocView</type>
<data>toc.xml</data>
</view>
<view>
<name>Index</name>
<label>Index</label>
<type>javax.help.IndexView</type>
<data>index.xml</data>
</view>
<view>
<name>Search</name>
<label>Søg</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
JavaHelpSearch
</data>
</view>
<view>
<name>Favorites</name>
<label>Favorites</label>
<type>javax.help.FavoritesView</type>
</view>
</helpset>
|
veggiespam/zap-extensions
|
addOns/invoke/src/main/javahelp/org/zaproxy/zap/extension/invoke/resources/help_da_DK/helpset_da_DK.hs
|
apache-2.0
| 981 | 78 | 55 | 160 | 424 | 213 | 211 | -1 | -1 |
module ImportsSemi where
{
; ; ; ; ; ;
import Data.List
;;;
}
|
mpickering/ghc-exactprint
|
tests/examples/ghc710/ImportsSemi.hs
|
bsd-3-clause
| 62 | 2 | 4 | 14 | 22 | 17 | 5 | 2 | 0 |
module Language.Haskell.GhcMod.Info (
info
, types
) where
import Control.Applicative ((<$>))
import Data.Function (on)
import Data.List (sortBy)
import Data.Maybe (catMaybes)
import Exception (ghandle, SomeException(..))
import GHC (GhcMonad, LHsBind, LHsExpr, LPat, Id, TypecheckedModule(..), SrcSpan, Type)
import qualified GHC as G
import Language.Haskell.GhcMod.Doc (showPage)
import Language.Haskell.GhcMod.Gap (HasType(..))
import qualified Language.Haskell.GhcMod.Gap as Gap
import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.SrcUtils
import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.Convert
----------------------------------------------------------------
-- | Obtaining information of a target expression. (GHCi's info:)
info :: IOish m
=> FilePath -- ^ A target file.
-> Expression -- ^ A Haskell expression.
-> GhcModT m String
info file expr = do
opt <- options
convert opt <$> ghandle handler body
where
body = inModuleContext file $ \dflag style -> do
sdoc <- Gap.infoThing expr
return $ showPage dflag style sdoc
handler (SomeException _) = return "Cannot show info"
----------------------------------------------------------------
-- | Obtaining type of a target expression. (GHCi's type:)
types :: IOish m
=> FilePath -- ^ A target file.
-> Int -- ^ Line number.
-> Int -- ^ Column number.
-> GhcModT m String
types file lineNo colNo = do
opt <- options
convert opt <$> ghandle handler body
where
body = inModuleContext file $ \dflag style -> do
modSum <- Gap.fileModSummary file
srcSpanTypes <- getSrcSpanType modSum lineNo colNo
return $ map (toTup dflag style) $ sortBy (cmp `on` fst) srcSpanTypes
handler (SomeException _) = return []
getSrcSpanType :: GhcMonad m => G.ModSummary -> Int -> Int -> m [(SrcSpan, Type)]
getSrcSpanType modSum lineNo colNo = do
p <- G.parseModule modSum
tcm@TypecheckedModule{tm_typechecked_source = tcs} <- G.typecheckModule p
let bs = listifySpans tcs (lineNo, colNo) :: [LHsBind Id]
es = listifySpans tcs (lineNo, colNo) :: [LHsExpr Id]
ps = listifySpans tcs (lineNo, colNo) :: [LPat Id]
bts <- mapM (getType tcm) bs
ets <- mapM (getType tcm) es
pts <- mapM (getType tcm) ps
return $ catMaybes $ concat [ets, bts, pts]
|
cabrera/ghc-mod
|
Language/Haskell/GhcMod/Info.hs
|
bsd-3-clause
| 2,410 | 0 | 15 | 509 | 715 | 386 | 329 | 52 | 1 |
module Language.Lukas
-- -- $Id$
( lukas
, nolukas
, dyck
, nodyck
)
where
-- Sprachen von Lukasiewicz, Dyck
import Autolib.Set
import Data.List ( mapAccumL, nub )
import Autolib.Util.Zufall
import Language.Type
lukas :: Language
lukas = Language
{ nametag = "Lukas"
, abbreviation = "Lukasiewicz-Sprache über {a,b}"
, alphabet = mkSet "ab"
, contains = lukas_ok
, sample = lukas_sam
, anti_sample = sample nolukas
}
nolukas :: Language
nolukas = Language
{ nametag = "ComLukas"
, abbreviation = "Komplement der Lukasiewicz-Sprache über {a,b}"
, alphabet = mkSet "ab"
, contains = not . lukas_ok
, sample = random_sample nolukas
, anti_sample = sample lukas
}
dyck :: Language
dyck = Language
{ nametag = "Dyck"
, abbreviation = "Dyck-Sprache (korrekt geklammerte Wörter über {a,b})"
, alphabet = mkSet "ab"
, contains = dyck_ok
, sample = dyck_sam
, anti_sample = sample nodyck
}
nodyck :: Language
nodyck = Language
{ nametag = "ComDyck"
, abbreviation = "Komplement der Dyck-Sprache (nicht korrekt geklammerte Wörter über {a,b})"
, alphabet = mkSet "ab"
, contains = not . dyck_ok
, sample = random_sample nodyck
, anti_sample = sample dyck
}
-------------------------------------------------------------------------
diffs :: String -> [ Int ]
diffs w = snd $ mapAccumL (\ x c ->
let y = case c of 'a' -> 1; 'b' -> -1
in (x+y, x+y) ) 0 w
lukas_ok :: String -> Bool
lukas_ok [] = False
lukas_ok w =
let ds = diffs w
in and [ d >= 0 | d <- init ds ]
&& last ds < 0
dyck_ok :: String -> Bool
dyck_ok [] = True
dyck_ok w =
let ds = diffs w
in and [ d >= 0 | d <- ds ]
&& last ds == 0
-------------------------------------------------------------------------
balanced :: RandomC m => Int -> m String
balanced n | n > 0 = do
a <- randomRIO (0,n-1)
let b = n-1-a
u <- balanced a
v <- balanced b
return $ "a" ++ u ++ "b" ++ v
balanced _ = return ""
-----------------------------------------------------------------
good :: RandomC m => Int -> m String
good n = do
w <- balanced n
return $ w ++ "b"
lukas_sam :: RandomC m => Int -> Int -> m [ String ]
lukas_sam c n | even n = return []
lukas_sam c n = do
ws <- sequence $ replicate c $ good (n `div` 2)
return $ nub ws
dyck_sam c n | odd n = return []
dyck_sam c n = do
ws <- sequence $ replicate c $ balanced (n `div` 2)
return $ nub ws
|
Erdwolf/autotool-bonn
|
src/Language/Lukas.hs
|
gpl-2.0
| 2,674 | 20 | 16 | 819 | 878 | 458 | 420 | 78 | 2 |
-- For all type variables a, we require (CNode a)
-- If we have a data constructor
-- X a_1 .. a_n, and exactly one a_k is a Language.C.Data.NodeInfo, then return that a_k
data Test1 = X Int NodeInfo | Y NodeInfo String | Z Int NodeInfo Integer deriving (Show {-! ,CNode !-})
-- If we have a data constructor
-- X a, then return nodeInfo a
data Test2 = U Test1 | V Test1 deriving (Show {-! ,CNode !-})
-- If we have a data constructor
-- X a_1 .. a_n, and exactly one a_k is a polymorphic variable, then return (nodeInfo a_k)
data Test3 a = A a Test1 | B Test2 a | C (Test3 a) a (Test3 a) | D (Test4 a) a deriving (Show {-! ,Functor,Annotated,CNode !-})
data Test4 a = Test4 NodeInfo (Test3 a) deriving (Show {-! ,Functor, CNode !-})
|
vincenthz/language-c
|
src/derive/DeriveTest2.hs
|
bsd-3-clause
| 744 | 0 | 8 | 156 | 152 | 89 | 63 | 4 | 0 |
{-# LANGUAGE GADTs, Rank2Types, CPP #-}
-----------------------------------------------------------------------------------------
-- |
-- Module : FRP.Yampa.Hybrid
-- Copyright : (c) Antony Courtney and Henrik Nilsson, Yale University, 2003
-- License : BSD-style (see the LICENSE file in the distribution)
--
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability : non-portable (GHC extensions)
--
-----------------------------------------------------------------------------------------
module FRP.Yampa.Hybrid (
-- * Discrete to continuous-time signal functions
-- ** Wave-form generation
hold, -- :: a -> SF (Event a) a
dHold, -- :: a -> SF (Event a) a
trackAndHold, -- :: a -> SF (Maybe a) a
dTrackAndHold, -- :: a -> SF (Maybe a) a
-- ** Accumulators
accum, -- :: a -> SF (Event (a -> a)) (Event a)
accumHold, -- :: a -> SF (Event (a -> a)) a
dAccumHold, -- :: a -> SF (Event (a -> a)) a
accumBy, -- :: (b -> a -> b) -> b -> SF (Event a) (Event b)
accumHoldBy, -- :: (b -> a -> b) -> b -> SF (Event a) b
dAccumHoldBy, -- :: (b -> a -> b) -> b -> SF (Event a) b
accumFilter, -- :: (c -> a -> (c, Maybe b)) -> c
-- -> SF (Event a) (Event b)
) where
import Control.Arrow
import FRP.Yampa.InternalCore (SF, epPrim)
import FRP.Yampa.Delays
import FRP.Yampa.Event
------------------------------------------------------------------------------
-- Wave-form generation
------------------------------------------------------------------------------
-- | Zero-order hold.
hold :: a -> SF (Event a) a
hold a_init = epPrim f () a_init
where
f _ a = ((), a, a)
-- !!!
-- !!! 2005-04-10: I DO NO LONGER THINK THIS IS CORRECT!
-- !!! CAN ONE POSSIBLY GET THE DESIRED STRICTNESS PROPERTIES
-- !!! ("DECOUPLING") this way???
-- !!! Also applies to the other "d" functions that were tentatively
-- !!! defined using only epPrim.
-- !!!
-- !!! 2005-06-13: Yes, indeed wrong! (But it's subtle, one has to
-- !!! make sure that the incoming event (and not just the payload
-- !!! of the event) is control dependent on the output of "dHold"
-- !!! to observe it.
-- !!!
-- !!! 2005-06-09: But if iPre can be defined in terms of sscan,
-- !!! and ep + sscan = sscan, then things might work, and
-- !!! it might be possible to define dHold simply as hold >>> iPre
-- !!! without any performance penalty.
-- | Zero-order hold with delay.
--
-- Identity: dHold a0 = hold a0 >>> iPre a0).
dHold :: a -> SF (Event a) a
dHold a0 = hold a0 >>> iPre a0
{-
-- THIS IS WRONG! SEE ABOVE.
dHold a_init = epPrim f a_init a_init
where
f a' a = (a, a', a)
-}
-- | Tracks input signal when available, holds last value when disappears.
--
-- !!! DANGER!!! Event used inside arr! Probably OK because arr will not be
-- !!! optimized to arrE. But still. Maybe rewrite this using, say, scan?
-- !!! or switch? Switching (in hold) for every input sample does not
-- !!! seem like such a great idea anyway.
trackAndHold :: a -> SF (Maybe a) a
trackAndHold a_init = arr (maybe NoEvent Event) >>> hold a_init
dTrackAndHold :: a -> SF (Maybe a) a
dTrackAndHold a_init = trackAndHold a_init >>> iPre a_init
------------------------------------------------------------------------------
-- Accumulators
------------------------------------------------------------------------------
-- | Given an initial value in an accumulator,
-- it returns a signal function that processes
-- an event carrying transformation functions.
-- Every time an 'Event' is received, the function
-- inside it is applied to the accumulator,
-- whose new value is outputted in an 'Event'.
--
accum :: a -> SF (Event (a -> a)) (Event a)
accum a_init = epPrim f a_init NoEvent
where
f a g = (a', Event a', NoEvent) -- Accumulator, output if Event, output if no event
where
a' = g a
-- | Zero-order hold accumulator (always produces the last outputted value
-- until an event arrives).
accumHold :: a -> SF (Event (a -> a)) a
accumHold a_init = epPrim f a_init a_init
where
f a g = (a', a', a') -- Accumulator, output if Event, output if no event
where
a' = g a
-- | Zero-order hold accumulator with delayed initialization (always produces
-- the last outputted value until an event arrives, but the very initial output
-- is always the given accumulator).
dAccumHold :: a -> SF (Event (a -> a)) a
dAccumHold a_init = accumHold a_init >>> iPre a_init
{-
-- WRONG!
-- epPrim DOES and MUST patternmatch
-- on the input at every time step.
-- Test case to check for this added!
dAccumHold a_init = epPrim f a_init a_init
where
f a g = (a', a, a')
where
a' = g a
-}
-- | Accumulator parameterized by the accumulation function.
accumBy :: (b -> a -> b) -> b -> SF (Event a) (Event b)
accumBy g b_init = epPrim f b_init NoEvent
where
f b a = (b', Event b', NoEvent)
where
b' = g b a
-- | Zero-order hold accumulator parameterized by the accumulation function.
accumHoldBy :: (b -> a -> b) -> b -> SF (Event a) b
accumHoldBy g b_init = epPrim f b_init b_init
where
f b a = (b', b', b')
where
b' = g b a
-- !!! This cannot be right since epPrim DOES and MUST patternmatch
-- !!! on the input at every time step.
-- !!! Add a test case to check for this!
-- | Zero-order hold accumulator parameterized by the accumulation function
-- with delayed initialization (initial output sample is always the
-- given accumulator).
dAccumHoldBy :: (b -> a -> b) -> b -> SF (Event a) b
dAccumHoldBy f a_init = accumHoldBy f a_init >>> iPre a_init
{-
-- WRONG!
-- epPrim DOES and MUST patternmatch
-- on the input at every time step.
-- Test case to check for this added!
dAccumHoldBy g b_init = epPrim f b_init b_init
where
f b a = (b', b, b')
where
b' = g b a
-}
{- Untested:
accumBy f b = switch (never &&& identity) $ \a ->
let b' = f b a in NoEvent >-- Event b' --> accumBy f b'
But no real improvement in clarity anyway.
-}
-- accumBy f b = accumFilter (\b -> a -> let b' = f b a in (b', Event b')) b
{-
-- Identity: accumBy f = accumFilter (\b a -> let b' = f b a in (b',Just b'))
accumBy :: (b -> a -> b) -> b -> SF (Event a) (Event b)
accumBy f b_init = SF {sfTF = tf0}
where
tf0 NoEvent = (abAux b_init, NoEvent)
tf0 (Event a0) = let b' = f b_init a0
in (abAux b', Event b')
abAux b = SF' {sfTF' = tf}
where
tf _ NoEvent = (abAux b, NoEvent)
tf _ (Event a) = let b' = f b a
in (abAux b', Event b')
-}
{-
accumFilter :: (c -> a -> (c, Maybe b)) -> c -> SF (Event a) (Event b)
accumFilter f c_init = SF {sfTF = tf0}
where
tf0 NoEvent = (afAux c_init, NoEvent)
tf0 (Event a0) = case f c_init a0 of
(c', Nothing) -> (afAux c', NoEvent)
(c', Just b0) -> (afAux c', Event b0)
afAux c = SF' {sfTF' = tf}
where
tf _ NoEvent = (afAux c, NoEvent)
tf _ (Event a) = case f c a of
(c', Nothing) -> (afAux c', NoEvent)
(c', Just b) -> (afAux c', Event b)
-}
-- | Accumulator parameterized by the accumulator function with filtering,
-- possibly discarding some of the input events based on whether the second
-- component of the result of applying the accumulation function is
-- 'Nothing' or 'Just' x for some x.
accumFilter :: (c -> a -> (c, Maybe b)) -> c -> SF (Event a) (Event b)
accumFilter g c_init = epPrim f c_init NoEvent
where
f c a = case g c a of
(c', Nothing) -> (c', NoEvent, NoEvent)
(c', Just b) -> (c', Event b, NoEvent)
-- Vim modeline
-- vim:set tabstop=8 expandtab:
|
ony/Yampa-core
|
src/FRP/Yampa/Hybrid.hs
|
bsd-3-clause
| 8,145 | 0 | 11 | 2,276 | 922 | 526 | 396 | 51 | 2 |
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd">
<helpset version="2.0" xml:lang="fr-FR">
<title>GraphQL Support Add-on</title>
<maps>
<homeID>graphql</homeID>
<mapref location="map.jhm"/>
</maps>
<view>
<name>TOC</name>
<label>Contents</label>
<type>org.zaproxy.zap.extension.help.ZapTocView</type>
<data>toc.xml</data>
</view>
<view>
<name>Index</name>
<label>Index</label>
<type>javax.help.IndexView</type>
<data>index.xml</data>
</view>
<view>
<name>Search</name>
<label>Search</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
JavaHelpSearch
</data>
</view>
<view>
<name>Favorites</name>
<label>Favorites</label>
<type>javax.help.FavoritesView</type>
</view>
</helpset>
|
thc202/zap-extensions
|
addOns/graphql/src/main/javahelp/org/zaproxy/addon/graphql/resources/help_fr_FR/helpset_fr_FR.hs
|
apache-2.0
| 971 | 77 | 67 | 157 | 413 | 209 | 204 | -1 | -1 |
{-|
Module : Idris.Options
Description : Compiler options for Idris.
License : BSD3
Maintainer : The Idris Community.
-}
{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, DeriveGeneric, PatternGuards #-}
module Idris.Options (Codegen(..), ConsoleWidth(..), HowMuchDocs(..), IRFormat(..),
LanguageExt(..), LogCat(..), Opt(..), Optimisation(..),
OutputFmt(..), REPLPort(..), codegenCats, elabCats, getBC,
getClient, getCodegen, getCodegenArgs, getColour, getConsoleWidth,
getEvalExpr, getExecScript, getFile, getIBCSubDir, getImportDir,
getLanguageExt, getOptLevel, getOptimisation, getOutput,
getOutputTy, getPkg, getPkgCheck, getPkgClean, getPkgDir,
getPkgIndex, getPkgMkDoc, getPkgREPL, getPkgTest, getPort,
getSourceDir, loggingCatsStr, opt, parserCats, strLogCat) where
import Data.Maybe
import GHC.Generics (Generic)
import IRTS.CodegenCommon (OutputType)
import Network.Socket (PortNumber)
data Opt = Filename String
| Quiet
| NoBanner
| ColourREPL Bool
| Idemode
| IdemodeSocket
| IndentWith Int
| IndentClause Int
| ShowAll
| ShowLibs
| ShowLibDir
| ShowDocDir
| ShowIncs
| ShowPkgs
| ShowLoggingCats
| NoBasePkgs
| NoPrelude
| NoBuiltins -- only for the really primitive stuff!
| NoREPL
| OLogging Int
| OLogCats [LogCat]
| Output String
| Interface
| TypeCase
| TypeInType
| DefaultTotal
| DefaultPartial
| WarnPartial
| WarnReach
| AuditIPkg
| EvalTypes
| NoCoverage
| ErrContext
| ShowImpl
| Verbose Int
| Port REPLPort -- ^ REPL TCP port
| IBCSubDir String
| ImportDir String
| SourceDir String
| PkgBuild String
| PkgInstall String
| PkgClean String
| PkgCheck String
| PkgREPL String
| PkgDocBuild String -- IdrisDoc
| PkgDocInstall String
| PkgTest String
| PkgIndex FilePath
| WarnOnly
| Pkg String
| BCAsm String
| DumpDefun String
| DumpCases String
| UseCodegen Codegen
| CodegenArgs String
| OutputTy OutputType
| Extension LanguageExt
| InterpretScript String
| EvalExpr String
| TargetTriple String
| TargetCPU String
| OptLevel Int
| AddOpt Optimisation
| RemoveOpt Optimisation
| Client String
| ShowOrigErr
| AutoWidth -- ^ Automatically adjust terminal width
| AutoSolve -- ^ Automatically issue "solve" tactic in old-style interactive prover
| UseConsoleWidth ConsoleWidth
| DumpHighlights
| DesugarNats
| NoOldTacticDeprecationWarnings -- ^ Don't show deprecation warnings for old-style tactics
| AllowCapitalizedPatternVariables -- ^ Allow pattern variables to be capitalized
deriving (Show, Eq, Generic)
data REPLPort = DontListen | ListenPort PortNumber
deriving (Eq, Generic, Show)
data Codegen = Via IRFormat String
| Bytecode
deriving (Show, Eq, Generic)
data LanguageExt = TypeProviders | ErrorReflection | UniquenessTypes
| DSLNotation | ElabReflection | FCReflection
| LinearTypes
deriving (Show, Eq, Read, Ord, Generic)
data IRFormat = IBCFormat | JSONFormat deriving (Show, Eq, Generic)
-- | How wide is the console?
data ConsoleWidth = InfinitelyWide -- ^ Have pretty-printer assume that lines should not be broken
| ColsWide Int -- ^ Manually specified - must be positive
| AutomaticWidth -- ^ Attempt to determine width, or 80 otherwise
deriving (Show, Eq, Generic)
data HowMuchDocs = FullDocs | OverviewDocs
data OutputFmt = HTMLOutput | LaTeXOutput
data Optimisation = PETransform | GeneralisedNatHack -- ^ partial eval and associated transforms
deriving (Show, Eq, Generic)
-- | Recognised logging categories for the Idris compiler.
--
-- @TODO add in sub categories.
data LogCat = IParse
| IElab
| ICodeGen
| IErasure
| ICoverage
| IIBC
deriving (Show, Eq, Ord, Generic)
strLogCat :: LogCat -> String
strLogCat IParse = "parser"
strLogCat IElab = "elab"
strLogCat ICodeGen = "codegen"
strLogCat IErasure = "erasure"
strLogCat ICoverage = "coverage"
strLogCat IIBC = "ibc"
codegenCats :: [LogCat]
codegenCats = [ICodeGen]
parserCats :: [LogCat]
parserCats = [IParse]
elabCats :: [LogCat]
elabCats = [IElab]
loggingCatsStr :: String
loggingCatsStr = unlines
[ (strLogCat IParse)
, (strLogCat IElab)
, (strLogCat ICodeGen)
, (strLogCat IErasure)
, (strLogCat ICoverage)
, (strLogCat IIBC)
]
getFile :: Opt -> Maybe String
getFile (Filename s) = Just s
getFile _ = Nothing
getBC :: Opt -> Maybe String
getBC (BCAsm s) = Just s
getBC _ = Nothing
getOutput :: Opt -> Maybe String
getOutput (Output s) = Just s
getOutput _ = Nothing
getIBCSubDir :: Opt -> Maybe String
getIBCSubDir (IBCSubDir s) = Just s
getIBCSubDir _ = Nothing
getImportDir :: Opt -> Maybe String
getImportDir (ImportDir s) = Just s
getImportDir _ = Nothing
getSourceDir :: Opt -> Maybe String
getSourceDir (SourceDir s) = Just s
getSourceDir _ = Nothing
getPkgDir :: Opt -> Maybe String
getPkgDir (Pkg s) = Just s
getPkgDir _ = Nothing
getPkg :: Opt -> Maybe (Bool, String)
getPkg (PkgBuild s) = Just (False, s)
getPkg (PkgInstall s) = Just (True, s)
getPkg _ = Nothing
getPkgClean :: Opt -> Maybe String
getPkgClean (PkgClean s) = Just s
getPkgClean _ = Nothing
getPkgREPL :: Opt -> Maybe String
getPkgREPL (PkgREPL s) = Just s
getPkgREPL _ = Nothing
getPkgCheck :: Opt -> Maybe String
getPkgCheck (PkgCheck s) = Just s
getPkgCheck _ = Nothing
-- | Returns None if given an Opt which is not PkgMkDoc
-- Otherwise returns Just x, where x is the contents of PkgMkDoc
getPkgMkDoc :: Opt -- ^ Opt to extract
-> Maybe (Bool, String) -- ^ Result
getPkgMkDoc (PkgDocBuild str) = Just (False,str)
getPkgMkDoc (PkgDocInstall str) = Just (True,str)
getPkgMkDoc _ = Nothing
getPkgTest :: Opt -- ^ the option to extract
-> Maybe String -- ^ the package file to test
getPkgTest (PkgTest f) = Just f
getPkgTest _ = Nothing
getCodegen :: Opt -> Maybe Codegen
getCodegen (UseCodegen x) = Just x
getCodegen _ = Nothing
getCodegenArgs :: Opt -> Maybe String
getCodegenArgs (CodegenArgs args) = Just args
getCodegenArgs _ = Nothing
getConsoleWidth :: Opt -> Maybe ConsoleWidth
getConsoleWidth (UseConsoleWidth x) = Just x
getConsoleWidth _ = Nothing
getExecScript :: Opt -> Maybe String
getExecScript (InterpretScript expr) = Just expr
getExecScript _ = Nothing
getPkgIndex :: Opt -> Maybe FilePath
getPkgIndex (PkgIndex file) = Just file
getPkgIndex _ = Nothing
getEvalExpr :: Opt -> Maybe String
getEvalExpr (EvalExpr expr) = Just expr
getEvalExpr _ = Nothing
getOutputTy :: Opt -> Maybe OutputType
getOutputTy (OutputTy t) = Just t
getOutputTy _ = Nothing
getLanguageExt :: Opt -> Maybe LanguageExt
getLanguageExt (Extension e) = Just e
getLanguageExt _ = Nothing
getTriple :: Opt -> Maybe String
getTriple (TargetTriple x) = Just x
getTriple _ = Nothing
getCPU :: Opt -> Maybe String
getCPU (TargetCPU x) = Just x
getCPU _ = Nothing
getOptLevel :: Opt -> Maybe Int
getOptLevel (OptLevel x) = Just x
getOptLevel _ = Nothing
getOptimisation :: Opt -> Maybe (Bool,Optimisation)
getOptimisation (AddOpt p) = Just (True, p)
getOptimisation (RemoveOpt p) = Just (False, p)
getOptimisation _ = Nothing
getColour :: Opt -> Maybe Bool
getColour (ColourREPL b) = Just b
getColour _ = Nothing
getClient :: Opt -> Maybe String
getClient (Client x) = Just x
getClient _ = Nothing
-- Get the first valid port
getPort :: [Opt] -> Maybe REPLPort
getPort [] = Nothing
getPort (Port p : _ ) = Just p
getPort (_ : xs) = getPort xs
opt :: (Opt -> Maybe a) -> [Opt] -> [a]
opt = mapMaybe
|
kojiromike/Idris-dev
|
src/Idris/Options.hs
|
bsd-3-clause
| 8,378 | 0 | 8 | 2,322 | 2,169 | 1,193 | 976 | 226 | 1 |
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE helpset
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN"
"http://java.sun.com/products/javahelp/helpset_2_0.dtd">
<helpset version="2.0" xml:lang="en-GB">
<title>Plug-n-Hack | ZAP Extension</title>
<maps>
<homeID>top</homeID>
<mapref location="map.jhm"/>
</maps>
<view>
<name>TOC</name>
<label>Contents</label>
<type>org.zaproxy.zap.extension.help.ZapTocView</type>
<data>toc.xml</data>
</view>
<view>
<name>Index</name>
<label>Index</label>
<type>javax.help.IndexView</type>
<data>index.xml</data>
</view>
<view>
<name>Search</name>
<label>Search</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
JavaHelpSearch
</data>
</view>
<view>
<name>Favorites</name>
<label>Favorites</label>
<type>javax.help.FavoritesView</type>
</view>
</helpset>
|
veggiespam/zap-extensions
|
addOns/plugnhack/src/main/javahelp/org/zaproxy/zap/extension/plugnhack/resources/help/helpset.hs
|
apache-2.0
| 985 | 82 | 69 | 171 | 429 | 219 | 210 | -1 | -1 |
{-# LANGUAGE TemplateHaskell #-}
module T3395 where
import Language.Haskell.TH
foo = $(return $
CompE
[NoBindS (VarE $ mkName "undefined")
,BindS (VarP $ mkName "r1") (VarE $ mkName "undefined") ])
|
ezyang/ghc
|
testsuite/tests/th/T3395.hs
|
bsd-3-clause
| 223 | 0 | 13 | 54 | 71 | 38 | 33 | 7 | 1 |
module System.Apotiki.Debian.Package where
import System.Apotiki.Ar
import System.Apotiki.Tar
import System.Apotiki.FileInfo
import System.Apotiki.Utils
import System.Apotiki.Config
import System.Apotiki.Logger
import System.Apotiki.Debian.Control
import Data.List
import System.Directory
import Data.ByteString.Char8 (pack, unpack)
import qualified Data.ByteString as B
import qualified Data.Map as M
writeToPool :: LogChan -> String -> (DebInfo, B.ByteString) -> IO ()
writeToPool logger repodir (info, payload) = do
let path = info M.! "Filename"
let dir_path = reverse $ snd $ break (== '/') $ reverse path
log_info logger $ "found filename: " ++ path
createDirectoryIfMissing True (repodir ++ "/" ++ dir_path)
B.writeFile (repodir ++ "/" ++ path) payload
B.writeFile (repodir ++ "/" ++ dir_path ++ "control") $ pack (show info)
toDebInfo :: String -> DebInfo
toDebInfo input = output where Right output = ctlFromData $ pack $ input
debInfo :: ApotikiConfig -> B.ByteString -> DebInfo
debInfo config payload =
M.union (fileinfo payload) (M.insert "Filename" path debinfo) where
Right archive = (arFromData payload)
ArEntry {entryData = entry} = archive M.! "control.tar.gz"
debinfo = toDebInfo $ getStrictControl entry
arch = case M.lookup "Architecture" debinfo of
Nothing -> "NOARCH"
Just x -> x
pkg = case M.lookup "Package" debinfo of
Nothing -> "NOPKG"
Just x -> x
pooldir = configPoolDir config
path = "pool/" ++ arch ++ "/" ++ pkg ++ "/" ++ pkg ++ ".deb"
|
pyr/apotiki
|
System/Apotiki/Debian/Package.hs
|
isc
| 1,535 | 0 | 13 | 278 | 510 | 269 | 241 | 37 | 3 |
module Frontend.Elaborate (elaborate) where
import Control.Applicative
import Control.Monad.Error
import Control.Monad.Reader
import Control.Monad.State
import Data.List
import Data.Maybe
import Data.Map (Map)
import qualified Data.Map as M
import qualified Data.Set as S
import Data.Bifunctor
import Frontend.AST
import Frontend.Types
import Frontend.Values
import Frontend.Primitives
import Frontend.Dianostic
import Internal
import Debug.Trace
-- Elaborate
elaborate :: MLProgram -> Either Dianostic AnnProgram
elaborate (tdecls, decls) = do
let conEnv = buildTypeConEnv builtinDataTypes
typs <- (builtinDataTypes ++) <$> buildDataTypes conEnv tdecls
let body = foldr MLLet (MLValue UnitValue) decls
env = (M.empty, buildConEnv typs)
((_, body'), s) <- runTC env $ tcExpr body
return (typs, substExpr s body')
-- Process datatype definitions
type TypeConEnv = Map Name Int
type ConEnv = Map Name (Int, Name, [Type])
builtinDataTypes :: [DataTypeDecl]
builtinDataTypes =
[ (1, Raw "list", [(Raw "[]", []), (Raw "::", [TypeVar 0, DataType [TypeVar 0] (Raw "list")])]) ]
buildDataTypes :: TypeConEnv -> [MLTypeDecl] -> Either Dianostic [DataTypeDecl]
buildDataTypes env decls = evalStateT (mapM build decls) env
where
build (params, tcon, cons) = do
let len = length params
env <- gets $ M.insert tcon len
put env
cons' <- lift $ forM cons $ \(name, args) ->
(,) name <$> mapM (evalType params env) args
return (len, tcon, cons')
evalType :: [Name] -> TypeConEnv -> MLType -> Either Dianostic Type
evalType params env t = eval t
where
eval (MLTypeVar tvar) =
case elemIndex tvar params of
Nothing -> unboundTypeVar tvar
Just i -> return $ TypeVar i
eval (MLTypeCon ts n@(Raw "int"))
| null ts = return IntType
| otherwise = typeConArgsNum n (length ts) 0
eval (MLTypeCon ts n@(Raw "float"))
| null ts = return FloatType
| otherwise = typeConArgsNum n (length ts) 0
eval (MLTypeCon ts n@(Raw "bool"))
| null ts = return BoolType
| otherwise = typeConArgsNum n (length ts) 0
eval (MLTypeCon ts n@(Raw "unit"))
| null ts = return UnitType
| otherwise = typeConArgsNum n (length ts) 0
eval (MLTypeCon ts tcon) =
case M.lookup tcon env of
Nothing -> unboundTypeCon tcon
Just len
| len == length ts -> flip DataType tcon <$> mapM eval ts
| otherwise -> typeConArgsNum tcon (length ts) len
eval (MLFunType e e') = FunType <$> eval e <*> eval e'
eval (MLTupleType es) = TupleType <$> mapM eval es
buildConEnv :: [DataTypeDecl] -> ConEnv
buildConEnv typs = M.fromList $ do
(i, tcon, cons) <- typs
(con, ts) <- cons
return (con, (i, tcon, ts))
buildTypeConEnv :: [DataTypeDecl] -> TypeConEnv
buildTypeConEnv = M.fromList . map (\(i, tcon, _) -> (tcon, i))
-- Typecheck
type TCEnv = (TypeEnv, ConEnv)
type TC a = ReaderT TCEnv (StateT TypeSubst (ErrorT Dianostic Fresh)) a
runTC :: TCEnv -> TC a -> Either Dianostic (a, TypeSubst)
runTC env = runFresh . runErrorT . flip runStateT M.empty . flip runReaderT env
genVar :: TC Type
genVar = TypeVar <$> fresh
withBind :: [PolyBinder] -> TC a -> TC a
withBind bs = local $ first $ flip (foldr $ uncurry M.insert) bs'
where
bs' = filter (not . isErased . fst) bs
update :: TypeLike t => t -> TC t
update t = gets $ flip subst t
generalize :: Type -> TC TypeScheme
generalize t = do
t' <- update t
env <- asks fst >>= update
return $ TypeScheme (S.elems $ S.difference (fv t') (fv env)) t'
instantiate :: TypeScheme -> TC ([Type], Type)
instantiate (TypeScheme vs t) = do
vs' <- mapM (const genVar) vs
let s = M.fromList $ zip vs vs'
(,) vs' . subst s <$> update t
bindVar :: TypeVar -> Type -> TC ()
bindVar v t
| TypeVar v == t = return ()
| S.member v (fv t) = imcompatibleTypes (TypeVar v) t
| otherwise = modify $ bind v t
unify :: Type -> Type -> TC ()
unify t1 t2 = do
t1' <- update t1
t2' <- update t2
unify' t1' t2'
where
unify' (TypeVar v) t = bindVar v t
unify' t (TypeVar v) = bindVar v t
unify' (FunType t1 t2) (FunType t1' t2') = unify t1 t1' >> unify t2 t2'
unify' t@(TupleType ts) t'@(TupleType ts')
| length ts == length ts' = zipWithM_ unify ts ts'
| otherwise = imcompatibleTypes t t'
unify' t@(DataType ts n) t'@(DataType ts' n')
| n == n' = zipWithM_ unify ts ts'
| otherwise = imcompatibleTypes t t'
unify' t t'
| t == t' = return ()
| otherwise = imcompatibleTypes t t'
tcExpr :: MLExpr -> TC (Type, AnnExpr)
tcExpr (MLVar name) = do
env <- asks fst
case M.lookup name env of
Just sc -> do
(targs, t) <- instantiate sc
return (t, AVar name targs)
Nothing -> unboundVar name
tcExpr (MLValue val) =
return (typeOfValue val, AValue val)
tcExpr (MLIf e1 e2 e3) = do
(t1, e1') <- tcExpr e1
unify t1 BoolType
(t2, e2') <- tcExpr e2
(t3, e3') <- tcExpr e3
unify t2 t3
return (t3, AIf e1' e2' e3')
tcExpr (MLLet d e) = do
(bs, d') <- tcDecl d
(t, e') <- withBind bs $ tcExpr e
return (t, ALet d' e')
tcExpr (MLMatch e alts) = do
(t, e') <- tcExpr e
v <- genVar
alts' <- forM alts $ \alt -> do
(t1, t2, alt') <- tcAlt alt
unify t t1
unify v t2
return alt'
return (v, AMatch e' alts')
tcExpr (MLFun b e) = do
v <- genVar
(t, e') <- withBind [(b, TypeScheme [] v)] $ tcExpr e
return (FunType v t, AFun (b, v) e')
tcExpr (MLApply e1 e2) = do
(t1, e1') <- tcExpr e1
(t2, e2') <- tcExpr e2
v <- genVar
unify t1 (FunType t2 v)
return (v, AApply e1' e2')
tcExpr (MLOp op@(Cmp _) es) = do
v <- genVar
es' <- forM es $ \e -> do
(t, e') <- tcExpr e
unify v t
return e'
return (BoolType, AOp op es')
tcExpr (MLOp op@(Arith _) es) = do
es' <- forM es $ \e -> do
(t, e') <- tcExpr e
unify IntType t
return e'
return (IntType, AOp op es')
tcExpr (MLOp op@(FArith _) es) = do
es' <- forM es $ \e -> do
(t, e') <- tcExpr e
unify FloatType t
return e'
return (FloatType, AOp op es')
tcExpr (MLCon con es) = do
env <- asks snd
case M.lookup con env of
Nothing -> unboundCon con
Just (i, tcon, ts)
| length ts == length es -> do
let sc = TypeScheme [0..i-1] $ TupleType ts
(targs, TupleType ts') <- instantiate sc
(ts'', es') <- unzip <$> mapM tcExpr es
zipWithM_ unify ts' ts''
let t = DataType targs tcon
return (t, ACon con tcon targs es')
| otherwise -> conArgsNum con (length ts) (length es)
tcExpr (MLTuple es) = do
(ts, es') <- unzip <$> mapM tcExpr es
return (TupleType ts, ATuple es')
tcDecl :: MLDecl -> TC ([PolyBinder], AnnDecl)
tcDecl (MLRecDecl b e) = do
v <- genVar
(t, e') <- withBind [(b, TypeScheme [] v)] $ tcExpr e
sc <- if isValue e' then generalize t
else return $ TypeScheme [] t
let b' = (b, sc)
return ([b'], ARecDecl b' e')
tcDecl (MLDecl b e) = do
(t, e') <- tcExpr e
sc <- if isValue e' then generalize t
else return $ TypeScheme [] t
let b' = (b, sc)
return ([b'], ADecl b' e')
tcDecl (MLUnitDecl e) = do
(t, e') <- tcExpr e
unify UnitType t
let b = (Erased, TypeScheme [] t)
return ([], ADecl b e')
tcDecl (MLTupleDecl bs e) = do
vs <- mapM (const genVar) bs
(t, e') <- tcExpr e
unify t (TupleType vs)
sc <- if isValue e' then generalize t
else return $ TypeScheme [] t
let bs' = case sc of
TypeScheme vs' (TupleType ts) ->
zip bs $ map (TypeScheme vs') ts
return (bs', ATupleDecl bs' e')
tcDecl (MLExtFunDecl b t s) = do
t' <- either throwError return $ evalType [] M.empty t
let (ts, t'') = uncurryType t' (-1)
ns = map (Raw . prefixOfType) ts
b' = (b, TypeScheme [] t')
return ([b'], ADecl b' $ foldr AFun (AExt s t'' ns) $ zip ns ts)
tcAlt :: MLAlt -> TC (Type, Type, AnnAlt)
tcAlt (MLConCase con bs e) = do
env <- asks snd
case M.lookup con env of
Nothing -> unboundCon con
Just (i, tcon, ts) -> do
let sc = TypeScheme [0..i-1] $ TupleType ts
(targs, TupleType ts') <- instantiate sc
let t = DataType targs tcon
bs' = zip bs ts'
(t', e') <- withBind (map (second $ TypeScheme []) bs') $ tcExpr e
return (t, t', AConCase con tcon targs bs' e')
tcAlt (MLDefaultCase e) = do
v <- genVar
(t, e') <- tcExpr e
return (v, t, ADefaultCase e')
|
alpicola/mel
|
src/Frontend/Elaborate.hs
|
mit
| 8,371 | 0 | 20 | 2,122 | 4,042 | 1,975 | 2,067 | 242 | 10 |
import Data.Char
findDigit :: String -> Maybe Int
findDigit (x: xs) | isDigit x = Just (digitToInt x)
| otherwise = findDigit xs
findDigit [] = Nothing
findDigitAndIndex :: String -> Maybe (Int, Int)
findDigitAndIndex = findRec 0
where findRec n [] = Nothing
findRec n (x:xs) | isDigit x = Just (digitToInt x, n)
| otherwise = findRec (n + 1) xs
findDigitAndIndexOrLen :: String -> Either (Int, Int) Int
findDigitAndIndexOrLen = findRec 0
where findRec n [] = Right n
findRec n (x:xs) | isDigit x = Left (digitToInt x, n)
| otherwise = findRec (n + 1) xs
data Result = DigitAndIndex Int Int | LetterAndIndex Char Int | Len Int deriving Show
findDigitAndIndexOrLetterAndIndexOrLen = findRec 0
where findRec n [] = Len n
findRec n (x:xs) | isDigit x = DigitAndIndex (digitToInt x) n
| isLetter x = LetterAndIndex x n
| otherwise = findRec (n + 1) xs
printResult :: Result -> String
printResult (DigitAndIndex a b) = "Found digit " ++ show a ++ " at index " ++ show b
printResult (LetterAndIndex a b) = "Found letter " ++ show a ++ " at index " ++ show b
printResult (Len n) = "Nothing found. Len = " ++ show n
data Tree a = L a | B a (Tree a) (Tree a) deriving Show
height :: Tree a -> Int
height (L a) = 1
height (B _ t1 t2) = 1 + max (height t1) (height t2)
avg :: Integral a => Tree a -> Double
avg t = (fromIntegral x) / y
where (x, y) = avgRec t
avgRec (L a) = (a, 1.0)
avgRec (B a t1 t2) = (a + t11 + t21, 1.0 + t12 + t22) where (t11, t12) = avgRec t1
(t21, t22) = avgRec t2
data Expr = Mul Expr Expr | Const Value | Plus Expr Expr deriving Show
eval :: Expr -> Int
eval (Const a) = a
eval (Plus a b) = (eval a) + (eval b)
eval (Mul a b) = (eval a) * (eval b)
|
SergeyKrivohatskiy/fp_haskell
|
class/class3.hs
|
mit
| 1,940 | 0 | 10 | 623 | 858 | 428 | 430 | 40 | 2 |
module Main (
main
) where
import Hpcb
import Data.Monoid
-- | Makes a vertical line on layers FCu and FMask
vline :: Float -- ^ Length
-> Circuit
vline l = (
line (V2 0 0) (V2 0 (-l)) # layer FCu
<> line (V2 0 0) (V2 0 (-l)) # layer FMask
) # width 0.15
-- | Draws a tree
tree :: Int -- ^ Depth of the tree
-> Float -- ^ Length of the trunk
-> Float -- ^ Length of the branches
-> Float -- ^ Angle of the branches
-> Float -- ^ Reduction factor
-> Circuit
tree 0 _ _ _ _ = mempty
tree n l lb a f =
vline l
<> branch # rotate (-a) # translate (V2 0 (-l))
<> branch # rotate a # translate (V2 0 (-l))
where
branch =
vline lb
<> tree (n-1) (l*f) (lb*f) a f # translate (V2 0 (-lb))
main :: IO ()
main = runCircuit $
tree 10 10 5 20 0.75
<> rectangle 70 60 # layer EdgeCuts # translate (V2 0 (-27))
|
iemxblog/hpcb
|
examples/tree.hs
|
mit
| 931 | 0 | 14 | 319 | 381 | 196 | 185 | 28 | 1 |
module Context
(
Context,
create,
nextKey
)
where
data Context =
Context Int
deriving Show
create :: Int -> Context
create k = Context k
nextKey :: Context -> (Int, Context)
nextKey (Context k) = (k, Context (k + 1))
|
rcook/hqdsl
|
src/lib/Context.hs
|
mit
| 231 | 0 | 8 | 54 | 92 | 52 | 40 | 12 | 1 |
-- | Benchmark for the field of view algorithm in the pathological case
-- (nothing obstructing anything)
--
{-# LANGUAGE BangPatterns #-}
module Main ( main ) where
import Control.Lens
import Control.Monad.Trans.State.Strict
import Criterion
import Criterion.Main
import Linear.V2
import RWPAS.Control
import RWPAS.Level
main :: IO ()
main =
let initial_world = singletonWorld (roomLevel (V2 200 200))
(level, _) = currentActorLevelAndCoordinates initial_world
in level `seq` initial_world `seq`
defaultMain [bench "fov benchmark" $
whnf (`execState` (0 :: Int)) $
levelFieldOfView (V2 100 100)
level
(\lid -> initial_world^.levelById lid)
(\(!_) (!_) (!_) -> modify (+1))]
|
Noeda/rwpas
|
fov-calculation-benchmark/Main.hs
|
mit
| 843 | 0 | 15 | 260 | 214 | 121 | 93 | 20 | 1 |
module Core.ZArray
( ZArray (..)
, unZArray
) where
import Control.Comonad
import Control.Monad
import Data.Array
import Data.Array.ST
data ZArray i e = ZArray i (Array i e)
unZArray :: ZArray i e -> Array i e
unZArray (ZArray _ arr) = arr
instance Ix i => Functor (ZArray i) where
fmap f (ZArray i arr) = ZArray i (fmap f arr)
instance Ix i => Comonad (ZArray i) where
extract (ZArray i arr) = arr ! i
extend f (ZArray i arr) = ZArray i $ runSTArray $ do
arr' <- newArray_ (bounds arr)
forM_ (indices arr) $ \i' -> writeArray arr' i' (f (ZArray i' arr))
return arr'
|
jameshsmith/HRL
|
Server/Core/ZArray.hs
|
mit
| 603 | 0 | 15 | 145 | 281 | 142 | 139 | 18 | 1 |
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-unused-do-bind #-}
module Vty where
import qualified Data.Text as T
import Graphics.Vty.Widgets.All
import Graphics.Vty.Input.Events
import Data.IORef
import Data.List
import Data.Maybe
import System.Exit
import Control.Concurrent
import Control.Lens
type SubscriptionChan = Chan T.Text
type ItemList = [(T.Text, T.Text)]
type ListChan = Chan ItemList
listUpdater :: ListChan -> Widget (List T.Text FormattedText) -> IO ()
listUpdater chan l = do
ls <- getChanContents chan
mapM_ (updateList l) ls
selectByVal :: Widget (List T.Text FormattedText) -> T.Text -> IO ()
selectByVal l val = getIndexByVal l val >>= scrollBy l . pred
getIndexByVal :: Widget (List T.Text FormattedText) -> T.Text -> IO Int
getIndexByVal l val = do
s <- getListSize l
items <- catMaybes `fmap` mapM (getListItem l) [0..s]
let x = findIndex ((== val) . fst) items
return $ fromMaybe 0 x
updateList :: Widget (List T.Text FormattedText) -> ItemList -> IO ()
updateList l1 l = schedule $ do
-- i <- getSelected l1
clearList l1
mapM_ (\(x,y) -> addToList l1 x =<< plainText y) l
-- forOf_ (_Just . _2 . _1) i (selectByVal l1)
sendKey :: Widget a -> Key -> [Modifier] -> IO Bool
sendKey w k l = do
w' <- readIORef w
keyEventHandler w' w k l
vtyApp :: SubscriptionChan -> ListChan -> ListChan -> IO ()
vtyApp subscriptions lists items = do
l1 <- newTextList [] 1
l2 <- newList 1
fg <- newFocusGroup
h <- return l1 <++> vBorder <++> return l2
coll <- newCollection
addToCollection coll h fg
addToFocusGroup fg l1
addToFocusGroup fg l2
-- Add Quit and Vim Keybindings
onKeyPressed fg $ \_ k m ->
case (k,m) of (KChar 'c', [MCtrl]) -> exitSuccess
(KChar 'q', _ ) -> exitSuccess
(KChar 'j', _ ) -> sendKey fg KDown [] >> return True
(KChar 'k', _ ) -> sendKey fg KUp [] >> return True
_ -> return False
onItemActivated l1 (activeItemHandler subscriptions)
-- onItemActivated l2 activeItemHandler
forkIO $ listUpdater lists l1
forkIO $ listUpdater items l2
runUi coll defaultContext
activeItemHandler :: Chan a -> ActivateItemEvent a t -> IO ()
activeItemHandler ch (ActivateItemEvent _ a _) = writeChan ch a
|
sordina/Deadpan-DDP
|
test/client/Vty.hs
|
mit
| 2,353 | 0 | 14 | 571 | 836 | 412 | 424 | 57 | 5 |
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE Arrows #-}
module Yage.Rendering.Pipeline.Deferred.Downsampling
( Downsampler
, downsampler
, batchedDownsampler
) where
import Yage.Prelude
import Quine.GL.Program
import Quine.GL.ProgramPipeline
import Quine.GL.Sampler
import Quine.GL.Uniform
import Quine.GL.VertexArray
import Quine.StateVar
import Control.Arrow
import Yage.GL
import Yage.Lens
import Yage.Math
import Yage.Geometry.D2.Rectangle
import Yage.Rendering.GL
import Yage.Rendering.Pipeline.Deferred.Common
import Yage.Rendering.RenderSystem
import Yage.Rendering.RenderTarget
import Yage.Rendering.Resources.GL
import Yage.Resources
import Yage.Uniform
#include "definitions.h"
type DownsamplerIn px = (RenderTarget (Texture2D px), Texture2D px)
type Downsampler m px = Pass (PassRes px) m (DownsamplerIn px) (Texture2D px)
data FragmentShader px = FragmentShader
{ iTexture :: UniformVar (Texture2D px)
, iTargetSize :: UniformVar (V2 Int)
}
data PassRes px = PassRes
{ vao :: VertexArray
, pipe :: Pipeline
, frag :: FragmentShader px
}
-- * Draw To Target
-- processDownsamples :: Monad m => Downsampler m px -> RenderSystem m ([RenderTarget (Texture2D px)], Texture2D px) [Texture2D px]
batchedDownsampler :: (Functor m, MonadIO m, MonadThrow m, ImageFormat px) => Downsampler m px -> RenderSystem m ([RenderTarget (Texture2D px)],[Texture2D px]) [Texture2D px]
batchedDownsampler p = proc (ta:targets,tex:texs) -> do
down <- processPass p -< (ta,tex)
if null targets
then returnA -< down:tex:texs
else batchedDownsampler p -< (targets,down:tex:texs)
downsampler :: (ImageFormat px, Functor m, MonadIO m, MonadThrow m) => YageResource (Downsampler m px)
downsampler = Pass <$> passRes <*> pure runRes where
passRes :: YageResource (PassRes px)
passRes = do
emptyvao <- glResource
boundVertexArray $= emptyvao
pipeline <- [ $(embedShaderFile "res/glsl/sampling/drawRectangle.vert")
, $(embedShaderFile "res/glsl/sampling/downsampling.frag")]
`compileShaderPipeline` includePaths
Just frag <- traverse fragmentUniforms =<< get (fragmentShader $ pipeline^.pipelineProgram)
return $ PassRes emptyvao pipeline frag
-- RenderPass
runRes :: (Functor m, MonadIO m, MonadThrow m, ImageFormat px) => RenderSystem (ReaderT (PassRes px) m) (DownsamplerIn px) (Texture2D px)
runRes = mkStaticRenderPass $ \(outTarget, toFilter) -> do
PassRes{..} <- ask
throwWithStack $ boundFramebuffer RWFramebuffer $= (outTarget^.framebufferObj)
glDepthMask GL_TRUE
glDisable GL_DEPTH_TEST
glDisable GL_BLEND
glDisable GL_CULL_FACE
glFrontFace GL_CCW
-- clear not neccessary
-- glClearColor 0 1 0 1
-- glClear $ GL_DEPTH_BUFFER_BIT .|. GL_STENCIL_BUFFER_BIT .|. GL_COLOR_BUFFER_BIT
{-# SCC boundVertexArray #-} throwWithStack $
boundVertexArray $= vao
-- set shader uniforms
boundProgramPipeline $= pipe^.pipelineProgram
checkPipelineError pipe
let FragmentShader{..} = frag
iTexture $= toFilter
iTargetSize $= outTarget^.asRectangle.extend
throwWithStack $ glDrawArrays GL_TRIANGLES 0 3
return $ outTarget^.renderTarget
-- * Shader Interface
fragmentUniforms :: Program -> YageResource (FragmentShader px)
fragmentUniforms prog = do
smpl <- mkDownsampler
FragmentShader
<$> fmap (contramap Just) (samplerUniform prog smpl "iTextures[0]")
<*> fmap (contramap dimensionToTargetSize . SettableStateVar.($=)) (programUniform programUniform4f prog "iTargetSize")
where
dimensionToTargetSize (V2 w h) = V4 (fromIntegral w) (fromIntegral h) (recip $ fromIntegral w) (recip $ fromIntegral h)
-- * Samplers
mkDownsampler :: YageResource (UniformSampler2D px)
mkDownsampler = throwWithStack $ sampler2D 0 <$> do
s <- glResource
samplerParameteri s GL_TEXTURE_WRAP_S $= GL_CLAMP_TO_EDGE
samplerParameteri s GL_TEXTURE_WRAP_T $= GL_CLAMP_TO_EDGE
samplerParameteri s GL_TEXTURE_MIN_FILTER $= GL_LINEAR_MIPMAP_LINEAR
samplerParameteri s GL_TEXTURE_MAG_FILTER $= GL_LINEAR
when gl_EXT_texture_filter_anisotropic $ samplerParameterf s GL_TEXTURE_MAX_ANISOTROPY_EXT $= 16
return s
|
MaxDaten/yage
|
src/Yage/Rendering/Pipeline/Deferred/Downsampling.hs
|
mit
| 4,457 | 1 | 15 | 797 | 1,130 | 586 | 544 | -1 | -1 |
letterCase :: Char -> String
letterCase c =
if c >= 'a' && c <= 'z'
then "Lower Case"
else if c >= 'A' && c <= 'Z'
then "Upper Case"
else "Not an ascii letter"
main = putStrLn (letterCase 'A')
|
creativcoder/recurse
|
check_case.hs
|
mit
| 206 | 10 | 9 | 54 | 82 | 43 | 39 | 8 | 3 |
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Pladen.Beets.Persist
import Database.Persist.Sqlite (createSqlitePool)
import Data.List (groupBy)
import qualified Data.Function as F
import Database.Esqueleto hiding (groupBy)
import Database.Persist.Sql ( ConnectionPool
, SqlPersistM
, runSqlPersistMPool )
dbpath = "/home/thomas/Musik/beets.blb"
run :: SqlPersistM a -> IO a
run p = do
pool <- createSqlitePool (dbpath) 5
runSqlPersistMPool p pool
|
geigerzaehler/pladen
|
Pladen/Test.hs
|
mit
| 538 | 0 | 9 | 122 | 121 | 69 | 52 | 15 | 1 |
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE NoImplicitPrelude #-}
-----------------------------------------------------------------------------
--
-- Module : IDE.TextEditor.CodeMirror
-- Copyright : 2007-2013 Juergen Nicklisch-Franken, Hamish Mackenzie
-- License : GPL Nothing
--
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------
module IDE.TextEditor.CodeMirror (
CodeMirror(..)
#ifdef LEKSAH_WITH_CODE_MIRROR
, TextEditor(..)
, EditorBuffer(..)
, EditorView(..)
, EditorIter(..)
, EditorMark(..)
, EditorTag(..)
, EditorTagTable(..)
, newCMBuffer
#endif
) where
import Data.Typeable (Typeable)
import Graphics.UI.Gtk (scrolledWindowSetShadowType)
import Graphics.UI.Gtk.General.Enums (ShadowType(..))
import Data.Text (Text)
import Text.Show (Show)
import Data.Tuple (snd, fst)
import Data.Function (($), (.))
import Data.Maybe (Maybe, Maybe(..))
import GHC.Base (Functor(..), Monad(..))
import Data.Int (Int)
import System.IO (FilePath)
import Data.List ((++))
import Data.Bool (Bool(..), not)
import GHC.Real (fromIntegral, RealFrac(..))
import GHC.Num (Num(..))
import Data.Eq (Eq(..))
import GHC.Float (Double)
import qualified Data.Text as T (pack)
#ifdef LEKSAH_WITH_CODE_MIRROR
import Control.Monad (unless)
import Data.Text (pack, unpack)
import IDE.TextEditor.Class (TextEditor(..))
import Graphics.UI.Gtk.WebKit.Types (WebView(..))
import Control.Monad.Reader (ReaderT(..))
import Language.Javascript.JSaddle
(valToObject, (#), JSContextRef, JSObjectRef, jsg, (<#), obj, js2,
js, JSM, js1, valToText, valToStr, js3, js0, MakeValueRef(..), MakeStringRef(..),
JSStringRef, JSValueRef, valToBool, strToText, valToNumber, MakeObjectRef)
import Control.Applicative ((<$>))
import Control.Monad.Reader.Class (MonadReader(..))
import Control.Concurrent (putMVar, newEmptyMVar, takeMVar, MVar, tryTakeMVar)
import IDE.Core.Types (IDEM)
import Control.Monad.IO.Class (MonadIO(..))
import Control.Monad.Trans.Class (MonadTrans(..))
import Control.Lens ((^.), IndexPreservingGetter)
import Graphics.UI.Gtk.WebKit.WebView
(webViewLoadUri, webViewLoadString, webViewGetMainFrame,
loadFinished, webViewNew)
import qualified GHCJS.CodeMirror as CM (getDataDir)
import System.Glib.Signals (after, on)
import Graphics.UI.Gtk.WebKit.JavaScriptCore.WebFrame
(webFrameGetGlobalContext)
import Text.Blaze.Html.Renderer.Text (renderHtml)
import Text.Hamlet (shamlet)
import Graphics.UI.Gtk
(ScrolledWindow, menuPopup, menuAttachToWidget, menuNew,
popupMenuSignal, eventModifier, widgetAddEvents, keyReleaseEvent,
leaveNotifyEvent, motionNotifyEvent, keyPressEvent,
buttonReleaseEvent, buttonPressEvent, focusInEvent,
widgetGrabFocus, widgetGetParent, castToScrolledWindow,
containerAdd, scrolledWindowNew, Rectangle(..),
EventMask(..), Modifier(..), ContainerClass, mainIteration,
castToWidget,
#ifdef MIN_VERSION_gtk3
widgetGetWindow
#else
widgetGetDrawWindow
#endif
)
import Data.Maybe (fromJust)
import IDE.Core.State (onIDE, reflectIDE, leksahOrPackageDir)
import Graphics.UI.Editor.Basics (Connection(..))
import System.Log.Logger (debugM)
#endif
data CodeMirror = CodeMirror deriving( Typeable, Show )
#ifdef LEKSAH_WITH_CODE_MIRROR
data CodeMirrorState = CodeMirrorState {
cmContext :: JSContextRef
, cmObject :: JSObjectRef }
type CM = ReaderT (WebView, CodeMirrorState) JSM
webView :: CM WebView
webView = fst <$> ask
codeMirror :: CM JSObjectRef
codeMirror = cmObject . snd <$> ask
runCM :: CodeMirrorRef -> CM a -> IDEM a
runCM (v, mvar) f = liftIO $ do
s <- guiTakeMVar mvar
runReaderT (runReaderT f (v, s)) (cmContext s)
where
guiTakeMVar mvar = do
maybeValue <- tryTakeMVar mvar
case maybeValue of
Just value -> do
putMVar mvar value
return value
Nothing -> do
debugM "leksah" "looping"
s <- loop mvar
debugM "leksah" "done looping"
return s
loop mvar = do
maybeValue <- tryTakeMVar mvar
case maybeValue of
Just value -> do
putMVar mvar value
return value
Nothing -> do
mainIteration
loop mvar
type CodeMirrorRef = (WebView, MVar CodeMirrorState)
body = js "body"
value = js "value"
setSize = js2 "setSize"
mode = js "mode"
line = js "line"
ch = js "ch"
left = js "left"
top = js "top"
right = js "right"
bottom = js "bottom"
lastLine = js0 "lastLine"
getRange = js2 "getRange"
setValue = js1 "setValue"
setBookmark' = js2 "setBookmark"
find = js0 "find"
from = js "from"
getCursor :: (MakeValueRef a0, MakeObjectRef o) => a0 -> IndexPreservingGetter o (JSM JSValueRef)
getCursor = js1 "getCursor"
isClean = js0 "isClean"
markText = js3 "markText"
className = js "className"
clearHistory = js0 "clearHistory"
callUndo = js0 "undo"
undo' = js "undo"
callRedo = js0 "redo"
redo' = js "redo"
historySize = js0 "historySize"
replaceRange = js3 "replaceRange"
insertAt = js2 "replaceRange"
replaceSelection = js1 "replaceSelection"
posFromIndex = js1 "posFromIndex"
lineCount = js0 "lineCount"
somethingSelected = js0 "somethingSelected"
setSelection = js2 "setSelection"
placeCursorAt = js1 "setSelection"
markClean = js0 "markClean"
coordsChar = js2 "coordsChar"
charCoords = js2 "charCoords"
scrollIntoView = js2 "scrollIntoView"
getAllMarks = js0 "getAllMarks"
indexFromPos = js1 "indexFromPos"
getLineText :: (MakeValueRef a0, MakeObjectRef o) => a0 -> IndexPreservingGetter o (JSM JSValueRef)
getLineText = js1 "getLine"
jsLength = js "length"
cmIter :: CodeMirrorRef -> Int -> Int -> CM (EditorIter CodeMirror)
cmIter cm l c = do
lift $ do
i <- obj
i ^. line <# (fromIntegral l :: Double)
i ^. ch <# (fromIntegral c :: Double)
return $ CMIter cm i
newCMBuffer :: Maybe FilePath -> Text -> IDEM (EditorBuffer CodeMirror)
newCMBuffer mbFilename contents = do
ideR <- ask
liftIO $ do
debugM "leksah" "newCMBuffer"
scrolledWindow <- scrolledWindowNew Nothing Nothing
scrolledWindowSetShadowType scrolledWindow ShadowIn
cmWebView <- webViewNew
containerAdd scrolledWindow cmWebView
dataDir <- liftIO $ leksahOrPackageDir "ghcjs-codemirror" CM.getDataDir
s <- newEmptyMVar
cmWebView `on` loadFinished $ \ _ -> do
debugM "leksah" "newCMBuffer loadFinished"
cmContext <- webViewGetMainFrame cmWebView >>= webFrameGetGlobalContext
let runjs f = f `runReaderT` cmContext
runjs $ do
document <- jsg "document"
codeMirror <- jsg "CodeMirror"
code <- obj
code ^. value <# contents
code ^. mode <# "haskell"
cmObject <- codeMirror # (document ^. body, code) >>= valToObject
cmObject ^. setSize "100%" "100%"
liftIO $ debugM "leksah" "newCMBuffer loaded"
liftIO . putMVar s $ CodeMirrorState{..}
webViewLoadString cmWebView (T.pack $
"<html><head>"
++ "<script src=\"lib/codemirror.js\">"
++ "<link rel=\"stylesheet\" href=\"lib/codemirror.css\">"
++ "<script src=\"mode/javascript/javascript.js\">"
++ "<script src=\"mode/haskell/haskell.js\">"
++ "</head>"
++ "<body style=\"margin:0;padding:0 auto;\">"
++ "</body></html>"
) Nothing (T.pack $ "file://" ++ dataDir ++ "/codemirror.html")
debugM "leksah" "newCMBuffer loading"
return $ CMBuffer (cmWebView, s)
instance TextEditor CodeMirror where
data EditorBuffer CodeMirror = CMBuffer CodeMirrorRef
data EditorView CodeMirror = CMView CodeMirrorRef
data EditorMark CodeMirror = CMMark JSObjectRef | CMCursor JSValueRef
data EditorIter CodeMirror = CMIter CodeMirrorRef JSObjectRef
data EditorTagTable CodeMirror = CMTagTable CodeMirrorRef
data EditorTag CodeMirror = CMTag
newBuffer = newCMBuffer
applyTagByName (CMBuffer cm) name (CMIter _ first) (CMIter _ last) = runCM cm $ do
m <- codeMirror
lift $ do
o <- obj
o ^. className <# name
m ^. markText first last o
return ()
beginNotUndoableAction (CMBuffer cm) = return () -- TODO
beginUserAction (CMBuffer cm) = return () -- TODO
canRedo (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ (m ^. historySize ^. redo') >>= valToBool
canUndo (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ (m ^. historySize ^. undo') >>= valToBool
copyClipboard (CMBuffer cm) _ = return () -- TODO
createMark (CMView cm) _name (CMIter _ i) _icon _tooltip = runCM cm $ do
m <- codeMirror
lift $ CMMark <$> do
o <- obj
m ^. setBookmark' i o
cutClipboard (CMBuffer cm) _ _ = return () -- TODO
delete (CMBuffer cm) (CMIter _ first) (CMIter _ last) = runCM cm $ do
m <- codeMirror
lift $ m ^. replaceRange "" first last
return ()
deleteSelection (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ m ^. replaceSelection ""
return ()
endNotUndoableAction (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ m ^. clearHistory
return ()
endUserAction (CMBuffer cm) = return () -- TODO
getEndIter (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ do
i <- obj
l <- m ^. lastLine
i ^. line <# l
i ^. ch <# m ^. getLineText l ^. jsLength
return $ CMIter cm i
getInsertMark (CMBuffer cm) = runCM cm . lift $ CMCursor <$> makeValueRef "head"
getIterAtLine (CMBuffer cm) line = runCM cm $ cmIter cm line 0
getIterAtMark (CMBuffer cm) (CMMark mark) = runCM cm $ do
lift $ CMIter cm <$> (mark ^. find ^. from >>= valToObject)
getIterAtMark (CMBuffer cm) (CMCursor c) = runCM cm $ do
m <- codeMirror
lift $ CMIter cm <$> ((m ^. getCursor c) >>= valToObject)
getIterAtOffset (CMBuffer cm) offset = runCM cm $ do
m <- codeMirror
lift $ CMIter cm <$> ((m ^. posFromIndex (fromIntegral offset :: Double)) >>= valToObject)
getLineCount (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ round <$> ((m ^. lineCount) >>= valToNumber)
getModified (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ not <$> ((m ^. isClean) >>= valToBool)
getSelectionBoundMark (CMBuffer cm) = runCM cm . lift $ CMCursor <$> makeValueRef "anchor"
getSelectionBounds (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ do
start <- (m ^. getCursor "start") >>= valToObject
end <- (m ^. getCursor "end") >>= valToObject
return (CMIter cm start, CMIter cm end)
getInsertIter (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ CMIter cm <$> (m ^. getCursor "head" >>= valToObject)
getSlice (CMBuffer cm) (CMIter _ first) (CMIter _ last) includeHidenChars = runCM cm $ do
m <- codeMirror
lift $ m ^. getRange first last >>= valToText
getStartIter (CMBuffer cm) = runCM cm $ cmIter cm 0 0
getTagTable (CMBuffer cm) = return $ CMTagTable cm
getText (CMBuffer cm) (CMIter _ first) (CMIter _ last) includeHidenChars = runCM cm $ do
m <- codeMirror
lift $ m ^. getRange first last >>= valToText
hasSelection (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ (m ^. somethingSelected) >>= valToBool
insert (CMBuffer cm) (CMIter _ p) text = runCM cm $ do
m <- codeMirror
lift $ m ^. insertAt text p >> return ()
newView (CMBuffer cm) mbFontString = return (CMView cm)
pasteClipboard (CMBuffer cm) clipboard (CMIter _ p) defaultEditable = return () -- TODO
placeCursor (CMBuffer cm) (CMIter _ i) = runCM cm $ do
m <- codeMirror
lift $ m ^. placeCursorAt i >> return ()
redo (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ m ^. callRedo
return ()
removeTagByName (CMBuffer cm) name = runCM cm $ do
m <- codeMirror
lift $ do
marks <- m ^. getAllMarks
-- TODO
return ()
selectRange (CMBuffer cm) (CMIter _ first) (CMIter _ last) = runCM cm $ do
m <- codeMirror
lift $ m ^. setSelection first last >> return ()
setModified (CMBuffer cm) modified = unless modified . runCM cm $ do
m <- codeMirror
lift $ m ^. markClean >> return ()
setStyle preferDark (CMBuffer cm) mbStyle = return () -- TODO
setText (CMBuffer cm) text = runCM cm $ do
m <- codeMirror
lift $ m ^. setValue text
return ()
undo (CMBuffer cm) = runCM cm $ do
m <- codeMirror
lift $ m ^. callUndo
return ()
bufferToWindowCoords (CMView cm) point = return point -- TODO
drawTabs (CMView _) = return () -- TODO
getBuffer (CMView cm) = return $ CMBuffer cm
getWindow (CMView cm) = runCM cm $ do
v <- webView
#ifdef MIN_VERSION_gtk3
liftIO $ widgetGetWindow v
#else
liftIO $ Just <$> widgetGetDrawWindow v
#endif
getIterAtLocation (CMView cm) x y = runCM cm $ do
m <- codeMirror
lift $ do
pos <- obj
pos ^. left <# (fromIntegral x :: Double)
pos ^. top <# (fromIntegral y :: Double)
CMIter cm <$> (m ^. coordsChar pos "window" >>= valToObject)
getIterLocation (CMView cm) (CMIter _ i) = runCM cm $ do
m <- codeMirror
lift $ do
rect <- (m ^. charCoords i "window" >>= valToObject)
l <- rect ^. left >>= valToNumber
r <- rect ^. right >>= valToNumber
t <- rect ^. top >>= valToNumber
b <- rect ^. bottom >>= valToNumber
return $ Rectangle (round l) (round t) (round $ r - l) (round $ b - t)
getOverwrite (CMView cm) = return False -- TODO
getScrolledWindow (CMView (v,_)) = liftIO . fmap (castToScrolledWindow . fromJust) $ widgetGetParent v
getEditorWidget (CMView (v,_)) = return $ castToWidget v
grabFocus (CMView cm) = runCM cm $ do
v <- webView
liftIO $ widgetGrabFocus v
scrollToMark (CMView cm) m withMargin mbAlign = do
i <- getIterAtMark (CMBuffer cm) m
scrollToIter (CMView cm) i withMargin mbAlign
scrollToIter (CMView cm) (CMIter _ i) withMargin mbAlign = runCM cm $ do
m <- codeMirror
lift $ m ^. scrollIntoView i withMargin >> return ()
setFont (CMView cm) mbFontString = return () -- TODO
setIndentWidth (CMView cm) width = return () -- TODO
setWrapMode (CMView cm) width = return () -- TODO
setRightMargin (CMView cm) mbRightMargin = return () -- TODO
setShowLineNumbers (CMView cm) show = return () -- TODO
setTabWidth (CMView cm) width = return () -- TODO
backwardCharC (CMIter cm i) = runCM cm $ do
m <- codeMirror
lift $ do
n <- m ^. indexFromPos i >>= valToNumber
i2 <- m ^. posFromIndex (n - 1)
return (CMIter cm i2)
backwardFindCharC (CMIter cm i) pred mbLimit = return Nothing -- TODO
backwardWordStartC (CMIter cm i) = return Nothing -- TODO
backwardToLineStartC (CMIter cm i) = runCM cm $ do
m <- codeMirror
lift $ do
i2 <- obj
i2 ^. line <# i ^. line
i2 ^. ch <# (0 :: Double)
return $ CMIter cm i2
endsWord (CMIter cm i) = return False -- TODO
forwardCharC (CMIter cm i) = runCM cm $ do
m <- codeMirror
lift $ do
n <- m ^. indexFromPos i >>= valToNumber
i2 <- m ^. posFromIndex (n + 1)
return (CMIter cm i2)
forwardCharsC (CMIter cm i) d = runCM cm $ do
m <- codeMirror
lift $ do
n <- m ^. indexFromPos i >>= valToNumber
i2 <- m ^. posFromIndex (n + fromIntegral d)
return (CMIter cm i2)
forwardFindCharC (CMIter cm i) pred mbLimit = return Nothing -- TODO
forwardSearch (CMIter cm i) str pred mbLimit = return Nothing -- TODO
forwardToLineEndC (CMIter cm i) = runCM cm $ do
m <- codeMirror
lift $ do
i2 <- obj
l <- i ^. line >>= makeValueRef
i2 ^. line <# l
i2 ^. ch <# m ^. getLineText l ^. jsLength
return $ CMIter cm i2
forwardWordEndC (CMIter cm i) = return Nothing -- TODO
getChar (CMIter cm i) = return Nothing -- TODO
getCharsInLine (CMIter cm i) = runCM cm $ do
m <- codeMirror
lift $ round <$> (m ^. getLineText (i ^. line) ^. jsLength >>= valToNumber)
getLine (CMIter cm i) = runCM cm $ do
lift $ round <$> (i ^. line >>= valToNumber)
getLineOffset (CMIter cm i) = runCM cm $ do
lift $ round <$> (i ^. ch >>= valToNumber)
getOffset (CMIter cm i) = runCM cm $ do
m <- codeMirror
lift $ round <$> (m ^. indexFromPos i >>= valToNumber)
isStart i@(CMIter cm _) = do
start <- getStartIter (CMBuffer cm)
iterEqual start i
isEnd i@(CMIter cm _) = do
end <- getEndIter (CMBuffer cm)
iterEqual end i
iterEqual (CMIter cm i1) (CMIter _ i2) = runCM cm . lift $ do
l1 <- i1 ^. line >>= valToNumber
l2 <- i2 ^. line >>= valToNumber
if l1 /= l2
then return False
else do
c1 <- i1 ^. ch >>= valToNumber
c2 <- i2 ^. ch >>= valToNumber
return $ c1 == c2
startsLine i = (== 0) <$> getLineOffset i
startsWord (CMIter cm i) = return False -- TODO
atEnd (CMIter cm _) = getEndIter (CMBuffer cm)
atLine (CMIter cm _) l = runCM cm $ do
m <- codeMirror
lift $ do
i2 <- obj
i2 ^. line <# (fromIntegral l :: Double)
i2 ^. ch <# (0 :: Double)
return $ CMIter cm i2
atLineOffset (CMIter cm i) column = runCM cm $ do
m <- codeMirror
lift $ do
i2 <- obj
i2 ^. line <# i ^. line
i2 ^. ch <# (fromIntegral column :: Double)
return $ CMIter cm i2
atOffset (CMIter cm _ ) offset = getIterAtOffset (CMBuffer cm) offset
atStart (CMIter cm _) = getStartIter (CMBuffer cm)
newTag (CMTagTable cm) name = return CMTag -- TODO
lookupTag (CMTagTable cm) name = return Nothing -- TODO
background (CMTag) color = return () -- TODO
underline (CMTag) value = return () -- TODO
afterFocusIn (CMView (v, _)) f = do
ideR <- ask
liftIO $ do
id1 <- v `after` focusInEvent $ lift $ reflectIDE f ideR >> return False
return [ConnectC id1]
afterModifiedChanged (CMBuffer cm) f = return [] -- TODO
afterMoveCursor (CMView cm) f = return [] -- TODO
afterToggleOverwrite (CMView cm) f = return [] -- TODO
onButtonPress (CMView (v, _)) f = do
id1 <- v `onIDE` buttonPressEvent $ f
return [ConnectC id1]
onButtonRelease (CMView (v, _)) f = do
id1 <- v `onIDE` buttonReleaseEvent $ f
return [ConnectC id1]
onCompletion (CMView cm) start cancel = return [] -- TODO
onKeyPress (CMView (v, _)) f = do
id1 <- v `onIDE` keyPressEvent $ f
return [ConnectC id1]
onMotionNotify (CMView (v, _)) f = do
id1 <- v `onIDE` motionNotifyEvent $ f
return [ConnectC id1]
onLeaveNotify (CMView (v, _)) f = do
id1 <- v `onIDE` leaveNotifyEvent $ f
return [ConnectC id1]
onKeyRelease (CMView (v, _)) f = do
id1 <- v `onIDE` keyReleaseEvent $ f
return [ConnectC id1]
onLookupInfo (CMView (v, _)) f = do
ideR <- ask
liftIO $ do
v `widgetAddEvents` [ButtonReleaseMask]
id1 <- (`reflectIDE` ideR) $ v `onIDE` buttonReleaseEvent $ do
mod <- lift $ eventModifier
case mod of
[Control] -> f >> return True
_ -> return False
return [ConnectC id1]
onMotionNotifyEvent (CMView cm) f = return [] -- TODO
onPopulatePopup (CMView (v, _)) f = do
ideR <- ask
liftIO $ do
id1 <- on v popupMenuSignal $ do
menu <- menuNew
menuAttachToWidget menu v
reflectIDE (f menu) ideR
menuPopup menu Nothing
return True
return [ConnectC id1]
#endif
|
cessationoftime/leksah
|
src/IDE/TextEditor/CodeMirror.hs
|
gpl-2.0
| 21,407 | 0 | 21 | 6,473 | 7,088 | 3,552 | 3,536 | 28 | 0 |
{-
Copyright (C) 2014 Matthew Pickering <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
This module exposes functions which attempt to approximate unicode characters as ASCII.
Information taken from the <https://pypi.python.org/pypi/Unidecode Unidecode python package> which is based upon
the <http://search.cpan.org/~sburke/Text-Unidecode-1.01/lib/Text/Unidecode.pm Text::Unidecode Perl Module> by Sean M. Burke.
-}
module Text.TeXMath.Unicode.ToASCII (getASCII) where
import qualified Data.IntMap as M
import Data.Char (ord)
import Data.Maybe (fromMaybe)
-- | Approximates a single unicode character as an ASCII string
-- (each character is between 0x00 and 0x7F).
getASCII :: Char -> String
getASCII u = fromMaybe "" (M.lookup (ord u) table)
table :: M.IntMap String
table = M.fromList
[ ( 9, "\\t")
, ( 10, "\\n")
, ( 32, " ")
, ( 33, "!")
, ( 34, "\"")
, ( 35, "#")
, ( 36, "$")
, ( 37, "%")
, ( 38, "&")
, ( 39, "'")
, ( 40, "(")
, ( 41, ")")
, ( 42, "*")
, ( 43, "+")
, ( 44, ",")
, ( 45, "-")
, ( 46, ".")
, ( 47, "/")
, ( 48, "0")
, ( 49, "1")
, ( 50, "2")
, ( 51, "3")
, ( 52, "4")
, ( 53, "5")
, ( 54, "6")
, ( 55, "7")
, ( 56, "8")
, ( 57, "9")
, ( 58, ":")
, ( 59, ";")
, ( 60, "<")
, ( 61, "=")
, ( 62, ">")
, ( 63, "?")
, ( 64, "@")
, ( 65, "A")
, ( 66, "B")
, ( 67, "C")
, ( 68, "D")
, ( 69, "E")
, ( 70, "F")
, ( 71, "G")
, ( 72, "H")
, ( 73, "I")
, ( 74, "J")
, ( 75, "K")
, ( 76, "L")
, ( 77, "M")
, ( 78, "N")
, ( 79, "O")
, ( 80, "P")
, ( 81, "Q")
, ( 82, "R")
, ( 83, "S")
, ( 84, "T")
, ( 85, "U")
, ( 86, "V")
, ( 87, "W")
, ( 88, "X")
, ( 89, "Y")
, ( 90, "Z")
, ( 91, "[")
, ( 92, "\\")
, ( 93, "]")
, ( 94, "^")
, ( 95, "_")
, ( 96, "`")
, ( 97, "a")
, ( 98, "b")
, ( 99, "c")
, ( 100, "d")
, ( 101, "e")
, ( 102, "f")
, ( 103, "g")
, ( 104, "h")
, ( 105, "i")
, ( 106, "j")
, ( 107, "k")
, ( 108, "l")
, ( 109, "m")
, ( 110, "n")
, ( 111, "o")
, ( 112, "p")
, ( 113, "q")
, ( 114, "r")
, ( 115, "s")
, ( 116, "t")
, ( 117, "u")
, ( 118, "v")
, ( 119, "w")
, ( 120, "x")
, ( 121, "y")
, ( 122, "z")
, ( 123, "{")
, ( 124, "|")
, ( 125, "}")
, ( 126, "~")
, ( 160, " ")
, ( 161, "!")
, ( 162, "C/")
, ( 163, "PS")
, ( 164, "$?")
, ( 165, "Y=")
, ( 166, "|")
, ( 167, "SS")
, ( 168, "\"")
, ( 169, "(c)")
, ( 170, "a")
, ( 171, "<<")
, ( 172, "!")
, ( 174, "(r)")
, ( 175, "-")
, ( 176, "deg")
, ( 177, "+-")
, ( 178, "2")
, ( 179, "3")
, ( 180, "'")
, ( 181, "u")
, ( 182, "P")
, ( 183, "*")
, ( 184, ",")
, ( 185, "1")
, ( 186, "o")
, ( 187, ">>")
, ( 188, "1/4")
, ( 189, "1/2")
, ( 190, "3/4")
, ( 191, "?")
, ( 192, "A")
, ( 193, "A")
, ( 194, "A")
, ( 195, "A")
, ( 196, "A")
, ( 197, "A")
, ( 198, "AE")
, ( 199, "C")
, ( 200, "E")
, ( 201, "E")
, ( 202, "E")
, ( 203, "E")
, ( 204, "I")
, ( 205, "I")
, ( 206, "I")
, ( 207, "I")
, ( 208, "D")
, ( 209, "N")
, ( 210, "O")
, ( 211, "O")
, ( 212, "O")
, ( 213, "O")
, ( 214, "O")
, ( 215, "x")
, ( 216, "O")
, ( 217, "U")
, ( 218, "U")
, ( 219, "U")
, ( 220, "U")
, ( 221, "Y")
, ( 222, "Th")
, ( 223, "ss")
, ( 224, "a")
, ( 225, "a")
, ( 226, "a")
, ( 227, "a")
, ( 228, "a")
, ( 229, "a")
, ( 230, "ae")
, ( 231, "c")
, ( 232, "e")
, ( 233, "e")
, ( 234, "e")
, ( 235, "e")
, ( 236, "i")
, ( 237, "i")
, ( 238, "i")
, ( 239, "i")
, ( 240, "d")
, ( 241, "n")
, ( 242, "o")
, ( 243, "o")
, ( 244, "o")
, ( 245, "o")
, ( 246, "o")
, ( 247, "/")
, ( 248, "o")
, ( 249, "u")
, ( 250, "u")
, ( 251, "u")
, ( 252, "u")
, ( 253, "y")
, ( 254, "th")
, ( 255, "y")
, ( 256, "A")
, ( 257, "a")
, ( 258, "A")
, ( 259, "a")
, ( 260, "A")
, ( 261, "a")
, ( 262, "C")
, ( 263, "c")
, ( 264, "C")
, ( 265, "c")
, ( 266, "C")
, ( 267, "c")
, ( 268, "C")
, ( 269, "c")
, ( 270, "D")
, ( 271, "d")
, ( 272, "D")
, ( 273, "d")
, ( 274, "E")
, ( 275, "e")
, ( 276, "E")
, ( 277, "e")
, ( 278, "E")
, ( 279, "e")
, ( 280, "E")
, ( 281, "e")
, ( 282, "E")
, ( 283, "e")
, ( 284, "G")
, ( 285, "g")
, ( 286, "G")
, ( 287, "g")
, ( 288, "G")
, ( 289, "g")
, ( 290, "G")
, ( 291, "g")
, ( 292, "H")
, ( 293, "h")
, ( 294, "H")
, ( 295, "h")
, ( 296, "I")
, ( 297, "i")
, ( 298, "I")
, ( 299, "i")
, ( 300, "I")
, ( 301, "i")
, ( 302, "I")
, ( 303, "i")
, ( 304, "I")
, ( 305, "i")
, ( 306, "IJ")
, ( 307, "ij")
, ( 308, "J")
, ( 309, "j")
, ( 310, "K")
, ( 311, "k")
, ( 312, "k")
, ( 313, "L")
, ( 314, "l")
, ( 315, "L")
, ( 316, "l")
, ( 317, "L")
, ( 318, "l")
, ( 319, "L")
, ( 320, "l")
, ( 321, "L")
, ( 322, "l")
, ( 323, "N")
, ( 324, "n")
, ( 325, "N")
, ( 326, "n")
, ( 327, "N")
, ( 328, "n")
, ( 329, "'n")
, ( 330, "ng")
, ( 331, "NG")
, ( 332, "O")
, ( 333, "o")
, ( 334, "O")
, ( 335, "o")
, ( 336, "O")
, ( 337, "o")
, ( 338, "OE")
, ( 339, "oe")
, ( 340, "R")
, ( 341, "r")
, ( 342, "R")
, ( 343, "r")
, ( 344, "R")
, ( 345, "r")
, ( 346, "S")
, ( 347, "s")
, ( 348, "S")
, ( 349, "s")
, ( 350, "S")
, ( 351, "s")
, ( 352, "S")
, ( 353, "s")
, ( 354, "T")
, ( 355, "t")
, ( 356, "T")
, ( 357, "t")
, ( 358, "T")
, ( 359, "t")
, ( 360, "U")
, ( 361, "u")
, ( 362, "U")
, ( 363, "u")
, ( 364, "U")
, ( 365, "u")
, ( 366, "U")
, ( 367, "u")
, ( 368, "U")
, ( 369, "u")
, ( 370, "U")
, ( 371, "u")
, ( 372, "W")
, ( 373, "w")
, ( 374, "Y")
, ( 375, "y")
, ( 376, "Y")
, ( 377, "Z")
, ( 378, "z")
, ( 379, "Z")
, ( 380, "z")
, ( 381, "Z")
, ( 382, "z")
, ( 383, "s")
, ( 384, "b")
, ( 385, "B")
, ( 386, "B")
, ( 387, "b")
, ( 388, "6")
, ( 389, "6")
, ( 390, "O")
, ( 391, "C")
, ( 392, "c")
, ( 393, "D")
, ( 394, "D")
, ( 395, "D")
, ( 396, "d")
, ( 397, "d")
, ( 398, "3")
, ( 399, "@")
, ( 400, "E")
, ( 401, "F")
, ( 402, "f")
, ( 403, "G")
, ( 404, "G")
, ( 405, "hv")
, ( 406, "I")
, ( 407, "I")
, ( 408, "K")
, ( 409, "k")
, ( 410, "l")
, ( 411, "l")
, ( 412, "W")
, ( 413, "N")
, ( 414, "n")
, ( 415, "O")
, ( 416, "O")
, ( 417, "o")
, ( 418, "OI")
, ( 419, "oi")
, ( 420, "P")
, ( 421, "p")
, ( 422, "YR")
, ( 423, "2")
, ( 424, "2")
, ( 425, "SH")
, ( 426, "sh")
, ( 427, "t")
, ( 428, "T")
, ( 429, "t")
, ( 430, "T")
, ( 431, "U")
, ( 432, "u")
, ( 433, "Y")
, ( 434, "V")
, ( 435, "Y")
, ( 436, "y")
, ( 437, "Z")
, ( 438, "z")
, ( 439, "ZH")
, ( 440, "ZH")
, ( 441, "zh")
, ( 442, "zh")
, ( 443, "2")
, ( 444, "5")
, ( 445, "5")
, ( 446, "ts")
, ( 447, "w")
, ( 448, "|")
, ( 449, "||")
, ( 450, "|=")
, ( 451, "!")
, ( 452, "DZ")
, ( 453, "Dz")
, ( 454, "dz")
, ( 455, "LJ")
, ( 456, "Lj")
, ( 457, "lj")
, ( 458, "NJ")
, ( 459, "Nj")
, ( 460, "nj")
, ( 461, "A")
, ( 462, "a")
, ( 463, "I")
, ( 464, "i")
, ( 465, "O")
, ( 466, "o")
, ( 467, "U")
, ( 468, "u")
, ( 469, "U")
, ( 470, "u")
, ( 471, "U")
, ( 472, "u")
, ( 473, "U")
, ( 474, "u")
, ( 475, "U")
, ( 476, "u")
, ( 477, "@")
, ( 478, "A")
, ( 479, "a")
, ( 480, "A")
, ( 481, "a")
, ( 482, "AE")
, ( 483, "ae")
, ( 484, "G")
, ( 485, "g")
, ( 486, "G")
, ( 487, "g")
, ( 488, "K")
, ( 489, "k")
, ( 490, "O")
, ( 491, "o")
, ( 492, "O")
, ( 493, "o")
, ( 494, "ZH")
, ( 495, "zh")
, ( 496, "j")
, ( 497, "DZ")
, ( 498, "Dz")
, ( 499, "dz")
, ( 500, "G")
, ( 501, "g")
, ( 502, "HV")
, ( 503, "W")
, ( 504, "N")
, ( 505, "n")
, ( 506, "A")
, ( 507, "a")
, ( 508, "AE")
, ( 509, "ae")
, ( 510, "O")
, ( 511, "o")
, ( 512, "A")
, ( 513, "a")
, ( 514, "A")
, ( 515, "a")
, ( 516, "E")
, ( 517, "e")
, ( 518, "E")
, ( 519, "e")
, ( 520, "I")
, ( 521, "i")
, ( 522, "I")
, ( 523, "i")
, ( 524, "O")
, ( 525, "o")
, ( 526, "O")
, ( 527, "o")
, ( 528, "R")
, ( 529, "r")
, ( 530, "R")
, ( 531, "r")
, ( 532, "U")
, ( 533, "u")
, ( 534, "U")
, ( 535, "u")
, ( 536, "S")
, ( 537, "s")
, ( 538, "T")
, ( 539, "t")
, ( 540, "Y")
, ( 541, "y")
, ( 542, "H")
, ( 543, "h")
, ( 544, "N")
, ( 545, "d")
, ( 546, "OU")
, ( 547, "ou")
, ( 548, "Z")
, ( 549, "z")
, ( 550, "A")
, ( 551, "a")
, ( 552, "E")
, ( 553, "e")
, ( 554, "O")
, ( 555, "o")
, ( 556, "O")
, ( 557, "o")
, ( 558, "O")
, ( 559, "o")
, ( 560, "O")
, ( 561, "o")
, ( 562, "Y")
, ( 563, "y")
, ( 564, "l")
, ( 565, "n")
, ( 566, "t")
, ( 567, "j")
, ( 568, "db")
, ( 569, "qp")
, ( 570, "A")
, ( 571, "C")
, ( 572, "c")
, ( 573, "L")
, ( 574, "T")
, ( 575, "s")
, ( 576, "z")
, ( 577, "[?]")
, ( 578, "[?]")
, ( 579, "B")
, ( 580, "U")
, ( 581, "^")
, ( 582, "E")
, ( 583, "e")
, ( 584, "J")
, ( 585, "j")
, ( 586, "q")
, ( 587, "q")
, ( 588, "R")
, ( 589, "r")
, ( 590, "Y")
, ( 591, "y")
, ( 592, "a")
, ( 593, "a")
, ( 594, "a")
, ( 595, "b")
, ( 596, "o")
, ( 597, "c")
, ( 598, "d")
, ( 599, "d")
, ( 600, "e")
, ( 601, "@")
, ( 602, "@")
, ( 603, "e")
, ( 604, "e")
, ( 605, "e")
, ( 606, "e")
, ( 607, "j")
, ( 608, "g")
, ( 609, "g")
, ( 610, "g")
, ( 611, "g")
, ( 612, "u")
, ( 613, "Y")
, ( 614, "h")
, ( 615, "h")
, ( 616, "i")
, ( 617, "i")
, ( 618, "I")
, ( 619, "l")
, ( 620, "l")
, ( 621, "l")
, ( 622, "lZ")
, ( 623, "W")
, ( 624, "W")
, ( 625, "m")
, ( 626, "n")
, ( 627, "n")
, ( 628, "n")
, ( 629, "o")
, ( 630, "OE")
, ( 631, "O")
, ( 632, "F")
, ( 633, "r")
, ( 634, "r")
, ( 635, "r")
, ( 636, "r")
, ( 637, "r")
, ( 638, "r")
, ( 639, "r")
, ( 640, "R")
, ( 641, "R")
, ( 642, "s")
, ( 643, "S")
, ( 644, "j")
, ( 645, "S")
, ( 646, "S")
, ( 647, "t")
, ( 648, "t")
, ( 649, "u")
, ( 650, "U")
, ( 651, "v")
, ( 652, "^")
, ( 653, "w")
, ( 654, "y")
, ( 655, "Y")
, ( 656, "z")
, ( 657, "z")
, ( 658, "Z")
, ( 659, "Z")
, ( 660, "?")
, ( 661, "?")
, ( 662, "?")
, ( 663, "C")
, ( 664, "@")
, ( 665, "B")
, ( 666, "E")
, ( 667, "G")
, ( 668, "H")
, ( 669, "j")
, ( 670, "k")
, ( 671, "L")
, ( 672, "q")
, ( 673, "?")
, ( 674, "?")
, ( 675, "dz")
, ( 676, "dZ")
, ( 677, "dz")
, ( 678, "ts")
, ( 679, "tS")
, ( 680, "tC")
, ( 681, "fN")
, ( 682, "ls")
, ( 683, "lz")
, ( 684, "WW")
, ( 685, "]]")
, ( 686, "h")
, ( 687, "h")
, ( 688, "k")
, ( 689, "h")
, ( 690, "j")
, ( 691, "r")
, ( 692, "r")
, ( 693, "r")
, ( 694, "r")
, ( 695, "w")
, ( 696, "y")
, ( 697, "'")
, ( 698, "\"")
, ( 699, "`")
, ( 700, "'")
, ( 701, "`")
, ( 702, "`")
, ( 703, "'")
, ( 704, "?")
, ( 705, "?")
, ( 706, "<")
, ( 707, ">")
, ( 708, "^")
, ( 709, "V")
, ( 710, "^")
, ( 711, "V")
, ( 712, "'")
, ( 713, "-")
, ( 714, "/")
, ( 715, "\\")
, ( 716, ",")
, ( 717, "_")
, ( 718, "\\")
, ( 719, "/")
, ( 720, ":")
, ( 721, ".")
, ( 722, "`")
, ( 723, "'")
, ( 724, "^")
, ( 725, "V")
, ( 726, "+")
, ( 727, "-")
, ( 728, "V")
, ( 729, ".")
, ( 730, "@")
, ( 731, ",")
, ( 732, "~")
, ( 733, "\"")
, ( 734, "R")
, ( 735, "X")
, ( 736, "G")
, ( 737, "l")
, ( 738, "s")
, ( 739, "x")
, ( 740, "?")
, ( 748, "V")
, ( 749, "=")
, ( 750, "\"")
, ( 751, "[?]")
, ( 752, "[?]")
, ( 753, "[?]")
, ( 754, "[?]")
, ( 755, "[?]")
, ( 756, "[?]")
, ( 757, "[?]")
, ( 758, "[?]")
, ( 759, "[?]")
, ( 760, "[?]")
, ( 761, "[?]")
, ( 762, "[?]")
, ( 763, "[?]")
, ( 764, "[?]")
, ( 765, "[?]")
, ( 766, "[?]")
, ( 847, "[?]")
, ( 848, "[?]")
, ( 849, "[?]")
, ( 850, "[?]")
, ( 851, "[?]")
, ( 852, "[?]")
, ( 853, "[?]")
, ( 854, "[?]")
, ( 855, "[?]")
, ( 856, "[?]")
, ( 857, "[?]")
, ( 858, "[?]")
, ( 859, "[?]")
, ( 860, "[?]")
, ( 861, "[?]")
, ( 862, "[?]")
, ( 863, "[?]")
, ( 867, "a")
, ( 868, "e")
, ( 869, "i")
, ( 870, "o")
, ( 871, "u")
, ( 872, "c")
, ( 873, "d")
, ( 874, "h")
, ( 875, "m")
, ( 876, "r")
, ( 877, "t")
, ( 878, "v")
, ( 879, "x")
, ( 880, "[?]")
, ( 881, "[?]")
, ( 882, "[?]")
, ( 883, "[?]")
, ( 884, "'")
, ( 885, ",")
, ( 886, "[?]")
, ( 887, "[?]")
, ( 888, "[?]")
, ( 889, "[?]")
, ( 891, "[?]")
, ( 892, "[?]")
, ( 893, "[?]")
, ( 894, "?")
, ( 895, "[?]")
, ( 896, "[?]")
, ( 897, "[?]")
, ( 898, "[?]")
, ( 899, "[?]")
, ( 902, "A")
, ( 903, ";")
, ( 904, "E")
, ( 905, "E")
, ( 906, "I")
, ( 907, "[?]")
, ( 908, "O")
, ( 909, "[?]")
, ( 910, "U")
, ( 911, "O")
, ( 912, "I")
, ( 913, "A")
, ( 914, "B")
, ( 915, "G")
, ( 916, "D")
, ( 917, "E")
, ( 918, "Z")
, ( 919, "E")
, ( 920, "Th")
, ( 921, "I")
, ( 922, "K")
, ( 923, "L")
, ( 924, "M")
, ( 925, "N")
, ( 926, "Ks")
, ( 927, "O")
, ( 928, "P")
, ( 929, "R")
, ( 930, "[?]")
, ( 931, "S")
, ( 932, "T")
, ( 933, "U")
, ( 934, "Ph")
, ( 935, "Kh")
, ( 936, "Ps")
, ( 937, "O")
, ( 938, "I")
, ( 939, "U")
, ( 940, "a")
, ( 941, "e")
, ( 942, "e")
, ( 943, "i")
, ( 944, "u")
, ( 945, "a")
, ( 946, "b")
, ( 947, "g")
, ( 948, "d")
, ( 949, "e")
, ( 950, "z")
, ( 951, "e")
, ( 952, "th")
, ( 953, "i")
, ( 954, "k")
, ( 955, "l")
, ( 956, "m")
, ( 957, "n")
, ( 958, "x")
, ( 959, "o")
, ( 960, "p")
, ( 961, "r")
, ( 962, "s")
, ( 963, "s")
, ( 964, "t")
, ( 965, "u")
, ( 966, "ph")
, ( 967, "kh")
, ( 968, "ps")
, ( 969, "o")
, ( 970, "i")
, ( 971, "u")
, ( 972, "o")
, ( 973, "u")
, ( 974, "o")
, ( 975, "[?]")
, ( 976, "b")
, ( 977, "th")
, ( 978, "U")
, ( 979, "U")
, ( 980, "U")
, ( 981, "ph")
, ( 982, "p")
, ( 983, "&")
, ( 984, "[?]")
, ( 985, "[?]")
, ( 986, "St")
, ( 987, "st")
, ( 988, "W")
, ( 989, "w")
, ( 990, "Q")
, ( 991, "q")
, ( 992, "Sp")
, ( 993, "sp")
, ( 994, "Sh")
, ( 995, "sh")
, ( 996, "F")
, ( 997, "f")
, ( 998, "Kh")
, ( 999, "kh")
, ( 1000, "H")
, ( 1001, "h")
, ( 1002, "G")
, ( 1003, "g")
, ( 1004, "CH")
, ( 1005, "ch")
, ( 1006, "Ti")
, ( 1007, "ti")
, ( 1008, "k")
, ( 1009, "r")
, ( 1010, "c")
, ( 1011, "j")
, ( 1012, "[?]")
, ( 1013, "[?]")
, ( 1014, "[?]")
, ( 1015, "[?]")
, ( 1016, "[?]")
, ( 1017, "[?]")
, ( 1018, "[?]")
, ( 1019, "[?]")
, ( 1020, "[?]")
, ( 1021, "[?]")
, ( 1022, "[?]")
, ( 1024, "Ie")
, ( 1025, "Io")
, ( 1026, "Dj")
, ( 1027, "Gj")
, ( 1028, "Ie")
, ( 1029, "Dz")
, ( 1030, "I")
, ( 1031, "Yi")
, ( 1032, "J")
, ( 1033, "Lj")
, ( 1034, "Nj")
, ( 1035, "Tsh")
, ( 1036, "Kj")
, ( 1037, "I")
, ( 1038, "U")
, ( 1039, "Dzh")
, ( 1040, "A")
, ( 1041, "B")
, ( 1042, "V")
, ( 1043, "G")
, ( 1044, "D")
, ( 1045, "E")
, ( 1046, "Zh")
, ( 1047, "Z")
, ( 1048, "I")
, ( 1049, "I")
, ( 1050, "K")
, ( 1051, "L")
, ( 1052, "M")
, ( 1053, "N")
, ( 1054, "O")
, ( 1055, "P")
, ( 1056, "R")
, ( 1057, "S")
, ( 1058, "T")
, ( 1059, "U")
, ( 1060, "F")
, ( 1061, "Kh")
, ( 1062, "Ts")
, ( 1063, "Ch")
, ( 1064, "Sh")
, ( 1065, "Shch")
, ( 1066, "'")
, ( 1067, "Y")
, ( 1068, "'")
, ( 1069, "E")
, ( 1070, "Iu")
, ( 1071, "Ia")
, ( 1072, "a")
, ( 1073, "b")
, ( 1074, "v")
, ( 1075, "g")
, ( 1076, "d")
, ( 1077, "e")
, ( 1078, "zh")
, ( 1079, "z")
, ( 1080, "i")
, ( 1081, "i")
, ( 1082, "k")
, ( 1083, "l")
, ( 1084, "m")
, ( 1085, "n")
, ( 1086, "o")
, ( 1087, "p")
, ( 1088, "r")
, ( 1089, "s")
, ( 1090, "t")
, ( 1091, "u")
, ( 1092, "f")
, ( 1093, "kh")
, ( 1094, "ts")
, ( 1095, "ch")
, ( 1096, "sh")
, ( 1097, "shch")
, ( 1098, "'")
, ( 1099, "y")
, ( 1100, "'")
, ( 1101, "e")
, ( 1102, "iu")
, ( 1103, "ia")
, ( 1104, "ie")
, ( 1105, "io")
, ( 1106, "dj")
, ( 1107, "gj")
, ( 1108, "ie")
, ( 1109, "dz")
, ( 1110, "i")
, ( 1111, "yi")
, ( 1112, "j")
, ( 1113, "lj")
, ( 1114, "nj")
, ( 1115, "tsh")
, ( 1116, "kj")
, ( 1117, "i")
, ( 1118, "u")
, ( 1119, "dzh")
, ( 1120, "O")
, ( 1121, "o")
, ( 1122, "E")
, ( 1123, "e")
, ( 1124, "Ie")
, ( 1125, "ie")
, ( 1126, "E")
, ( 1127, "e")
, ( 1128, "Ie")
, ( 1129, "ie")
, ( 1130, "O")
, ( 1131, "o")
, ( 1132, "Io")
, ( 1133, "io")
, ( 1134, "Ks")
, ( 1135, "ks")
, ( 1136, "Ps")
, ( 1137, "ps")
, ( 1138, "F")
, ( 1139, "f")
, ( 1140, "Y")
, ( 1141, "y")
, ( 1142, "Y")
, ( 1143, "y")
, ( 1144, "u")
, ( 1145, "u")
, ( 1146, "O")
, ( 1147, "o")
, ( 1148, "O")
, ( 1149, "o")
, ( 1150, "Ot")
, ( 1151, "ot")
, ( 1152, "Q")
, ( 1153, "q")
, ( 1154, "*1000*")
, ( 1159, "[?]")
, ( 1160, "*100.000*")
, ( 1161, "*1.000.000*")
, ( 1162, "[?]")
, ( 1163, "[?]")
, ( 1164, "\"")
, ( 1165, "\"")
, ( 1166, "R'")
, ( 1167, "r'")
, ( 1168, "G'")
, ( 1169, "g'")
, ( 1170, "G'")
, ( 1171, "g'")
, ( 1172, "G'")
, ( 1173, "g'")
, ( 1174, "Zh'")
, ( 1175, "zh'")
, ( 1176, "Z'")
, ( 1177, "z'")
, ( 1178, "K'")
, ( 1179, "k'")
, ( 1180, "K'")
, ( 1181, "k'")
, ( 1182, "K'")
, ( 1183, "k'")
, ( 1184, "K'")
, ( 1185, "k'")
, ( 1186, "N'")
, ( 1187, "n'")
, ( 1188, "Ng")
, ( 1189, "ng")
, ( 1190, "P'")
, ( 1191, "p'")
, ( 1192, "Kh")
, ( 1193, "kh")
, ( 1194, "S'")
, ( 1195, "s'")
, ( 1196, "T'")
, ( 1197, "t'")
, ( 1198, "U")
, ( 1199, "u")
, ( 1200, "U'")
, ( 1201, "u'")
, ( 1202, "Kh'")
, ( 1203, "kh'")
, ( 1204, "Tts")
, ( 1205, "tts")
, ( 1206, "Ch'")
, ( 1207, "ch'")
, ( 1208, "Ch'")
, ( 1209, "ch'")
, ( 1210, "H")
, ( 1211, "h")
, ( 1212, "Ch")
, ( 1213, "ch")
, ( 1214, "Ch'")
, ( 1215, "ch'")
, ( 1216, "`")
, ( 1217, "Zh")
, ( 1218, "zh")
, ( 1219, "K'")
, ( 1220, "k'")
, ( 1221, "[?]")
, ( 1222, "[?]")
, ( 1223, "N'")
, ( 1224, "n'")
, ( 1225, "[?]")
, ( 1226, "[?]")
, ( 1227, "Ch")
, ( 1228, "ch")
, ( 1229, "[?]")
, ( 1230, "[?]")
, ( 1231, "[?]")
, ( 1232, "a")
, ( 1233, "a")
, ( 1234, "A")
, ( 1235, "a")
, ( 1236, "Ae")
, ( 1237, "ae")
, ( 1238, "Ie")
, ( 1239, "ie")
, ( 1240, "@")
, ( 1241, "@")
, ( 1242, "@")
, ( 1243, "@")
, ( 1244, "Zh")
, ( 1245, "zh")
, ( 1246, "Z")
, ( 1247, "z")
, ( 1248, "Dz")
, ( 1249, "dz")
, ( 1250, "I")
, ( 1251, "i")
, ( 1252, "I")
, ( 1253, "i")
, ( 1254, "O")
, ( 1255, "o")
, ( 1256, "O")
, ( 1257, "o")
, ( 1258, "O")
, ( 1259, "o")
, ( 1260, "E")
, ( 1261, "e")
, ( 1262, "U")
, ( 1263, "u")
, ( 1264, "U")
, ( 1265, "u")
, ( 1266, "U")
, ( 1267, "u")
, ( 1268, "Ch")
, ( 1269, "ch")
, ( 1270, "[?]")
, ( 1271, "[?]")
, ( 1272, "Y")
, ( 1273, "y")
, ( 1274, "[?]")
, ( 1275, "[?]")
, ( 1276, "[?]")
, ( 1277, "[?]")
, ( 1278, "[?]")
, ( 1280, "[?]")
, ( 1281, "[?]")
, ( 1282, "[?]")
, ( 1283, "[?]")
, ( 1284, "[?]")
, ( 1285, "[?]")
, ( 1286, "[?]")
, ( 1287, "[?]")
, ( 1288, "[?]")
, ( 1289, "[?]")
, ( 1290, "[?]")
, ( 1291, "[?]")
, ( 1292, "[?]")
, ( 1293, "[?]")
, ( 1294, "[?]")
, ( 1295, "[?]")
, ( 1296, "[?]")
, ( 1297, "[?]")
, ( 1298, "[?]")
, ( 1299, "[?]")
, ( 1300, "[?]")
, ( 1301, "[?]")
, ( 1302, "[?]")
, ( 1303, "[?]")
, ( 1304, "[?]")
, ( 1305, "[?]")
, ( 1306, "[?]")
, ( 1307, "[?]")
, ( 1308, "[?]")
, ( 1309, "[?]")
, ( 1310, "[?]")
, ( 1311, "[?]")
, ( 1312, "[?]")
, ( 1313, "[?]")
, ( 1314, "[?]")
, ( 1315, "[?]")
, ( 1316, "[?]")
, ( 1317, "[?]")
, ( 1318, "[?]")
, ( 1319, "[?]")
, ( 1320, "[?]")
, ( 1321, "[?]")
, ( 1322, "[?]")
, ( 1323, "[?]")
, ( 1324, "[?]")
, ( 1325, "[?]")
, ( 1326, "[?]")
, ( 1327, "[?]")
, ( 1328, "[?]")
, ( 1329, "A")
, ( 1330, "B")
, ( 1331, "G")
, ( 1332, "D")
, ( 1333, "E")
, ( 1334, "Z")
, ( 1335, "E")
, ( 1336, "E")
, ( 1337, "T`")
, ( 1338, "Zh")
, ( 1339, "I")
, ( 1340, "L")
, ( 1341, "Kh")
, ( 1342, "Ts")
, ( 1343, "K")
, ( 1344, "H")
, ( 1345, "Dz")
, ( 1346, "Gh")
, ( 1347, "Ch")
, ( 1348, "M")
, ( 1349, "Y")
, ( 1350, "N")
, ( 1351, "Sh")
, ( 1352, "O")
, ( 1353, "Ch`")
, ( 1354, "P")
, ( 1355, "J")
, ( 1356, "Rh")
, ( 1357, "S")
, ( 1358, "V")
, ( 1359, "T")
, ( 1360, "R")
, ( 1361, "Ts`")
, ( 1362, "W")
, ( 1363, "P`")
, ( 1364, "K`")
, ( 1365, "O")
, ( 1366, "F")
, ( 1367, "[?]")
, ( 1368, "[?]")
, ( 1369, "<")
, ( 1370, "'")
, ( 1371, "/")
, ( 1372, "!")
, ( 1373, ",")
, ( 1374, "?")
, ( 1375, ".")
, ( 1376, "[?]")
, ( 1377, "a")
, ( 1378, "b")
, ( 1379, "g")
, ( 1380, "d")
, ( 1381, "e")
, ( 1382, "z")
, ( 1383, "e")
, ( 1384, "e")
, ( 1385, "t`")
, ( 1386, "zh")
, ( 1387, "i")
, ( 1388, "l")
, ( 1389, "kh")
, ( 1390, "ts")
, ( 1391, "k")
, ( 1392, "h")
, ( 1393, "dz")
, ( 1394, "gh")
, ( 1395, "ch")
, ( 1396, "m")
, ( 1397, "y")
, ( 1398, "n")
, ( 1399, "sh")
, ( 1400, "o")
, ( 1401, "ch`")
, ( 1402, "p")
, ( 1403, "j")
, ( 1404, "rh")
, ( 1405, "s")
, ( 1406, "v")
, ( 1407, "t")
, ( 1408, "r")
, ( 1409, "ts`")
, ( 1410, "w")
, ( 1411, "p`")
, ( 1412, "k`")
, ( 1413, "o")
, ( 1414, "f")
, ( 1415, "ew")
, ( 1416, "[?]")
, ( 1417, ":")
, ( 1418, "-")
, ( 1419, "[?]")
, ( 1420, "[?]")
, ( 1421, "[?]")
, ( 1422, "[?]")
, ( 1423, "[?]")
, ( 1424, "[?]")
, ( 1442, "[?]")
, ( 1456, "@")
, ( 1457, "e")
, ( 1458, "a")
, ( 1459, "o")
, ( 1460, "i")
, ( 1461, "e")
, ( 1462, "e")
, ( 1463, "a")
, ( 1464, "a")
, ( 1465, "o")
, ( 1466, "[?]")
, ( 1467, "u")
, ( 1468, "'")
, ( 1472, "|")
, ( 1475, ":")
, ( 1477, "[?]")
, ( 1478, "[?]")
, ( 1479, "[?]")
, ( 1480, "[?]")
, ( 1481, "[?]")
, ( 1482, "[?]")
, ( 1483, "[?]")
, ( 1484, "[?]")
, ( 1485, "[?]")
, ( 1486, "[?]")
, ( 1487, "[?]")
, ( 1489, "b")
, ( 1490, "g")
, ( 1491, "d")
, ( 1492, "h")
, ( 1493, "v")
, ( 1494, "z")
, ( 1495, "kh")
, ( 1496, "t")
, ( 1497, "y")
, ( 1498, "k")
, ( 1499, "k")
, ( 1500, "l")
, ( 1501, "m")
, ( 1502, "m")
, ( 1503, "n")
, ( 1504, "n")
, ( 1505, "s")
, ( 1506, "`")
, ( 1507, "p")
, ( 1508, "p")
, ( 1509, "ts")
, ( 1510, "ts")
, ( 1511, "q")
, ( 1512, "r")
, ( 1513, "sh")
, ( 1514, "t")
, ( 1515, "[?]")
, ( 1516, "[?]")
, ( 1517, "[?]")
, ( 1518, "[?]")
, ( 1519, "[?]")
, ( 1520, "V")
, ( 1521, "oy")
, ( 1522, "i")
, ( 1523, "'")
, ( 1524, "\"")
, ( 1525, "[?]")
, ( 1526, "[?]")
, ( 1527, "[?]")
, ( 1528, "[?]")
, ( 1529, "[?]")
, ( 1530, "[?]")
, ( 1531, "[?]")
, ( 1532, "[?]")
, ( 1533, "[?]")
, ( 1534, "[?]")
, ( 1536, "[?]")
, ( 1537, "[?]")
, ( 1538, "[?]")
, ( 1539, "[?]")
, ( 1540, "[?]")
, ( 1541, "[?]")
, ( 1542, "[?]")
, ( 1543, "[?]")
, ( 1544, "[?]")
, ( 1545, "[?]")
, ( 1546, "[?]")
, ( 1547, "[?]")
, ( 1548, ",")
, ( 1549, "[?]")
, ( 1550, "[?]")
, ( 1551, "[?]")
, ( 1552, "[?]")
, ( 1553, "[?]")
, ( 1554, "[?]")
, ( 1555, "[?]")
, ( 1556, "[?]")
, ( 1557, "[?]")
, ( 1558, "[?]")
, ( 1559, "[?]")
, ( 1560, "[?]")
, ( 1561, "[?]")
, ( 1562, "[?]")
, ( 1563, ";")
, ( 1564, "[?]")
, ( 1565, "[?]")
, ( 1566, "[?]")
, ( 1567, "?")
, ( 1568, "[?]")
, ( 1570, "a")
, ( 1571, "'")
, ( 1572, "w'")
, ( 1574, "y'")
, ( 1576, "b")
, ( 1577, "@")
, ( 1578, "t")
, ( 1579, "th")
, ( 1580, "j")
, ( 1581, "H")
, ( 1582, "kh")
, ( 1583, "d")
, ( 1584, "dh")
, ( 1585, "r")
, ( 1586, "z")
, ( 1587, "s")
, ( 1588, "sh")
, ( 1589, "S")
, ( 1590, "D")
, ( 1591, "T")
, ( 1592, "Z")
, ( 1593, "`")
, ( 1594, "G")
, ( 1595, "[?]")
, ( 1596, "[?]")
, ( 1597, "[?]")
, ( 1598, "[?]")
, ( 1599, "[?]")
, ( 1601, "f")
, ( 1602, "q")
, ( 1603, "k")
, ( 1604, "l")
, ( 1605, "m")
, ( 1606, "n")
, ( 1607, "h")
, ( 1608, "w")
, ( 1609, "~")
, ( 1610, "y")
, ( 1611, "an")
, ( 1612, "un")
, ( 1613, "in")
, ( 1614, "a")
, ( 1615, "u")
, ( 1616, "i")
, ( 1617, "W")
, ( 1620, "'")
, ( 1621, "'")
, ( 1622, "[?]")
, ( 1623, "[?]")
, ( 1624, "[?]")
, ( 1625, "[?]")
, ( 1626, "[?]")
, ( 1627, "[?]")
, ( 1628, "[?]")
, ( 1629, "[?]")
, ( 1630, "[?]")
, ( 1631, "[?]")
, ( 1632, "0")
, ( 1633, "1")
, ( 1634, "2")
, ( 1635, "3")
, ( 1636, "4")
, ( 1637, "5")
, ( 1638, "6")
, ( 1639, "7")
, ( 1640, "8")
, ( 1641, "9")
, ( 1642, "%")
, ( 1643, ".")
, ( 1644, ",")
, ( 1645, "*")
, ( 1646, "[?]")
, ( 1647, "[?]")
, ( 1649, "'")
, ( 1650, "'")
, ( 1651, "'")
, ( 1653, "'")
, ( 1654, "'w")
, ( 1655, "'u")
, ( 1656, "'y")
, ( 1657, "tt")
, ( 1658, "tth")
, ( 1659, "b")
, ( 1660, "t")
, ( 1661, "T")
, ( 1662, "p")
, ( 1663, "th")
, ( 1664, "bh")
, ( 1665, "'h")
, ( 1666, "H")
, ( 1667, "ny")
, ( 1668, "dy")
, ( 1669, "H")
, ( 1670, "ch")
, ( 1671, "cch")
, ( 1672, "dd")
, ( 1673, "D")
, ( 1674, "D")
, ( 1675, "Dt")
, ( 1676, "dh")
, ( 1677, "ddh")
, ( 1678, "d")
, ( 1679, "D")
, ( 1680, "D")
, ( 1681, "rr")
, ( 1682, "R")
, ( 1683, "R")
, ( 1684, "R")
, ( 1685, "R")
, ( 1686, "R")
, ( 1687, "R")
, ( 1688, "j")
, ( 1689, "R")
, ( 1690, "S")
, ( 1691, "S")
, ( 1692, "S")
, ( 1693, "S")
, ( 1694, "S")
, ( 1695, "T")
, ( 1696, "GH")
, ( 1697, "F")
, ( 1698, "F")
, ( 1699, "F")
, ( 1700, "v")
, ( 1701, "f")
, ( 1702, "ph")
, ( 1703, "Q")
, ( 1704, "Q")
, ( 1705, "kh")
, ( 1706, "k")
, ( 1707, "K")
, ( 1708, "K")
, ( 1709, "ng")
, ( 1710, "K")
, ( 1711, "g")
, ( 1712, "G")
, ( 1713, "N")
, ( 1714, "G")
, ( 1715, "G")
, ( 1716, "G")
, ( 1717, "L")
, ( 1718, "L")
, ( 1719, "L")
, ( 1720, "L")
, ( 1721, "N")
, ( 1722, "N")
, ( 1723, "N")
, ( 1724, "N")
, ( 1725, "N")
, ( 1726, "h")
, ( 1727, "Ch")
, ( 1728, "hy")
, ( 1729, "h")
, ( 1730, "H")
, ( 1731, "@")
, ( 1732, "W")
, ( 1733, "oe")
, ( 1734, "oe")
, ( 1735, "u")
, ( 1736, "yu")
, ( 1737, "yu")
, ( 1738, "W")
, ( 1739, "v")
, ( 1740, "y")
, ( 1741, "Y")
, ( 1742, "Y")
, ( 1743, "W")
, ( 1746, "y")
, ( 1747, "y'")
, ( 1748, ".")
, ( 1749, "ae")
, ( 1757, "@")
, ( 1758, "#")
, ( 1769, "^")
, ( 1774, "[?]")
, ( 1775, "[?]")
, ( 1776, "0")
, ( 1777, "1")
, ( 1778, "2")
, ( 1779, "3")
, ( 1780, "4")
, ( 1781, "5")
, ( 1782, "6")
, ( 1783, "7")
, ( 1784, "8")
, ( 1785, "9")
, ( 1786, "Sh")
, ( 1787, "D")
, ( 1788, "Gh")
, ( 1789, "&")
, ( 1790, "+m")
, ( 1792, "//")
, ( 1793, "/")
, ( 1794, ",")
, ( 1795, "!")
, ( 1796, "!")
, ( 1797, "-")
, ( 1798, ",")
, ( 1799, ",")
, ( 1800, ";")
, ( 1801, "?")
, ( 1802, "~")
, ( 1803, "{")
, ( 1804, "}")
, ( 1805, "*")
, ( 1806, "[?]")
, ( 1808, "'")
, ( 1810, "b")
, ( 1811, "g")
, ( 1812, "g")
, ( 1813, "d")
, ( 1814, "d")
, ( 1815, "h")
, ( 1816, "w")
, ( 1817, "z")
, ( 1818, "H")
, ( 1819, "t")
, ( 1820, "t")
, ( 1821, "y")
, ( 1822, "yh")
, ( 1823, "k")
, ( 1824, "l")
, ( 1825, "m")
, ( 1826, "n")
, ( 1827, "s")
, ( 1828, "s")
, ( 1829, "`")
, ( 1830, "p")
, ( 1831, "p")
, ( 1832, "S")
, ( 1833, "q")
, ( 1834, "r")
, ( 1835, "sh")
, ( 1836, "t")
, ( 1837, "[?]")
, ( 1838, "[?]")
, ( 1839, "[?]")
, ( 1840, "a")
, ( 1841, "a")
, ( 1842, "a")
, ( 1843, "A")
, ( 1844, "A")
, ( 1845, "A")
, ( 1846, "e")
, ( 1847, "e")
, ( 1848, "e")
, ( 1849, "E")
, ( 1850, "i")
, ( 1851, "i")
, ( 1852, "u")
, ( 1853, "u")
, ( 1854, "u")
, ( 1855, "o")
, ( 1857, "`")
, ( 1858, "'")
, ( 1861, "X")
, ( 1862, "Q")
, ( 1863, "@")
, ( 1864, "@")
, ( 1865, "|")
, ( 1866, "+")
, ( 1867, "[?]")
, ( 1868, "[?]")
, ( 1869, "[?]")
, ( 1870, "[?]")
, ( 1871, "[?]")
, ( 1872, "[?]")
, ( 1873, "[?]")
, ( 1874, "[?]")
, ( 1875, "[?]")
, ( 1876, "[?]")
, ( 1877, "[?]")
, ( 1878, "[?]")
, ( 1879, "[?]")
, ( 1880, "[?]")
, ( 1881, "[?]")
, ( 1882, "[?]")
, ( 1883, "[?]")
, ( 1884, "[?]")
, ( 1885, "[?]")
, ( 1886, "[?]")
, ( 1887, "[?]")
, ( 1888, "[?]")
, ( 1889, "[?]")
, ( 1890, "[?]")
, ( 1891, "[?]")
, ( 1892, "[?]")
, ( 1893, "[?]")
, ( 1894, "[?]")
, ( 1895, "[?]")
, ( 1896, "[?]")
, ( 1897, "[?]")
, ( 1898, "[?]")
, ( 1899, "[?]")
, ( 1900, "[?]")
, ( 1901, "[?]")
, ( 1902, "[?]")
, ( 1903, "[?]")
, ( 1904, "[?]")
, ( 1905, "[?]")
, ( 1906, "[?]")
, ( 1907, "[?]")
, ( 1908, "[?]")
, ( 1909, "[?]")
, ( 1910, "[?]")
, ( 1911, "[?]")
, ( 1912, "[?]")
, ( 1913, "[?]")
, ( 1914, "[?]")
, ( 1915, "[?]")
, ( 1916, "[?]")
, ( 1917, "[?]")
, ( 1918, "[?]")
, ( 1919, "[?]")
, ( 1920, "h")
, ( 1921, "sh")
, ( 1922, "n")
, ( 1923, "r")
, ( 1924, "b")
, ( 1925, "L")
, ( 1926, "k")
, ( 1927, "'")
, ( 1928, "v")
, ( 1929, "m")
, ( 1930, "f")
, ( 1931, "dh")
, ( 1932, "th")
, ( 1933, "l")
, ( 1934, "g")
, ( 1935, "ny")
, ( 1936, "s")
, ( 1937, "d")
, ( 1938, "z")
, ( 1939, "t")
, ( 1940, "y")
, ( 1941, "p")
, ( 1942, "j")
, ( 1943, "ch")
, ( 1944, "tt")
, ( 1945, "hh")
, ( 1946, "kh")
, ( 1947, "th")
, ( 1948, "z")
, ( 1949, "sh")
, ( 1950, "s")
, ( 1951, "d")
, ( 1952, "t")
, ( 1953, "z")
, ( 1954, "`")
, ( 1955, "gh")
, ( 1956, "q")
, ( 1957, "w")
, ( 1958, "a")
, ( 1959, "aa")
, ( 1960, "i")
, ( 1961, "ee")
, ( 1962, "u")
, ( 1963, "oo")
, ( 1964, "e")
, ( 1965, "ey")
, ( 1966, "o")
, ( 1967, "oa")
, ( 1969, "[?]")
, ( 1970, "[?]")
, ( 1971, "[?]")
, ( 1972, "[?]")
, ( 1973, "[?]")
, ( 1974, "[?]")
, ( 1975, "[?]")
, ( 1976, "[?]")
, ( 1977, "[?]")
, ( 1978, "[?]")
, ( 1979, "[?]")
, ( 1980, "[?]")
, ( 1981, "[?]")
, ( 1982, "[?]")
, ( 1983, "[?]")
, ( 1984, "[?]")
, ( 1985, "[?]")
, ( 1986, "[?]")
, ( 1987, "[?]")
, ( 1988, "[?]")
, ( 1989, "[?]")
, ( 1990, "[?]")
, ( 1991, "[?]")
, ( 1992, "[?]")
, ( 1993, "[?]")
, ( 1994, "[?]")
, ( 1995, "[?]")
, ( 1996, "[?]")
, ( 1997, "[?]")
, ( 1998, "[?]")
, ( 1999, "[?]")
, ( 2000, "[?]")
, ( 2001, "[?]")
, ( 2002, "[?]")
, ( 2003, "[?]")
, ( 2004, "[?]")
, ( 2005, "[?]")
, ( 2006, "[?]")
, ( 2007, "[?]")
, ( 2008, "[?]")
, ( 2009, "[?]")
, ( 2010, "[?]")
, ( 2011, "[?]")
, ( 2012, "[?]")
, ( 2013, "[?]")
, ( 2014, "[?]")
, ( 2015, "[?]")
, ( 2016, "[?]")
, ( 2017, "[?]")
, ( 2018, "[?]")
, ( 2019, "[?]")
, ( 2020, "[?]")
, ( 2021, "[?]")
, ( 2022, "[?]")
, ( 2023, "[?]")
, ( 2024, "[?]")
, ( 2025, "[?]")
, ( 2026, "[?]")
, ( 2027, "[?]")
, ( 2028, "[?]")
, ( 2029, "[?]")
, ( 2030, "[?]")
, ( 2031, "[?]")
, ( 2032, "[?]")
, ( 2033, "[?]")
, ( 2034, "[?]")
, ( 2035, "[?]")
, ( 2036, "[?]")
, ( 2037, "[?]")
, ( 2038, "[?]")
, ( 2039, "[?]")
, ( 2040, "[?]")
, ( 2041, "[?]")
, ( 2042, "[?]")
, ( 2043, "[?]")
, ( 2044, "[?]")
, ( 2045, "[?]")
, ( 2046, "[?]")
, ( 2304, "[?]")
, ( 2305, "N")
, ( 2306, "N")
, ( 2307, "H")
, ( 2308, "[?]")
, ( 2309, "a")
, ( 2310, "aa")
, ( 2311, "i")
, ( 2312, "ii")
, ( 2313, "u")
, ( 2314, "uu")
, ( 2315, "R")
, ( 2316, "L")
, ( 2317, "eN")
, ( 2318, "e")
, ( 2319, "e")
, ( 2320, "ai")
, ( 2321, "oN")
, ( 2322, "o")
, ( 2323, "o")
, ( 2324, "au")
, ( 2325, "k")
, ( 2326, "kh")
, ( 2327, "g")
, ( 2328, "gh")
, ( 2329, "ng")
, ( 2330, "c")
, ( 2331, "ch")
, ( 2332, "j")
, ( 2333, "jh")
, ( 2334, "ny")
, ( 2335, "tt")
, ( 2336, "tth")
, ( 2337, "dd")
, ( 2338, "ddh")
, ( 2339, "nn")
, ( 2340, "t")
, ( 2341, "th")
, ( 2342, "d")
, ( 2343, "dh")
, ( 2344, "n")
, ( 2345, "nnn")
, ( 2346, "p")
, ( 2347, "ph")
, ( 2348, "b")
, ( 2349, "bh")
, ( 2350, "m")
, ( 2351, "y")
, ( 2352, "r")
, ( 2353, "rr")
, ( 2354, "l")
, ( 2355, "l")
, ( 2356, "lll")
, ( 2357, "v")
, ( 2358, "sh")
, ( 2359, "ss")
, ( 2360, "s")
, ( 2361, "h")
, ( 2362, "[?]")
, ( 2363, "[?]")
, ( 2364, "'")
, ( 2365, "'")
, ( 2366, "aa")
, ( 2367, "i")
, ( 2368, "ii")
, ( 2369, "u")
, ( 2370, "uu")
, ( 2371, "R")
, ( 2372, "RR")
, ( 2373, "eN")
, ( 2374, "e")
, ( 2375, "e")
, ( 2376, "ai")
, ( 2377, "oN")
, ( 2378, "o")
, ( 2379, "o")
, ( 2380, "au")
, ( 2382, "[?]")
, ( 2383, "[?]")
, ( 2384, "AUM")
, ( 2385, "'")
, ( 2386, "'")
, ( 2387, "`")
, ( 2388, "'")
, ( 2389, "[?]")
, ( 2390, "[?]")
, ( 2391, "[?]")
, ( 2392, "q")
, ( 2393, "khh")
, ( 2394, "ghh")
, ( 2395, "z")
, ( 2396, "dddh")
, ( 2397, "rh")
, ( 2398, "f")
, ( 2399, "yy")
, ( 2400, "RR")
, ( 2401, "LL")
, ( 2402, "L")
, ( 2403, "LL")
, ( 2404, " / ")
, ( 2405, " // ")
, ( 2406, "0")
, ( 2407, "1")
, ( 2408, "2")
, ( 2409, "3")
, ( 2410, "4")
, ( 2411, "5")
, ( 2412, "6")
, ( 2413, "7")
, ( 2414, "8")
, ( 2415, "9")
, ( 2416, ".")
, ( 2417, "[?]")
, ( 2418, "[?]")
, ( 2419, "[?]")
, ( 2420, "[?]")
, ( 2421, "[?]")
, ( 2422, "[?]")
, ( 2423, "[?]")
, ( 2424, "[?]")
, ( 2425, "[?]")
, ( 2426, "[?]")
, ( 2427, "[?]")
, ( 2428, "[?]")
, ( 2429, "[?]")
, ( 2430, "[?]")
, ( 2431, "[?]")
, ( 2432, "[?]")
, ( 2433, "N")
, ( 2434, "N")
, ( 2435, "H")
, ( 2436, "[?]")
, ( 2437, "a")
, ( 2438, "aa")
, ( 2439, "i")
, ( 2440, "ii")
, ( 2441, "u")
, ( 2442, "uu")
, ( 2443, "R")
, ( 2444, "RR")
, ( 2445, "[?]")
, ( 2446, "[?]")
, ( 2447, "e")
, ( 2448, "ai")
, ( 2449, "[?]")
, ( 2450, "[?]")
, ( 2451, "o")
, ( 2452, "au")
, ( 2453, "k")
, ( 2454, "kh")
, ( 2455, "g")
, ( 2456, "gh")
, ( 2457, "ng")
, ( 2458, "c")
, ( 2459, "ch")
, ( 2460, "j")
, ( 2461, "jh")
, ( 2462, "ny")
, ( 2463, "tt")
, ( 2464, "tth")
, ( 2465, "dd")
, ( 2466, "ddh")
, ( 2467, "nn")
, ( 2468, "t")
, ( 2469, "th")
, ( 2470, "d")
, ( 2471, "dh")
, ( 2472, "n")
, ( 2473, "[?]")
, ( 2474, "p")
, ( 2475, "ph")
, ( 2476, "b")
, ( 2477, "bh")
, ( 2478, "m")
, ( 2479, "y")
, ( 2480, "r")
, ( 2481, "[?]")
, ( 2482, "l")
, ( 2483, "[?]")
, ( 2484, "[?]")
, ( 2485, "[?]")
, ( 2486, "sh")
, ( 2487, "ss")
, ( 2488, "s")
, ( 2489, "h")
, ( 2490, "[?]")
, ( 2491, "[?]")
, ( 2492, "'")
, ( 2493, "[?]")
, ( 2494, "aa")
, ( 2495, "i")
, ( 2496, "ii")
, ( 2497, "u")
, ( 2498, "uu")
, ( 2499, "R")
, ( 2500, "RR")
, ( 2501, "[?]")
, ( 2502, "[?]")
, ( 2503, "e")
, ( 2504, "ai")
, ( 2505, "[?]")
, ( 2506, "[?]")
, ( 2507, "o")
, ( 2508, "au")
, ( 2510, "[?]")
, ( 2511, "[?]")
, ( 2512, "[?]")
, ( 2513, "[?]")
, ( 2514, "[?]")
, ( 2515, "[?]")
, ( 2516, "[?]")
, ( 2517, "[?]")
, ( 2518, "[?]")
, ( 2519, "+")
, ( 2520, "[?]")
, ( 2521, "[?]")
, ( 2522, "[?]")
, ( 2523, "[?]")
, ( 2524, "rr")
, ( 2525, "rh")
, ( 2526, "[?]")
, ( 2527, "yy")
, ( 2528, "RR")
, ( 2529, "LL")
, ( 2530, "L")
, ( 2531, "LL")
, ( 2532, "[?]")
, ( 2533, "[?]")
, ( 2534, "0")
, ( 2535, "1")
, ( 2536, "2")
, ( 2537, "3")
, ( 2538, "4")
, ( 2539, "5")
, ( 2540, "6")
, ( 2541, "7")
, ( 2542, "8")
, ( 2543, "9")
, ( 2544, "r'")
, ( 2545, "r`")
, ( 2546, "Rs")
, ( 2547, "Rs")
, ( 2548, "1/")
, ( 2549, "2/")
, ( 2550, "3/")
, ( 2551, "4/")
, ( 2552, " 1 - 1/")
, ( 2553, "/16")
, ( 2555, "[?]")
, ( 2556, "[?]")
, ( 2557, "[?]")
, ( 2558, "[?]")
, ( 2560, "[?]")
, ( 2561, "[?]")
, ( 2562, "N")
, ( 2563, "[?]")
, ( 2564, "[?]")
, ( 2565, "a")
, ( 2566, "aa")
, ( 2567, "i")
, ( 2568, "ii")
, ( 2569, "u")
, ( 2570, "uu")
, ( 2571, "[?]")
, ( 2572, "[?]")
, ( 2573, "[?]")
, ( 2574, "[?]")
, ( 2575, "ee")
, ( 2576, "ai")
, ( 2577, "[?]")
, ( 2578, "[?]")
, ( 2579, "oo")
, ( 2580, "au")
, ( 2581, "k")
, ( 2582, "kh")
, ( 2583, "g")
, ( 2584, "gh")
, ( 2585, "ng")
, ( 2586, "c")
, ( 2587, "ch")
, ( 2588, "j")
, ( 2589, "jh")
, ( 2590, "ny")
, ( 2591, "tt")
, ( 2592, "tth")
, ( 2593, "dd")
, ( 2594, "ddh")
, ( 2595, "nn")
, ( 2596, "t")
, ( 2597, "th")
, ( 2598, "d")
, ( 2599, "dh")
, ( 2600, "n")
, ( 2601, "[?]")
, ( 2602, "p")
, ( 2603, "ph")
, ( 2604, "b")
, ( 2605, "bb")
, ( 2606, "m")
, ( 2607, "y")
, ( 2608, "r")
, ( 2609, "[?]")
, ( 2610, "l")
, ( 2611, "ll")
, ( 2612, "[?]")
, ( 2613, "v")
, ( 2614, "sh")
, ( 2615, "[?]")
, ( 2616, "s")
, ( 2617, "h")
, ( 2618, "[?]")
, ( 2619, "[?]")
, ( 2620, "'")
, ( 2621, "[?]")
, ( 2622, "aa")
, ( 2623, "i")
, ( 2624, "ii")
, ( 2625, "u")
, ( 2626, "uu")
, ( 2627, "[?]")
, ( 2628, "[?]")
, ( 2629, "[?]")
, ( 2630, "[?]")
, ( 2631, "ee")
, ( 2632, "ai")
, ( 2633, "[?]")
, ( 2634, "[?]")
, ( 2635, "oo")
, ( 2636, "au")
, ( 2638, "[?]")
, ( 2639, "[?]")
, ( 2640, "[?]")
, ( 2641, "[?]")
, ( 2642, "[?]")
, ( 2643, "[?]")
, ( 2644, "[?]")
, ( 2645, "[?]")
, ( 2646, "[?]")
, ( 2647, "[?]")
, ( 2648, "[?]")
, ( 2649, "khh")
, ( 2650, "ghh")
, ( 2651, "z")
, ( 2652, "rr")
, ( 2653, "[?]")
, ( 2654, "f")
, ( 2655, "[?]")
, ( 2656, "[?]")
, ( 2657, "[?]")
, ( 2658, "[?]")
, ( 2659, "[?]")
, ( 2660, "[?]")
, ( 2661, "[?]")
, ( 2662, "0")
, ( 2663, "1")
, ( 2664, "2")
, ( 2665, "3")
, ( 2666, "4")
, ( 2667, "5")
, ( 2668, "6")
, ( 2669, "7")
, ( 2670, "8")
, ( 2671, "9")
, ( 2672, "N")
, ( 2673, "H")
, ( 2676, "G.E.O.")
, ( 2677, "[?]")
, ( 2678, "[?]")
, ( 2679, "[?]")
, ( 2680, "[?]")
, ( 2681, "[?]")
, ( 2682, "[?]")
, ( 2683, "[?]")
, ( 2684, "[?]")
, ( 2685, "[?]")
, ( 2686, "[?]")
, ( 2687, "[?]")
, ( 2688, "[?]")
, ( 2689, "N")
, ( 2690, "N")
, ( 2691, "H")
, ( 2692, "[?]")
, ( 2693, "a")
, ( 2694, "aa")
, ( 2695, "i")
, ( 2696, "ii")
, ( 2697, "u")
, ( 2698, "uu")
, ( 2699, "R")
, ( 2700, "[?]")
, ( 2701, "eN")
, ( 2702, "[?]")
, ( 2703, "e")
, ( 2704, "ai")
, ( 2705, "oN")
, ( 2706, "[?]")
, ( 2707, "o")
, ( 2708, "au")
, ( 2709, "k")
, ( 2710, "kh")
, ( 2711, "g")
, ( 2712, "gh")
, ( 2713, "ng")
, ( 2714, "c")
, ( 2715, "ch")
, ( 2716, "j")
, ( 2717, "jh")
, ( 2718, "ny")
, ( 2719, "tt")
, ( 2720, "tth")
, ( 2721, "dd")
, ( 2722, "ddh")
, ( 2723, "nn")
, ( 2724, "t")
, ( 2725, "th")
, ( 2726, "d")
, ( 2727, "dh")
, ( 2728, "n")
, ( 2729, "[?]")
, ( 2730, "p")
, ( 2731, "ph")
, ( 2732, "b")
, ( 2733, "bh")
, ( 2734, "m")
, ( 2735, "ya")
, ( 2736, "r")
, ( 2737, "[?]")
, ( 2738, "l")
, ( 2739, "ll")
, ( 2740, "[?]")
, ( 2741, "v")
, ( 2742, "sh")
, ( 2743, "ss")
, ( 2744, "s")
, ( 2745, "h")
, ( 2746, "[?]")
, ( 2747, "[?]")
, ( 2748, "'")
, ( 2749, "'")
, ( 2750, "aa")
, ( 2751, "i")
, ( 2752, "ii")
, ( 2753, "u")
, ( 2754, "uu")
, ( 2755, "R")
, ( 2756, "RR")
, ( 2757, "eN")
, ( 2758, "[?]")
, ( 2759, "e")
, ( 2760, "ai")
, ( 2761, "oN")
, ( 2762, "[?]")
, ( 2763, "o")
, ( 2764, "au")
, ( 2766, "[?]")
, ( 2767, "[?]")
, ( 2768, "AUM")
, ( 2769, "[?]")
, ( 2770, "[?]")
, ( 2771, "[?]")
, ( 2772, "[?]")
, ( 2773, "[?]")
, ( 2774, "[?]")
, ( 2775, "[?]")
, ( 2776, "[?]")
, ( 2777, "[?]")
, ( 2778, "[?]")
, ( 2779, "[?]")
, ( 2780, "[?]")
, ( 2781, "[?]")
, ( 2782, "[?]")
, ( 2783, "[?]")
, ( 2784, "RR")
, ( 2785, "[?]")
, ( 2786, "[?]")
, ( 2787, "[?]")
, ( 2788, "[?]")
, ( 2789, "[?]")
, ( 2790, "0")
, ( 2791, "1")
, ( 2792, "2")
, ( 2793, "3")
, ( 2794, "4")
, ( 2795, "5")
, ( 2796, "6")
, ( 2797, "7")
, ( 2798, "8")
, ( 2799, "9")
, ( 2800, "[?]")
, ( 2801, "[?]")
, ( 2802, "[?]")
, ( 2803, "[?]")
, ( 2804, "[?]")
, ( 2805, "[?]")
, ( 2806, "[?]")
, ( 2807, "[?]")
, ( 2808, "[?]")
, ( 2809, "[?]")
, ( 2810, "[?]")
, ( 2811, "[?]")
, ( 2812, "[?]")
, ( 2813, "[?]")
, ( 2814, "[?]")
, ( 2816, "[?]")
, ( 2817, "N")
, ( 2818, "N")
, ( 2819, "H")
, ( 2820, "[?]")
, ( 2821, "a")
, ( 2822, "aa")
, ( 2823, "i")
, ( 2824, "ii")
, ( 2825, "u")
, ( 2826, "uu")
, ( 2827, "R")
, ( 2828, "L")
, ( 2829, "[?]")
, ( 2830, "[?]")
, ( 2831, "e")
, ( 2832, "ai")
, ( 2833, "[?]")
, ( 2834, "[?]")
, ( 2835, "o")
, ( 2836, "au")
, ( 2837, "k")
, ( 2838, "kh")
, ( 2839, "g")
, ( 2840, "gh")
, ( 2841, "ng")
, ( 2842, "c")
, ( 2843, "ch")
, ( 2844, "j")
, ( 2845, "jh")
, ( 2846, "ny")
, ( 2847, "tt")
, ( 2848, "tth")
, ( 2849, "dd")
, ( 2850, "ddh")
, ( 2851, "nn")
, ( 2852, "t")
, ( 2853, "th")
, ( 2854, "d")
, ( 2855, "dh")
, ( 2856, "n")
, ( 2857, "[?]")
, ( 2858, "p")
, ( 2859, "ph")
, ( 2860, "b")
, ( 2861, "bh")
, ( 2862, "m")
, ( 2863, "y")
, ( 2864, "r")
, ( 2865, "[?]")
, ( 2866, "l")
, ( 2867, "ll")
, ( 2868, "[?]")
, ( 2870, "sh")
, ( 2871, "ss")
, ( 2872, "s")
, ( 2873, "h")
, ( 2874, "[?]")
, ( 2875, "[?]")
, ( 2876, "'")
, ( 2877, "'")
, ( 2878, "aa")
, ( 2879, "i")
, ( 2880, "ii")
, ( 2881, "u")
, ( 2882, "uu")
, ( 2883, "R")
, ( 2884, "[?]")
, ( 2885, "[?]")
, ( 2886, "[?]")
, ( 2887, "e")
, ( 2888, "ai")
, ( 2889, "[?]")
, ( 2890, "[?]")
, ( 2891, "o")
, ( 2892, "au")
, ( 2894, "[?]")
, ( 2895, "[?]")
, ( 2896, "[?]")
, ( 2897, "[?]")
, ( 2898, "[?]")
, ( 2899, "[?]")
, ( 2900, "[?]")
, ( 2901, "[?]")
, ( 2902, "+")
, ( 2903, "+")
, ( 2904, "[?]")
, ( 2905, "[?]")
, ( 2906, "[?]")
, ( 2907, "[?]")
, ( 2908, "rr")
, ( 2909, "rh")
, ( 2910, "[?]")
, ( 2911, "yy")
, ( 2912, "RR")
, ( 2913, "LL")
, ( 2914, "[?]")
, ( 2915, "[?]")
, ( 2916, "[?]")
, ( 2917, "[?]")
, ( 2918, "0")
, ( 2919, "1")
, ( 2920, "2")
, ( 2921, "3")
, ( 2922, "4")
, ( 2923, "5")
, ( 2924, "6")
, ( 2925, "7")
, ( 2926, "8")
, ( 2927, "9")
, ( 2929, "[?]")
, ( 2930, "[?]")
, ( 2931, "[?]")
, ( 2932, "[?]")
, ( 2933, "[?]")
, ( 2934, "[?]")
, ( 2935, "[?]")
, ( 2936, "[?]")
, ( 2937, "[?]")
, ( 2938, "[?]")
, ( 2939, "[?]")
, ( 2940, "[?]")
, ( 2941, "[?]")
, ( 2942, "[?]")
, ( 2943, "[?]")
, ( 2944, "[?]")
, ( 2945, "[?]")
, ( 2946, "N")
, ( 2947, "H")
, ( 2948, "[?]")
, ( 2949, "a")
, ( 2950, "aa")
, ( 2951, "i")
, ( 2952, "ii")
, ( 2953, "u")
, ( 2954, "uu")
, ( 2955, "[?]")
, ( 2956, "[?]")
, ( 2957, "[?]")
, ( 2958, "e")
, ( 2959, "ee")
, ( 2960, "ai")
, ( 2961, "[?]")
, ( 2962, "o")
, ( 2963, "oo")
, ( 2964, "au")
, ( 2965, "k")
, ( 2966, "[?]")
, ( 2967, "[?]")
, ( 2968, "[?]")
, ( 2969, "ng")
, ( 2970, "c")
, ( 2971, "[?]")
, ( 2972, "j")
, ( 2973, "[?]")
, ( 2974, "ny")
, ( 2975, "tt")
, ( 2976, "[?]")
, ( 2977, "[?]")
, ( 2978, "[?]")
, ( 2979, "nn")
, ( 2980, "t")
, ( 2981, "[?]")
, ( 2982, "[?]")
, ( 2983, "[?]")
, ( 2984, "n")
, ( 2985, "nnn")
, ( 2986, "p")
, ( 2987, "[?]")
, ( 2988, "[?]")
, ( 2989, "[?]")
, ( 2990, "m")
, ( 2991, "y")
, ( 2992, "r")
, ( 2993, "rr")
, ( 2994, "l")
, ( 2995, "ll")
, ( 2996, "lll")
, ( 2997, "v")
, ( 2998, "[?]")
, ( 2999, "ss")
, ( 3000, "s")
, ( 3001, "h")
, ( 3002, "[?]")
, ( 3003, "[?]")
, ( 3004, "[?]")
, ( 3005, "[?]")
, ( 3006, "aa")
, ( 3007, "i")
, ( 3008, "ii")
, ( 3009, "u")
, ( 3010, "uu")
, ( 3011, "[?]")
, ( 3012, "[?]")
, ( 3013, "[?]")
, ( 3014, "e")
, ( 3015, "ee")
, ( 3016, "ai")
, ( 3017, "[?]")
, ( 3018, "o")
, ( 3019, "oo")
, ( 3020, "au")
, ( 3022, "[?]")
, ( 3023, "[?]")
, ( 3024, "[?]")
, ( 3025, "[?]")
, ( 3026, "[?]")
, ( 3027, "[?]")
, ( 3028, "[?]")
, ( 3029, "[?]")
, ( 3030, "[?]")
, ( 3031, "+")
, ( 3032, "[?]")
, ( 3033, "[?]")
, ( 3034, "[?]")
, ( 3035, "[?]")
, ( 3036, "[?]")
, ( 3037, "[?]")
, ( 3038, "[?]")
, ( 3039, "[?]")
, ( 3040, "[?]")
, ( 3041, "[?]")
, ( 3042, "[?]")
, ( 3043, "[?]")
, ( 3044, "[?]")
, ( 3045, "[?]")
, ( 3046, "0")
, ( 3047, "1")
, ( 3048, "2")
, ( 3049, "3")
, ( 3050, "4")
, ( 3051, "5")
, ( 3052, "6")
, ( 3053, "7")
, ( 3054, "8")
, ( 3055, "9")
, ( 3056, "+10+")
, ( 3057, "+100+")
, ( 3058, "+1000+")
, ( 3059, "[?]")
, ( 3060, "[?]")
, ( 3061, "[?]")
, ( 3062, "[?]")
, ( 3063, "[?]")
, ( 3064, "[?]")
, ( 3065, "[?]")
, ( 3066, "[?]")
, ( 3067, "[?]")
, ( 3068, "[?]")
, ( 3069, "[?]")
, ( 3070, "[?]")
, ( 3072, "[?]")
, ( 3073, "N")
, ( 3074, "N")
, ( 3075, "H")
, ( 3076, "[?]")
, ( 3077, "a")
, ( 3078, "aa")
, ( 3079, "i")
, ( 3080, "ii")
, ( 3081, "u")
, ( 3082, "uu")
, ( 3083, "R")
, ( 3084, "L")
, ( 3085, "[?]")
, ( 3086, "e")
, ( 3087, "ee")
, ( 3088, "ai")
, ( 3089, "[?]")
, ( 3090, "o")
, ( 3091, "oo")
, ( 3092, "au")
, ( 3093, "k")
, ( 3094, "kh")
, ( 3095, "g")
, ( 3096, "gh")
, ( 3097, "ng")
, ( 3098, "c")
, ( 3099, "ch")
, ( 3100, "j")
, ( 3101, "jh")
, ( 3102, "ny")
, ( 3103, "tt")
, ( 3104, "tth")
, ( 3105, "dd")
, ( 3106, "ddh")
, ( 3107, "nn")
, ( 3108, "t")
, ( 3109, "th")
, ( 3110, "d")
, ( 3111, "dh")
, ( 3112, "n")
, ( 3113, "[?]")
, ( 3114, "p")
, ( 3115, "ph")
, ( 3116, "b")
, ( 3117, "bh")
, ( 3118, "m")
, ( 3119, "y")
, ( 3120, "r")
, ( 3121, "rr")
, ( 3122, "l")
, ( 3123, "ll")
, ( 3124, "[?]")
, ( 3125, "v")
, ( 3126, "sh")
, ( 3127, "ss")
, ( 3128, "s")
, ( 3129, "h")
, ( 3130, "[?]")
, ( 3131, "[?]")
, ( 3132, "[?]")
, ( 3133, "[?]")
, ( 3134, "aa")
, ( 3135, "i")
, ( 3136, "ii")
, ( 3137, "u")
, ( 3138, "uu")
, ( 3139, "R")
, ( 3140, "RR")
, ( 3141, "[?]")
, ( 3142, "e")
, ( 3143, "ee")
, ( 3144, "ai")
, ( 3145, "[?]")
, ( 3146, "o")
, ( 3147, "oo")
, ( 3148, "au")
, ( 3150, "[?]")
, ( 3151, "[?]")
, ( 3152, "[?]")
, ( 3153, "[?]")
, ( 3154, "[?]")
, ( 3155, "[?]")
, ( 3156, "[?]")
, ( 3157, "+")
, ( 3158, "+")
, ( 3159, "[?]")
, ( 3160, "[?]")
, ( 3161, "[?]")
, ( 3162, "[?]")
, ( 3163, "[?]")
, ( 3164, "[?]")
, ( 3165, "[?]")
, ( 3166, "[?]")
, ( 3167, "[?]")
, ( 3168, "RR")
, ( 3169, "LL")
, ( 3170, "[?]")
, ( 3171, "[?]")
, ( 3172, "[?]")
, ( 3173, "[?]")
, ( 3174, "0")
, ( 3175, "1")
, ( 3176, "2")
, ( 3177, "3")
, ( 3178, "4")
, ( 3179, "5")
, ( 3180, "6")
, ( 3181, "7")
, ( 3182, "8")
, ( 3183, "9")
, ( 3184, "[?]")
, ( 3185, "[?]")
, ( 3186, "[?]")
, ( 3187, "[?]")
, ( 3188, "[?]")
, ( 3189, "[?]")
, ( 3190, "[?]")
, ( 3191, "[?]")
, ( 3192, "[?]")
, ( 3193, "[?]")
, ( 3194, "[?]")
, ( 3195, "[?]")
, ( 3196, "[?]")
, ( 3197, "[?]")
, ( 3198, "[?]")
, ( 3199, "[?]")
, ( 3200, "[?]")
, ( 3201, "[?]")
, ( 3202, "N")
, ( 3203, "H")
, ( 3204, "[?]")
, ( 3205, "a")
, ( 3206, "aa")
, ( 3207, "i")
, ( 3208, "ii")
, ( 3209, "u")
, ( 3210, "uu")
, ( 3211, "R")
, ( 3212, "L")
, ( 3213, "[?]")
, ( 3214, "e")
, ( 3215, "ee")
, ( 3216, "ai")
, ( 3217, "[?]")
, ( 3218, "o")
, ( 3219, "oo")
, ( 3220, "au")
, ( 3221, "k")
, ( 3222, "kh")
, ( 3223, "g")
, ( 3224, "gh")
, ( 3225, "ng")
, ( 3226, "c")
, ( 3227, "ch")
, ( 3228, "j")
, ( 3229, "jh")
, ( 3230, "ny")
, ( 3231, "tt")
, ( 3232, "tth")
, ( 3233, "dd")
, ( 3234, "ddh")
, ( 3235, "nn")
, ( 3236, "t")
, ( 3237, "th")
, ( 3238, "d")
, ( 3239, "dh")
, ( 3240, "n")
, ( 3241, "[?]")
, ( 3242, "p")
, ( 3243, "ph")
, ( 3244, "b")
, ( 3245, "bh")
, ( 3246, "m")
, ( 3247, "y")
, ( 3248, "r")
, ( 3249, "rr")
, ( 3250, "l")
, ( 3251, "ll")
, ( 3252, "[?]")
, ( 3253, "v")
, ( 3254, "sh")
, ( 3255, "ss")
, ( 3256, "s")
, ( 3257, "h")
, ( 3258, "[?]")
, ( 3259, "[?]")
, ( 3260, "[?]")
, ( 3261, "[?]")
, ( 3262, "aa")
, ( 3263, "i")
, ( 3264, "ii")
, ( 3265, "u")
, ( 3266, "uu")
, ( 3267, "R")
, ( 3268, "RR")
, ( 3269, "[?]")
, ( 3270, "e")
, ( 3271, "ee")
, ( 3272, "ai")
, ( 3273, "[?]")
, ( 3274, "o")
, ( 3275, "oo")
, ( 3276, "au")
, ( 3278, "[?]")
, ( 3279, "[?]")
, ( 3280, "[?]")
, ( 3281, "[?]")
, ( 3282, "[?]")
, ( 3283, "[?]")
, ( 3284, "[?]")
, ( 3285, "+")
, ( 3286, "+")
, ( 3287, "[?]")
, ( 3288, "[?]")
, ( 3289, "[?]")
, ( 3290, "[?]")
, ( 3291, "[?]")
, ( 3292, "[?]")
, ( 3293, "[?]")
, ( 3294, "lll")
, ( 3295, "[?]")
, ( 3296, "RR")
, ( 3297, "LL")
, ( 3298, "[?]")
, ( 3299, "[?]")
, ( 3300, "[?]")
, ( 3301, "[?]")
, ( 3302, "0")
, ( 3303, "1")
, ( 3304, "2")
, ( 3305, "3")
, ( 3306, "4")
, ( 3307, "5")
, ( 3308, "6")
, ( 3309, "7")
, ( 3310, "8")
, ( 3311, "9")
, ( 3312, "[?]")
, ( 3313, "[?]")
, ( 3314, "[?]")
, ( 3315, "[?]")
, ( 3316, "[?]")
, ( 3317, "[?]")
, ( 3318, "[?]")
, ( 3319, "[?]")
, ( 3320, "[?]")
, ( 3321, "[?]")
, ( 3322, "[?]")
, ( 3323, "[?]")
, ( 3324, "[?]")
, ( 3325, "[?]")
, ( 3326, "[?]")
, ( 3328, "[?]")
, ( 3329, "[?]")
, ( 3330, "N")
, ( 3331, "H")
, ( 3332, "[?]")
, ( 3333, "a")
, ( 3334, "aa")
, ( 3335, "i")
, ( 3336, "ii")
, ( 3337, "u")
, ( 3338, "uu")
, ( 3339, "R")
, ( 3340, "L")
, ( 3341, "[?]")
, ( 3342, "e")
, ( 3343, "ee")
, ( 3344, "ai")
, ( 3345, "[?]")
, ( 3346, "o")
, ( 3347, "oo")
, ( 3348, "au")
, ( 3349, "k")
, ( 3350, "kh")
, ( 3351, "g")
, ( 3352, "gh")
, ( 3353, "ng")
, ( 3354, "c")
, ( 3355, "ch")
, ( 3356, "j")
, ( 3357, "jh")
, ( 3358, "ny")
, ( 3359, "tt")
, ( 3360, "tth")
, ( 3361, "dd")
, ( 3362, "ddh")
, ( 3363, "nn")
, ( 3364, "t")
, ( 3365, "th")
, ( 3366, "d")
, ( 3367, "dh")
, ( 3368, "n")
, ( 3369, "[?]")
, ( 3370, "p")
, ( 3371, "ph")
, ( 3372, "b")
, ( 3373, "bh")
, ( 3374, "m")
, ( 3375, "y")
, ( 3376, "r")
, ( 3377, "rr")
, ( 3378, "l")
, ( 3379, "ll")
, ( 3380, "lll")
, ( 3381, "v")
, ( 3382, "sh")
, ( 3383, "ss")
, ( 3384, "s")
, ( 3385, "h")
, ( 3386, "[?]")
, ( 3387, "[?]")
, ( 3388, "[?]")
, ( 3389, "[?]")
, ( 3390, "aa")
, ( 3391, "i")
, ( 3392, "ii")
, ( 3393, "u")
, ( 3394, "uu")
, ( 3395, "R")
, ( 3396, "[?]")
, ( 3397, "[?]")
, ( 3398, "e")
, ( 3399, "ee")
, ( 3400, "ai")
, ( 3402, "o")
, ( 3403, "oo")
, ( 3404, "au")
, ( 3406, "[?]")
, ( 3407, "[?]")
, ( 3408, "[?]")
, ( 3409, "[?]")
, ( 3410, "[?]")
, ( 3411, "[?]")
, ( 3412, "[?]")
, ( 3413, "[?]")
, ( 3414, "[?]")
, ( 3415, "+")
, ( 3416, "[?]")
, ( 3417, "[?]")
, ( 3418, "[?]")
, ( 3419, "[?]")
, ( 3420, "[?]")
, ( 3421, "[?]")
, ( 3422, "[?]")
, ( 3423, "[?]")
, ( 3424, "RR")
, ( 3425, "LL")
, ( 3426, "[?]")
, ( 3427, "[?]")
, ( 3428, "[?]")
, ( 3429, "[?]")
, ( 3430, "0")
, ( 3431, "1")
, ( 3432, "2")
, ( 3433, "3")
, ( 3434, "4")
, ( 3435, "5")
, ( 3436, "6")
, ( 3437, "7")
, ( 3438, "8")
, ( 3439, "9")
, ( 3440, "[?]")
, ( 3441, "[?]")
, ( 3442, "[?]")
, ( 3443, "[?]")
, ( 3444, "[?]")
, ( 3445, "[?]")
, ( 3446, "[?]")
, ( 3447, "[?]")
, ( 3448, "[?]")
, ( 3449, "[?]")
, ( 3450, "[?]")
, ( 3451, "[?]")
, ( 3452, "[?]")
, ( 3453, "[?]")
, ( 3454, "[?]")
, ( 3455, "[?]")
, ( 3456, "[?]")
, ( 3457, "[?]")
, ( 3458, "N")
, ( 3459, "H")
, ( 3460, "[?]")
, ( 3461, "a")
, ( 3462, "aa")
, ( 3463, "ae")
, ( 3464, "aae")
, ( 3465, "i")
, ( 3466, "ii")
, ( 3467, "u")
, ( 3468, "uu")
, ( 3469, "R")
, ( 3470, "RR")
, ( 3471, "L")
, ( 3472, "LL")
, ( 3473, "e")
, ( 3474, "ee")
, ( 3475, "ai")
, ( 3476, "o")
, ( 3477, "oo")
, ( 3478, "au")
, ( 3479, "[?]")
, ( 3480, "[?]")
, ( 3481, "[?]")
, ( 3482, "k")
, ( 3483, "kh")
, ( 3484, "g")
, ( 3485, "gh")
, ( 3486, "ng")
, ( 3487, "nng")
, ( 3488, "c")
, ( 3489, "ch")
, ( 3490, "j")
, ( 3491, "jh")
, ( 3492, "ny")
, ( 3493, "jny")
, ( 3494, "nyj")
, ( 3495, "tt")
, ( 3496, "tth")
, ( 3497, "dd")
, ( 3498, "ddh")
, ( 3499, "nn")
, ( 3500, "nndd")
, ( 3501, "t")
, ( 3502, "th")
, ( 3503, "d")
, ( 3504, "dh")
, ( 3505, "n")
, ( 3506, "[?]")
, ( 3507, "nd")
, ( 3508, "p")
, ( 3509, "ph")
, ( 3510, "b")
, ( 3511, "bh")
, ( 3512, "m")
, ( 3513, "mb")
, ( 3514, "y")
, ( 3515, "r")
, ( 3516, "[?]")
, ( 3517, "l")
, ( 3518, "[?]")
, ( 3519, "[?]")
, ( 3520, "v")
, ( 3521, "sh")
, ( 3522, "ss")
, ( 3523, "s")
, ( 3524, "h")
, ( 3525, "ll")
, ( 3526, "f")
, ( 3527, "[?]")
, ( 3528, "[?]")
, ( 3529, "[?]")
, ( 3531, "[?]")
, ( 3532, "[?]")
, ( 3533, "[?]")
, ( 3534, "[?]")
, ( 3535, "aa")
, ( 3536, "ae")
, ( 3537, "aae")
, ( 3538, "i")
, ( 3539, "ii")
, ( 3540, "u")
, ( 3541, "[?]")
, ( 3542, "uu")
, ( 3543, "[?]")
, ( 3544, "R")
, ( 3545, "e")
, ( 3546, "ee")
, ( 3547, "ai")
, ( 3548, "o")
, ( 3549, "oo")
, ( 3550, "au")
, ( 3551, "L")
, ( 3552, "[?]")
, ( 3553, "[?]")
, ( 3554, "[?]")
, ( 3555, "[?]")
, ( 3556, "[?]")
, ( 3557, "[?]")
, ( 3558, "[?]")
, ( 3559, "[?]")
, ( 3560, "[?]")
, ( 3561, "[?]")
, ( 3562, "[?]")
, ( 3563, "[?]")
, ( 3564, "[?]")
, ( 3565, "[?]")
, ( 3566, "[?]")
, ( 3567, "[?]")
, ( 3568, "[?]")
, ( 3569, "[?]")
, ( 3570, "RR")
, ( 3571, "LL")
, ( 3572, " . ")
, ( 3573, "[?]")
, ( 3574, "[?]")
, ( 3575, "[?]")
, ( 3576, "[?]")
, ( 3577, "[?]")
, ( 3578, "[?]")
, ( 3579, "[?]")
, ( 3580, "[?]")
, ( 3581, "[?]")
, ( 3582, "[?]")
, ( 3584, "[?]")
, ( 3585, "k")
, ( 3586, "kh")
, ( 3587, "kh")
, ( 3588, "kh")
, ( 3589, "kh")
, ( 3590, "kh")
, ( 3591, "ng")
, ( 3592, "cch")
, ( 3593, "ch")
, ( 3594, "ch")
, ( 3595, "ch")
, ( 3596, "ch")
, ( 3597, "y")
, ( 3598, "d")
, ( 3599, "t")
, ( 3600, "th")
, ( 3601, "th")
, ( 3602, "th")
, ( 3603, "n")
, ( 3604, "d")
, ( 3605, "t")
, ( 3606, "th")
, ( 3607, "th")
, ( 3608, "th")
, ( 3609, "n")
, ( 3610, "b")
, ( 3611, "p")
, ( 3612, "ph")
, ( 3613, "f")
, ( 3614, "ph")
, ( 3615, "f")
, ( 3616, "ph")
, ( 3617, "m")
, ( 3618, "y")
, ( 3619, "r")
, ( 3620, "R")
, ( 3621, "l")
, ( 3622, "L")
, ( 3623, "w")
, ( 3624, "s")
, ( 3625, "s")
, ( 3626, "s")
, ( 3627, "h")
, ( 3628, "l")
, ( 3629, "`")
, ( 3630, "h")
, ( 3631, "~")
, ( 3632, "a")
, ( 3633, "a")
, ( 3634, "aa")
, ( 3635, "am")
, ( 3636, "i")
, ( 3637, "ii")
, ( 3638, "ue")
, ( 3639, "uue")
, ( 3640, "u")
, ( 3641, "uu")
, ( 3642, "'")
, ( 3643, "[?]")
, ( 3644, "[?]")
, ( 3645, "[?]")
, ( 3646, "[?]")
, ( 3647, "Bh.")
, ( 3648, "e")
, ( 3649, "ae")
, ( 3650, "o")
, ( 3651, "ai")
, ( 3652, "ai")
, ( 3653, "ao")
, ( 3654, "+")
, ( 3661, "M")
, ( 3663, " * ")
, ( 3664, "0")
, ( 3665, "1")
, ( 3666, "2")
, ( 3667, "3")
, ( 3668, "4")
, ( 3669, "5")
, ( 3670, "6")
, ( 3671, "7")
, ( 3672, "8")
, ( 3673, "9")
, ( 3674, " // ")
, ( 3675, " /// ")
, ( 3676, "[?]")
, ( 3677, "[?]")
, ( 3678, "[?]")
, ( 3679, "[?]")
, ( 3680, "[?]")
, ( 3681, "[?]")
, ( 3682, "[?]")
, ( 3683, "[?]")
, ( 3684, "[?]")
, ( 3685, "[?]")
, ( 3686, "[?]")
, ( 3687, "[?]")
, ( 3688, "[?]")
, ( 3689, "[?]")
, ( 3690, "[?]")
, ( 3691, "[?]")
, ( 3692, "[?]")
, ( 3693, "[?]")
, ( 3694, "[?]")
, ( 3695, "[?]")
, ( 3696, "[?]")
, ( 3697, "[?]")
, ( 3698, "[?]")
, ( 3699, "[?]")
, ( 3700, "[?]")
, ( 3701, "[?]")
, ( 3702, "[?]")
, ( 3703, "[?]")
, ( 3704, "[?]")
, ( 3705, "[?]")
, ( 3706, "[?]")
, ( 3707, "[?]")
, ( 3708, "[?]")
, ( 3709, "[?]")
, ( 3710, "[?]")
, ( 3711, "[?]")
, ( 3712, "[?]")
, ( 3713, "k")
, ( 3714, "kh")
, ( 3715, "[?]")
, ( 3716, "kh")
, ( 3717, "[?]")
, ( 3718, "[?]")
, ( 3719, "ng")
, ( 3720, "ch")
, ( 3721, "[?]")
, ( 3722, "s")
, ( 3723, "[?]")
, ( 3724, "[?]")
, ( 3725, "ny")
, ( 3726, "[?]")
, ( 3727, "[?]")
, ( 3728, "[?]")
, ( 3729, "[?]")
, ( 3730, "[?]")
, ( 3731, "[?]")
, ( 3732, "d")
, ( 3733, "h")
, ( 3734, "th")
, ( 3735, "th")
, ( 3736, "[?]")
, ( 3737, "n")
, ( 3738, "b")
, ( 3739, "p")
, ( 3740, "ph")
, ( 3741, "f")
, ( 3742, "ph")
, ( 3743, "f")
, ( 3744, "[?]")
, ( 3745, "m")
, ( 3746, "y")
, ( 3747, "r")
, ( 3748, "[?]")
, ( 3749, "l")
, ( 3750, "[?]")
, ( 3751, "w")
, ( 3752, "[?]")
, ( 3753, "[?]")
, ( 3754, "s")
, ( 3755, "h")
, ( 3756, "[?]")
, ( 3757, "`")
, ( 3759, "~")
, ( 3760, "a")
, ( 3762, "aa")
, ( 3763, "am")
, ( 3764, "i")
, ( 3765, "ii")
, ( 3766, "y")
, ( 3767, "yy")
, ( 3768, "u")
, ( 3769, "uu")
, ( 3770, "[?]")
, ( 3771, "o")
, ( 3772, "l")
, ( 3773, "ny")
, ( 3774, "[?]")
, ( 3775, "[?]")
, ( 3776, "e")
, ( 3777, "ei")
, ( 3778, "o")
, ( 3779, "ay")
, ( 3780, "ai")
, ( 3781, "[?]")
, ( 3782, "+")
, ( 3783, "[?]")
, ( 3789, "M")
, ( 3790, "[?]")
, ( 3791, "[?]")
, ( 3792, "0")
, ( 3793, "1")
, ( 3794, "2")
, ( 3795, "3")
, ( 3796, "4")
, ( 3797, "5")
, ( 3798, "6")
, ( 3799, "7")
, ( 3800, "8")
, ( 3801, "9")
, ( 3802, "[?]")
, ( 3803, "[?]")
, ( 3804, "hn")
, ( 3805, "hm")
, ( 3806, "[?]")
, ( 3807, "[?]")
, ( 3808, "[?]")
, ( 3809, "[?]")
, ( 3810, "[?]")
, ( 3811, "[?]")
, ( 3812, "[?]")
, ( 3813, "[?]")
, ( 3814, "[?]")
, ( 3815, "[?]")
, ( 3816, "[?]")
, ( 3817, "[?]")
, ( 3818, "[?]")
, ( 3819, "[?]")
, ( 3820, "[?]")
, ( 3821, "[?]")
, ( 3822, "[?]")
, ( 3823, "[?]")
, ( 3824, "[?]")
, ( 3825, "[?]")
, ( 3826, "[?]")
, ( 3827, "[?]")
, ( 3828, "[?]")
, ( 3829, "[?]")
, ( 3830, "[?]")
, ( 3831, "[?]")
, ( 3832, "[?]")
, ( 3833, "[?]")
, ( 3834, "[?]")
, ( 3835, "[?]")
, ( 3836, "[?]")
, ( 3837, "[?]")
, ( 3838, "[?]")
, ( 3840, "AUM")
, ( 3848, " // ")
, ( 3849, " * ")
, ( 3851, "-")
, ( 3852, " / ")
, ( 3853, " / ")
, ( 3854, " // ")
, ( 3855, " -/ ")
, ( 3856, " +/ ")
, ( 3857, " X/ ")
, ( 3858, " /XX/ ")
, ( 3859, " /X/ ")
, ( 3860, ", ")
, ( 3872, "0")
, ( 3873, "1")
, ( 3874, "2")
, ( 3875, "3")
, ( 3876, "4")
, ( 3877, "5")
, ( 3878, "6")
, ( 3879, "7")
, ( 3880, "8")
, ( 3881, "9")
, ( 3882, ".5")
, ( 3883, "1.5")
, ( 3884, "2.5")
, ( 3885, "3.5")
, ( 3886, "4.5")
, ( 3887, "5.5")
, ( 3888, "6.5")
, ( 3889, "7.5")
, ( 3890, "8.5")
, ( 3891, "-.5")
, ( 3892, "+")
, ( 3893, "*")
, ( 3894, "^")
, ( 3895, "_")
, ( 3897, "~")
, ( 3898, "[?]")
, ( 3899, "]")
, ( 3900, "[[")
, ( 3901, "]]")
, ( 3904, "k")
, ( 3905, "kh")
, ( 3906, "g")
, ( 3907, "gh")
, ( 3908, "ng")
, ( 3909, "c")
, ( 3910, "ch")
, ( 3911, "j")
, ( 3912, "[?]")
, ( 3913, "ny")
, ( 3914, "tt")
, ( 3915, "tth")
, ( 3916, "dd")
, ( 3917, "ddh")
, ( 3918, "nn")
, ( 3919, "t")
, ( 3920, "th")
, ( 3921, "d")
, ( 3922, "dh")
, ( 3923, "n")
, ( 3924, "p")
, ( 3925, "ph")
, ( 3926, "b")
, ( 3927, "bh")
, ( 3928, "m")
, ( 3929, "ts")
, ( 3930, "tsh")
, ( 3931, "dz")
, ( 3932, "dzh")
, ( 3933, "w")
, ( 3934, "zh")
, ( 3935, "z")
, ( 3936, "'")
, ( 3937, "y")
, ( 3938, "r")
, ( 3939, "l")
, ( 3940, "sh")
, ( 3941, "ssh")
, ( 3942, "s")
, ( 3943, "h")
, ( 3944, "a")
, ( 3945, "kss")
, ( 3946, "r")
, ( 3947, "[?]")
, ( 3948, "[?]")
, ( 3949, "[?]")
, ( 3950, "[?]")
, ( 3951, "[?]")
, ( 3952, "[?]")
, ( 3953, "aa")
, ( 3954, "i")
, ( 3955, "ii")
, ( 3956, "u")
, ( 3957, "uu")
, ( 3958, "R")
, ( 3959, "RR")
, ( 3960, "L")
, ( 3961, "LL")
, ( 3962, "e")
, ( 3963, "ee")
, ( 3964, "o")
, ( 3965, "oo")
, ( 3966, "M")
, ( 3967, "H")
, ( 3968, "i")
, ( 3969, "ii")
, ( 3980, "[?]")
, ( 3981, "[?]")
, ( 3982, "[?]")
, ( 3983, "[?]")
, ( 3984, "k")
, ( 3985, "kh")
, ( 3986, "g")
, ( 3987, "gh")
, ( 3988, "ng")
, ( 3989, "c")
, ( 3990, "ch")
, ( 3991, "j")
, ( 3992, "[?]")
, ( 3993, "ny")
, ( 3994, "tt")
, ( 3995, "tth")
, ( 3996, "dd")
, ( 3997, "ddh")
, ( 3998, "nn")
, ( 3999, "t")
, ( 4000, "th")
, ( 4001, "d")
, ( 4002, "dh")
, ( 4003, "n")
, ( 4004, "p")
, ( 4005, "ph")
, ( 4006, "b")
, ( 4007, "bh")
, ( 4008, "m")
, ( 4009, "ts")
, ( 4010, "tsh")
, ( 4011, "dz")
, ( 4012, "dzh")
, ( 4013, "w")
, ( 4014, "zh")
, ( 4015, "z")
, ( 4016, "'")
, ( 4017, "y")
, ( 4018, "r")
, ( 4019, "l")
, ( 4020, "sh")
, ( 4021, "ss")
, ( 4022, "s")
, ( 4023, "h")
, ( 4024, "a")
, ( 4025, "kss")
, ( 4026, "w")
, ( 4027, "y")
, ( 4028, "r")
, ( 4029, "[?]")
, ( 4030, "X")
, ( 4031, " :X: ")
, ( 4032, " /O/ ")
, ( 4033, " /o/ ")
, ( 4034, " \\o\\ ")
, ( 4035, " (O) ")
, ( 4045, "[?]")
, ( 4046, "[?]")
, ( 4048, "[?]")
, ( 4049, "[?]")
, ( 4050, "[?]")
, ( 4051, "[?]")
, ( 4052, "[?]")
, ( 4053, "[?]")
, ( 4054, "[?]")
, ( 4055, "[?]")
, ( 4056, "[?]")
, ( 4057, "[?]")
, ( 4058, "[?]")
, ( 4059, "[?]")
, ( 4060, "[?]")
, ( 4061, "[?]")
, ( 4062, "[?]")
, ( 4063, "[?]")
, ( 4064, "[?]")
, ( 4065, "[?]")
, ( 4066, "[?]")
, ( 4067, "[?]")
, ( 4068, "[?]")
, ( 4069, "[?]")
, ( 4070, "[?]")
, ( 4071, "[?]")
, ( 4072, "[?]")
, ( 4073, "[?]")
, ( 4074, "[?]")
, ( 4075, "[?]")
, ( 4076, "[?]")
, ( 4077, "[?]")
, ( 4078, "[?]")
, ( 4079, "[?]")
, ( 4080, "[?]")
, ( 4081, "[?]")
, ( 4082, "[?]")
, ( 4083, "[?]")
, ( 4084, "[?]")
, ( 4085, "[?]")
, ( 4086, "[?]")
, ( 4087, "[?]")
, ( 4088, "[?]")
, ( 4089, "[?]")
, ( 4090, "[?]")
, ( 4091, "[?]")
, ( 4092, "[?]")
, ( 4093, "[?]")
, ( 4094, "[?]")
, ( 4096, "k")
, ( 4097, "kh")
, ( 4098, "g")
, ( 4099, "gh")
, ( 4100, "ng")
, ( 4101, "c")
, ( 4102, "ch")
, ( 4103, "j")
, ( 4104, "jh")
, ( 4105, "ny")
, ( 4106, "nny")
, ( 4107, "tt")
, ( 4108, "tth")
, ( 4109, "dd")
, ( 4110, "ddh")
, ( 4111, "nn")
, ( 4112, "tt")
, ( 4113, "th")
, ( 4114, "d")
, ( 4115, "dh")
, ( 4116, "n")
, ( 4117, "p")
, ( 4118, "ph")
, ( 4119, "b")
, ( 4120, "bh")
, ( 4121, "m")
, ( 4122, "y")
, ( 4123, "r")
, ( 4124, "l")
, ( 4125, "w")
, ( 4126, "s")
, ( 4127, "h")
, ( 4128, "ll")
, ( 4129, "a")
, ( 4130, "[?]")
, ( 4131, "i")
, ( 4132, "ii")
, ( 4133, "u")
, ( 4134, "uu")
, ( 4135, "e")
, ( 4136, "[?]")
, ( 4137, "o")
, ( 4138, "au")
, ( 4139, "[?]")
, ( 4140, "aa")
, ( 4141, "i")
, ( 4142, "ii")
, ( 4143, "u")
, ( 4144, "uu")
, ( 4145, "e")
, ( 4146, "ai")
, ( 4147, "[?]")
, ( 4148, "[?]")
, ( 4149, "[?]")
, ( 4150, "N")
, ( 4151, "'")
, ( 4152, ":")
, ( 4154, "[?]")
, ( 4155, "[?]")
, ( 4156, "[?]")
, ( 4157, "[?]")
, ( 4158, "[?]")
, ( 4159, "[?]")
, ( 4160, "0")
, ( 4161, "1")
, ( 4162, "2")
, ( 4163, "3")
, ( 4164, "4")
, ( 4165, "5")
, ( 4166, "6")
, ( 4167, "7")
, ( 4168, "8")
, ( 4169, "9")
, ( 4170, " / ")
, ( 4171, " // ")
, ( 4172, "n*")
, ( 4173, "r*")
, ( 4174, "l*")
, ( 4175, "e*")
, ( 4176, "sh")
, ( 4177, "ss")
, ( 4178, "R")
, ( 4179, "RR")
, ( 4180, "L")
, ( 4181, "LL")
, ( 4182, "R")
, ( 4183, "RR")
, ( 4184, "L")
, ( 4185, "LL")
, ( 4186, "[?]")
, ( 4187, "[?]")
, ( 4188, "[?]")
, ( 4189, "[?]")
, ( 4190, "[?]")
, ( 4191, "[?]")
, ( 4192, "[?]")
, ( 4193, "[?]")
, ( 4194, "[?]")
, ( 4195, "[?]")
, ( 4196, "[?]")
, ( 4197, "[?]")
, ( 4198, "[?]")
, ( 4199, "[?]")
, ( 4200, "[?]")
, ( 4201, "[?]")
, ( 4202, "[?]")
, ( 4203, "[?]")
, ( 4204, "[?]")
, ( 4205, "[?]")
, ( 4206, "[?]")
, ( 4207, "[?]")
, ( 4208, "[?]")
, ( 4209, "[?]")
, ( 4210, "[?]")
, ( 4211, "[?]")
, ( 4212, "[?]")
, ( 4213, "[?]")
, ( 4214, "[?]")
, ( 4215, "[?]")
, ( 4216, "[?]")
, ( 4217, "[?]")
, ( 4218, "[?]")
, ( 4219, "[?]")
, ( 4220, "[?]")
, ( 4221, "[?]")
, ( 4222, "[?]")
, ( 4223, "[?]")
, ( 4224, "[?]")
, ( 4225, "[?]")
, ( 4226, "[?]")
, ( 4227, "[?]")
, ( 4228, "[?]")
, ( 4229, "[?]")
, ( 4230, "[?]")
, ( 4231, "[?]")
, ( 4232, "[?]")
, ( 4233, "[?]")
, ( 4234, "[?]")
, ( 4235, "[?]")
, ( 4236, "[?]")
, ( 4237, "[?]")
, ( 4238, "[?]")
, ( 4239, "[?]")
, ( 4240, "[?]")
, ( 4241, "[?]")
, ( 4242, "[?]")
, ( 4243, "[?]")
, ( 4244, "[?]")
, ( 4245, "[?]")
, ( 4246, "[?]")
, ( 4247, "[?]")
, ( 4248, "[?]")
, ( 4249, "[?]")
, ( 4250, "[?]")
, ( 4251, "[?]")
, ( 4252, "[?]")
, ( 4253, "[?]")
, ( 4254, "[?]")
, ( 4255, "[?]")
, ( 4256, "A")
, ( 4257, "B")
, ( 4258, "G")
, ( 4259, "D")
, ( 4260, "E")
, ( 4261, "V")
, ( 4262, "Z")
, ( 4263, "T`")
, ( 4264, "I")
, ( 4265, "K")
, ( 4266, "L")
, ( 4267, "M")
, ( 4268, "N")
, ( 4269, "O")
, ( 4270, "P")
, ( 4271, "Zh")
, ( 4272, "R")
, ( 4273, "S")
, ( 4274, "T")
, ( 4275, "U")
, ( 4276, "P`")
, ( 4277, "K`")
, ( 4278, "G'")
, ( 4279, "Q")
, ( 4280, "Sh")
, ( 4281, "Ch`")
, ( 4282, "C`")
, ( 4283, "Z'")
, ( 4284, "C")
, ( 4285, "Ch")
, ( 4286, "X")
, ( 4287, "J")
, ( 4288, "H")
, ( 4289, "E")
, ( 4290, "Y")
, ( 4291, "W")
, ( 4292, "Xh")
, ( 4293, "OE")
, ( 4294, "[?]")
, ( 4295, "[?]")
, ( 4296, "[?]")
, ( 4297, "[?]")
, ( 4298, "[?]")
, ( 4299, "[?]")
, ( 4300, "[?]")
, ( 4301, "[?]")
, ( 4302, "[?]")
, ( 4303, "[?]")
, ( 4304, "a")
, ( 4305, "b")
, ( 4306, "g")
, ( 4307, "d")
, ( 4308, "e")
, ( 4309, "v")
, ( 4310, "z")
, ( 4311, "t`")
, ( 4312, "i")
, ( 4313, "k")
, ( 4314, "l")
, ( 4315, "m")
, ( 4316, "n")
, ( 4317, "o")
, ( 4318, "p")
, ( 4319, "zh")
, ( 4320, "r")
, ( 4321, "s")
, ( 4322, "t")
, ( 4323, "u")
, ( 4324, "p`")
, ( 4325, "k`")
, ( 4326, "g'")
, ( 4327, "q")
, ( 4328, "sh")
, ( 4329, "ch`")
, ( 4330, "c`")
, ( 4331, "z'")
, ( 4332, "c")
, ( 4333, "ch")
, ( 4334, "x")
, ( 4335, "j")
, ( 4336, "h")
, ( 4337, "e")
, ( 4338, "y")
, ( 4339, "w")
, ( 4340, "xh")
, ( 4341, "oe")
, ( 4342, "f")
, ( 4343, "[?]")
, ( 4344, "[?]")
, ( 4345, "[?]")
, ( 4346, "[?]")
, ( 4347, " // ")
, ( 4348, "[?]")
, ( 4349, "[?]")
, ( 4350, "[?]")
, ( 4352, "g")
, ( 4353, "gg")
, ( 4354, "n")
, ( 4355, "d")
, ( 4356, "dd")
, ( 4357, "r")
, ( 4358, "m")
, ( 4359, "b")
, ( 4360, "bb")
, ( 4361, "s")
, ( 4362, "ss")
, ( 4364, "j")
, ( 4365, "jj")
, ( 4366, "c")
, ( 4367, "k")
, ( 4368, "t")
, ( 4369, "p")
, ( 4370, "h")
, ( 4371, "ng")
, ( 4372, "nn")
, ( 4373, "nd")
, ( 4374, "nb")
, ( 4375, "dg")
, ( 4376, "rn")
, ( 4377, "rr")
, ( 4378, "rh")
, ( 4379, "rN")
, ( 4380, "mb")
, ( 4381, "mN")
, ( 4382, "bg")
, ( 4383, "bn")
, ( 4385, "bs")
, ( 4386, "bsg")
, ( 4387, "bst")
, ( 4388, "bsb")
, ( 4389, "bss")
, ( 4390, "bsj")
, ( 4391, "bj")
, ( 4392, "bc")
, ( 4393, "bt")
, ( 4394, "bp")
, ( 4395, "bN")
, ( 4396, "bbN")
, ( 4397, "sg")
, ( 4398, "sn")
, ( 4399, "sd")
, ( 4400, "sr")
, ( 4401, "sm")
, ( 4402, "sb")
, ( 4403, "sbg")
, ( 4404, "sss")
, ( 4405, "s")
, ( 4406, "sj")
, ( 4407, "sc")
, ( 4408, "sk")
, ( 4409, "st")
, ( 4410, "sp")
, ( 4411, "sh")
, ( 4416, "Z")
, ( 4417, "g")
, ( 4418, "d")
, ( 4419, "m")
, ( 4420, "b")
, ( 4421, "s")
, ( 4422, "Z")
, ( 4424, "j")
, ( 4425, "c")
, ( 4426, "t")
, ( 4427, "p")
, ( 4428, "N")
, ( 4429, "j")
, ( 4434, "ck")
, ( 4435, "ch")
, ( 4438, "pb")
, ( 4439, "pN")
, ( 4440, "hh")
, ( 4441, "Q")
, ( 4442, "[?]")
, ( 4443, "[?]")
, ( 4444, "[?]")
, ( 4445, "[?]")
, ( 4446, "[?]")
, ( 4449, "a")
, ( 4450, "ae")
, ( 4451, "ya")
, ( 4452, "yae")
, ( 4453, "eo")
, ( 4454, "e")
, ( 4455, "yeo")
, ( 4456, "ye")
, ( 4457, "o")
, ( 4458, "wa")
, ( 4459, "wae")
, ( 4460, "oe")
, ( 4461, "yo")
, ( 4462, "u")
, ( 4463, "weo")
, ( 4464, "we")
, ( 4465, "wi")
, ( 4466, "yu")
, ( 4467, "eu")
, ( 4468, "yi")
, ( 4469, "i")
, ( 4470, "a-o")
, ( 4471, "a-u")
, ( 4472, "ya-o")
, ( 4473, "ya-yo")
, ( 4474, "eo-o")
, ( 4475, "eo-u")
, ( 4476, "eo-eu")
, ( 4477, "yeo-o")
, ( 4478, "yeo-u")
, ( 4479, "o-eo")
, ( 4480, "o-e")
, ( 4481, "o-ye")
, ( 4482, "o-o")
, ( 4483, "o-u")
, ( 4484, "yo-ya")
, ( 4485, "yo-yae")
, ( 4486, "yo-yeo")
, ( 4487, "yo-o")
, ( 4488, "yo-i")
, ( 4489, "u-a")
, ( 4490, "u-ae")
, ( 4491, "u-eo-eu")
, ( 4492, "u-ye")
, ( 4493, "u-u")
, ( 4494, "yu-a")
, ( 4495, "yu-eo")
, ( 4496, "yu-e")
, ( 4497, "yu-yeo")
, ( 4498, "yu-ye")
, ( 4499, "yu-u")
, ( 4500, "yu-i")
, ( 4501, "eu-u")
, ( 4502, "eu-eu")
, ( 4503, "yi-u")
, ( 4504, "i-a")
, ( 4505, "i-ya")
, ( 4506, "i-o")
, ( 4507, "i-u")
, ( 4508, "i-eu")
, ( 4509, "i-U")
, ( 4510, "U")
, ( 4511, "U-eo")
, ( 4512, "U-u")
, ( 4513, "U-i")
, ( 4514, "UU")
, ( 4515, "[?]")
, ( 4516, "[?]")
, ( 4517, "[?]")
, ( 4518, "[?]")
, ( 4519, "[?]")
, ( 4520, "g")
, ( 4521, "gg")
, ( 4522, "gs")
, ( 4523, "n")
, ( 4524, "nj")
, ( 4525, "nh")
, ( 4526, "d")
, ( 4527, "l")
, ( 4528, "lg")
, ( 4529, "lm")
, ( 4530, "lb")
, ( 4531, "ls")
, ( 4532, "lt")
, ( 4533, "lp")
, ( 4534, "lh")
, ( 4535, "m")
, ( 4536, "b")
, ( 4537, "bs")
, ( 4538, "s")
, ( 4539, "ss")
, ( 4540, "ng")
, ( 4541, "j")
, ( 4542, "c")
, ( 4543, "k")
, ( 4544, "t")
, ( 4545, "p")
, ( 4546, "h")
, ( 4547, "gl")
, ( 4548, "gsg")
, ( 4549, "ng")
, ( 4550, "nd")
, ( 4551, "ns")
, ( 4552, "nZ")
, ( 4553, "nt")
, ( 4554, "dg")
, ( 4555, "tl")
, ( 4556, "lgs")
, ( 4557, "ln")
, ( 4558, "ld")
, ( 4559, "lth")
, ( 4560, "ll")
, ( 4561, "lmg")
, ( 4562, "lms")
, ( 4563, "lbs")
, ( 4564, "lbh")
, ( 4565, "rNp")
, ( 4566, "lss")
, ( 4567, "lZ")
, ( 4568, "lk")
, ( 4569, "lQ")
, ( 4570, "mg")
, ( 4571, "ml")
, ( 4572, "mb")
, ( 4573, "ms")
, ( 4574, "mss")
, ( 4575, "mZ")
, ( 4576, "mc")
, ( 4577, "mh")
, ( 4578, "mN")
, ( 4579, "bl")
, ( 4580, "bp")
, ( 4581, "ph")
, ( 4582, "pN")
, ( 4583, "sg")
, ( 4584, "sd")
, ( 4585, "sl")
, ( 4586, "sb")
, ( 4587, "Z")
, ( 4588, "g")
, ( 4589, "ss")
, ( 4591, "kh")
, ( 4592, "N")
, ( 4593, "Ns")
, ( 4594, "NZ")
, ( 4595, "pb")
, ( 4596, "pN")
, ( 4597, "hn")
, ( 4598, "hl")
, ( 4599, "hm")
, ( 4600, "hb")
, ( 4601, "Q")
, ( 4602, "[?]")
, ( 4603, "[?]")
, ( 4604, "[?]")
, ( 4605, "[?]")
, ( 4606, "[?]")
, ( 4608, "ha")
, ( 4609, "hu")
, ( 4610, "hi")
, ( 4611, "haa")
, ( 4612, "hee")
, ( 4613, "he")
, ( 4614, "ho")
, ( 4615, "[?]")
, ( 4616, "la")
, ( 4617, "lu")
, ( 4618, "li")
, ( 4619, "laa")
, ( 4620, "lee")
, ( 4621, "le")
, ( 4622, "lo")
, ( 4623, "lwa")
, ( 4624, "hha")
, ( 4625, "hhu")
, ( 4626, "hhi")
, ( 4627, "hhaa")
, ( 4628, "hhee")
, ( 4629, "hhe")
, ( 4630, "hho")
, ( 4631, "hhwa")
, ( 4632, "ma")
, ( 4633, "mu")
, ( 4634, "mi")
, ( 4635, "maa")
, ( 4636, "mee")
, ( 4637, "me")
, ( 4638, "mo")
, ( 4639, "mwa")
, ( 4640, "sza")
, ( 4641, "szu")
, ( 4642, "szi")
, ( 4643, "szaa")
, ( 4644, "szee")
, ( 4645, "sze")
, ( 4646, "szo")
, ( 4647, "szwa")
, ( 4648, "ra")
, ( 4649, "ru")
, ( 4650, "ri")
, ( 4651, "raa")
, ( 4652, "ree")
, ( 4653, "re")
, ( 4654, "ro")
, ( 4655, "rwa")
, ( 4656, "sa")
, ( 4657, "su")
, ( 4658, "si")
, ( 4659, "saa")
, ( 4660, "see")
, ( 4661, "se")
, ( 4662, "so")
, ( 4663, "swa")
, ( 4664, "sha")
, ( 4665, "shu")
, ( 4666, "shi")
, ( 4667, "shaa")
, ( 4668, "shee")
, ( 4669, "she")
, ( 4670, "sho")
, ( 4671, "shwa")
, ( 4672, "qa")
, ( 4673, "qu")
, ( 4674, "qi")
, ( 4675, "qaa")
, ( 4676, "qee")
, ( 4677, "qe")
, ( 4678, "qo")
, ( 4679, "[?]")
, ( 4680, "qwa")
, ( 4681, "[?]")
, ( 4682, "qwi")
, ( 4683, "qwaa")
, ( 4684, "qwee")
, ( 4685, "qwe")
, ( 4686, "[?]")
, ( 4687, "[?]")
, ( 4688, "qha")
, ( 4689, "qhu")
, ( 4690, "qhi")
, ( 4691, "qhaa")
, ( 4692, "qhee")
, ( 4693, "qhe")
, ( 4694, "qho")
, ( 4695, "[?]")
, ( 4696, "qhwa")
, ( 4697, "[?]")
, ( 4698, "qhwi")
, ( 4699, "qhwaa")
, ( 4700, "qhwee")
, ( 4701, "qhwe")
, ( 4702, "[?]")
, ( 4703, "[?]")
, ( 4704, "ba")
, ( 4705, "bu")
, ( 4706, "bi")
, ( 4707, "baa")
, ( 4708, "bee")
, ( 4709, "be")
, ( 4710, "bo")
, ( 4711, "bwa")
, ( 4712, "va")
, ( 4713, "vu")
, ( 4714, "vi")
, ( 4715, "vaa")
, ( 4716, "vee")
, ( 4717, "ve")
, ( 4718, "vo")
, ( 4719, "vwa")
, ( 4720, "ta")
, ( 4721, "tu")
, ( 4722, "ti")
, ( 4723, "taa")
, ( 4724, "tee")
, ( 4725, "te")
, ( 4726, "to")
, ( 4727, "twa")
, ( 4728, "ca")
, ( 4729, "cu")
, ( 4730, "ci")
, ( 4731, "caa")
, ( 4732, "cee")
, ( 4733, "ce")
, ( 4734, "co")
, ( 4735, "cwa")
, ( 4736, "xa")
, ( 4737, "xu")
, ( 4738, "xi")
, ( 4739, "xaa")
, ( 4740, "xee")
, ( 4741, "xe")
, ( 4742, "xo")
, ( 4743, "[?]")
, ( 4744, "xwa")
, ( 4745, "[?]")
, ( 4746, "xwi")
, ( 4747, "xwaa")
, ( 4748, "xwee")
, ( 4749, "xwe")
, ( 4750, "[?]")
, ( 4751, "[?]")
, ( 4752, "na")
, ( 4753, "nu")
, ( 4754, "ni")
, ( 4755, "naa")
, ( 4756, "nee")
, ( 4757, "ne")
, ( 4758, "no")
, ( 4759, "nwa")
, ( 4760, "nya")
, ( 4761, "nyu")
, ( 4762, "nyi")
, ( 4763, "nyaa")
, ( 4764, "nyee")
, ( 4765, "nye")
, ( 4766, "nyo")
, ( 4767, "nywa")
, ( 4768, "'a")
, ( 4769, "'u")
, ( 4770, "[?]")
, ( 4771, "'aa")
, ( 4772, "'ee")
, ( 4773, "'e")
, ( 4774, "'o")
, ( 4775, "'wa")
, ( 4776, "ka")
, ( 4777, "ku")
, ( 4778, "ki")
, ( 4779, "kaa")
, ( 4780, "kee")
, ( 4781, "ke")
, ( 4782, "ko")
, ( 4783, "[?]")
, ( 4784, "kwa")
, ( 4785, "[?]")
, ( 4786, "kwi")
, ( 4787, "kwaa")
, ( 4788, "kwee")
, ( 4789, "kwe")
, ( 4790, "[?]")
, ( 4791, "[?]")
, ( 4792, "kxa")
, ( 4793, "kxu")
, ( 4794, "kxi")
, ( 4795, "kxaa")
, ( 4796, "kxee")
, ( 4797, "kxe")
, ( 4798, "kxo")
, ( 4799, "[?]")
, ( 4800, "kxwa")
, ( 4801, "[?]")
, ( 4802, "kxwi")
, ( 4803, "kxwaa")
, ( 4804, "kxwee")
, ( 4805, "kxwe")
, ( 4806, "[?]")
, ( 4807, "[?]")
, ( 4808, "wa")
, ( 4809, "wu")
, ( 4810, "wi")
, ( 4811, "waa")
, ( 4812, "wee")
, ( 4813, "we")
, ( 4814, "wo")
, ( 4815, "[?]")
, ( 4816, "`a")
, ( 4817, "`u")
, ( 4818, "`i")
, ( 4819, "`aa")
, ( 4820, "`ee")
, ( 4821, "`e")
, ( 4822, "`o")
, ( 4823, "[?]")
, ( 4824, "za")
, ( 4825, "zu")
, ( 4826, "zi")
, ( 4827, "zaa")
, ( 4828, "zee")
, ( 4829, "ze")
, ( 4830, "zo")
, ( 4831, "zwa")
, ( 4832, "zha")
, ( 4833, "zhu")
, ( 4834, "zhi")
, ( 4835, "zhaa")
, ( 4836, "zhee")
, ( 4837, "zhe")
, ( 4838, "zho")
, ( 4839, "zhwa")
, ( 4840, "ya")
, ( 4841, "yu")
, ( 4842, "yi")
, ( 4843, "yaa")
, ( 4844, "yee")
, ( 4845, "ye")
, ( 4846, "yo")
, ( 4847, "[?]")
, ( 4848, "da")
, ( 4849, "du")
, ( 4850, "di")
, ( 4851, "daa")
, ( 4852, "dee")
, ( 4853, "de")
, ( 4854, "do")
, ( 4855, "dwa")
, ( 4856, "dda")
, ( 4857, "ddu")
, ( 4858, "ddi")
, ( 4859, "ddaa")
, ( 4860, "ddee")
, ( 4861, "dde")
, ( 4862, "ddo")
, ( 4863, "ddwa")
, ( 4864, "ja")
, ( 4865, "ju")
, ( 4866, "ji")
, ( 4867, "jaa")
, ( 4868, "jee")
, ( 4869, "je")
, ( 4870, "jo")
, ( 4871, "jwa")
, ( 4872, "ga")
, ( 4873, "gu")
, ( 4874, "gi")
, ( 4875, "gaa")
, ( 4876, "gee")
, ( 4877, "ge")
, ( 4878, "go")
, ( 4879, "[?]")
, ( 4880, "gwa")
, ( 4881, "[?]")
, ( 4882, "gwi")
, ( 4883, "gwaa")
, ( 4884, "gwee")
, ( 4885, "gwe")
, ( 4886, "[?]")
, ( 4887, "[?]")
, ( 4888, "gga")
, ( 4889, "ggu")
, ( 4890, "ggi")
, ( 4891, "ggaa")
, ( 4892, "ggee")
, ( 4893, "gge")
, ( 4894, "ggo")
, ( 4895, "[?]")
, ( 4896, "tha")
, ( 4897, "thu")
, ( 4898, "thi")
, ( 4899, "thaa")
, ( 4900, "thee")
, ( 4901, "the")
, ( 4902, "tho")
, ( 4903, "thwa")
, ( 4904, "cha")
, ( 4905, "chu")
, ( 4906, "chi")
, ( 4907, "chaa")
, ( 4908, "chee")
, ( 4909, "che")
, ( 4910, "cho")
, ( 4911, "chwa")
, ( 4912, "pha")
, ( 4913, "phu")
, ( 4914, "phi")
, ( 4915, "phaa")
, ( 4916, "phee")
, ( 4917, "phe")
, ( 4918, "pho")
, ( 4919, "phwa")
, ( 4920, "tsa")
, ( 4921, "tsu")
, ( 4922, "tsi")
, ( 4923, "tsaa")
, ( 4924, "tsee")
, ( 4925, "tse")
, ( 4926, "tso")
, ( 4927, "tswa")
, ( 4928, "tza")
, ( 4929, "tzu")
, ( 4930, "tzi")
, ( 4931, "tzaa")
, ( 4932, "tzee")
, ( 4933, "tze")
, ( 4934, "tzo")
, ( 4935, "[?]")
, ( 4936, "fa")
, ( 4937, "fu")
, ( 4938, "fi")
, ( 4939, "faa")
, ( 4940, "fee")
, ( 4941, "fe")
, ( 4942, "fo")
, ( 4943, "fwa")
, ( 4944, "pa")
, ( 4945, "pu")
, ( 4946, "pi")
, ( 4947, "paa")
, ( 4948, "pee")
, ( 4949, "pe")
, ( 4950, "po")
, ( 4951, "pwa")
, ( 4952, "rya")
, ( 4953, "mya")
, ( 4954, "fya")
, ( 4955, "[?]")
, ( 4956, "[?]")
, ( 4957, "[?]")
, ( 4958, "[?]")
, ( 4959, "[?]")
, ( 4960, "[?]")
, ( 4961, " ")
, ( 4962, ".")
, ( 4963, ",")
, ( 4964, ";")
, ( 4965, ":")
, ( 4966, ":: ")
, ( 4967, "?")
, ( 4968, "//")
, ( 4969, "1")
, ( 4970, "2")
, ( 4971, "3")
, ( 4972, "4")
, ( 4973, "5")
, ( 4974, "6")
, ( 4975, "7")
, ( 4976, "8")
, ( 4977, "9")
, ( 4978, "10+")
, ( 4979, "20+")
, ( 4980, "30+")
, ( 4981, "40+")
, ( 4982, "50+")
, ( 4983, "60+")
, ( 4984, "70+")
, ( 4985, "80+")
, ( 4986, "90+")
, ( 4987, "100+")
, ( 4988, "10,000+")
, ( 4989, "[?]")
, ( 4990, "[?]")
, ( 4991, "[?]")
, ( 4992, "[?]")
, ( 4993, "[?]")
, ( 4994, "[?]")
, ( 4995, "[?]")
, ( 4996, "[?]")
, ( 4997, "[?]")
, ( 4998, "[?]")
, ( 4999, "[?]")
, ( 5000, "[?]")
, ( 5001, "[?]")
, ( 5002, "[?]")
, ( 5003, "[?]")
, ( 5004, "[?]")
, ( 5005, "[?]")
, ( 5006, "[?]")
, ( 5007, "[?]")
, ( 5008, "[?]")
, ( 5009, "[?]")
, ( 5010, "[?]")
, ( 5011, "[?]")
, ( 5012, "[?]")
, ( 5013, "[?]")
, ( 5014, "[?]")
, ( 5015, "[?]")
, ( 5016, "[?]")
, ( 5017, "[?]")
, ( 5018, "[?]")
, ( 5019, "[?]")
, ( 5020, "[?]")
, ( 5021, "[?]")
, ( 5022, "[?]")
, ( 5023, "[?]")
, ( 5024, "a")
, ( 5025, "e")
, ( 5026, "i")
, ( 5027, "o")
, ( 5028, "u")
, ( 5029, "v")
, ( 5030, "ga")
, ( 5031, "ka")
, ( 5032, "ge")
, ( 5033, "gi")
, ( 5034, "go")
, ( 5035, "gu")
, ( 5036, "gv")
, ( 5037, "ha")
, ( 5038, "he")
, ( 5039, "hi")
, ( 5040, "ho")
, ( 5041, "hu")
, ( 5042, "hv")
, ( 5043, "la")
, ( 5044, "le")
, ( 5045, "li")
, ( 5046, "lo")
, ( 5047, "lu")
, ( 5048, "lv")
, ( 5049, "ma")
, ( 5050, "me")
, ( 5051, "mi")
, ( 5052, "mo")
, ( 5053, "mu")
, ( 5054, "na")
, ( 5055, "hna")
, ( 5056, "nah")
, ( 5057, "ne")
, ( 5058, "ni")
, ( 5059, "no")
, ( 5060, "nu")
, ( 5061, "nv")
, ( 5062, "qua")
, ( 5063, "que")
, ( 5064, "qui")
, ( 5065, "quo")
, ( 5066, "quu")
, ( 5067, "quv")
, ( 5068, "sa")
, ( 5069, "s")
, ( 5070, "se")
, ( 5071, "si")
, ( 5072, "so")
, ( 5073, "su")
, ( 5074, "sv")
, ( 5075, "da")
, ( 5076, "ta")
, ( 5077, "de")
, ( 5078, "te")
, ( 5079, "di")
, ( 5080, "ti")
, ( 5081, "do")
, ( 5082, "du")
, ( 5083, "dv")
, ( 5084, "dla")
, ( 5085, "tla")
, ( 5086, "tle")
, ( 5087, "tli")
, ( 5088, "tlo")
, ( 5089, "tlu")
, ( 5090, "tlv")
, ( 5091, "tsa")
, ( 5092, "tse")
, ( 5093, "tsi")
, ( 5094, "tso")
, ( 5095, "tsu")
, ( 5096, "tsv")
, ( 5097, "wa")
, ( 5098, "we")
, ( 5099, "wi")
, ( 5100, "wo")
, ( 5101, "wu")
, ( 5102, "wv")
, ( 5103, "ya")
, ( 5104, "ye")
, ( 5105, "yi")
, ( 5106, "yo")
, ( 5107, "yu")
, ( 5108, "yv")
, ( 5109, "[?]")
, ( 5110, "[?]")
, ( 5111, "[?]")
, ( 5112, "[?]")
, ( 5113, "[?]")
, ( 5114, "[?]")
, ( 5115, "[?]")
, ( 5116, "[?]")
, ( 5117, "[?]")
, ( 5118, "[?]")
, ( 5120, "[?]")
, ( 5121, "e")
, ( 5122, "aai")
, ( 5123, "i")
, ( 5124, "ii")
, ( 5125, "o")
, ( 5126, "oo")
, ( 5127, "oo")
, ( 5128, "ee")
, ( 5129, "i")
, ( 5130, "a")
, ( 5131, "aa")
, ( 5132, "we")
, ( 5133, "we")
, ( 5134, "wi")
, ( 5135, "wi")
, ( 5136, "wii")
, ( 5137, "wii")
, ( 5138, "wo")
, ( 5139, "wo")
, ( 5140, "woo")
, ( 5141, "woo")
, ( 5142, "woo")
, ( 5143, "wa")
, ( 5144, "wa")
, ( 5145, "waa")
, ( 5146, "waa")
, ( 5147, "waa")
, ( 5148, "ai")
, ( 5149, "w")
, ( 5150, "'")
, ( 5151, "t")
, ( 5152, "k")
, ( 5153, "sh")
, ( 5154, "s")
, ( 5155, "n")
, ( 5156, "w")
, ( 5157, "n")
, ( 5158, "[?]")
, ( 5159, "w")
, ( 5160, "c")
, ( 5161, "?")
, ( 5162, "l")
, ( 5163, "en")
, ( 5164, "in")
, ( 5165, "on")
, ( 5166, "an")
, ( 5167, "pe")
, ( 5168, "paai")
, ( 5169, "pi")
, ( 5170, "pii")
, ( 5171, "po")
, ( 5172, "poo")
, ( 5173, "poo")
, ( 5174, "hee")
, ( 5175, "hi")
, ( 5176, "pa")
, ( 5177, "paa")
, ( 5178, "pwe")
, ( 5179, "pwe")
, ( 5180, "pwi")
, ( 5181, "pwi")
, ( 5182, "pwii")
, ( 5183, "pwii")
, ( 5184, "pwo")
, ( 5185, "pwo")
, ( 5186, "pwoo")
, ( 5187, "pwoo")
, ( 5188, "pwa")
, ( 5189, "pwa")
, ( 5190, "pwaa")
, ( 5191, "pwaa")
, ( 5192, "pwaa")
, ( 5193, "p")
, ( 5194, "p")
, ( 5195, "h")
, ( 5196, "te")
, ( 5197, "taai")
, ( 5198, "ti")
, ( 5199, "tii")
, ( 5200, "to")
, ( 5201, "too")
, ( 5202, "too")
, ( 5203, "dee")
, ( 5204, "di")
, ( 5205, "ta")
, ( 5206, "taa")
, ( 5207, "twe")
, ( 5208, "twe")
, ( 5209, "twi")
, ( 5210, "twi")
, ( 5211, "twii")
, ( 5212, "twii")
, ( 5213, "two")
, ( 5214, "two")
, ( 5215, "twoo")
, ( 5216, "twoo")
, ( 5217, "twa")
, ( 5218, "twa")
, ( 5219, "twaa")
, ( 5220, "twaa")
, ( 5221, "twaa")
, ( 5222, "t")
, ( 5223, "tte")
, ( 5224, "tti")
, ( 5225, "tto")
, ( 5226, "tta")
, ( 5227, "ke")
, ( 5228, "kaai")
, ( 5229, "ki")
, ( 5230, "kii")
, ( 5231, "ko")
, ( 5232, "koo")
, ( 5233, "koo")
, ( 5234, "ka")
, ( 5235, "kaa")
, ( 5236, "kwe")
, ( 5237, "kwe")
, ( 5238, "kwi")
, ( 5239, "kwi")
, ( 5240, "kwii")
, ( 5241, "kwii")
, ( 5242, "kwo")
, ( 5243, "kwo")
, ( 5244, "kwoo")
, ( 5245, "kwoo")
, ( 5246, "kwa")
, ( 5247, "kwa")
, ( 5248, "kwaa")
, ( 5249, "kwaa")
, ( 5250, "kwaa")
, ( 5251, "k")
, ( 5252, "kw")
, ( 5253, "keh")
, ( 5254, "kih")
, ( 5255, "koh")
, ( 5256, "kah")
, ( 5257, "ce")
, ( 5258, "caai")
, ( 5259, "ci")
, ( 5260, "cii")
, ( 5261, "co")
, ( 5262, "coo")
, ( 5263, "coo")
, ( 5264, "ca")
, ( 5265, "caa")
, ( 5266, "cwe")
, ( 5267, "cwe")
, ( 5268, "cwi")
, ( 5269, "cwi")
, ( 5270, "cwii")
, ( 5271, "cwii")
, ( 5272, "cwo")
, ( 5273, "cwo")
, ( 5274, "cwoo")
, ( 5275, "cwoo")
, ( 5276, "cwa")
, ( 5277, "cwa")
, ( 5278, "cwaa")
, ( 5279, "cwaa")
, ( 5280, "cwaa")
, ( 5281, "c")
, ( 5282, "th")
, ( 5283, "me")
, ( 5284, "maai")
, ( 5285, "mi")
, ( 5286, "mii")
, ( 5287, "mo")
, ( 5288, "moo")
, ( 5289, "moo")
, ( 5290, "ma")
, ( 5291, "maa")
, ( 5292, "mwe")
, ( 5293, "mwe")
, ( 5294, "mwi")
, ( 5295, "mwi")
, ( 5296, "mwii")
, ( 5297, "mwii")
, ( 5298, "mwo")
, ( 5299, "mwo")
, ( 5300, "mwoo")
, ( 5301, "mwoo")
, ( 5302, "mwa")
, ( 5303, "mwa")
, ( 5304, "mwaa")
, ( 5305, "mwaa")
, ( 5306, "mwaa")
, ( 5307, "m")
, ( 5308, "m")
, ( 5309, "mh")
, ( 5310, "m")
, ( 5311, "m")
, ( 5312, "ne")
, ( 5313, "naai")
, ( 5314, "ni")
, ( 5315, "nii")
, ( 5316, "no")
, ( 5317, "noo")
, ( 5318, "noo")
, ( 5319, "na")
, ( 5320, "naa")
, ( 5321, "nwe")
, ( 5322, "nwe")
, ( 5323, "nwa")
, ( 5324, "nwa")
, ( 5325, "nwaa")
, ( 5326, "nwaa")
, ( 5327, "nwaa")
, ( 5328, "n")
, ( 5329, "ng")
, ( 5330, "nh")
, ( 5331, "le")
, ( 5332, "laai")
, ( 5333, "li")
, ( 5334, "lii")
, ( 5335, "lo")
, ( 5336, "loo")
, ( 5337, "loo")
, ( 5338, "la")
, ( 5339, "laa")
, ( 5340, "lwe")
, ( 5341, "lwe")
, ( 5342, "lwi")
, ( 5343, "lwi")
, ( 5344, "lwii")
, ( 5345, "lwii")
, ( 5346, "lwo")
, ( 5347, "lwo")
, ( 5348, "lwoo")
, ( 5349, "lwoo")
, ( 5350, "lwa")
, ( 5351, "lwa")
, ( 5352, "lwaa")
, ( 5353, "lwaa")
, ( 5354, "l")
, ( 5355, "l")
, ( 5356, "l")
, ( 5357, "se")
, ( 5358, "saai")
, ( 5359, "si")
, ( 5360, "sii")
, ( 5361, "so")
, ( 5362, "soo")
, ( 5363, "soo")
, ( 5364, "sa")
, ( 5365, "saa")
, ( 5366, "swe")
, ( 5367, "swe")
, ( 5368, "swi")
, ( 5369, "swi")
, ( 5370, "swii")
, ( 5371, "swii")
, ( 5372, "swo")
, ( 5373, "swo")
, ( 5374, "swoo")
, ( 5375, "swoo")
, ( 5376, "swa")
, ( 5377, "swa")
, ( 5378, "swaa")
, ( 5379, "swaa")
, ( 5380, "swaa")
, ( 5381, "s")
, ( 5382, "s")
, ( 5383, "sw")
, ( 5384, "s")
, ( 5385, "sk")
, ( 5386, "skw")
, ( 5387, "sW")
, ( 5388, "spwa")
, ( 5389, "stwa")
, ( 5390, "skwa")
, ( 5391, "scwa")
, ( 5392, "she")
, ( 5393, "shi")
, ( 5394, "shii")
, ( 5395, "sho")
, ( 5396, "shoo")
, ( 5397, "sha")
, ( 5398, "shaa")
, ( 5399, "shwe")
, ( 5400, "shwe")
, ( 5401, "shwi")
, ( 5402, "shwi")
, ( 5403, "shwii")
, ( 5404, "shwii")
, ( 5405, "shwo")
, ( 5406, "shwo")
, ( 5407, "shwoo")
, ( 5408, "shwoo")
, ( 5409, "shwa")
, ( 5410, "shwa")
, ( 5411, "shwaa")
, ( 5412, "shwaa")
, ( 5413, "sh")
, ( 5414, "ye")
, ( 5415, "yaai")
, ( 5416, "yi")
, ( 5417, "yii")
, ( 5418, "yo")
, ( 5419, "yoo")
, ( 5420, "yoo")
, ( 5421, "ya")
, ( 5422, "yaa")
, ( 5423, "ywe")
, ( 5424, "ywe")
, ( 5425, "ywi")
, ( 5426, "ywi")
, ( 5427, "ywii")
, ( 5428, "ywii")
, ( 5429, "ywo")
, ( 5430, "ywo")
, ( 5431, "ywoo")
, ( 5432, "ywoo")
, ( 5433, "ywa")
, ( 5434, "ywa")
, ( 5435, "ywaa")
, ( 5436, "ywaa")
, ( 5437, "ywaa")
, ( 5438, "y")
, ( 5439, "y")
, ( 5440, "y")
, ( 5441, "yi")
, ( 5442, "re")
, ( 5443, "re")
, ( 5444, "le")
, ( 5445, "raai")
, ( 5446, "ri")
, ( 5447, "rii")
, ( 5448, "ro")
, ( 5449, "roo")
, ( 5450, "lo")
, ( 5451, "ra")
, ( 5452, "raa")
, ( 5453, "la")
, ( 5454, "rwaa")
, ( 5455, "rwaa")
, ( 5456, "r")
, ( 5457, "r")
, ( 5458, "r")
, ( 5459, "fe")
, ( 5460, "faai")
, ( 5461, "fi")
, ( 5462, "fii")
, ( 5463, "fo")
, ( 5464, "foo")
, ( 5465, "fa")
, ( 5466, "faa")
, ( 5467, "fwaa")
, ( 5468, "fwaa")
, ( 5469, "f")
, ( 5470, "the")
, ( 5471, "the")
, ( 5472, "thi")
, ( 5473, "thi")
, ( 5474, "thii")
, ( 5475, "thii")
, ( 5476, "tho")
, ( 5477, "thoo")
, ( 5478, "tha")
, ( 5479, "thaa")
, ( 5480, "thwaa")
, ( 5481, "thwaa")
, ( 5482, "th")
, ( 5483, "tthe")
, ( 5484, "tthi")
, ( 5485, "ttho")
, ( 5486, "ttha")
, ( 5487, "tth")
, ( 5488, "tye")
, ( 5489, "tyi")
, ( 5490, "tyo")
, ( 5491, "tya")
, ( 5492, "he")
, ( 5493, "hi")
, ( 5494, "hii")
, ( 5495, "ho")
, ( 5496, "hoo")
, ( 5497, "ha")
, ( 5498, "haa")
, ( 5499, "h")
, ( 5500, "h")
, ( 5501, "hk")
, ( 5502, "qaai")
, ( 5503, "qi")
, ( 5504, "qii")
, ( 5505, "qo")
, ( 5506, "qoo")
, ( 5507, "qa")
, ( 5508, "qaa")
, ( 5509, "q")
, ( 5510, "tlhe")
, ( 5511, "tlhi")
, ( 5512, "tlho")
, ( 5513, "tlha")
, ( 5514, "re")
, ( 5515, "ri")
, ( 5516, "ro")
, ( 5517, "ra")
, ( 5518, "ngaai")
, ( 5519, "ngi")
, ( 5520, "ngii")
, ( 5521, "ngo")
, ( 5522, "ngoo")
, ( 5523, "nga")
, ( 5524, "ngaa")
, ( 5525, "ng")
, ( 5526, "nng")
, ( 5527, "she")
, ( 5528, "shi")
, ( 5529, "sho")
, ( 5530, "sha")
, ( 5531, "the")
, ( 5532, "thi")
, ( 5533, "tho")
, ( 5534, "tha")
, ( 5535, "th")
, ( 5536, "lhi")
, ( 5537, "lhii")
, ( 5538, "lho")
, ( 5539, "lhoo")
, ( 5540, "lha")
, ( 5541, "lhaa")
, ( 5542, "lh")
, ( 5543, "the")
, ( 5544, "thi")
, ( 5545, "thii")
, ( 5546, "tho")
, ( 5547, "thoo")
, ( 5548, "tha")
, ( 5549, "thaa")
, ( 5550, "th")
, ( 5551, "b")
, ( 5552, "e")
, ( 5553, "i")
, ( 5554, "o")
, ( 5555, "a")
, ( 5556, "we")
, ( 5557, "wi")
, ( 5558, "wo")
, ( 5559, "wa")
, ( 5560, "ne")
, ( 5561, "ni")
, ( 5562, "no")
, ( 5563, "na")
, ( 5564, "ke")
, ( 5565, "ki")
, ( 5566, "ko")
, ( 5567, "ka")
, ( 5568, "he")
, ( 5569, "hi")
, ( 5570, "ho")
, ( 5571, "ha")
, ( 5572, "ghu")
, ( 5573, "gho")
, ( 5574, "ghe")
, ( 5575, "ghee")
, ( 5576, "ghi")
, ( 5577, "gha")
, ( 5578, "ru")
, ( 5579, "ro")
, ( 5580, "re")
, ( 5581, "ree")
, ( 5582, "ri")
, ( 5583, "ra")
, ( 5584, "wu")
, ( 5585, "wo")
, ( 5586, "we")
, ( 5587, "wee")
, ( 5588, "wi")
, ( 5589, "wa")
, ( 5590, "hwu")
, ( 5591, "hwo")
, ( 5592, "hwe")
, ( 5593, "hwee")
, ( 5594, "hwi")
, ( 5595, "hwa")
, ( 5596, "thu")
, ( 5597, "tho")
, ( 5598, "the")
, ( 5599, "thee")
, ( 5600, "thi")
, ( 5601, "tha")
, ( 5602, "ttu")
, ( 5603, "tto")
, ( 5604, "tte")
, ( 5605, "ttee")
, ( 5606, "tti")
, ( 5607, "tta")
, ( 5608, "pu")
, ( 5609, "po")
, ( 5610, "pe")
, ( 5611, "pee")
, ( 5612, "pi")
, ( 5613, "pa")
, ( 5614, "p")
, ( 5615, "gu")
, ( 5616, "go")
, ( 5617, "ge")
, ( 5618, "gee")
, ( 5619, "gi")
, ( 5620, "ga")
, ( 5621, "khu")
, ( 5622, "kho")
, ( 5623, "khe")
, ( 5624, "khee")
, ( 5625, "khi")
, ( 5626, "kha")
, ( 5627, "kku")
, ( 5628, "kko")
, ( 5629, "kke")
, ( 5630, "kkee")
, ( 5631, "kki")
, ( 5632, "kka")
, ( 5633, "kk")
, ( 5634, "nu")
, ( 5635, "no")
, ( 5636, "ne")
, ( 5637, "nee")
, ( 5638, "ni")
, ( 5639, "na")
, ( 5640, "mu")
, ( 5641, "mo")
, ( 5642, "me")
, ( 5643, "mee")
, ( 5644, "mi")
, ( 5645, "ma")
, ( 5646, "yu")
, ( 5647, "yo")
, ( 5648, "ye")
, ( 5649, "yee")
, ( 5650, "yi")
, ( 5651, "ya")
, ( 5652, "ju")
, ( 5653, "ju")
, ( 5654, "jo")
, ( 5655, "je")
, ( 5656, "jee")
, ( 5657, "ji")
, ( 5658, "ji")
, ( 5659, "ja")
, ( 5660, "jju")
, ( 5661, "jjo")
, ( 5662, "jje")
, ( 5663, "jjee")
, ( 5664, "jji")
, ( 5665, "jja")
, ( 5666, "lu")
, ( 5667, "lo")
, ( 5668, "le")
, ( 5669, "lee")
, ( 5670, "li")
, ( 5671, "la")
, ( 5672, "dlu")
, ( 5673, "dlo")
, ( 5674, "dle")
, ( 5675, "dlee")
, ( 5676, "dli")
, ( 5677, "dla")
, ( 5678, "lhu")
, ( 5679, "lho")
, ( 5680, "lhe")
, ( 5681, "lhee")
, ( 5682, "lhi")
, ( 5683, "lha")
, ( 5684, "tlhu")
, ( 5685, "tlho")
, ( 5686, "tlhe")
, ( 5687, "tlhee")
, ( 5688, "tlhi")
, ( 5689, "tlha")
, ( 5690, "tlu")
, ( 5691, "tlo")
, ( 5692, "tle")
, ( 5693, "tlee")
, ( 5694, "tli")
, ( 5695, "tla")
, ( 5696, "zu")
, ( 5697, "zo")
, ( 5698, "ze")
, ( 5699, "zee")
, ( 5700, "zi")
, ( 5701, "za")
, ( 5702, "z")
, ( 5703, "z")
, ( 5704, "dzu")
, ( 5705, "dzo")
, ( 5706, "dze")
, ( 5707, "dzee")
, ( 5708, "dzi")
, ( 5709, "dza")
, ( 5710, "su")
, ( 5711, "so")
, ( 5712, "se")
, ( 5713, "see")
, ( 5714, "si")
, ( 5715, "sa")
, ( 5716, "shu")
, ( 5717, "sho")
, ( 5718, "she")
, ( 5719, "shee")
, ( 5720, "shi")
, ( 5721, "sha")
, ( 5722, "sh")
, ( 5723, "tsu")
, ( 5724, "tso")
, ( 5725, "tse")
, ( 5726, "tsee")
, ( 5727, "tsi")
, ( 5728, "tsa")
, ( 5729, "chu")
, ( 5730, "cho")
, ( 5731, "che")
, ( 5732, "chee")
, ( 5733, "chi")
, ( 5734, "cha")
, ( 5735, "ttsu")
, ( 5736, "ttso")
, ( 5737, "ttse")
, ( 5738, "ttsee")
, ( 5739, "ttsi")
, ( 5740, "ttsa")
, ( 5741, "X")
, ( 5742, ".")
, ( 5743, "qai")
, ( 5744, "ngai")
, ( 5745, "nngi")
, ( 5746, "nngii")
, ( 5747, "nngo")
, ( 5748, "nngoo")
, ( 5749, "nnga")
, ( 5750, "nngaa")
, ( 5751, "[?]")
, ( 5752, "[?]")
, ( 5753, "[?]")
, ( 5754, "[?]")
, ( 5755, "[?]")
, ( 5756, "[?]")
, ( 5757, "[?]")
, ( 5758, "[?]")
, ( 5759, "[?]")
, ( 5760, " ")
, ( 5761, "b")
, ( 5762, "l")
, ( 5763, "f")
, ( 5764, "s")
, ( 5765, "n")
, ( 5766, "h")
, ( 5767, "d")
, ( 5768, "t")
, ( 5769, "c")
, ( 5770, "q")
, ( 5771, "m")
, ( 5772, "g")
, ( 5773, "ng")
, ( 5774, "z")
, ( 5775, "r")
, ( 5776, "a")
, ( 5777, "o")
, ( 5778, "u")
, ( 5779, "e")
, ( 5780, "i")
, ( 5781, "ch")
, ( 5782, "th")
, ( 5783, "ph")
, ( 5784, "p")
, ( 5785, "x")
, ( 5786, "p")
, ( 5787, "<")
, ( 5788, ">")
, ( 5789, "[?]")
, ( 5790, "[?]")
, ( 5791, "[?]")
, ( 5792, "f")
, ( 5793, "v")
, ( 5794, "u")
, ( 5795, "yr")
, ( 5796, "y")
, ( 5797, "w")
, ( 5798, "th")
, ( 5799, "th")
, ( 5800, "a")
, ( 5801, "o")
, ( 5802, "ac")
, ( 5803, "ae")
, ( 5804, "o")
, ( 5805, "o")
, ( 5806, "o")
, ( 5807, "oe")
, ( 5808, "on")
, ( 5809, "r")
, ( 5810, "k")
, ( 5811, "c")
, ( 5812, "k")
, ( 5813, "g")
, ( 5814, "ng")
, ( 5815, "g")
, ( 5816, "g")
, ( 5817, "w")
, ( 5818, "h")
, ( 5819, "h")
, ( 5820, "h")
, ( 5821, "h")
, ( 5822, "n")
, ( 5823, "n")
, ( 5824, "n")
, ( 5825, "i")
, ( 5826, "e")
, ( 5827, "j")
, ( 5828, "g")
, ( 5829, "ae")
, ( 5830, "a")
, ( 5831, "eo")
, ( 5832, "p")
, ( 5833, "z")
, ( 5834, "s")
, ( 5835, "s")
, ( 5836, "s")
, ( 5837, "c")
, ( 5838, "z")
, ( 5839, "t")
, ( 5840, "t")
, ( 5841, "d")
, ( 5842, "b")
, ( 5843, "b")
, ( 5844, "p")
, ( 5845, "p")
, ( 5846, "e")
, ( 5847, "m")
, ( 5848, "m")
, ( 5849, "m")
, ( 5850, "l")
, ( 5851, "l")
, ( 5852, "ng")
, ( 5853, "ng")
, ( 5854, "d")
, ( 5855, "o")
, ( 5856, "ear")
, ( 5857, "ior")
, ( 5858, "qu")
, ( 5859, "qu")
, ( 5860, "qu")
, ( 5861, "s")
, ( 5862, "yr")
, ( 5863, "yr")
, ( 5864, "yr")
, ( 5865, "q")
, ( 5866, "x")
, ( 5867, ".")
, ( 5868, ":")
, ( 5869, "+")
, ( 5870, "17")
, ( 5871, "18")
, ( 5872, "19")
, ( 5873, "[?]")
, ( 5874, "[?]")
, ( 5875, "[?]")
, ( 5876, "[?]")
, ( 5877, "[?]")
, ( 5878, "[?]")
, ( 5879, "[?]")
, ( 5880, "[?]")
, ( 5881, "[?]")
, ( 5882, "[?]")
, ( 5883, "[?]")
, ( 5884, "[?]")
, ( 5885, "[?]")
, ( 5886, "[?]")
, ( 5888, "[?]")
, ( 5889, "[?]")
, ( 5890, "[?]")
, ( 5891, "[?]")
, ( 5892, "[?]")
, ( 5893, "[?]")
, ( 5894, "[?]")
, ( 5895, "[?]")
, ( 5896, "[?]")
, ( 5897, "[?]")
, ( 5898, "[?]")
, ( 5899, "[?]")
, ( 5900, "[?]")
, ( 5901, "[?]")
, ( 5902, "[?]")
, ( 5903, "[?]")
, ( 5904, "[?]")
, ( 5905, "[?]")
, ( 5906, "[?]")
, ( 5907, "[?]")
, ( 5908, "[?]")
, ( 5909, "[?]")
, ( 5910, "[?]")
, ( 5911, "[?]")
, ( 5912, "[?]")
, ( 5913, "[?]")
, ( 5914, "[?]")
, ( 5915, "[?]")
, ( 5916, "[?]")
, ( 5917, "[?]")
, ( 5918, "[?]")
, ( 5919, "[?]")
, ( 5920, "[?]")
, ( 5921, "[?]")
, ( 5922, "[?]")
, ( 5923, "[?]")
, ( 5924, "[?]")
, ( 5925, "[?]")
, ( 5926, "[?]")
, ( 5927, "[?]")
, ( 5928, "[?]")
, ( 5929, "[?]")
, ( 5930, "[?]")
, ( 5931, "[?]")
, ( 5932, "[?]")
, ( 5933, "[?]")
, ( 5934, "[?]")
, ( 5935, "[?]")
, ( 5936, "[?]")
, ( 5937, "[?]")
, ( 5938, "[?]")
, ( 5939, "[?]")
, ( 5940, "[?]")
, ( 5941, "[?]")
, ( 5942, "[?]")
, ( 5943, "[?]")
, ( 5944, "[?]")
, ( 5945, "[?]")
, ( 5946, "[?]")
, ( 5947, "[?]")
, ( 5948, "[?]")
, ( 5949, "[?]")
, ( 5950, "[?]")
, ( 5951, "[?]")
, ( 5952, "[?]")
, ( 5953, "[?]")
, ( 5954, "[?]")
, ( 5955, "[?]")
, ( 5956, "[?]")
, ( 5957, "[?]")
, ( 5958, "[?]")
, ( 5959, "[?]")
, ( 5960, "[?]")
, ( 5961, "[?]")
, ( 5962, "[?]")
, ( 5963, "[?]")
, ( 5964, "[?]")
, ( 5965, "[?]")
, ( 5966, "[?]")
, ( 5967, "[?]")
, ( 5968, "[?]")
, ( 5969, "[?]")
, ( 5970, "[?]")
, ( 5971, "[?]")
, ( 5972, "[?]")
, ( 5973, "[?]")
, ( 5974, "[?]")
, ( 5975, "[?]")
, ( 5976, "[?]")
, ( 5977, "[?]")
, ( 5978, "[?]")
, ( 5979, "[?]")
, ( 5980, "[?]")
, ( 5981, "[?]")
, ( 5982, "[?]")
, ( 5983, "[?]")
, ( 5984, "[?]")
, ( 5985, "[?]")
, ( 5986, "[?]")
, ( 5987, "[?]")
, ( 5988, "[?]")
, ( 5989, "[?]")
, ( 5990, "[?]")
, ( 5991, "[?]")
, ( 5992, "[?]")
, ( 5993, "[?]")
, ( 5994, "[?]")
, ( 5995, "[?]")
, ( 5996, "[?]")
, ( 5997, "[?]")
, ( 5998, "[?]")
, ( 5999, "[?]")
, ( 6000, "[?]")
, ( 6001, "[?]")
, ( 6002, "[?]")
, ( 6003, "[?]")
, ( 6004, "[?]")
, ( 6005, "[?]")
, ( 6006, "[?]")
, ( 6007, "[?]")
, ( 6008, "[?]")
, ( 6009, "[?]")
, ( 6010, "[?]")
, ( 6011, "[?]")
, ( 6012, "[?]")
, ( 6013, "[?]")
, ( 6014, "[?]")
, ( 6015, "[?]")
, ( 6016, "k")
, ( 6017, "kh")
, ( 6018, "g")
, ( 6019, "gh")
, ( 6020, "ng")
, ( 6021, "c")
, ( 6022, "ch")
, ( 6023, "j")
, ( 6024, "jh")
, ( 6025, "ny")
, ( 6026, "t")
, ( 6027, "tth")
, ( 6028, "d")
, ( 6029, "ddh")
, ( 6030, "nn")
, ( 6031, "t")
, ( 6032, "th")
, ( 6033, "d")
, ( 6034, "dh")
, ( 6035, "n")
, ( 6036, "p")
, ( 6037, "ph")
, ( 6038, "b")
, ( 6039, "bh")
, ( 6040, "m")
, ( 6041, "y")
, ( 6042, "r")
, ( 6043, "l")
, ( 6044, "v")
, ( 6045, "sh")
, ( 6046, "ss")
, ( 6047, "s")
, ( 6048, "h")
, ( 6049, "l")
, ( 6050, "q")
, ( 6051, "a")
, ( 6052, "aa")
, ( 6053, "i")
, ( 6054, "ii")
, ( 6055, "u")
, ( 6056, "uk")
, ( 6057, "uu")
, ( 6058, "uuv")
, ( 6059, "ry")
, ( 6060, "ryy")
, ( 6061, "ly")
, ( 6062, "lyy")
, ( 6063, "e")
, ( 6064, "ai")
, ( 6065, "oo")
, ( 6066, "oo")
, ( 6067, "au")
, ( 6068, "a")
, ( 6069, "aa")
, ( 6070, "aa")
, ( 6071, "i")
, ( 6072, "ii")
, ( 6073, "y")
, ( 6074, "yy")
, ( 6075, "u")
, ( 6076, "uu")
, ( 6077, "ua")
, ( 6078, "oe")
, ( 6079, "ya")
, ( 6080, "ie")
, ( 6081, "e")
, ( 6082, "ae")
, ( 6083, "ai")
, ( 6084, "oo")
, ( 6085, "au")
, ( 6086, "M")
, ( 6087, "H")
, ( 6088, "a`")
, ( 6092, "r")
, ( 6094, "!")
, ( 6100, ".")
, ( 6101, " // ")
, ( 6102, ":")
, ( 6103, "+")
, ( 6104, "++")
, ( 6105, " * ")
, ( 6106, " /// ")
, ( 6107, "KR")
, ( 6108, "'")
, ( 6109, "[?]")
, ( 6110, "[?]")
, ( 6111, "[?]")
, ( 6112, "0")
, ( 6113, "1")
, ( 6114, "2")
, ( 6115, "3")
, ( 6116, "4")
, ( 6117, "5")
, ( 6118, "6")
, ( 6119, "7")
, ( 6120, "8")
, ( 6121, "9")
, ( 6122, "[?]")
, ( 6123, "[?]")
, ( 6124, "[?]")
, ( 6125, "[?]")
, ( 6126, "[?]")
, ( 6127, "[?]")
, ( 6128, "[?]")
, ( 6129, "[?]")
, ( 6130, "[?]")
, ( 6131, "[?]")
, ( 6132, "[?]")
, ( 6133, "[?]")
, ( 6134, "[?]")
, ( 6135, "[?]")
, ( 6136, "[?]")
, ( 6137, "[?]")
, ( 6138, "[?]")
, ( 6139, "[?]")
, ( 6140, "[?]")
, ( 6141, "[?]")
, ( 6142, "[?]")
, ( 6144, " @ ")
, ( 6145, " ... ")
, ( 6146, ", ")
, ( 6147, ". ")
, ( 6148, ": ")
, ( 6149, " // ")
, ( 6151, "-")
, ( 6152, ", ")
, ( 6153, ". ")
, ( 6159, "[?]")
, ( 6160, "0")
, ( 6161, "1")
, ( 6162, "2")
, ( 6163, "3")
, ( 6164, "4")
, ( 6165, "5")
, ( 6166, "6")
, ( 6167, "7")
, ( 6168, "8")
, ( 6169, "9")
, ( 6170, "[?]")
, ( 6171, "[?]")
, ( 6172, "[?]")
, ( 6173, "[?]")
, ( 6174, "[?]")
, ( 6175, "[?]")
, ( 6176, "a")
, ( 6177, "e")
, ( 6178, "i")
, ( 6179, "o")
, ( 6180, "u")
, ( 6181, "O")
, ( 6182, "U")
, ( 6183, "ee")
, ( 6184, "n")
, ( 6185, "ng")
, ( 6186, "b")
, ( 6187, "p")
, ( 6188, "q")
, ( 6189, "g")
, ( 6190, "m")
, ( 6191, "l")
, ( 6192, "s")
, ( 6193, "sh")
, ( 6194, "t")
, ( 6195, "d")
, ( 6196, "ch")
, ( 6197, "j")
, ( 6198, "y")
, ( 6199, "r")
, ( 6200, "w")
, ( 6201, "f")
, ( 6202, "k")
, ( 6203, "kha")
, ( 6204, "ts")
, ( 6205, "z")
, ( 6206, "h")
, ( 6207, "zr")
, ( 6208, "lh")
, ( 6209, "zh")
, ( 6210, "ch")
, ( 6211, "-")
, ( 6212, "e")
, ( 6213, "i")
, ( 6214, "o")
, ( 6215, "u")
, ( 6216, "O")
, ( 6217, "U")
, ( 6218, "ng")
, ( 6219, "b")
, ( 6220, "p")
, ( 6221, "q")
, ( 6222, "g")
, ( 6223, "m")
, ( 6224, "t")
, ( 6225, "d")
, ( 6226, "ch")
, ( 6227, "j")
, ( 6228, "ts")
, ( 6229, "y")
, ( 6230, "w")
, ( 6231, "k")
, ( 6232, "g")
, ( 6233, "h")
, ( 6234, "jy")
, ( 6235, "ny")
, ( 6236, "dz")
, ( 6237, "e")
, ( 6238, "i")
, ( 6239, "iy")
, ( 6240, "U")
, ( 6241, "u")
, ( 6242, "ng")
, ( 6243, "k")
, ( 6244, "g")
, ( 6245, "h")
, ( 6246, "p")
, ( 6247, "sh")
, ( 6248, "t")
, ( 6249, "d")
, ( 6250, "j")
, ( 6251, "f")
, ( 6252, "g")
, ( 6253, "h")
, ( 6254, "ts")
, ( 6255, "z")
, ( 6256, "r")
, ( 6257, "ch")
, ( 6258, "zh")
, ( 6259, "i")
, ( 6260, "k")
, ( 6261, "r")
, ( 6262, "f")
, ( 6263, "zh")
, ( 6264, "[?]")
, ( 6265, "[?]")
, ( 6266, "[?]")
, ( 6267, "[?]")
, ( 6268, "[?]")
, ( 6269, "[?]")
, ( 6270, "[?]")
, ( 6271, "[?]")
, ( 6272, "[?]")
, ( 6273, "H")
, ( 6274, "X")
, ( 6275, "W")
, ( 6276, "M")
, ( 6277, " 3 ")
, ( 6278, " 333 ")
, ( 6279, "a")
, ( 6280, "i")
, ( 6281, "k")
, ( 6282, "ng")
, ( 6283, "c")
, ( 6284, "tt")
, ( 6285, "tth")
, ( 6286, "dd")
, ( 6287, "nn")
, ( 6288, "t")
, ( 6289, "d")
, ( 6290, "p")
, ( 6291, "ph")
, ( 6292, "ss")
, ( 6293, "zh")
, ( 6294, "z")
, ( 6295, "a")
, ( 6296, "t")
, ( 6297, "zh")
, ( 6298, "gh")
, ( 6299, "ng")
, ( 6300, "c")
, ( 6301, "jh")
, ( 6302, "tta")
, ( 6303, "ddh")
, ( 6304, "t")
, ( 6305, "dh")
, ( 6306, "ss")
, ( 6307, "cy")
, ( 6308, "zh")
, ( 6309, "z")
, ( 6310, "u")
, ( 6311, "y")
, ( 6312, "bh")
, ( 6313, "'")
, ( 6314, "[?]")
, ( 6315, "[?]")
, ( 6316, "[?]")
, ( 6317, "[?]")
, ( 6318, "[?]")
, ( 6319, "[?]")
, ( 6320, "[?]")
, ( 6321, "[?]")
, ( 6322, "[?]")
, ( 6323, "[?]")
, ( 6324, "[?]")
, ( 6325, "[?]")
, ( 6326, "[?]")
, ( 6327, "[?]")
, ( 6328, "[?]")
, ( 6329, "[?]")
, ( 6330, "[?]")
, ( 6331, "[?]")
, ( 6332, "[?]")
, ( 6333, "[?]")
, ( 6334, "[?]")
, ( 6335, "[?]")
, ( 6336, "[?]")
, ( 6337, "[?]")
, ( 6338, "[?]")
, ( 6339, "[?]")
, ( 6340, "[?]")
, ( 6341, "[?]")
, ( 6342, "[?]")
, ( 6343, "[?]")
, ( 6344, "[?]")
, ( 6345, "[?]")
, ( 6346, "[?]")
, ( 6347, "[?]")
, ( 6348, "[?]")
, ( 6349, "[?]")
, ( 6350, "[?]")
, ( 6351, "[?]")
, ( 6352, "[?]")
, ( 6353, "[?]")
, ( 6354, "[?]")
, ( 6355, "[?]")
, ( 6356, "[?]")
, ( 6357, "[?]")
, ( 6358, "[?]")
, ( 6359, "[?]")
, ( 6360, "[?]")
, ( 6361, "[?]")
, ( 6362, "[?]")
, ( 6363, "[?]")
, ( 6364, "[?]")
, ( 6365, "[?]")
, ( 6366, "[?]")
, ( 6367, "[?]")
, ( 6368, "[?]")
, ( 6369, "[?]")
, ( 6370, "[?]")
, ( 6371, "[?]")
, ( 6372, "[?]")
, ( 6373, "[?]")
, ( 6374, "[?]")
, ( 6375, "[?]")
, ( 6376, "[?]")
, ( 6377, "[?]")
, ( 6378, "[?]")
, ( 6379, "[?]")
, ( 6380, "[?]")
, ( 6381, "[?]")
, ( 6382, "[?]")
, ( 6383, "[?]")
, ( 6384, "[?]")
, ( 6385, "[?]")
, ( 6386, "[?]")
, ( 6387, "[?]")
, ( 6388, "[?]")
, ( 6389, "[?]")
, ( 6390, "[?]")
, ( 6391, "[?]")
, ( 6392, "[?]")
, ( 6393, "[?]")
, ( 6394, "[?]")
, ( 6395, "[?]")
, ( 6396, "[?]")
, ( 6397, "[?]")
, ( 6398, "[?]")
, ( 7532, "b")
, ( 7533, "d")
, ( 7534, "f")
, ( 7535, "m")
, ( 7536, "n")
, ( 7537, "p")
, ( 7538, "r")
, ( 7539, "r")
, ( 7540, "s")
, ( 7541, "t")
, ( 7542, "z")
, ( 7543, "g")
, ( 7549, "p")
, ( 7552, "b")
, ( 7553, "d")
, ( 7554, "f")
, ( 7555, "g")
, ( 7556, "k")
, ( 7557, "l")
, ( 7558, "m")
, ( 7559, "n")
, ( 7560, "p")
, ( 7561, "r")
, ( 7562, "s")
, ( 7564, "v")
, ( 7565, "x")
, ( 7566, "z")
, ( 7680, "A")
, ( 7681, "a")
, ( 7682, "B")
, ( 7683, "b")
, ( 7684, "B")
, ( 7685, "b")
, ( 7686, "B")
, ( 7687, "b")
, ( 7688, "C")
, ( 7689, "c")
, ( 7690, "D")
, ( 7691, "d")
, ( 7692, "D")
, ( 7693, "d")
, ( 7694, "D")
, ( 7695, "d")
, ( 7696, "D")
, ( 7697, "d")
, ( 7698, "D")
, ( 7699, "d")
, ( 7700, "E")
, ( 7701, "e")
, ( 7702, "E")
, ( 7703, "e")
, ( 7704, "E")
, ( 7705, "e")
, ( 7706, "E")
, ( 7707, "e")
, ( 7708, "E")
, ( 7709, "e")
, ( 7710, "F")
, ( 7711, "f")
, ( 7712, "G")
, ( 7713, "g")
, ( 7714, "H")
, ( 7715, "h")
, ( 7716, "H")
, ( 7717, "h")
, ( 7718, "H")
, ( 7719, "h")
, ( 7720, "H")
, ( 7721, "h")
, ( 7722, "H")
, ( 7723, "h")
, ( 7724, "I")
, ( 7725, "i")
, ( 7726, "I")
, ( 7727, "i")
, ( 7728, "K")
, ( 7729, "k")
, ( 7730, "K")
, ( 7731, "k")
, ( 7732, "K")
, ( 7733, "k")
, ( 7734, "L")
, ( 7735, "l")
, ( 7736, "L")
, ( 7737, "l")
, ( 7738, "L")
, ( 7739, "l")
, ( 7740, "L")
, ( 7741, "l")
, ( 7742, "M")
, ( 7743, "m")
, ( 7744, "M")
, ( 7745, "m")
, ( 7746, "M")
, ( 7747, "m")
, ( 7748, "N")
, ( 7749, "n")
, ( 7750, "N")
, ( 7751, "n")
, ( 7752, "N")
, ( 7753, "n")
, ( 7754, "N")
, ( 7755, "n")
, ( 7756, "O")
, ( 7757, "o")
, ( 7758, "O")
, ( 7759, "o")
, ( 7760, "O")
, ( 7761, "o")
, ( 7762, "O")
, ( 7763, "o")
, ( 7764, "P")
, ( 7765, "p")
, ( 7766, "P")
, ( 7767, "p")
, ( 7768, "R")
, ( 7769, "r")
, ( 7770, "R")
, ( 7771, "r")
, ( 7772, "R")
, ( 7773, "r")
, ( 7774, "R")
, ( 7775, "r")
, ( 7776, "S")
, ( 7777, "s")
, ( 7778, "S")
, ( 7779, "s")
, ( 7780, "S")
, ( 7781, "s")
, ( 7782, "S")
, ( 7783, "s")
, ( 7784, "S")
, ( 7785, "s")
, ( 7786, "T")
, ( 7787, "t")
, ( 7788, "T")
, ( 7789, "t")
, ( 7790, "T")
, ( 7791, "t")
, ( 7792, "T")
, ( 7793, "t")
, ( 7794, "U")
, ( 7795, "u")
, ( 7796, "U")
, ( 7797, "u")
, ( 7798, "U")
, ( 7799, "u")
, ( 7800, "U")
, ( 7801, "u")
, ( 7802, "U")
, ( 7803, "u")
, ( 7804, "V")
, ( 7805, "v")
, ( 7806, "V")
, ( 7807, "v")
, ( 7808, "W")
, ( 7809, "w")
, ( 7810, "W")
, ( 7811, "w")
, ( 7812, "W")
, ( 7813, "w")
, ( 7814, "W")
, ( 7815, "w")
, ( 7816, "W")
, ( 7817, "w")
, ( 7818, "X")
, ( 7819, "x")
, ( 7820, "X")
, ( 7821, "x")
, ( 7822, "Y")
, ( 7823, "y")
, ( 7824, "Z")
, ( 7825, "z")
, ( 7826, "Z")
, ( 7827, "z")
, ( 7828, "Z")
, ( 7829, "z")
, ( 7830, "h")
, ( 7831, "t")
, ( 7832, "w")
, ( 7833, "y")
, ( 7834, "a")
, ( 7835, "S")
, ( 7836, "[?]")
, ( 7837, "[?]")
, ( 7838, "Ss")
, ( 7839, "[?]")
, ( 7840, "A")
, ( 7841, "a")
, ( 7842, "A")
, ( 7843, "a")
, ( 7844, "A")
, ( 7845, "a")
, ( 7846, "A")
, ( 7847, "a")
, ( 7848, "A")
, ( 7849, "a")
, ( 7850, "A")
, ( 7851, "a")
, ( 7852, "A")
, ( 7853, "a")
, ( 7854, "A")
, ( 7855, "a")
, ( 7856, "A")
, ( 7857, "a")
, ( 7858, "A")
, ( 7859, "a")
, ( 7860, "A")
, ( 7861, "a")
, ( 7862, "A")
, ( 7863, "a")
, ( 7864, "E")
, ( 7865, "e")
, ( 7866, "E")
, ( 7867, "e")
, ( 7868, "E")
, ( 7869, "e")
, ( 7870, "E")
, ( 7871, "e")
, ( 7872, "E")
, ( 7873, "e")
, ( 7874, "E")
, ( 7875, "e")
, ( 7876, "E")
, ( 7877, "e")
, ( 7878, "E")
, ( 7879, "e")
, ( 7880, "I")
, ( 7881, "i")
, ( 7882, "I")
, ( 7883, "i")
, ( 7884, "O")
, ( 7885, "o")
, ( 7886, "O")
, ( 7887, "o")
, ( 7888, "O")
, ( 7889, "o")
, ( 7890, "O")
, ( 7891, "o")
, ( 7892, "O")
, ( 7893, "o")
, ( 7894, "O")
, ( 7895, "o")
, ( 7896, "O")
, ( 7897, "o")
, ( 7898, "O")
, ( 7899, "o")
, ( 7900, "O")
, ( 7901, "o")
, ( 7902, "O")
, ( 7903, "o")
, ( 7904, "O")
, ( 7905, "o")
, ( 7906, "O")
, ( 7907, "o")
, ( 7908, "U")
, ( 7909, "u")
, ( 7910, "U")
, ( 7911, "u")
, ( 7912, "U")
, ( 7913, "u")
, ( 7914, "U")
, ( 7915, "u")
, ( 7916, "U")
, ( 7917, "u")
, ( 7918, "U")
, ( 7919, "u")
, ( 7920, "U")
, ( 7921, "u")
, ( 7922, "Y")
, ( 7923, "y")
, ( 7924, "Y")
, ( 7925, "y")
, ( 7926, "Y")
, ( 7927, "y")
, ( 7928, "Y")
, ( 7929, "y")
, ( 7930, "[?]")
, ( 7931, "[?]")
, ( 7932, "[?]")
, ( 7933, "[?]")
, ( 7934, "[?]")
, ( 7936, "a")
, ( 7937, "a")
, ( 7938, "a")
, ( 7939, "a")
, ( 7940, "a")
, ( 7941, "a")
, ( 7942, "a")
, ( 7943, "a")
, ( 7944, "A")
, ( 7945, "A")
, ( 7946, "A")
, ( 7947, "A")
, ( 7948, "A")
, ( 7949, "A")
, ( 7950, "A")
, ( 7951, "A")
, ( 7952, "e")
, ( 7953, "e")
, ( 7954, "e")
, ( 7955, "e")
, ( 7956, "e")
, ( 7957, "e")
, ( 7958, "[?]")
, ( 7959, "[?]")
, ( 7960, "E")
, ( 7961, "E")
, ( 7962, "E")
, ( 7963, "E")
, ( 7964, "E")
, ( 7965, "E")
, ( 7966, "[?]")
, ( 7967, "[?]")
, ( 7968, "e")
, ( 7969, "e")
, ( 7970, "e")
, ( 7971, "e")
, ( 7972, "e")
, ( 7973, "e")
, ( 7974, "e")
, ( 7975, "e")
, ( 7976, "E")
, ( 7977, "E")
, ( 7978, "E")
, ( 7979, "E")
, ( 7980, "E")
, ( 7981, "E")
, ( 7982, "E")
, ( 7983, "E")
, ( 7984, "i")
, ( 7985, "i")
, ( 7986, "i")
, ( 7987, "i")
, ( 7988, "i")
, ( 7989, "i")
, ( 7990, "i")
, ( 7991, "i")
, ( 7992, "I")
, ( 7993, "I")
, ( 7994, "I")
, ( 7995, "I")
, ( 7996, "I")
, ( 7997, "I")
, ( 7998, "I")
, ( 7999, "I")
, ( 8000, "o")
, ( 8001, "o")
, ( 8002, "o")
, ( 8003, "o")
, ( 8004, "o")
, ( 8005, "o")
, ( 8006, "[?]")
, ( 8007, "[?]")
, ( 8008, "O")
, ( 8009, "O")
, ( 8010, "O")
, ( 8011, "O")
, ( 8012, "O")
, ( 8013, "O")
, ( 8014, "[?]")
, ( 8015, "[?]")
, ( 8016, "u")
, ( 8017, "u")
, ( 8018, "u")
, ( 8019, "u")
, ( 8020, "u")
, ( 8021, "u")
, ( 8022, "u")
, ( 8023, "u")
, ( 8024, "[?]")
, ( 8025, "U")
, ( 8026, "[?]")
, ( 8027, "U")
, ( 8028, "[?]")
, ( 8029, "U")
, ( 8030, "[?]")
, ( 8031, "U")
, ( 8032, "o")
, ( 8033, "o")
, ( 8034, "o")
, ( 8035, "o")
, ( 8036, "o")
, ( 8037, "o")
, ( 8038, "o")
, ( 8039, "o")
, ( 8040, "O")
, ( 8041, "O")
, ( 8042, "O")
, ( 8043, "O")
, ( 8044, "O")
, ( 8045, "O")
, ( 8046, "O")
, ( 8047, "O")
, ( 8048, "a")
, ( 8049, "a")
, ( 8050, "e")
, ( 8051, "e")
, ( 8052, "e")
, ( 8053, "e")
, ( 8054, "i")
, ( 8055, "i")
, ( 8056, "o")
, ( 8057, "o")
, ( 8058, "u")
, ( 8059, "u")
, ( 8060, "o")
, ( 8061, "o")
, ( 8062, "[?]")
, ( 8063, "[?]")
, ( 8064, "a")
, ( 8065, "a")
, ( 8066, "a")
, ( 8067, "a")
, ( 8068, "a")
, ( 8069, "a")
, ( 8070, "a")
, ( 8071, "a")
, ( 8072, "A")
, ( 8073, "A")
, ( 8074, "A")
, ( 8075, "A")
, ( 8076, "A")
, ( 8077, "A")
, ( 8078, "A")
, ( 8079, "A")
, ( 8080, "e")
, ( 8081, "e")
, ( 8082, "e")
, ( 8083, "e")
, ( 8084, "e")
, ( 8085, "e")
, ( 8086, "e")
, ( 8087, "e")
, ( 8088, "E")
, ( 8089, "E")
, ( 8090, "E")
, ( 8091, "E")
, ( 8092, "E")
, ( 8093, "E")
, ( 8094, "E")
, ( 8095, "E")
, ( 8096, "o")
, ( 8097, "o")
, ( 8098, "o")
, ( 8099, "o")
, ( 8100, "o")
, ( 8101, "o")
, ( 8102, "o")
, ( 8103, "o")
, ( 8104, "O")
, ( 8105, "O")
, ( 8106, "O")
, ( 8107, "O")
, ( 8108, "O")
, ( 8109, "O")
, ( 8110, "O")
, ( 8111, "O")
, ( 8112, "a")
, ( 8113, "a")
, ( 8114, "a")
, ( 8115, "a")
, ( 8116, "a")
, ( 8117, "[?]")
, ( 8118, "a")
, ( 8119, "a")
, ( 8120, "A")
, ( 8121, "A")
, ( 8122, "A")
, ( 8123, "A")
, ( 8124, "A")
, ( 8125, "'")
, ( 8126, "i")
, ( 8127, "'")
, ( 8128, "~")
, ( 8129, "\"~")
, ( 8130, "e")
, ( 8131, "e")
, ( 8132, "e")
, ( 8133, "[?]")
, ( 8134, "e")
, ( 8135, "e")
, ( 8136, "E")
, ( 8137, "E")
, ( 8138, "E")
, ( 8139, "E")
, ( 8140, "E")
, ( 8141, "'`")
, ( 8142, "''")
, ( 8143, "'~")
, ( 8144, "i")
, ( 8145, "i")
, ( 8146, "i")
, ( 8147, "i")
, ( 8148, "[?]")
, ( 8149, "[?]")
, ( 8150, "i")
, ( 8151, "i")
, ( 8152, "I")
, ( 8153, "I")
, ( 8154, "I")
, ( 8155, "I")
, ( 8156, "[?]")
, ( 8157, "`'")
, ( 8158, "`'")
, ( 8159, "`~")
, ( 8160, "u")
, ( 8161, "u")
, ( 8162, "u")
, ( 8163, "u")
, ( 8164, "R")
, ( 8165, "R")
, ( 8166, "u")
, ( 8167, "u")
, ( 8168, "U")
, ( 8169, "U")
, ( 8170, "U")
, ( 8171, "U")
, ( 8172, "R")
, ( 8173, "\"`")
, ( 8174, "\"'")
, ( 8175, "`")
, ( 8176, "[?]")
, ( 8177, "[?]")
, ( 8178, "o")
, ( 8179, "o")
, ( 8180, "o")
, ( 8181, "[?]")
, ( 8182, "o")
, ( 8183, "o")
, ( 8184, "O")
, ( 8185, "O")
, ( 8186, "O")
, ( 8187, "O")
, ( 8188, "O")
, ( 8189, "'")
, ( 8190, "`")
, ( 8192, " ")
, ( 8193, " ")
, ( 8194, " ")
, ( 8195, " ")
, ( 8196, " ")
, ( 8197, " ")
, ( 8198, " ")
, ( 8199, " ")
, ( 8200, " ")
, ( 8201, " ")
, ( 8202, " ")
, ( 8203, " ")
, ( 8208, "-")
, ( 8209, "-")
, ( 8210, "-")
, ( 8211, "-")
, ( 8212, "--")
, ( 8213, "--")
, ( 8214, "||")
, ( 8215, "_")
, ( 8216, "'")
, ( 8217, "'")
, ( 8218, ",")
, ( 8219, "'")
, ( 8220, "\"")
, ( 8221, "\"")
, ( 8222, ",,")
, ( 8223, "\"")
, ( 8224, "+")
, ( 8225, "++")
, ( 8226, "*")
, ( 8227, "*>")
, ( 8228, ".")
, ( 8229, "..")
, ( 8230, "...")
, ( 8231, ".")
, ( 8232, "\n")
, ( 8233, "\n")
, ( 8239, " ")
, ( 8240, "%0")
, ( 8241, "%00")
, ( 8242, "'")
, ( 8243, "''")
, ( 8244, "'''")
, ( 8245, "`")
, ( 8246, "``")
, ( 8247, "```")
, ( 8248, "^")
, ( 8249, "<")
, ( 8250, ">")
, ( 8251, "*")
, ( 8252, "!!")
, ( 8253, "!?")
, ( 8254, "-")
, ( 8255, "_")
, ( 8256, "-")
, ( 8257, "^")
, ( 8258, "***")
, ( 8259, "--")
, ( 8260, "/")
, ( 8261, "-[")
, ( 8262, "]-")
, ( 8263, "??")
, ( 8264, "?!")
, ( 8265, "!?")
, ( 8266, "7")
, ( 8267, "PP")
, ( 8268, "(]")
, ( 8269, "[)")
, ( 8270, "*")
, ( 8271, "[?]")
, ( 8272, "[?]")
, ( 8273, "[?]")
, ( 8274, "%")
, ( 8275, "~")
, ( 8276, "[?]")
, ( 8277, "[?]")
, ( 8278, "[?]")
, ( 8279, "''''")
, ( 8280, "[?]")
, ( 8281, "[?]")
, ( 8282, "[?]")
, ( 8283, "[?]")
, ( 8284, "[?]")
, ( 8285, "[?]")
, ( 8286, "[?]")
, ( 8287, "[?]")
, ( 8289, "[?]")
, ( 8290, "[?]")
, ( 8291, "[?]")
, ( 8292, "[?]")
, ( 8293, "[?]")
, ( 8294, "[?]")
, ( 8295, "[?]")
, ( 8296, "[?]")
, ( 8297, "[?]")
, ( 8304, "0")
, ( 8308, "4")
, ( 8309, "5")
, ( 8310, "6")
, ( 8311, "7")
, ( 8312, "8")
, ( 8313, "9")
, ( 8314, "+")
, ( 8315, "-")
, ( 8316, "=")
, ( 8317, "(")
, ( 8318, ")")
, ( 8319, "n")
, ( 8320, "0")
, ( 8321, "1")
, ( 8322, "2")
, ( 8323, "3")
, ( 8324, "4")
, ( 8325, "5")
, ( 8326, "6")
, ( 8327, "7")
, ( 8328, "8")
, ( 8329, "9")
, ( 8330, "+")
, ( 8331, "-")
, ( 8332, "=")
, ( 8333, "(")
, ( 8334, ")")
, ( 8335, "[?]")
, ( 8336, "[?]")
, ( 8337, "[?]")
, ( 8338, "[?]")
, ( 8339, "[?]")
, ( 8340, "[?]")
, ( 8341, "[?]")
, ( 8342, "[?]")
, ( 8343, "[?]")
, ( 8344, "[?]")
, ( 8345, "[?]")
, ( 8346, "[?]")
, ( 8347, "[?]")
, ( 8348, "[?]")
, ( 8349, "[?]")
, ( 8350, "[?]")
, ( 8351, "[?]")
, ( 8352, "ECU")
, ( 8353, "CL")
, ( 8354, "Cr")
, ( 8355, "FF")
, ( 8356, "L")
, ( 8357, "mil")
, ( 8358, "N")
, ( 8359, "Pts")
, ( 8360, "Rs")
, ( 8361, "W")
, ( 8362, "NS")
, ( 8363, "D")
, ( 8364, "EUR")
, ( 8365, "K")
, ( 8366, "T")
, ( 8367, "Dr")
, ( 8368, "[?]")
, ( 8369, "[?]")
, ( 8370, "[?]")
, ( 8371, "[?]")
, ( 8372, "[?]")
, ( 8373, "[?]")
, ( 8374, "[?]")
, ( 8375, "[?]")
, ( 8376, "[?]")
, ( 8377, "[?]")
, ( 8378, "[?]")
, ( 8379, "[?]")
, ( 8380, "[?]")
, ( 8381, "[?]")
, ( 8382, "[?]")
, ( 8383, "[?]")
, ( 8384, "[?]")
, ( 8385, "[?]")
, ( 8386, "[?]")
, ( 8387, "[?]")
, ( 8388, "[?]")
, ( 8389, "[?]")
, ( 8390, "[?]")
, ( 8391, "[?]")
, ( 8392, "[?]")
, ( 8393, "[?]")
, ( 8394, "[?]")
, ( 8395, "[?]")
, ( 8396, "[?]")
, ( 8397, "[?]")
, ( 8398, "[?]")
, ( 8399, "[?]")
, ( 8420, "[?]")
, ( 8422, "[?]")
, ( 8423, "[?]")
, ( 8519, "e")
, ( 8520, "i")
, ( 40961, "ix")
, ( 40962, "i")
, ( 40963, "ip")
, ( 40964, "iet")
, ( 40965, "iex")
, ( 40966, "ie")
, ( 40967, "iep")
, ( 40968, "at")
, ( 40969, "ax")
, ( 40970, "a")
, ( 40971, "ap")
, ( 40972, "uox")
, ( 40973, "uo")
, ( 40974, "uop")
, ( 40975, "ot")
, ( 40976, "ox")
, ( 40977, "o")
, ( 40978, "op")
, ( 40979, "ex")
, ( 40980, "e")
, ( 40981, "wu")
, ( 40982, "bit")
, ( 40983, "bix")
, ( 40984, "bi")
, ( 40985, "bip")
, ( 40986, "biet")
, ( 40987, "biex")
, ( 40988, "bie")
, ( 40989, "biep")
, ( 40990, "bat")
, ( 40991, "bax")
, ( 40992, "ba")
, ( 40993, "bap")
, ( 40994, "buox")
, ( 40995, "buo")
, ( 40996, "buop")
, ( 40997, "bot")
, ( 40998, "box")
, ( 40999, "bo")
, ( 41000, "bop")
, ( 41001, "bex")
, ( 41002, "be")
, ( 41003, "bep")
, ( 41004, "but")
, ( 41005, "bux")
, ( 41006, "bu")
, ( 41007, "bup")
, ( 41008, "burx")
, ( 41009, "bur")
, ( 41010, "byt")
, ( 41011, "byx")
, ( 41012, "by")
, ( 41013, "byp")
, ( 41014, "byrx")
, ( 41015, "byr")
, ( 41016, "pit")
, ( 41017, "pix")
, ( 41018, "pi")
, ( 41019, "pip")
, ( 41020, "piex")
, ( 41021, "pie")
, ( 41022, "piep")
, ( 41023, "pat")
, ( 41024, "pax")
, ( 41025, "pa")
, ( 41026, "pap")
, ( 41027, "puox")
, ( 41028, "puo")
, ( 41029, "puop")
, ( 41030, "pot")
, ( 41031, "pox")
, ( 41032, "po")
, ( 41033, "pop")
, ( 41034, "put")
, ( 41035, "pux")
, ( 41036, "pu")
, ( 41037, "pup")
, ( 41038, "purx")
, ( 41039, "pur")
, ( 41040, "pyt")
, ( 41041, "pyx")
, ( 41042, "py")
, ( 41043, "pyp")
, ( 41044, "pyrx")
, ( 41045, "pyr")
, ( 41046, "bbit")
, ( 41047, "bbix")
, ( 41048, "bbi")
, ( 41049, "bbip")
, ( 41050, "bbiet")
, ( 41051, "bbiex")
, ( 41052, "bbie")
, ( 41053, "bbiep")
, ( 41054, "bbat")
, ( 41055, "bbax")
, ( 41056, "bba")
, ( 41057, "bbap")
, ( 41058, "bbuox")
, ( 41059, "bbuo")
, ( 41060, "bbuop")
, ( 41061, "bbot")
, ( 41062, "bbox")
, ( 41063, "bbo")
, ( 41064, "bbop")
, ( 41065, "bbex")
, ( 41066, "bbe")
, ( 41067, "bbep")
, ( 41068, "bbut")
, ( 41069, "bbux")
, ( 41070, "bbu")
, ( 41071, "bbup")
, ( 41072, "bburx")
, ( 41073, "bbur")
, ( 41074, "bbyt")
, ( 41075, "bbyx")
, ( 41076, "bby")
, ( 41077, "bbyp")
, ( 41078, "nbit")
, ( 41079, "nbix")
, ( 41080, "nbi")
, ( 41081, "nbip")
, ( 41082, "nbiex")
, ( 41083, "nbie")
, ( 41084, "nbiep")
, ( 41085, "nbat")
, ( 41086, "nbax")
, ( 41087, "nba")
, ( 41088, "nbap")
, ( 41089, "nbot")
, ( 41090, "nbox")
, ( 41091, "nbo")
, ( 41092, "nbop")
, ( 41093, "nbut")
, ( 41094, "nbux")
, ( 41095, "nbu")
, ( 41096, "nbup")
, ( 41097, "nburx")
, ( 41098, "nbur")
, ( 41099, "nbyt")
, ( 41100, "nbyx")
, ( 41101, "nby")
, ( 41102, "nbyp")
, ( 41103, "nbyrx")
, ( 41104, "nbyr")
, ( 41105, "hmit")
, ( 41106, "hmix")
, ( 41107, "hmi")
, ( 41108, "hmip")
, ( 41109, "hmiex")
, ( 41110, "hmie")
, ( 41111, "hmiep")
, ( 41112, "hmat")
, ( 41113, "hmax")
, ( 41114, "hma")
, ( 41115, "hmap")
, ( 41116, "hmuox")
, ( 41117, "hmuo")
, ( 41118, "hmuop")
, ( 41119, "hmot")
, ( 41120, "hmox")
, ( 41121, "hmo")
, ( 41122, "hmop")
, ( 41123, "hmut")
, ( 41124, "hmux")
, ( 41125, "hmu")
, ( 41126, "hmup")
, ( 41127, "hmurx")
, ( 41128, "hmur")
, ( 41129, "hmyx")
, ( 41130, "hmy")
, ( 41131, "hmyp")
, ( 41132, "hmyrx")
, ( 41133, "hmyr")
, ( 41134, "mit")
, ( 41135, "mix")
, ( 41136, "mi")
, ( 41137, "mip")
, ( 41138, "miex")
, ( 41139, "mie")
, ( 41140, "miep")
, ( 41141, "mat")
, ( 41142, "max")
, ( 41143, "ma")
, ( 41144, "map")
, ( 41145, "muot")
, ( 41146, "muox")
, ( 41147, "muo")
, ( 41148, "muop")
, ( 41149, "mot")
, ( 41150, "mox")
, ( 41151, "mo")
, ( 41152, "mop")
, ( 41153, "mex")
, ( 41154, "me")
, ( 41155, "mut")
, ( 41156, "mux")
, ( 41157, "mu")
, ( 41158, "mup")
, ( 41159, "murx")
, ( 41160, "mur")
, ( 41161, "myt")
, ( 41162, "myx")
, ( 41163, "my")
, ( 41164, "myp")
, ( 41165, "fit")
, ( 41166, "fix")
, ( 41167, "fi")
, ( 41168, "fip")
, ( 41169, "fat")
, ( 41170, "fax")
, ( 41171, "fa")
, ( 41172, "fap")
, ( 41173, "fox")
, ( 41174, "fo")
, ( 41175, "fop")
, ( 41176, "fut")
, ( 41177, "fux")
, ( 41178, "fu")
, ( 41179, "fup")
, ( 41180, "furx")
, ( 41181, "fur")
, ( 41182, "fyt")
, ( 41183, "fyx")
, ( 41184, "fy")
, ( 41185, "fyp")
, ( 41186, "vit")
, ( 41187, "vix")
, ( 41188, "vi")
, ( 41189, "vip")
, ( 41190, "viet")
, ( 41191, "viex")
, ( 41192, "vie")
, ( 41193, "viep")
, ( 41194, "vat")
, ( 41195, "vax")
, ( 41196, "va")
, ( 41197, "vap")
, ( 41198, "vot")
, ( 41199, "vox")
, ( 41200, "vo")
, ( 41201, "vop")
, ( 41202, "vex")
, ( 41203, "vep")
, ( 41204, "vut")
, ( 41205, "vux")
, ( 41206, "vu")
, ( 41207, "vup")
, ( 41208, "vurx")
, ( 41209, "vur")
, ( 41210, "vyt")
, ( 41211, "vyx")
, ( 41212, "vy")
, ( 41213, "vyp")
, ( 41214, "vyrx")
, ( 41215, "vyr")
, ( 41216, "dit")
, ( 41217, "dix")
, ( 41218, "di")
, ( 41219, "dip")
, ( 41220, "diex")
, ( 41221, "die")
, ( 41222, "diep")
, ( 41223, "dat")
, ( 41224, "dax")
, ( 41225, "da")
, ( 41226, "dap")
, ( 41227, "duox")
, ( 41228, "duo")
, ( 41229, "dot")
, ( 41230, "dox")
, ( 41231, "do")
, ( 41232, "dop")
, ( 41233, "dex")
, ( 41234, "de")
, ( 41235, "dep")
, ( 41236, "dut")
, ( 41237, "dux")
, ( 41238, "du")
, ( 41239, "dup")
, ( 41240, "durx")
, ( 41241, "dur")
, ( 41242, "tit")
, ( 41243, "tix")
, ( 41244, "ti")
, ( 41245, "tip")
, ( 41246, "tiex")
, ( 41247, "tie")
, ( 41248, "tiep")
, ( 41249, "tat")
, ( 41250, "tax")
, ( 41251, "ta")
, ( 41252, "tap")
, ( 41253, "tuot")
, ( 41254, "tuox")
, ( 41255, "tuo")
, ( 41256, "tuop")
, ( 41257, "tot")
, ( 41258, "tox")
, ( 41259, "to")
, ( 41260, "top")
, ( 41261, "tex")
, ( 41262, "te")
, ( 41263, "tep")
, ( 41264, "tut")
, ( 41265, "tux")
, ( 41266, "tu")
, ( 41267, "tup")
, ( 41268, "turx")
, ( 41269, "tur")
, ( 41270, "ddit")
, ( 41271, "ddix")
, ( 41272, "ddi")
, ( 41273, "ddip")
, ( 41274, "ddiex")
, ( 41275, "ddie")
, ( 41276, "ddiep")
, ( 41277, "ddat")
, ( 41278, "ddax")
, ( 41279, "dda")
, ( 41280, "ddap")
, ( 41281, "dduox")
, ( 41282, "dduo")
, ( 41283, "dduop")
, ( 41284, "ddot")
, ( 41285, "ddox")
, ( 41286, "ddo")
, ( 41287, "ddop")
, ( 41288, "ddex")
, ( 41289, "dde")
, ( 41290, "ddep")
, ( 41291, "ddut")
, ( 41292, "ddux")
, ( 41293, "ddu")
, ( 41294, "ddup")
, ( 41295, "ddurx")
, ( 41296, "ddur")
, ( 41297, "ndit")
, ( 41298, "ndix")
, ( 41299, "ndi")
, ( 41300, "ndip")
, ( 41301, "ndiex")
, ( 41302, "ndie")
, ( 41303, "ndat")
, ( 41304, "ndax")
, ( 41305, "nda")
, ( 41306, "ndap")
, ( 41307, "ndot")
, ( 41308, "ndox")
, ( 41309, "ndo")
, ( 41310, "ndop")
, ( 41311, "ndex")
, ( 41312, "nde")
, ( 41313, "ndep")
, ( 41314, "ndut")
, ( 41315, "ndux")
, ( 41316, "ndu")
, ( 41317, "ndup")
, ( 41318, "ndurx")
, ( 41319, "ndur")
, ( 41320, "hnit")
, ( 41321, "hnix")
, ( 41322, "hni")
, ( 41323, "hnip")
, ( 41324, "hniet")
, ( 41325, "hniex")
, ( 41326, "hnie")
, ( 41327, "hniep")
, ( 41328, "hnat")
, ( 41329, "hnax")
, ( 41330, "hna")
, ( 41331, "hnap")
, ( 41332, "hnuox")
, ( 41333, "hnuo")
, ( 41334, "hnot")
, ( 41335, "hnox")
, ( 41336, "hnop")
, ( 41337, "hnex")
, ( 41338, "hne")
, ( 41339, "hnep")
, ( 41340, "hnut")
, ( 41341, "nit")
, ( 41342, "nix")
, ( 41343, "ni")
, ( 41344, "nip")
, ( 41345, "niex")
, ( 41346, "nie")
, ( 41347, "niep")
, ( 41348, "nax")
, ( 41349, "na")
, ( 41350, "nap")
, ( 41351, "nuox")
, ( 41352, "nuo")
, ( 41353, "nuop")
, ( 41354, "not")
, ( 41355, "nox")
, ( 41356, "no")
, ( 41357, "nop")
, ( 41358, "nex")
, ( 41359, "ne")
, ( 41360, "nep")
, ( 41361, "nut")
, ( 41362, "nux")
, ( 41363, "nu")
, ( 41364, "nup")
, ( 41365, "nurx")
, ( 41366, "nur")
, ( 41367, "hlit")
, ( 41368, "hlix")
, ( 41369, "hli")
, ( 41370, "hlip")
, ( 41371, "hliex")
, ( 41372, "hlie")
, ( 41373, "hliep")
, ( 41374, "hlat")
, ( 41375, "hlax")
, ( 41376, "hla")
, ( 41377, "hlap")
, ( 41378, "hluox")
, ( 41379, "hluo")
, ( 41380, "hluop")
, ( 41381, "hlox")
, ( 41382, "hlo")
, ( 41383, "hlop")
, ( 41384, "hlex")
, ( 41385, "hle")
, ( 41386, "hlep")
, ( 41387, "hlut")
, ( 41388, "hlux")
, ( 41389, "hlu")
, ( 41390, "hlup")
, ( 41391, "hlurx")
, ( 41392, "hlur")
, ( 41393, "hlyt")
, ( 41394, "hlyx")
, ( 41395, "hly")
, ( 41396, "hlyp")
, ( 41397, "hlyrx")
, ( 41398, "hlyr")
, ( 41399, "lit")
, ( 41400, "lix")
, ( 41401, "li")
, ( 41402, "lip")
, ( 41403, "liet")
, ( 41404, "liex")
, ( 41405, "lie")
, ( 41406, "liep")
, ( 41407, "lat")
, ( 41408, "lax")
, ( 41409, "la")
, ( 41410, "lap")
, ( 41411, "luot")
, ( 41412, "luox")
, ( 41413, "luo")
, ( 41414, "luop")
, ( 41415, "lot")
, ( 41416, "lox")
, ( 41417, "lo")
, ( 41418, "lop")
, ( 41419, "lex")
, ( 41420, "le")
, ( 41421, "lep")
, ( 41422, "lut")
, ( 41423, "lux")
, ( 41424, "lu")
, ( 41425, "lup")
, ( 41426, "lurx")
, ( 41427, "lur")
, ( 41428, "lyt")
, ( 41429, "lyx")
, ( 41430, "ly")
, ( 41431, "lyp")
, ( 41432, "lyrx")
, ( 41433, "lyr")
, ( 41434, "git")
, ( 41435, "gix")
, ( 41436, "gi")
, ( 41437, "gip")
, ( 41438, "giet")
, ( 41439, "giex")
, ( 41440, "gie")
, ( 41441, "giep")
, ( 41442, "gat")
, ( 41443, "gax")
, ( 41444, "ga")
, ( 41445, "gap")
, ( 41446, "guot")
, ( 41447, "guox")
, ( 41448, "guo")
, ( 41449, "guop")
, ( 41450, "got")
, ( 41451, "gox")
, ( 41452, "go")
, ( 41453, "gop")
, ( 41454, "get")
, ( 41455, "gex")
, ( 41456, "ge")
, ( 41457, "gep")
, ( 41458, "gut")
, ( 41459, "gux")
, ( 41460, "gu")
, ( 41461, "gup")
, ( 41462, "gurx")
, ( 41463, "gur")
, ( 41464, "kit")
, ( 41465, "kix")
, ( 41466, "ki")
, ( 41467, "kip")
, ( 41468, "kiex")
, ( 41469, "kie")
, ( 41470, "kiep")
, ( 41471, "kat")
, ( 41472, "kax")
, ( 41473, "ka")
, ( 41474, "kap")
, ( 41475, "kuox")
, ( 41476, "kuo")
, ( 41477, "kuop")
, ( 41478, "kot")
, ( 41479, "kox")
, ( 41480, "ko")
, ( 41481, "kop")
, ( 41482, "ket")
, ( 41483, "kex")
, ( 41484, "ke")
, ( 41485, "kep")
, ( 41486, "kut")
, ( 41487, "kux")
, ( 41488, "ku")
, ( 41489, "kup")
, ( 41490, "kurx")
, ( 41491, "kur")
, ( 41492, "ggit")
, ( 41493, "ggix")
, ( 41494, "ggi")
, ( 41495, "ggiex")
, ( 41496, "ggie")
, ( 41497, "ggiep")
, ( 41498, "ggat")
, ( 41499, "ggax")
, ( 41500, "gga")
, ( 41501, "ggap")
, ( 41502, "gguot")
, ( 41503, "gguox")
, ( 41504, "gguo")
, ( 41505, "gguop")
, ( 41506, "ggot")
, ( 41507, "ggox")
, ( 41508, "ggo")
, ( 41509, "ggop")
, ( 41510, "gget")
, ( 41511, "ggex")
, ( 41512, "gge")
, ( 41513, "ggep")
, ( 41514, "ggut")
, ( 41515, "ggux")
, ( 41516, "ggu")
, ( 41517, "ggup")
, ( 41518, "ggurx")
, ( 41519, "ggur")
, ( 41520, "mgiex")
, ( 41521, "mgie")
, ( 41522, "mgat")
, ( 41523, "mgax")
, ( 41524, "mga")
, ( 41525, "mgap")
, ( 41526, "mguox")
, ( 41527, "mguo")
, ( 41528, "mguop")
, ( 41529, "mgot")
, ( 41530, "mgox")
, ( 41531, "mgo")
, ( 41532, "mgop")
, ( 41533, "mgex")
, ( 41534, "mge")
, ( 41535, "mgep")
, ( 41536, "mgut")
, ( 41537, "mgux")
, ( 41538, "mgu")
, ( 41539, "mgup")
, ( 41540, "mgurx")
, ( 41541, "mgur")
, ( 41542, "hxit")
, ( 41543, "hxix")
, ( 41544, "hxi")
, ( 41545, "hxip")
, ( 41546, "hxiet")
, ( 41547, "hxiex")
, ( 41548, "hxie")
, ( 41549, "hxiep")
, ( 41550, "hxat")
, ( 41551, "hxax")
, ( 41552, "hxa")
, ( 41553, "hxap")
, ( 41554, "hxuot")
, ( 41555, "hxuox")
, ( 41556, "hxuo")
, ( 41557, "hxuop")
, ( 41558, "hxot")
, ( 41559, "hxox")
, ( 41560, "hxo")
, ( 41561, "hxop")
, ( 41562, "hxex")
, ( 41563, "hxe")
, ( 41564, "hxep")
, ( 41565, "ngiex")
, ( 41566, "ngie")
, ( 41567, "ngiep")
, ( 41568, "ngat")
, ( 41569, "ngax")
, ( 41570, "nga")
, ( 41571, "ngap")
, ( 41572, "nguot")
, ( 41573, "nguox")
, ( 41574, "nguo")
, ( 41575, "ngot")
, ( 41576, "ngox")
, ( 41577, "ngo")
, ( 41578, "ngop")
, ( 41579, "ngex")
, ( 41580, "nge")
, ( 41581, "ngep")
, ( 41582, "hit")
, ( 41583, "hiex")
, ( 41584, "hie")
, ( 41585, "hat")
, ( 41586, "hax")
, ( 41587, "ha")
, ( 41588, "hap")
, ( 41589, "huot")
, ( 41590, "huox")
, ( 41591, "huo")
, ( 41592, "huop")
, ( 41593, "hot")
, ( 41594, "hox")
, ( 41595, "ho")
, ( 41596, "hop")
, ( 41597, "hex")
, ( 41598, "he")
, ( 41599, "hep")
, ( 41600, "wat")
, ( 41601, "wax")
, ( 41602, "wa")
, ( 41603, "wap")
, ( 41604, "wuox")
, ( 41605, "wuo")
, ( 41606, "wuop")
, ( 41607, "wox")
, ( 41608, "wo")
, ( 41609, "wop")
, ( 41610, "wex")
, ( 41611, "we")
, ( 41612, "wep")
, ( 41613, "zit")
, ( 41614, "zix")
, ( 41615, "zi")
, ( 41616, "zip")
, ( 41617, "ziex")
, ( 41618, "zie")
, ( 41619, "ziep")
, ( 41620, "zat")
, ( 41621, "zax")
, ( 41622, "za")
, ( 41623, "zap")
, ( 41624, "zuox")
, ( 41625, "zuo")
, ( 41626, "zuop")
, ( 41627, "zot")
, ( 41628, "zox")
, ( 41629, "zo")
, ( 41630, "zop")
, ( 41631, "zex")
, ( 41632, "ze")
, ( 41633, "zep")
, ( 41634, "zut")
, ( 41635, "zux")
, ( 41636, "zu")
, ( 41637, "zup")
, ( 41638, "zurx")
, ( 41639, "zur")
, ( 41640, "zyt")
, ( 41641, "zyx")
, ( 41642, "zy")
, ( 41643, "zyp")
, ( 41644, "zyrx")
, ( 41645, "zyr")
, ( 41646, "cit")
, ( 41647, "cix")
, ( 41648, "ci")
, ( 41649, "cip")
, ( 41650, "ciet")
, ( 41651, "ciex")
, ( 41652, "cie")
, ( 41653, "ciep")
, ( 41654, "cat")
, ( 41655, "cax")
, ( 41656, "ca")
, ( 41657, "cap")
, ( 41658, "cuox")
, ( 41659, "cuo")
, ( 41660, "cuop")
, ( 41661, "cot")
, ( 41662, "cox")
, ( 41663, "co")
, ( 41664, "cop")
, ( 41665, "cex")
, ( 41666, "ce")
, ( 41667, "cep")
, ( 41668, "cut")
, ( 41669, "cux")
, ( 41670, "cu")
, ( 41671, "cup")
, ( 41672, "curx")
, ( 41673, "cur")
, ( 41674, "cyt")
, ( 41675, "cyx")
, ( 41676, "cy")
, ( 41677, "cyp")
, ( 41678, "cyrx")
, ( 41679, "cyr")
, ( 41680, "zzit")
, ( 41681, "zzix")
, ( 41682, "zzi")
, ( 41683, "zzip")
, ( 41684, "zziet")
, ( 41685, "zziex")
, ( 41686, "zzie")
, ( 41687, "zziep")
, ( 41688, "zzat")
, ( 41689, "zzax")
, ( 41690, "zza")
, ( 41691, "zzap")
, ( 41692, "zzox")
, ( 41693, "zzo")
, ( 41694, "zzop")
, ( 41695, "zzex")
, ( 41696, "zze")
, ( 41697, "zzep")
, ( 41698, "zzux")
, ( 41699, "zzu")
, ( 41700, "zzup")
, ( 41701, "zzurx")
, ( 41702, "zzur")
, ( 41703, "zzyt")
, ( 41704, "zzyx")
, ( 41705, "zzy")
, ( 41706, "zzyp")
, ( 41707, "zzyrx")
, ( 41708, "zzyr")
, ( 41709, "nzit")
, ( 41710, "nzix")
, ( 41711, "nzi")
, ( 41712, "nzip")
, ( 41713, "nziex")
, ( 41714, "nzie")
, ( 41715, "nziep")
, ( 41716, "nzat")
, ( 41717, "nzax")
, ( 41718, "nza")
, ( 41719, "nzap")
, ( 41720, "nzuox")
, ( 41721, "nzuo")
, ( 41722, "nzox")
, ( 41723, "nzop")
, ( 41724, "nzex")
, ( 41725, "nze")
, ( 41726, "nzux")
, ( 41727, "nzu")
, ( 41728, "nzup")
, ( 41729, "nzurx")
, ( 41730, "nzur")
, ( 41731, "nzyt")
, ( 41732, "nzyx")
, ( 41733, "nzy")
, ( 41734, "nzyp")
, ( 41735, "nzyrx")
, ( 41736, "nzyr")
, ( 41737, "sit")
, ( 41738, "six")
, ( 41739, "si")
, ( 41740, "sip")
, ( 41741, "siex")
, ( 41742, "sie")
, ( 41743, "siep")
, ( 41744, "sat")
, ( 41745, "sax")
, ( 41746, "sa")
, ( 41747, "sap")
, ( 41748, "suox")
, ( 41749, "suo")
, ( 41750, "suop")
, ( 41751, "sot")
, ( 41752, "sox")
, ( 41753, "so")
, ( 41754, "sop")
, ( 41755, "sex")
, ( 41756, "se")
, ( 41757, "sep")
, ( 41758, "sut")
, ( 41759, "sux")
, ( 41760, "su")
, ( 41761, "sup")
, ( 41762, "surx")
, ( 41763, "sur")
, ( 41764, "syt")
, ( 41765, "syx")
, ( 41766, "sy")
, ( 41767, "syp")
, ( 41768, "syrx")
, ( 41769, "syr")
, ( 41770, "ssit")
, ( 41771, "ssix")
, ( 41772, "ssi")
, ( 41773, "ssip")
, ( 41774, "ssiex")
, ( 41775, "ssie")
, ( 41776, "ssiep")
, ( 41777, "ssat")
, ( 41778, "ssax")
, ( 41779, "ssa")
, ( 41780, "ssap")
, ( 41781, "ssot")
, ( 41782, "ssox")
, ( 41783, "sso")
, ( 41784, "ssop")
, ( 41785, "ssex")
, ( 41786, "sse")
, ( 41787, "ssep")
, ( 41788, "ssut")
, ( 41789, "ssux")
, ( 41790, "ssu")
, ( 41791, "ssup")
, ( 41792, "ssyt")
, ( 41793, "ssyx")
, ( 41794, "ssy")
, ( 41795, "ssyp")
, ( 41796, "ssyrx")
, ( 41797, "ssyr")
, ( 41798, "zhat")
, ( 41799, "zhax")
, ( 41800, "zha")
, ( 41801, "zhap")
, ( 41802, "zhuox")
, ( 41803, "zhuo")
, ( 41804, "zhuop")
, ( 41805, "zhot")
, ( 41806, "zhox")
, ( 41807, "zho")
, ( 41808, "zhop")
, ( 41809, "zhet")
, ( 41810, "zhex")
, ( 41811, "zhe")
, ( 41812, "zhep")
, ( 41813, "zhut")
, ( 41814, "zhux")
, ( 41815, "zhu")
, ( 41816, "zhup")
, ( 41817, "zhurx")
, ( 41818, "zhur")
, ( 41819, "zhyt")
, ( 41820, "zhyx")
, ( 41821, "zhy")
, ( 41822, "zhyp")
, ( 41823, "zhyrx")
, ( 41824, "zhyr")
, ( 41825, "chat")
, ( 41826, "chax")
, ( 41827, "cha")
, ( 41828, "chap")
, ( 41829, "chuot")
, ( 41830, "chuox")
, ( 41831, "chuo")
, ( 41832, "chuop")
, ( 41833, "chot")
, ( 41834, "chox")
, ( 41835, "cho")
, ( 41836, "chop")
, ( 41837, "chet")
, ( 41838, "chex")
, ( 41839, "che")
, ( 41840, "chep")
, ( 41841, "chux")
, ( 41842, "chu")
, ( 41843, "chup")
, ( 41844, "churx")
, ( 41845, "chur")
, ( 41846, "chyt")
, ( 41847, "chyx")
, ( 41848, "chy")
, ( 41849, "chyp")
, ( 41850, "chyrx")
, ( 41851, "chyr")
, ( 41852, "rrax")
, ( 41853, "rra")
, ( 41854, "rruox")
, ( 41855, "rruo")
, ( 41856, "rrot")
, ( 41857, "rrox")
, ( 41858, "rro")
, ( 41859, "rrop")
, ( 41860, "rret")
, ( 41861, "rrex")
, ( 41862, "rre")
, ( 41863, "rrep")
, ( 41864, "rrut")
, ( 41865, "rrux")
, ( 41866, "rru")
, ( 41867, "rrup")
, ( 41868, "rrurx")
, ( 41869, "rrur")
, ( 41870, "rryt")
, ( 41871, "rryx")
, ( 41872, "rry")
, ( 41873, "rryp")
, ( 41874, "rryrx")
, ( 41875, "rryr")
, ( 41876, "nrat")
, ( 41877, "nrax")
, ( 41878, "nra")
, ( 41879, "nrap")
, ( 41880, "nrox")
, ( 41881, "nro")
, ( 41882, "nrop")
, ( 41883, "nret")
, ( 41884, "nrex")
, ( 41885, "nre")
, ( 41886, "nrep")
, ( 41887, "nrut")
, ( 41888, "nrux")
, ( 41889, "nru")
, ( 41890, "nrup")
, ( 41891, "nrurx")
, ( 41892, "nrur")
, ( 41893, "nryt")
, ( 41894, "nryx")
, ( 41895, "nry")
, ( 41896, "nryp")
, ( 41897, "nryrx")
, ( 41898, "nryr")
, ( 41899, "shat")
, ( 41900, "shax")
, ( 41901, "sha")
, ( 41902, "shap")
, ( 41903, "shuox")
, ( 41904, "shuo")
, ( 41905, "shuop")
, ( 41906, "shot")
, ( 41907, "shox")
, ( 41908, "sho")
, ( 41909, "shop")
, ( 41910, "shet")
, ( 41911, "shex")
, ( 41912, "she")
, ( 41913, "shep")
, ( 41914, "shut")
, ( 41915, "shux")
, ( 41916, "shu")
, ( 41917, "shup")
, ( 41918, "shurx")
, ( 41919, "shur")
, ( 41920, "shyt")
, ( 41921, "shyx")
, ( 41922, "shy")
, ( 41923, "shyp")
, ( 41924, "shyrx")
, ( 41925, "shyr")
, ( 41926, "rat")
, ( 41927, "rax")
, ( 41928, "ra")
, ( 41929, "rap")
, ( 41930, "ruox")
, ( 41931, "ruo")
, ( 41932, "ruop")
, ( 41933, "rot")
, ( 41934, "rox")
, ( 41935, "ro")
, ( 41936, "rop")
, ( 41937, "rex")
, ( 41938, "re")
, ( 41939, "rep")
, ( 41940, "rut")
, ( 41941, "rux")
, ( 41942, "ru")
, ( 41943, "rup")
, ( 41944, "rurx")
, ( 41945, "rur")
, ( 41946, "ryt")
, ( 41947, "ryx")
, ( 41948, "ry")
, ( 41949, "ryp")
, ( 41950, "ryrx")
, ( 41951, "ryr")
, ( 41952, "jit")
, ( 41953, "jix")
, ( 41954, "ji")
, ( 41955, "jip")
, ( 41956, "jiet")
, ( 41957, "jiex")
, ( 41958, "jie")
, ( 41959, "jiep")
, ( 41960, "juot")
, ( 41961, "juox")
, ( 41962, "juo")
, ( 41963, "juop")
, ( 41964, "jot")
, ( 41965, "jox")
, ( 41966, "jo")
, ( 41967, "jop")
, ( 41968, "jut")
, ( 41969, "jux")
, ( 41970, "ju")
, ( 41971, "jup")
, ( 41972, "jurx")
, ( 41973, "jur")
, ( 41974, "jyt")
, ( 41975, "jyx")
, ( 41976, "jy")
, ( 41977, "jyp")
, ( 41978, "jyrx")
, ( 41979, "jyr")
, ( 41980, "qit")
, ( 41981, "qix")
, ( 41982, "qi")
, ( 41983, "qip")
, ( 41984, "qiet")
, ( 41985, "qiex")
, ( 41986, "qie")
, ( 41987, "qiep")
, ( 41988, "quot")
, ( 41989, "quox")
, ( 41990, "quo")
, ( 41991, "quop")
, ( 41992, "qot")
, ( 41993, "qox")
, ( 41994, "qo")
, ( 41995, "qop")
, ( 41996, "qut")
, ( 41997, "qux")
, ( 41998, "qu")
, ( 41999, "qup")
, ( 42000, "qurx")
, ( 42001, "qur")
, ( 42002, "qyt")
, ( 42003, "qyx")
, ( 42004, "qy")
, ( 42005, "qyp")
, ( 42006, "qyrx")
, ( 42007, "qyr")
, ( 42008, "jjit")
, ( 42009, "jjix")
, ( 42010, "jji")
, ( 42011, "jjip")
, ( 42012, "jjiet")
, ( 42013, "jjiex")
, ( 42014, "jjie")
, ( 42015, "jjiep")
, ( 42016, "jjuox")
, ( 42017, "jjuo")
, ( 42018, "jjuop")
, ( 42019, "jjot")
, ( 42020, "jjox")
, ( 42021, "jjo")
, ( 42022, "jjop")
, ( 42023, "jjut")
, ( 42024, "jjux")
, ( 42025, "jju")
, ( 42026, "jjup")
, ( 42027, "jjurx")
, ( 42028, "jjur")
, ( 42029, "jjyt")
, ( 42030, "jjyx")
, ( 42031, "jjy")
, ( 42032, "jjyp")
, ( 42033, "njit")
, ( 42034, "njix")
, ( 42035, "nji")
, ( 42036, "njip")
, ( 42037, "njiet")
, ( 42038, "njiex")
, ( 42039, "njie")
, ( 42040, "njiep")
, ( 42041, "njuox")
, ( 42042, "njuo")
, ( 42043, "njot")
, ( 42044, "njox")
, ( 42045, "njo")
, ( 42046, "njop")
, ( 42047, "njux")
, ( 42048, "nju")
, ( 42049, "njup")
, ( 42050, "njurx")
, ( 42051, "njur")
, ( 42052, "njyt")
, ( 42053, "njyx")
, ( 42054, "njy")
, ( 42055, "njyp")
, ( 42056, "njyrx")
, ( 42057, "njyr")
, ( 42058, "nyit")
, ( 42059, "nyix")
, ( 42060, "nyi")
, ( 42061, "nyip")
, ( 42062, "nyiet")
, ( 42063, "nyiex")
, ( 42064, "nyie")
, ( 42065, "nyiep")
, ( 42066, "nyuox")
, ( 42067, "nyuo")
, ( 42068, "nyuop")
, ( 42069, "nyot")
, ( 42070, "nyox")
, ( 42071, "nyo")
, ( 42072, "nyop")
, ( 42073, "nyut")
, ( 42074, "nyux")
, ( 42075, "nyu")
, ( 42076, "nyup")
, ( 42077, "xit")
, ( 42078, "xix")
, ( 42079, "xi")
, ( 42080, "xip")
, ( 42081, "xiet")
, ( 42082, "xiex")
, ( 42083, "xie")
, ( 42084, "xiep")
, ( 42085, "xuox")
, ( 42086, "xuo")
, ( 42087, "xot")
, ( 42088, "xox")
, ( 42089, "xo")
, ( 42090, "xop")
, ( 42091, "xyt")
, ( 42092, "xyx")
, ( 42093, "xy")
, ( 42094, "xyp")
, ( 42095, "xyrx")
, ( 42096, "xyr")
, ( 42097, "yit")
, ( 42098, "yix")
, ( 42099, "yi")
, ( 42100, "yip")
, ( 42101, "yiet")
, ( 42102, "yiex")
, ( 42103, "yie")
, ( 42104, "yiep")
, ( 42105, "yuot")
, ( 42106, "yuox")
, ( 42107, "yuo")
, ( 42108, "yuop")
, ( 42109, "yot")
, ( 42110, "yox")
, ( 42111, "yo")
, ( 42112, "yop")
, ( 42113, "yut")
, ( 42114, "yux")
, ( 42115, "yu")
, ( 42116, "yup")
, ( 42117, "yurx")
, ( 42118, "yur")
, ( 42119, "yyt")
, ( 42120, "yyx")
, ( 42121, "yy")
, ( 42122, "yyp")
, ( 42123, "yyrx")
, ( 42124, "yyr")
, ( 42125, "[?]")
, ( 42126, "[?]")
, ( 42127, "[?]")
, ( 42128, "Qot")
, ( 42129, "Li")
, ( 42130, "Kit")
, ( 42131, "Nyip")
, ( 42132, "Cyp")
, ( 42133, "Ssi")
, ( 42134, "Ggop")
, ( 42135, "Gep")
, ( 42136, "Mi")
, ( 42137, "Hxit")
, ( 42138, "Lyr")
, ( 42139, "Bbut")
, ( 42140, "Mop")
, ( 42141, "Yo")
, ( 42142, "Put")
, ( 42143, "Hxuo")
, ( 42144, "Tat")
, ( 42145, "Ga")
, ( 42146, "[?]")
, ( 42147, "[?]")
, ( 42148, "Ddur")
, ( 42149, "Bur")
, ( 42150, "Gguo")
, ( 42151, "Nyop")
, ( 42152, "Tu")
, ( 42153, "Op")
, ( 42154, "Jjut")
, ( 42155, "Zot")
, ( 42156, "Pyt")
, ( 42157, "Hmo")
, ( 42158, "Yit")
, ( 42159, "Vur")
, ( 42160, "Shy")
, ( 42161, "Vep")
, ( 42162, "Za")
, ( 42163, "Jo")
, ( 42164, "[?]")
, ( 42165, "Jjy")
, ( 42166, "Got")
, ( 42167, "Jjie")
, ( 42168, "Wo")
, ( 42169, "Du")
, ( 42170, "Shur")
, ( 42171, "Lie")
, ( 42172, "Cy")
, ( 42173, "Cuop")
, ( 42174, "Cip")
, ( 42175, "Hxop")
, ( 42176, "Shat")
, ( 42177, "[?]")
, ( 42178, "Shop")
, ( 42179, "Che")
, ( 42180, "Zziet")
, ( 42181, "[?]")
, ( 42182, "Ke")
, ( 42183, "[?]")
, ( 42184, "[?]")
, ( 42185, "[?]")
, ( 42186, "[?]")
, ( 42187, "[?]")
, ( 42188, "[?]")
, ( 42189, "[?]")
, ( 42190, "[?]")
, ( 42191, "[?]")
, ( 42192, "[?]")
, ( 42193, "[?]")
, ( 42194, "[?]")
, ( 42195, "[?]")
, ( 42196, "[?]")
, ( 42197, "[?]")
, ( 42198, "[?]")
, ( 42199, "[?]")
, ( 42200, "[?]")
, ( 42201, "[?]")
, ( 42202, "[?]")
, ( 42203, "[?]")
, ( 42204, "[?]")
, ( 42205, "[?]")
, ( 42206, "[?]")
, ( 42207, "[?]")
, ( 42208, "[?]")
, ( 42209, "[?]")
, ( 42210, "[?]")
, ( 42211, "[?]")
, ( 42212, "[?]")
, ( 42213, "[?]")
, ( 42214, "[?]")
, ( 42215, "[?]")
, ( 42216, "[?]")
, ( 42217, "[?]")
, ( 42218, "[?]")
, ( 42219, "[?]")
, ( 42220, "[?]")
, ( 42221, "[?]")
, ( 42222, "[?]")
, ( 42223, "[?]")
, ( 42224, "[?]")
, ( 42225, "[?]")
, ( 42226, "[?]")
, ( 42227, "[?]")
, ( 42228, "[?]")
, ( 42229, "[?]")
, ( 42230, "[?]")
, ( 42231, "[?]")
, ( 42232, "[?]")
, ( 42233, "[?]")
, ( 42234, "[?]")
, ( 42235, "[?]")
, ( 42236, "[?]")
, ( 42237, "[?]")
, ( 42238, "[?]")
, ( 55204, "[?]")
, ( 55205, "[?]")
, ( 55206, "[?]")
, ( 55207, "[?]")
, ( 55208, "[?]")
, ( 55209, "[?]")
, ( 55210, "[?]")
, ( 55211, "[?]")
, ( 55212, "[?]")
, ( 55213, "[?]")
, ( 55214, "[?]")
, ( 55215, "[?]")
, ( 55216, "[?]")
, ( 55217, "[?]")
, ( 55218, "[?]")
, ( 55219, "[?]")
, ( 55220, "[?]")
, ( 55221, "[?]")
, ( 55222, "[?]")
, ( 55223, "[?]")
, ( 55224, "[?]")
, ( 55225, "[?]")
, ( 55226, "[?]")
, ( 55227, "[?]")
, ( 55228, "[?]")
, ( 55229, "[?]")
, ( 55230, "[?]")
, ( 55231, "[?]")
, ( 55232, "[?]")
, ( 55233, "[?]")
, ( 55234, "[?]")
, ( 55235, "[?]")
, ( 55236, "[?]")
, ( 55237, "[?]")
, ( 55238, "[?]")
, ( 55239, "[?]")
, ( 55240, "[?]")
, ( 55241, "[?]")
, ( 55242, "[?]")
, ( 55243, "[?]")
, ( 55244, "[?]")
, ( 55245, "[?]")
, ( 55246, "[?]")
, ( 55247, "[?]")
, ( 55248, "[?]")
, ( 55249, "[?]")
, ( 55250, "[?]")
, ( 55251, "[?]")
, ( 55252, "[?]")
, ( 55253, "[?]")
, ( 55254, "[?]")
, ( 55255, "[?]")
, ( 55256, "[?]")
, ( 55257, "[?]")
, ( 55258, "[?]")
, ( 55259, "[?]")
, ( 55260, "[?]")
, ( 55261, "[?]")
, ( 55262, "[?]")
, ( 55263, "[?]")
, ( 55264, "[?]")
, ( 55265, "[?]")
, ( 55266, "[?]")
, ( 55267, "[?]")
, ( 55268, "[?]")
, ( 55269, "[?]")
, ( 55270, "[?]")
, ( 55271, "[?]")
, ( 55272, "[?]")
, ( 55273, "[?]")
, ( 55274, "[?]")
, ( 55275, "[?]")
, ( 55276, "[?]")
, ( 55277, "[?]")
, ( 55278, "[?]")
, ( 55279, "[?]")
, ( 55280, "[?]")
, ( 55281, "[?]")
, ( 55282, "[?]")
, ( 55283, "[?]")
, ( 55284, "[?]")
, ( 55285, "[?]")
, ( 55286, "[?]")
, ( 55287, "[?]")
, ( 55288, "[?]")
, ( 55289, "[?]")
, ( 55290, "[?]")
, ( 55291, "[?]")
, ( 55292, "[?]")
, ( 55293, "[?]")
, ( 55294, "[?]")
, ( 63744, "Kay ")
, ( 63745, "Kayng ")
, ( 63746, "Ke ")
, ( 63747, "Ko ")
, ( 63748, "Kol ")
, ( 63749, "Koc ")
, ( 63750, "Kwi ")
, ( 63751, "Kwi ")
, ( 63752, "Kyun ")
, ( 63753, "Kul ")
, ( 63754, "Kum ")
, ( 63755, "Na ")
, ( 63756, "Na ")
, ( 63757, "Na ")
, ( 63758, "La ")
, ( 63759, "Na ")
, ( 63760, "Na ")
, ( 63761, "Na ")
, ( 63762, "Na ")
, ( 63763, "Na ")
, ( 63764, "Nak ")
, ( 63765, "Nak ")
, ( 63766, "Nak ")
, ( 63767, "Nak ")
, ( 63768, "Nak ")
, ( 63769, "Nak ")
, ( 63770, "Nak ")
, ( 63771, "Nan ")
, ( 63772, "Nan ")
, ( 63773, "Nan ")
, ( 63774, "Nan ")
, ( 63775, "Nan ")
, ( 63776, "Nan ")
, ( 63777, "Nam ")
, ( 63778, "Nam ")
, ( 63779, "Nam ")
, ( 63780, "Nam ")
, ( 63781, "Nap ")
, ( 63782, "Nap ")
, ( 63783, "Nap ")
, ( 63784, "Nang ")
, ( 63785, "Nang ")
, ( 63786, "Nang ")
, ( 63787, "Nang ")
, ( 63788, "Nang ")
, ( 63789, "Nay ")
, ( 63790, "Nayng ")
, ( 63791, "No ")
, ( 63792, "No ")
, ( 63793, "No ")
, ( 63794, "No ")
, ( 63795, "No ")
, ( 63796, "No ")
, ( 63797, "No ")
, ( 63798, "No ")
, ( 63799, "No ")
, ( 63800, "No ")
, ( 63801, "No ")
, ( 63802, "No ")
, ( 63803, "Nok ")
, ( 63804, "Nok ")
, ( 63805, "Nok ")
, ( 63806, "Nok ")
, ( 63807, "Nok ")
, ( 63808, "Nok ")
, ( 63809, "Non ")
, ( 63810, "Nong ")
, ( 63811, "Nong ")
, ( 63812, "Nong ")
, ( 63813, "Nong ")
, ( 63814, "Noy ")
, ( 63815, "Noy ")
, ( 63816, "Noy ")
, ( 63817, "Noy ")
, ( 63818, "Nwu ")
, ( 63819, "Nwu ")
, ( 63820, "Nwu ")
, ( 63821, "Nwu ")
, ( 63822, "Nwu ")
, ( 63823, "Nwu ")
, ( 63824, "Nwu ")
, ( 63825, "Nwu ")
, ( 63826, "Nuk ")
, ( 63827, "Nuk ")
, ( 63828, "Num ")
, ( 63829, "Nung ")
, ( 63830, "Nung ")
, ( 63831, "Nung ")
, ( 63832, "Nung ")
, ( 63833, "Nung ")
, ( 63834, "Twu ")
, ( 63835, "La ")
, ( 63836, "Lak ")
, ( 63837, "Lak ")
, ( 63838, "Lan ")
, ( 63839, "Lyeng ")
, ( 63840, "Lo ")
, ( 63841, "Lyul ")
, ( 63842, "Li ")
, ( 63843, "Pey ")
, ( 63844, "Pen ")
, ( 63845, "Pyen ")
, ( 63846, "Pwu ")
, ( 63847, "Pwul ")
, ( 63848, "Pi ")
, ( 63849, "Sak ")
, ( 63850, "Sak ")
, ( 63851, "Sam ")
, ( 63852, "Sayk ")
, ( 63853, "Sayng ")
, ( 63854, "Sep ")
, ( 63855, "Sey ")
, ( 63856, "Sway ")
, ( 63857, "Sin ")
, ( 63858, "Sim ")
, ( 63859, "Sip ")
, ( 63860, "Ya ")
, ( 63861, "Yak ")
, ( 63862, "Yak ")
, ( 63863, "Yang ")
, ( 63864, "Yang ")
, ( 63865, "Yang ")
, ( 63866, "Yang ")
, ( 63867, "Yang ")
, ( 63868, "Yang ")
, ( 63869, "Yang ")
, ( 63870, "Yang ")
, ( 63871, "Ye ")
, ( 63872, "Ye ")
, ( 63873, "Ye ")
, ( 63874, "Ye ")
, ( 63875, "Ye ")
, ( 63876, "Ye ")
, ( 63877, "Ye ")
, ( 63878, "Ye ")
, ( 63879, "Ye ")
, ( 63880, "Ye ")
, ( 63881, "Ye ")
, ( 63882, "Yek ")
, ( 63883, "Yek ")
, ( 63884, "Yek ")
, ( 63885, "Yek ")
, ( 63886, "Yen ")
, ( 63887, "Yen ")
, ( 63888, "Yen ")
, ( 63889, "Yen ")
, ( 63890, "Yen ")
, ( 63891, "Yen ")
, ( 63892, "Yen ")
, ( 63893, "Yen ")
, ( 63894, "Yen ")
, ( 63895, "Yen ")
, ( 63896, "Yen ")
, ( 63897, "Yen ")
, ( 63898, "Yen ")
, ( 63899, "Yen ")
, ( 63900, "Yel ")
, ( 63901, "Yel ")
, ( 63902, "Yel ")
, ( 63903, "Yel ")
, ( 63904, "Yel ")
, ( 63905, "Yel ")
, ( 63906, "Yem ")
, ( 63907, "Yem ")
, ( 63908, "Yem ")
, ( 63909, "Yem ")
, ( 63910, "Yem ")
, ( 63911, "Yep ")
, ( 63912, "Yeng ")
, ( 63913, "Yeng ")
, ( 63914, "Yeng ")
, ( 63915, "Yeng ")
, ( 63916, "Yeng ")
, ( 63917, "Yeng ")
, ( 63918, "Yeng ")
, ( 63919, "Yeng ")
, ( 63920, "Yeng ")
, ( 63921, "Yeng ")
, ( 63922, "Yeng ")
, ( 63923, "Yeng ")
, ( 63924, "Yeng ")
, ( 63925, "Yey ")
, ( 63926, "Yey ")
, ( 63927, "Yey ")
, ( 63928, "Yey ")
, ( 63929, "O ")
, ( 63930, "Yo ")
, ( 63931, "Yo ")
, ( 63932, "Yo ")
, ( 63933, "Yo ")
, ( 63934, "Yo ")
, ( 63935, "Yo ")
, ( 63936, "Yo ")
, ( 63937, "Yo ")
, ( 63938, "Yo ")
, ( 63939, "Yo ")
, ( 63940, "Yong ")
, ( 63941, "Wun ")
, ( 63942, "Wen ")
, ( 63943, "Yu ")
, ( 63944, "Yu ")
, ( 63945, "Yu ")
, ( 63946, "Yu ")
, ( 63947, "Yu ")
, ( 63948, "Yu ")
, ( 63949, "Yu ")
, ( 63950, "Yu ")
, ( 63951, "Yu ")
, ( 63952, "Yu ")
, ( 63953, "Yuk ")
, ( 63954, "Yuk ")
, ( 63955, "Yuk ")
, ( 63956, "Yun ")
, ( 63957, "Yun ")
, ( 63958, "Yun ")
, ( 63959, "Yun ")
, ( 63960, "Yul ")
, ( 63961, "Yul ")
, ( 63962, "Yul ")
, ( 63963, "Yul ")
, ( 63964, "Yung ")
, ( 63965, "I ")
, ( 63966, "I ")
, ( 63967, "I ")
, ( 63968, "I ")
, ( 63969, "I ")
, ( 63970, "I ")
, ( 63971, "I ")
, ( 63972, "I ")
, ( 63973, "I ")
, ( 63974, "I ")
, ( 63975, "I ")
, ( 63976, "I ")
, ( 63977, "I ")
, ( 63978, "I ")
, ( 63979, "Ik ")
, ( 63980, "Ik ")
, ( 63981, "In ")
, ( 63982, "In ")
, ( 63983, "In ")
, ( 63984, "In ")
, ( 63985, "In ")
, ( 63986, "In ")
, ( 63987, "In ")
, ( 63988, "Im ")
, ( 63989, "Im ")
, ( 63990, "Im ")
, ( 63991, "Ip ")
, ( 63992, "Ip ")
, ( 63993, "Ip ")
, ( 63994, "Cang ")
, ( 63995, "Cek ")
, ( 63996, "Ci ")
, ( 63997, "Cip ")
, ( 63998, "Cha ")
, ( 63999, "Chek ")
, ( 64000, "Chey ")
, ( 64001, "Thak ")
, ( 64002, "Thak ")
, ( 64003, "Thang ")
, ( 64004, "Thayk ")
, ( 64005, "Thong ")
, ( 64006, "Pho ")
, ( 64007, "Phok ")
, ( 64008, "Hang ")
, ( 64009, "Hang ")
, ( 64010, "Hyen ")
, ( 64011, "Hwak ")
, ( 64012, "Wu ")
, ( 64013, "Huo ")
, ( 64014, "[?] ")
, ( 64015, "[?] ")
, ( 64016, "Zhong ")
, ( 64017, "[?] ")
, ( 64018, "Qing ")
, ( 64019, "[?] ")
, ( 64020, "[?] ")
, ( 64021, "Xi ")
, ( 64022, "Zhu ")
, ( 64023, "Yi ")
, ( 64024, "Li ")
, ( 64025, "Shen ")
, ( 64026, "Xiang ")
, ( 64027, "Fu ")
, ( 64028, "Jing ")
, ( 64029, "Jing ")
, ( 64030, "Yu ")
, ( 64031, "[?] ")
, ( 64032, "Hagi ")
, ( 64033, "[?] ")
, ( 64034, "Zhu ")
, ( 64035, "[?] ")
, ( 64036, "[?] ")
, ( 64037, "Yi ")
, ( 64038, "Du ")
, ( 64039, "[?] ")
, ( 64040, "[?] ")
, ( 64041, "[?] ")
, ( 64042, "Fan ")
, ( 64043, "Si ")
, ( 64044, "Guan ")
, ( 64045, "[?]")
, ( 64046, "[?]")
, ( 64047, "[?]")
, ( 64048, "[?]")
, ( 64049, "[?]")
, ( 64050, "[?]")
, ( 64051, "[?]")
, ( 64052, "[?]")
, ( 64053, "[?]")
, ( 64054, "[?]")
, ( 64055, "[?]")
, ( 64056, "[?]")
, ( 64057, "[?]")
, ( 64058, "[?]")
, ( 64059, "[?]")
, ( 64060, "[?]")
, ( 64061, "[?]")
, ( 64062, "[?]")
, ( 64063, "[?]")
, ( 64064, "[?]")
, ( 64065, "[?]")
, ( 64066, "[?]")
, ( 64067, "[?]")
, ( 64068, "[?]")
, ( 64069, "[?]")
, ( 64070, "[?]")
, ( 64071, "[?]")
, ( 64072, "[?]")
, ( 64073, "[?]")
, ( 64074, "[?]")
, ( 64075, "[?]")
, ( 64076, "[?]")
, ( 64077, "[?]")
, ( 64078, "[?]")
, ( 64079, "[?]")
, ( 64080, "[?]")
, ( 64081, "[?]")
, ( 64082, "[?]")
, ( 64083, "[?]")
, ( 64084, "[?]")
, ( 64085, "[?]")
, ( 64086, "[?]")
, ( 64087, "[?]")
, ( 64088, "[?]")
, ( 64089, "[?]")
, ( 64090, "[?]")
, ( 64091, "[?]")
, ( 64092, "[?]")
, ( 64093, "[?]")
, ( 64094, "[?]")
, ( 64095, "[?]")
, ( 64096, "[?]")
, ( 64097, "[?]")
, ( 64098, "[?]")
, ( 64099, "[?]")
, ( 64100, "[?]")
, ( 64101, "[?]")
, ( 64102, "[?]")
, ( 64103, "[?]")
, ( 64104, "[?]")
, ( 64105, "[?]")
, ( 64106, "[?]")
, ( 64107, "[?]")
, ( 64108, "[?]")
, ( 64109, "[?]")
, ( 64110, "[?]")
, ( 64111, "[?]")
, ( 64112, "[?]")
, ( 64113, "[?]")
, ( 64114, "[?]")
, ( 64115, "[?]")
, ( 64116, "[?]")
, ( 64117, "[?]")
, ( 64118, "[?]")
, ( 64119, "[?]")
, ( 64120, "[?]")
, ( 64121, "[?]")
, ( 64122, "[?]")
, ( 64123, "[?]")
, ( 64124, "[?]")
, ( 64125, "[?]")
, ( 64126, "[?]")
, ( 64127, "[?]")
, ( 64128, "[?]")
, ( 64129, "[?]")
, ( 64130, "[?]")
, ( 64131, "[?]")
, ( 64132, "[?]")
, ( 64133, "[?]")
, ( 64134, "[?]")
, ( 64135, "[?]")
, ( 64136, "[?]")
, ( 64137, "[?]")
, ( 64138, "[?]")
, ( 64139, "[?]")
, ( 64140, "[?]")
, ( 64141, "[?]")
, ( 64142, "[?]")
, ( 64143, "[?]")
, ( 64144, "[?]")
, ( 64145, "[?]")
, ( 64146, "[?]")
, ( 64147, "[?]")
, ( 64148, "[?]")
, ( 64149, "[?]")
, ( 64150, "[?]")
, ( 64151, "[?]")
, ( 64152, "[?]")
, ( 64153, "[?]")
, ( 64154, "[?]")
, ( 64155, "[?]")
, ( 64156, "[?]")
, ( 64157, "[?]")
, ( 64158, "[?]")
, ( 64159, "[?]")
, ( 64160, "[?]")
, ( 64161, "[?]")
, ( 64162, "[?]")
, ( 64163, "[?]")
, ( 64164, "[?]")
, ( 64165, "[?]")
, ( 64166, "[?]")
, ( 64167, "[?]")
, ( 64168, "[?]")
, ( 64169, "[?]")
, ( 64170, "[?]")
, ( 64171, "[?]")
, ( 64172, "[?]")
, ( 64173, "[?]")
, ( 64174, "[?]")
, ( 64175, "[?]")
, ( 64176, "[?]")
, ( 64177, "[?]")
, ( 64178, "[?]")
, ( 64179, "[?]")
, ( 64180, "[?]")
, ( 64181, "[?]")
, ( 64182, "[?]")
, ( 64183, "[?]")
, ( 64184, "[?]")
, ( 64185, "[?]")
, ( 64186, "[?]")
, ( 64187, "[?]")
, ( 64188, "[?]")
, ( 64189, "[?]")
, ( 64190, "[?]")
, ( 64191, "[?]")
, ( 64192, "[?]")
, ( 64193, "[?]")
, ( 64194, "[?]")
, ( 64195, "[?]")
, ( 64196, "[?]")
, ( 64197, "[?]")
, ( 64198, "[?]")
, ( 64199, "[?]")
, ( 64200, "[?]")
, ( 64201, "[?]")
, ( 64202, "[?]")
, ( 64203, "[?]")
, ( 64204, "[?]")
, ( 64205, "[?]")
, ( 64206, "[?]")
, ( 64207, "[?]")
, ( 64208, "[?]")
, ( 64209, "[?]")
, ( 64210, "[?]")
, ( 64211, "[?]")
, ( 64212, "[?]")
, ( 64213, "[?]")
, ( 64214, "[?]")
, ( 64215, "[?]")
, ( 64216, "[?]")
, ( 64217, "[?]")
, ( 64218, "[?]")
, ( 64219, "[?]")
, ( 64220, "[?]")
, ( 64221, "[?]")
, ( 64222, "[?]")
, ( 64223, "[?]")
, ( 64224, "[?]")
, ( 64225, "[?]")
, ( 64226, "[?]")
, ( 64227, "[?]")
, ( 64228, "[?]")
, ( 64229, "[?]")
, ( 64230, "[?]")
, ( 64231, "[?]")
, ( 64232, "[?]")
, ( 64233, "[?]")
, ( 64234, "[?]")
, ( 64235, "[?]")
, ( 64236, "[?]")
, ( 64237, "[?]")
, ( 64238, "[?]")
, ( 64239, "[?]")
, ( 64240, "[?]")
, ( 64241, "[?]")
, ( 64242, "[?]")
, ( 64243, "[?]")
, ( 64244, "[?]")
, ( 64245, "[?]")
, ( 64246, "[?]")
, ( 64247, "[?]")
, ( 64248, "[?]")
, ( 64249, "[?]")
, ( 64250, "[?]")
, ( 64251, "[?]")
, ( 64252, "[?]")
, ( 64253, "[?]")
, ( 64254, "[?]")
, ( 64256, "ff")
, ( 64257, "fi")
, ( 64258, "fl")
, ( 64259, "ffi")
, ( 64260, "ffl")
, ( 64261, "st")
, ( 64262, "st")
, ( 64263, "[?]")
, ( 64264, "[?]")
, ( 64265, "[?]")
, ( 64266, "[?]")
, ( 64267, "[?]")
, ( 64268, "[?]")
, ( 64269, "[?]")
, ( 64270, "[?]")
, ( 64271, "[?]")
, ( 64272, "[?]")
, ( 64273, "[?]")
, ( 64274, "[?]")
, ( 64275, "mn")
, ( 64276, "me")
, ( 64277, "mi")
, ( 64278, "vn")
, ( 64279, "mkh")
, ( 64280, "[?]")
, ( 64281, "[?]")
, ( 64282, "[?]")
, ( 64283, "[?]")
, ( 64284, "[?]")
, ( 64285, "yi")
, ( 64287, "ay")
, ( 64288, "`")
, ( 64290, "d")
, ( 64291, "h")
, ( 64292, "k")
, ( 64293, "l")
, ( 64294, "m")
, ( 64295, "m")
, ( 64296, "t")
, ( 64297, "+")
, ( 64298, "sh")
, ( 64299, "s")
, ( 64300, "sh")
, ( 64301, "s")
, ( 64302, "a")
, ( 64303, "a")
, ( 64305, "b")
, ( 64306, "g")
, ( 64307, "d")
, ( 64308, "h")
, ( 64309, "v")
, ( 64310, "z")
, ( 64311, "[?]")
, ( 64312, "t")
, ( 64313, "y")
, ( 64314, "k")
, ( 64315, "k")
, ( 64316, "l")
, ( 64317, "[?]")
, ( 64318, "l")
, ( 64319, "[?]")
, ( 64320, "n")
, ( 64321, "n")
, ( 64322, "[?]")
, ( 64323, "p")
, ( 64324, "p")
, ( 64325, "[?]")
, ( 64326, "ts")
, ( 64327, "ts")
, ( 64328, "r")
, ( 64329, "sh")
, ( 64330, "t")
, ( 64331, "vo")
, ( 64332, "b")
, ( 64333, "k")
, ( 64334, "p")
, ( 64335, "l")
, ( 64434, "[?]")
, ( 64435, "[?]")
, ( 64436, "[?]")
, ( 64437, "[?]")
, ( 64438, "[?]")
, ( 64439, "[?]")
, ( 64440, "[?]")
, ( 64441, "[?]")
, ( 64442, "[?]")
, ( 64443, "[?]")
, ( 64444, "[?]")
, ( 64445, "[?]")
, ( 64446, "[?]")
, ( 64447, "[?]")
, ( 64448, "[?]")
, ( 64449, "[?]")
, ( 64450, "[?]")
, ( 64451, "[?]")
, ( 64452, "[?]")
, ( 64453, "[?]")
, ( 64454, "[?]")
, ( 64455, "[?]")
, ( 64456, "[?]")
, ( 64457, "[?]")
, ( 64458, "[?]")
, ( 64459, "[?]")
, ( 64460, "[?]")
, ( 64461, "[?]")
, ( 64462, "[?]")
, ( 64463, "[?]")
, ( 64464, "[?]")
, ( 64465, "[?]")
, ( 64466, "[?]")
, ( 64832, "[?]")
, ( 64833, "[?]")
, ( 64834, "[?]")
, ( 64835, "[?]")
, ( 64836, "[?]")
, ( 64837, "[?]")
, ( 64838, "[?]")
, ( 64839, "[?]")
, ( 64840, "[?]")
, ( 64841, "[?]")
, ( 64842, "[?]")
, ( 64843, "[?]")
, ( 64844, "[?]")
, ( 64845, "[?]")
, ( 64846, "[?]")
, ( 64847, "[?]")
, ( 64912, "[?]")
, ( 64913, "[?]")
, ( 64968, "[?]")
, ( 64969, "[?]")
, ( 64970, "[?]")
, ( 64971, "[?]")
, ( 64972, "[?]")
, ( 64973, "[?]")
, ( 64974, "[?]")
, ( 64975, "[?]")
, ( 64976, "[?]")
, ( 64977, "[?]")
, ( 64978, "[?]")
, ( 64979, "[?]")
, ( 64980, "[?]")
, ( 64981, "[?]")
, ( 64982, "[?]")
, ( 64983, "[?]")
, ( 64984, "[?]")
, ( 64985, "[?]")
, ( 64986, "[?]")
, ( 64987, "[?]")
, ( 64988, "[?]")
, ( 64989, "[?]")
, ( 64990, "[?]")
, ( 64991, "[?]")
, ( 64992, "[?]")
, ( 64993, "[?]")
, ( 64994, "[?]")
, ( 64995, "[?]")
, ( 64996, "[?]")
, ( 64997, "[?]")
, ( 64998, "[?]")
, ( 64999, "[?]")
, ( 65000, "[?]")
, ( 65001, "[?]")
, ( 65002, "[?]")
, ( 65003, "[?]")
, ( 65004, "[?]")
, ( 65005, "[?]")
, ( 65006, "[?]")
, ( 65007, "[?]")
, ( 65020, "[?]")
, ( 65021, "[?]")
, ( 65022, "[?]")
, ( 65024, "[?]")
, ( 65025, "[?]")
, ( 65026, "[?]")
, ( 65027, "[?]")
, ( 65028, "[?]")
, ( 65029, "[?]")
, ( 65030, "[?]")
, ( 65031, "[?]")
, ( 65032, "[?]")
, ( 65033, "[?]")
, ( 65034, "[?]")
, ( 65035, "[?]")
, ( 65036, "[?]")
, ( 65037, "[?]")
, ( 65038, "[?]")
, ( 65039, "[?]")
, ( 65040, "[?]")
, ( 65041, "[?]")
, ( 65042, "[?]")
, ( 65043, "[?]")
, ( 65044, "[?]")
, ( 65045, "[?]")
, ( 65046, "[?]")
, ( 65047, "[?]")
, ( 65048, "[?]")
, ( 65049, "[?]")
, ( 65050, "[?]")
, ( 65051, "[?]")
, ( 65052, "[?]")
, ( 65053, "[?]")
, ( 65054, "[?]")
, ( 65055, "[?]")
, ( 65059, "~")
, ( 65060, "[?]")
, ( 65061, "[?]")
, ( 65062, "[?]")
, ( 65063, "[?]")
, ( 65064, "[?]")
, ( 65065, "[?]")
, ( 65066, "[?]")
, ( 65067, "[?]")
, ( 65068, "[?]")
, ( 65069, "[?]")
, ( 65070, "[?]")
, ( 65071, "[?]")
, ( 65072, "..")
, ( 65073, "--")
, ( 65074, "-")
, ( 65075, "_")
, ( 65076, "_")
, ( 65077, "(")
, ( 65078, ") ")
, ( 65079, "{")
, ( 65080, "} ")
, ( 65081, "[")
, ( 65082, "] ")
, ( 65083, "[(")
, ( 65084, ")] ")
, ( 65085, "<<")
, ( 65086, ">> ")
, ( 65087, "<")
, ( 65088, "> ")
, ( 65089, "[")
, ( 65090, "] ")
, ( 65091, "{")
, ( 65092, "}")
, ( 65093, "[?]")
, ( 65094, "[?]")
, ( 65095, "[?]")
, ( 65096, "[?]")
, ( 65104, ",")
, ( 65105, ",")
, ( 65106, ".")
, ( 65108, ";")
, ( 65109, ":")
, ( 65110, "?")
, ( 65111, "!")
, ( 65112, "-")
, ( 65113, "(")
, ( 65114, ")")
, ( 65115, "{")
, ( 65116, "}")
, ( 65117, "{")
, ( 65118, "}")
, ( 65119, "#")
, ( 65120, "&")
, ( 65121, "*")
, ( 65122, "+")
, ( 65123, "-")
, ( 65124, "<")
, ( 65125, ">")
, ( 65126, "=")
, ( 65128, "\\")
, ( 65129, "$")
, ( 65130, "%")
, ( 65131, "@")
, ( 65132, "[?]")
, ( 65133, "[?]")
, ( 65134, "[?]")
, ( 65135, "[?]")
, ( 65139, "[?]")
, ( 65141, "[?]")
, ( 65277, "[?]")
, ( 65278, "[?]")
, ( 65280, "[?]")
, ( 65281, "!")
, ( 65282, "\"")
, ( 65283, "#")
, ( 65284, "$")
, ( 65285, "%")
, ( 65286, "&")
, ( 65287, "'")
, ( 65288, "(")
, ( 65289, ")")
, ( 65290, "*")
, ( 65291, "+")
, ( 65292, ",")
, ( 65293, "-")
, ( 65294, ".")
, ( 65295, "/")
, ( 65296, "0")
, ( 65297, "1")
, ( 65298, "2")
, ( 65299, "3")
, ( 65300, "4")
, ( 65301, "5")
, ( 65302, "6")
, ( 65303, "7")
, ( 65304, "8")
, ( 65305, "9")
, ( 65306, ":")
, ( 65307, ";")
, ( 65308, "<")
, ( 65309, "=")
, ( 65310, ">")
, ( 65311, "?")
, ( 65312, "@")
, ( 65313, "A")
, ( 65314, "B")
, ( 65315, "C")
, ( 65316, "D")
, ( 65317, "E")
, ( 65318, "F")
, ( 65319, "G")
, ( 65320, "H")
, ( 65321, "I")
, ( 65322, "J")
, ( 65323, "K")
, ( 65324, "L")
, ( 65325, "M")
, ( 65326, "N")
, ( 65327, "O")
, ( 65328, "P")
, ( 65329, "Q")
, ( 65330, "R")
, ( 65331, "S")
, ( 65332, "T")
, ( 65333, "U")
, ( 65334, "V")
, ( 65335, "W")
, ( 65336, "X")
, ( 65337, "Y")
, ( 65338, "Z")
, ( 65339, "[")
, ( 65340, "\\")
, ( 65341, "]")
, ( 65342, "^")
, ( 65343, "_")
, ( 65344, "`")
, ( 65345, "a")
, ( 65346, "b")
, ( 65347, "c")
, ( 65348, "d")
, ( 65349, "e")
, ( 65350, "f")
, ( 65351, "g")
, ( 65352, "h")
, ( 65353, "i")
, ( 65354, "j")
, ( 65355, "k")
, ( 65356, "l")
, ( 65357, "m")
, ( 65358, "n")
, ( 65359, "o")
, ( 65360, "p")
, ( 65361, "q")
, ( 65362, "r")
, ( 65363, "s")
, ( 65364, "t")
, ( 65365, "u")
, ( 65366, "v")
, ( 65367, "w")
, ( 65368, "x")
, ( 65369, "y")
, ( 65370, "z")
, ( 65371, "{")
, ( 65372, "|")
, ( 65373, "}")
, ( 65374, "~")
, ( 65375, "[?]")
, ( 65376, "[?]")
, ( 65377, ".")
, ( 65378, "[")
, ( 65379, "]")
, ( 65380, ",")
, ( 65381, "*")
, ( 65382, "wo")
, ( 65383, "a")
, ( 65384, "i")
, ( 65385, "u")
, ( 65386, "e")
, ( 65387, "o")
, ( 65388, "ya")
, ( 65389, "yu")
, ( 65390, "yo")
, ( 65391, "tu")
, ( 65392, "+")
, ( 65393, "a")
, ( 65394, "i")
, ( 65395, "u")
, ( 65396, "e")
, ( 65397, "o")
, ( 65398, "ka")
, ( 65399, "ki")
, ( 65400, "ku")
, ( 65401, "ke")
, ( 65402, "ko")
, ( 65403, "sa")
, ( 65404, "si")
, ( 65405, "su")
, ( 65406, "se")
, ( 65407, "so")
, ( 65408, "ta")
, ( 65409, "ti")
, ( 65410, "tu")
, ( 65411, "te")
, ( 65412, "to")
, ( 65413, "na")
, ( 65414, "ni")
, ( 65415, "nu")
, ( 65416, "ne")
, ( 65417, "no")
, ( 65418, "ha")
, ( 65419, "hi")
, ( 65420, "hu")
, ( 65421, "he")
, ( 65422, "ho")
, ( 65423, "ma")
, ( 65424, "mi")
, ( 65425, "mu")
, ( 65426, "me")
, ( 65427, "mo")
, ( 65428, "ya")
, ( 65429, "yu")
, ( 65430, "yo")
, ( 65431, "ra")
, ( 65432, "ri")
, ( 65433, "ru")
, ( 65434, "re")
, ( 65435, "ro")
, ( 65436, "wa")
, ( 65437, "n")
, ( 65438, ":")
, ( 65439, ";")
, ( 65441, "g")
, ( 65442, "gg")
, ( 65443, "gs")
, ( 65444, "n")
, ( 65445, "nj")
, ( 65446, "nh")
, ( 65447, "d")
, ( 65448, "dd")
, ( 65449, "r")
, ( 65450, "lg")
, ( 65451, "lm")
, ( 65452, "lb")
, ( 65453, "ls")
, ( 65454, "lt")
, ( 65455, "lp")
, ( 65456, "rh")
, ( 65457, "m")
, ( 65458, "b")
, ( 65459, "bb")
, ( 65460, "bs")
, ( 65461, "s")
, ( 65462, "ss")
, ( 65464, "j")
, ( 65465, "jj")
, ( 65466, "c")
, ( 65467, "k")
, ( 65468, "t")
, ( 65469, "p")
, ( 65470, "h")
, ( 65471, "[?]")
, ( 65472, "[?]")
, ( 65473, "[?]")
, ( 65474, "a")
, ( 65475, "ae")
, ( 65476, "ya")
, ( 65477, "yae")
, ( 65478, "eo")
, ( 65479, "e")
, ( 65480, "[?]")
, ( 65481, "[?]")
, ( 65482, "yeo")
, ( 65483, "ye")
, ( 65484, "o")
, ( 65485, "wa")
, ( 65486, "wae")
, ( 65487, "oe")
, ( 65488, "[?]")
, ( 65489, "[?]")
, ( 65490, "yo")
, ( 65491, "u")
, ( 65492, "weo")
, ( 65493, "we")
, ( 65494, "wi")
, ( 65495, "yu")
, ( 65496, "[?]")
, ( 65497, "[?]")
, ( 65498, "eu")
, ( 65499, "yi")
, ( 65500, "i")
, ( 65501, "[?]")
, ( 65502, "[?]")
, ( 65503, "[?]")
, ( 65504, "/C")
, ( 65505, "PS")
, ( 65506, "!")
, ( 65507, "-")
, ( 65508, "|")
, ( 65509, "Y=")
, ( 65510, "W=")
, ( 65511, "[?]")
, ( 65512, "|")
, ( 65513, "-")
, ( 65514, "|")
, ( 65515, "-")
, ( 65516, "|")
, ( 65517, "#")
, ( 65518, "O")
, ( 65519, "[?]")
, ( 65520, "[?]")
, ( 65521, "[?]")
, ( 65522, "[?]")
, ( 65523, "[?]")
, ( 65524, "[?]")
, ( 65525, "[?]")
, ( 65526, "[?]")
, ( 65527, "[?]")
, ( 65528, "[?]")
, ( 65529, "{")
, ( 65530, "|")
, ( 65531, "}") ]
|
timtylin/scholdoc-texmath
|
src/Text/TeXMath/Unicode/ToASCII.hs
|
gpl-2.0
| 166,341 | 0 | 9 | 54,163 | 80,410 | 53,598 | 26,812 | 8,931 | 1 |
module Lamdu.GUI.DefinitionEdit
( make
) where
import qualified Control.Lens as Lens
import Control.Monad.Unit (Unit)
import qualified GUI.Momentu as M
import qualified GUI.Momentu.EventMap as E
import GUI.Momentu.Responsive (Responsive)
import qualified GUI.Momentu.Responsive as Responsive
import qualified GUI.Momentu.State as GuiState
import qualified GUI.Momentu.Widget as Widget
import qualified GUI.Momentu.Widgets.Label as Label
import qualified Lamdu.Config as Config
import qualified Lamdu.Config.Theme.TextColors as TextColors
import qualified Lamdu.GUI.Expr.AssignmentEdit as AssignmentEdit
import qualified Lamdu.GUI.Expr.BuiltinEdit as BuiltinEdit
import qualified Lamdu.GUI.Expr.TagEdit as TagEdit
import Lamdu.GUI.Monad (GuiM)
import qualified Lamdu.GUI.TypeView as TypeView
import qualified Lamdu.GUI.Types as ExprGui
import qualified Lamdu.GUI.WidgetIds as WidgetIds
import qualified Lamdu.I18N.CodeUI as Texts
import Lamdu.Name (Name(..))
import qualified Lamdu.Sugar.Types as Sugar
import Lamdu.Prelude
makeExprDefinition ::
_ =>
ExprGui.Top Sugar.Definition i o ->
ExprGui.Top Sugar.DefinitionExpression i o ->
M.WidgetId ->
GuiM env i o (Responsive o)
makeExprDefinition def bodyExpr myId =
TagEdit.makeBinderTagEdit TextColors.definitionColor (def ^. Sugar.drName)
<&> Responsive.fromWithTextPos
>>= AssignmentEdit.make (bodyExpr ^. Sugar.dePresentationMode) nameEditId (bodyExpr ^. Sugar.deContent)
& GuiState.assignCursor myId nameEditId
where
nameEditId =
def ^. Sugar.drName . Sugar.oTag . Sugar.tagRefTag . Sugar.tagInstance & WidgetIds.fromEntityId
makeBuiltinDefinition ::
_ =>
Sugar.Definition v Name i o (Sugar.Payload v o) ->
Sugar.DefinitionBuiltin Name o ->
M.WidgetId ->
GuiM env i o (M.TextWidget o)
makeBuiltinDefinition def builtin myId =
TagEdit.makeBinderTagEdit TextColors.definitionColor name
M./|/ Label.make " = "
M./|/ BuiltinEdit.make builtin myId
M./-/ ( topLevelSchemeTypeView (builtin ^. Sugar.biType)
& local (M.animIdPrefix .~ animId ++ ["builtinType"])
)
where
name = def ^. Sugar.drName
animId = myId & Widget.toAnimId
make ::
_ =>
ExprGui.Top Sugar.Definition i o ->
M.WidgetId ->
GuiM env i o (Responsive o)
make def myId =
do
env <- Lens.view id
let nextOutdated =
E.keyPresses
(env ^. has . Config.pane . Config.nextOutdatedKeys)
(E.Doc [env ^. has . Texts.gotoNextOutdated])
(def ^. Sugar.drGotoNextOutdated
<&> foldMap (GuiState.updateCursor . WidgetIds.fromEntityId))
case def ^. Sugar.drBody of
Sugar.DefinitionBodyExpression bodyExpr ->
makeExprDefinition def bodyExpr myId
Sugar.DefinitionBodyBuiltin builtin ->
makeBuiltinDefinition def builtin myId <&> Responsive.fromWithTextPos
<&> M.weakerEvents nextOutdated
& local (M.animIdPrefix .~ Widget.toAnimId myId)
topLevelSchemeTypeView :: _ => Sugar.Scheme Name Unit -> GuiM env i o (M.WithTextPos M.View)
topLevelSchemeTypeView scheme =
-- At the definition-level, Schemes can be shown as ordinary
-- types to avoid confusing forall's:
TypeView.make (scheme ^. Sugar.schemeType)
|
lamdu/lamdu
|
src/Lamdu/GUI/DefinitionEdit.hs
|
gpl-3.0
| 3,406 | 0 | 17 | 763 | 881 | 486 | 395 | -1 | -1 |
{-# language DeriveDataTypeable, TemplateHaskell #-}
{-# language TypeFamilies #-}
module Chart where
import qualified Bank
import qualified Spieler
import Data.Time
import Data.Time.LocalTime
import Data.SafeCopy
import Data.Typeable
import Data.Acid
import Control.Monad.State
import Control.Monad.Reader ( ask )
import Data.Colour.Names
import Data.Colour
import Data.Colour.SRGB
import Data.Accessor
import Graphics.Rendering.Chart
import qualified Data.Map as M
import Control.Monad ( void )
-- | minimum interval between chart checkpoints, in seconds
chart_interval = 5 * 60
chart_location = "chart.png"
newtype Chart = Chart [ (UTCTime, Bank.Bank) ]
deriving ( Typeable )
$(deriveSafeCopy 0 'base ''Chart)
empty :: Chart
empty = Chart []
add :: UTCTime -> Bank.Bank -> Update Chart ()
add time b = do
Chart entries <- get
put $ Chart $ (time,b) : entries
snapshot :: Query Chart Chart
snapshot = ask
$(makeAcidic ''Chart [ 'add, 'snapshot ])
names (Chart ch) = M.keys $ foldr M.union M.empty
$ do ( t, Bank.Bank n ) <- ch ; return n
coloured xs = do
let n = length xs
(i, x) <- zip [0 .. ] xs
let t :: Double
t = fromIntegral i / fromIntegral (n-1)
r = t
g = 1 - t
( _, b ) = properFraction $ 4 * t
return ( x, sRGB r g b )
local t = utcToLocalTime ( read "CET" ) t
curve (Chart ch) (n @ ( Spieler.Name s), c) = id
$ plot_lines_style .> line_color ^= opaque c
$ plot_lines_values ^= ( return $ do
( t, Bank.Bank b ) <- ch
Just k <- return $ M.lookup n b
return ( local t , Bank.rating k ) )
$ plot_lines_title ^= s
$ defaultPlotLines
ratings t ch = layout1_title ^=
( "Ratings Chart " ++ "("++ show t ++ ")" )
$ layout1_left_axis ^: laxis_override ^= axisGridHide
$ layout1_right_axis ^: laxis_override ^= axisGridHide
$ layout1_bottom_axis ^: laxis_override ^= axisGridHide
$ layout1_plots ^= ( do nc <- coloured ( names ch )
return $ Left $ toPlot $ curve ch nc )
$ layout1_grid_last ^= False
$ defaultLayout1
write ch = void $ do
now <- getCurrentTime
renderableToPNGFile
( toRenderable $ ratings ( local now ) ch )
800 600 chart_location
|
jwaldmann/mex
|
src/Chart.hs
|
gpl-3.0
| 2,364 | 1 | 23 | 674 | 793 | 412 | 381 | 67 | 1 |
#!/usr/bin/env runhaskell
-- You need the 'json' package: cabal install json
-- Test from the command line:
-- runhaskell Shrdlite.hs < ../examples/medium.json
module Main where
import CombinatorParser
import Control.Monad (foldM, liftM)
import Data.List (findIndex, intersperse, nub)
import qualified Data.Map as M
import Data.Maybe (fromJust, isJust, isNothing)
import ShrdliteGrammar
import Text.JSON
import DataTypes
import Interpreter
import Plan
import Suggestions
main :: IO ()
main = getContents >>= putStrLn . encode . jsonMain . ok . decode
jsonMain :: JSObject JSValue -> JSValue
jsonMain jsinput = makeObj result
where
utterance = ok (valFromObj "utterance" jsinput) :: Utterance
world = ok (fmap (map reverse) $ valFromObj "world" jsinput) :: World
holding = ok (valFromObj "holding" jsinput >>= parseId ) :: Maybe Id
objects = ok (valFromObj "objects" jsinput >>= parseObjects ) :: Objects
algorithm = ok (valFromObj "strategy" jsinput >>= parseStrategy) :: Strategy
trees = parse command utterance :: [Command]
(nonFilteredGoals, ambs) = let (g, a) = unzip $ map findG trees in (concat g, concat a)
goals = filter validGoal $ map clearGoal nonFilteredGoals
validGoal (Or []) = False
validGoal (And []) = False
validGoal _ = True
clearGoal (And list) = And $ filter validGoal list
clearGoal (Or list) = Or $ filter validGoal list
clearGoal other = other
findG tree =
case interpret currentWorld tree of
Left list -> (list, [])
Right amb -> ([], amb)
disambiguity = if null ambs
then []
else map (unwords . getObjectDescription currentWorld) ambs
currentWorld = WState holding (getPositions world) world objects
(solution,stats) = plan algorithm currentWorld (head goals) :: (Maybe (Plan,WorldState), Int)
output = if null trees then "Parse error!"
else
if null goals then "Interpretation error!"
else
if (length goals >= 2 || (not $ null disambiguity))
then "Ambiguous sentence, please provide more information."
else
if isNothing solution then "Planning error!"
else "Success!"
Just (finalPlan, finalWorld) = solution
result = [("utterance", showJSON utterance),
("trees", showJSON (map show trees)),
("goals", if length trees >= 1 then showJSON (map show goals)
else JSNull),
("plan", if (length goals == 1 && null disambiguity) && isJust solution then
showJSON (duplicate finalPlan)
else JSNull),
("output", showJSON output),
("suggestions", if length goals == 1 && isJust solution
then
showJSON $ suggest finalWorld
else
showJSON $ suggest currentWorld),
("disambiguity", if null (filter (not . null) disambiguity)
then JSNull
else showJSON disambiguity),
("states", if length goals == 1 then
showJSON $ stats
else
JSNull) ]
duplicate :: [String] -> [String]
duplicate [] = []
duplicate (x:xs) = ("I do: " ++ x) : x : duplicate xs
-- | Parse a JSValue to a Maybe Id
parseId :: JSValue -> Result (Maybe Id)
parseId JSNull = return Nothing
parseId (JSString str) = return . return . fromJSString $ str
parseStrategy :: JSValue -> Result Strategy
parseStrategy (JSString str) =
case fromJSString str of
"0" -> return AStar
"1" -> return BFS
other -> error other
-- | Parse JSON Object to real Object representation.
parseObjects :: JSObject JSValue -> Result Objects
parseObjects = foldM (\m (id,JSObject o) -> readObj (fromJSObject o)
>>= \obj -> return $ M.insert id obj m) M.empty
. fromJSObject
where
readObj :: [(String,JSValue)]-> Result Object
readObj object = do
form <- look "form" object >>= toForm . fromJSString
color <- look "color" object >>= toColor . fromJSString
size <- look "size" object >>= toSize . fromJSString
return $ Object size color form
toForm form = case form of
"anyform" -> return AnyForm
"brick" -> return Brick
"plank" -> return Plank
"ball" -> return Ball
"pyramid" -> return Pyramid
"box" -> return Box
"table" -> return Table
str -> fail $ "Not a form: " ++ str
toColor col = case col of
"anycolor" -> return AnyColor
"black" -> return Black
"white" -> return White
"blue" -> return Blue
"green" -> return Green
"yellow" -> return Yellow
"red" -> return Red
str -> fail $ "Not a color: " ++ str
toSize size = case size of
"anysize" -> return AnySize
"small" -> return Small
"large" -> return Large
str -> fail $ "Not a size: " ++ str
look str list = maybe (fail "Not in the list")
(\(JSString s) -> return s) $ lookup str list
ok :: Result a -> a
ok (Ok res) = res
ok (Error err) = error err
|
carlostome/shrdlite
|
haskell/Shrdlite.hs
|
gpl-3.0
| 6,148 | 2 | 14 | 2,513 | 1,608 | 826 | 782 | 113 | 18 |
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
-- | Server implementation for mintette
module RSCoin.Mintette.Server
( serve
, handlePeriodFinished
, handleNewPeriod
, handleCheckTx
, handleCheckTxBatch
, handleCommitTx
, handleGetMintettePeriod
, handleGetUtxo
, handleGetLogs
) where
import Control.Lens (view)
import Control.Monad (unless, when)
import Control.Monad.Catch (catch, throwM, try)
import Control.Monad.Extra (unlessM)
import Control.Monad.Trans (lift)
import Data.Bifunctor (first)
import qualified Data.Map as M
import Data.Maybe (fromMaybe)
import qualified Data.Text as T
import Formatting (build, int, sformat, (%))
import Serokell.Util.Common (subList)
import Serokell.Util.Text (listBuilderJSON, listBuilderJSONIndent,
pairBuilder, show')
import Control.TimeWarp.Rpc (ServerT, serverTypeRestriction0,
serverTypeRestriction1,
serverTypeRestriction2,
serverTypeRestriction3)
import qualified RSCoin.Core as C
import RSCoin.Mintette.Acidic (ApplyExtraAddresses (..), ApplyExtraUtxo (..),
CheckNotDoubleSpent (..), CommitTx (..),
FinishPeriod (..), GetLastLBlocks (..),
GetLogs (..), GetPeriodId (..),
GetPreviousMintetteId (..), GetUtxoPset (..),
StartPeriod (..), tidyState)
import RSCoin.Mintette.AcidState (State, query, update)
import RSCoin.Mintette.Env (RuntimeEnv)
import RSCoin.Mintette.Error (MintetteError (..), logMintetteError)
serve :: C.WorkMode m => Int -> State -> RuntimeEnv -> m ()
serve port st env = do
idr1 <- serverTypeRestriction1
idr2 <- serverTypeRestriction1
idr3 <- serverTypeRestriction3
idr4 <- serverTypeRestriction2
idr5 <- serverTypeRestriction2
idr6 <- serverTypeRestriction0
idr7 <- serverTypeRestriction0
idr8 <- serverTypeRestriction1
idr9 <- serverTypeRestriction1
idr10 <- serverTypeRestriction1
idr11 <- serverTypeRestriction1
idr12 <- serverTypeRestriction1
C.serve port
[ C.method (C.RSCMintette C.PeriodFinished) $
idr1 $ handlePeriodFinished env st
, C.method (C.RSCMintette C.AnnounceNewPeriod) $
idr2 $ handleNewPeriod env st
, C.method (C.RSCMintette C.CheckTx) $
idr3 $ handleCheckTx env st
, C.method (C.RSCMintette C.CheckTxBatch) $
idr4 $ handleCheckTxBatch env st
, C.method (C.RSCMintette C.CommitTx) $
idr5 $ handleCommitTx env st
, C.method (C.RSCMintette C.GetMintettePeriod) $
idr6 $ handleGetMintettePeriod st
, C.method (C.RSCDump C.GetMintetteUtxo) $
idr7 $ handleGetUtxo st
, C.method (C.RSCDump C.GetMintetteLogs) $
idr8 $ handleGetLogs st
, C.method (C.RSCMintette C.GetExtraBlocks) $
idr9 $ handleGetExtraBlocks st
, C.method (C.RSCMintette C.GetExtraLogs) $
idr10 $ handleGetExtraLogs st
, C.method (C.RSCMintette C.AnnounceExtraUtxo) $
idr11 $ handleAnnounceExtraUtxo st
, C.method (C.RSCMintette C.AnnounceExtraAddresses) $
idr12 $ handleAnnounceExtraAddresses st
]
type ServerTE m a = ServerT m (Either T.Text a)
toServer :: C.WorkMode m => m a -> ServerTE m a
toServer action = lift $ (Right <$> action) `catch` handler
where
handler (e :: MintetteError) = do
C.logError $ show' e
return $ Left $ show' e
handlePeriodFinished
:: C.WorkMode m
=> RuntimeEnv
-> State
-> C.WithSignature C.PeriodId
-> ServerTE m C.PeriodResult
handlePeriodFinished env st signed =
toServer $
do bankPublicKey <- view C.bankPublicKey <$> C.getNodeContext
unless (C.verifyWithSignature bankPublicKey signed) $
throwM MEInvalidBankSignature
let pId = C.wsValue signed
(curUtxo, curPset) <- query st GetUtxoPset
C.logDebug $
sformat
("Before period end utxo is: " % build % "\nCurrent pset is: " %
build)
curUtxo
curPset
C.logInfo $ sformat ("Period " % int % " has just finished!") pId
res <-
update st $
FinishPeriod C.lBlocksQueryLimit C.actionLogQueryLimit pId env
C.logInfo $
sformat
("Here is PeriodResult:\n " % build % "\n")
res
(curUtxo', curPset') <- query st GetUtxoPset
C.logDebug $
sformat
("After period end utxo is: " % build % "\nCurrent pset is: " %
build)
curUtxo'
curPset'
res <$ tidyState st
handleNewPeriod
:: C.WorkMode m
=> RuntimeEnv -> State -> C.WithSignature C.NewPeriodData -> ServerTE m ()
handleNewPeriod env st signed =
toServer $
do bankPublicKey <- view C.bankPublicKey <$> C.getNodeContext
unless (C.verifyWithSignature bankPublicKey signed) $
throwM MEInvalidBankSignature
let npd = C.wsValue signed
prevMid <- query st GetPreviousMintetteId
C.logInfo $
sformat
("New period has just started, I am mintette #" % build %
" (prevId).\nHere is new period data:\n " % build)
prevMid npd
update st $ StartPeriod npd env
(curUtxo,curPset) <- query st GetUtxoPset
C.logDebug $
sformat
("After start of new period, my utxo: " % build %
"\nCurrent pset is: " % build)
curUtxo curPset
handleCheckTx
:: C.WorkMode m
=> RuntimeEnv
-> State
-> C.Transaction
-> C.AddrId
-> [(C.Address, C.Signature C.Transaction)]
-> ServerTE m C.CheckConfirmation
handleCheckTx env st tx addrId sg =
toServer $
do C.guardTransactionValidity tx
C.logDebug $
sformat ("Checking addrid (" % build % ") from transaction: " % build)
addrId tx
(curUtxo,curPset) <- query st GetUtxoPset
C.logDebug $
sformat
("My current utxo is: " % build % "\nCurrent pset is: " % build)
curUtxo curPset
res <- update st $ CheckNotDoubleSpent tx addrId sg env
C.logInfo $
sformat ("Confirmed addrid (" % build % ") from transaction: " % build)
addrId tx
C.logDebug $ sformat ("Confirmation: " % build) res
return res
handleCheckTxBatch
:: C.WorkMode m
=> RuntimeEnv
-> State
-> C.Transaction
-> M.Map C.AddrId [(C.Address, C.Signature C.Transaction)]
-> ServerTE m (M.Map C.AddrId (Either T.Text C.CheckConfirmation))
handleCheckTxBatch env st tx sigs =
toServer $
do C.guardTransactionValidity tx
when (M.size sigs > length (C.txInputs tx)) $
throwM $ C.BadRequest "Size of batch is more than number of inputs"
C.logDebug $
sformat
("Checking addrids " % build % "of transaction: " % build)
(listBuilderJSON $ M.keys sigs)
tx
(curUtxo, curPset) <- query st GetUtxoPset
C.logDebug $
sformat
("My current utxo is: " % build % "\nCurrent pset is: " % build)
curUtxo
curPset
res <-
M.fromList <$>
mapM
(\(addrId, sig) ->
(addrId, ) <$>
try' (update st $ CheckNotDoubleSpent tx addrId sig env))
(M.assocs sigs)
C.logInfo $
sformat ("Confirmed addrids: " % build) $
listBuilderJSON $ M.keys sigs
return res
where
try'
:: (C.WorkMode m)
=> m a -> m (Either T.Text a)
try' action = do
(res :: Either MintetteError a) <- try action
return $ first show' res
handleCommitTx
:: C.WorkMode m
=> RuntimeEnv
-> State
-> C.Transaction
-> C.CheckConfirmations
-> ServerTE m C.CommitAcknowledgment
handleCommitTx env st tx cc =
toServer $
do C.guardTransactionValidity tx
C.logDebug $
sformat ("There is an attempt to commit transaction (" % build % ").") tx
C.logDebug $ sformat ("Here are confirmations: " % build) cc
res <- update st $ CommitTx tx cc env
C.logInfo $ sformat ("Successfully committed transaction " % build) tx
return res
handleGetMintettePeriod
:: C.WorkMode m
=> State -> ServerTE m (Maybe C.PeriodId)
handleGetMintettePeriod st =
toServer $
do C.logDebug "Querying periodId"
res <- try $ query st GetPeriodId
either onError onSuccess res
where
onError e = do
logMintetteError e "Failed to query periodId"
return Nothing
onSuccess pid = do
C.logInfo $ sformat ("Successfully returning periodId " % int) pid
return $ Just pid
-- Dumping Mintette state
handleGetUtxo :: C.WorkMode m => State -> ServerTE m C.Utxo
handleGetUtxo st =
toServer $
do unlessM C.isTestRun $
throwM $ C.BadRequest "getMintetteUtxo is only available in test run"
C.logDebug "Getting utxo"
(curUtxo, _) <- query st GetUtxoPset
C.logDebug $ sformat ("Current utxo is: " % build) curUtxo
return curUtxo
handleGetLogs
:: C.WorkMode m
=> State -> C.PeriodId -> ServerTE m (Maybe C.ActionLog)
handleGetLogs st pId =
toServer $
do res <- query st $ GetLogs pId
C.logDebug $
sformat ("Getting logs for periodId " % int % ": " % build)
pId (listBuilderJSONIndent 2 . map pairBuilder <$> res)
return res
handleGetExtraBlocks
:: C.WorkMode m
=> State
-> C.WithSignature (C.PeriodId, (Word, Word))
-> ServerTE m [C.LBlock]
handleGetExtraBlocks st signed =
toServer $
do bankPublicKey <- view C.bankPublicKey <$> C.getNodeContext
unless (C.verifyWithSignature bankPublicKey signed) $
throwM MEInvalidBankSignature
let (pId, (lo, hi)) = C.wsValue signed
expectedPId <- query st GetPeriodId
unless (pId == expectedPId) $ throwM $ MEPeriodMismatch expectedPId pId
when (hi - lo > C.actionLogQueryLimit) $
throwM $ C.BadRequest "too many blocks requested"
subList (lo, hi + 1) <$> query st GetLastLBlocks
handleGetExtraLogs
:: C.WorkMode m
=> State
-> C.WithSignature (C.PeriodId, (Word, Word))
-> ServerTE m C.ActionLog
handleGetExtraLogs st signed =
toServer $
do bankPublicKey <- view C.bankPublicKey <$> C.getNodeContext
unless (C.verifyWithSignature bankPublicKey signed) $
throwM MEInvalidBankSignature
let (pId, (lo, hi)) = C.wsValue signed
expectedPId <- query st GetPeriodId
unless (pId == expectedPId) $ throwM $ MEPeriodMismatch expectedPId pId
when (hi - lo > C.actionLogQueryLimit) $
throwM $ C.BadRequest "too many blocks requested"
subList (lo, hi + 1) . fromMaybe [] <$> query st (GetLogs pId)
handleAnnounceExtraUtxo
:: C.WorkMode m
=> State
-> C.WithSignature C.Utxo
-> ServerTE m ()
handleAnnounceExtraUtxo st signed =
toServer $
do bankPublicKey <- view C.bankPublicKey <$> C.getNodeContext
unless (C.verifyWithSignature bankPublicKey signed) $
throwM MEInvalidBankSignature
let utxo = C.wsValue signed
update st $ ApplyExtraUtxo utxo
handleAnnounceExtraAddresses
:: C.WorkMode m
=> State
-> C.WithSignature C.AddressToTxStrategyMap
-> ServerTE m ()
handleAnnounceExtraAddresses st signed =
toServer $
do bankPublicKey <- view C.bankPublicKey <$> C.getNodeContext
unless (C.verifyWithSignature bankPublicKey signed) $
throwM MEInvalidBankSignature
let addresses = C.wsValue signed
update st $ ApplyExtraAddresses addresses
|
input-output-hk/rscoin-haskell
|
src/RSCoin/Mintette/Server.hs
|
gpl-3.0
| 12,489 | 0 | 17 | 4,078 | 3,405 | 1,679 | 1,726 | 311 | 1 |
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
module Table where
import Data.Text
import qualified Data.Map.Strict as Map
-- Derived from unimathsymbols.hs
latexToUnicode :: Map.Map Text Char
latexToUnicode =
[ ("!", '!')
, ("\\#", '#')
, ("\\$", '$')
, ("\\%", '%')
, ("\\&", '&')
, ("(", '(')
, (")", ')')
, ("*", '*')
, ("+", '+')
, (",", ',')
, (".", '.')
, ("/", '/')
, ("0", '0')
, ("1", '1')
, ("2", '2')
, ("3", '3')
, ("4", '4')
, ("5", '5')
, ("6", '6')
, ("7", '7')
, ("8", '8')
, ("9", '9')
, (":", ':')
, (";", ';')
, ("<", '<')
, ("=", '=')
, (">", '>')
, ("?", '?')
, ("@", '@')
, ("A", 'A')
, ("B", 'B')
, ("C", 'C')
, ("D", 'D')
, ("E", 'E')
, ("F", 'F')
, ("G", 'G')
, ("H", 'H')
, ("I", 'I')
, ("J", 'J')
, ("K", 'K')
, ("L", 'L')
, ("M", 'M')
, ("N", 'N')
, ("O", 'O')
, ("P", 'P')
, ("Q", 'Q')
, ("R", 'R')
, ("S", 'S')
, ("T", 'T')
, ("U", 'U')
, ("V", 'V')
, ("W", 'W')
, ("X", 'X')
, ("Y", 'Y')
, ("Z", 'Z')
, ("\\lbrack", '[')
, ("\\backslash", '\\')
, ("\\rbrack", ']')
, ("\\_", '_')
, ("a", 'a')
, ("b", 'b')
, ("c", 'c')
, ("d", 'd')
, ("e", 'e')
, ("f", 'f')
, ("g", 'g')
, ("h", 'h')
, ("i", 'i')
, ("j", 'j')
, ("k", 'k')
, ("l", 'l')
, ("m", 'm')
, ("n", 'n')
, ("o", 'o')
, ("p", 'p')
, ("q", 'q')
, ("r", 'r')
, ("s", 's')
, ("t", 't')
, ("u", 'u')
, ("v", 'v')
, ("w", 'w')
, ("x", 'x')
, ("y", 'y')
, ("z", 'z')
, ("\\{", '{')
, ("|", '|')
, ("\\}", '}')
, ("\\sptilde", '~')
, ("\\cent", '¢')
, ("\\pounds", '£'), ("\\yen", '¥')
, ("\\spddot", '¨')
, ("\\neg", '¬')
, ("\\circledR", '®')
, ("\\pm", '±'), ("\\Micro", 'µ'), ("\\cdotp", '·'), ("\\times", '×')
, ("\\eth", 'ð')
, ("\\div", '÷')
, ("\\imath", 'ı')
, ("\\Zbar", 'Ƶ')
, ("\\jmath", 'ȷ')
, ("\\upAlpha", 'Α')
, ("\\upBeta", 'Β')
, ("\\Gamma", 'Γ')
, ("\\Delta", 'Δ')
, ("\\upEpsilon", 'Ε')
, ("\\upZeta", 'Ζ')
, ("\\upEta", 'Η')
, ("\\Theta", 'Θ')
, ("\\upIota", 'Ι')
, ("\\upKappa", 'Κ')
, ("\\Lambda", 'Λ')
, ("\\upMu", 'Μ')
, ("\\upNu", 'Ν')
, ("\\Xi", 'Ξ')
, ("\\upOmicron", 'Ο')
, ("\\Pi", 'Π')
, ("\\upRho", 'Ρ')
, ("\\Sigma", 'Σ')
, ("\\upTau", 'Τ')
, ("\\Upsilon", 'Υ')
, ("\\Phi", 'Φ')
, ("\\upChi", 'Χ')
, ("\\Psi", 'Ψ')
, ("\\Omega", 'Ω')
, ("\\alpha", 'α')
, ("\\beta", 'β')
, ("\\gamma", 'γ')
, ("\\delta", 'δ')
, ("\\varepsilon", 'ε')
, ("\\zeta", 'ζ')
, ("\\eta", 'η')
, ("\\theta", 'θ')
, ("\\iota", 'ι')
, ("\\kappa", 'κ')
, ("\\lambda", 'λ')
, ("\\mu", 'μ')
, ("\\nu", 'ν')
, ("\\xi", 'ξ')
, ("\\upomicron", 'ο')
, ("\\pi", 'π')
, ("\\rho", 'ρ')
, ("\\varsigma", 'ς')
, ("\\sigma", 'σ')
, ("\\tau", 'τ')
, ("\\upsilon", 'υ')
, ("\\varphi", 'φ')
, ("\\chi", 'χ')
, ("\\psi", 'ψ')
, ("\\omega", 'ω')
, ("\\varbeta", 'ϐ')
, ("\\vartheta", 'ϑ')
, ("\\upUpsilon", 'ϒ')
, ("\\phi", 'ϕ')
, ("\\varpi", 'ϖ')
, ("\\Qoppa", 'Ϙ')
, ("\\qoppa", 'ϙ')
, ("\\Stigma", 'Ϛ')
, ("\\stigma", 'ϛ')
, ("\\Digamma", 'Ϝ')
, ("\\digamma", 'ϝ')
, ("\\Koppa", 'Ϟ')
, ("\\koppa", 'ϟ')
, ("\\Sampi", 'Ϡ')
, ("\\sampi", 'ϡ')
, ("\\varkappa", 'ϰ')
, ("\\varrho", 'ϱ')
, ("\\upvarTheta", 'ϴ')
, ("\\epsilon", 'ϵ')
, ("\\backepsilon", '϶'), ("\\quad", ' '), ("\\horizbar", '―')
, ("\\|", '‖')
, ("\\twolowline", '‗')
, ("\\dagger", '†')
, ("\\ddagger", '‡')
, ("\\bullet", '•')
, ("\\enleadertwodots", '‥')
, ("\\ldots", '…')
, ("\\prime", '′')
, ("\\second", '″')
, ("\\third", '‴')
, ("\\backprime", '‵')
, ("\\backdprime", '‶')
, ("\\backtrprime", '‷')
, ("\\caretinsert", '‸'), ("\\Exclam", '‼')
, ("\\cat", '⁀')
, ("\\hyphenbullet", '⁃')
, ("\\fracslash", '⁄')
, ("\\Question", '⁇')
, ("\\closure", '⁐')
, ("\\fourth", '⁗')
, ("\\:", ' ')
, ("\\euro", '€')
, ("\\mathbb{C}", 'ℂ')
, ("\\Euler", 'ℇ')
, ("\\mathcal{g}", 'ℊ')
, ("\\mathcal{H}", 'ℋ')
, ("\\mathfrak{H}", 'ℌ')
, ("\\mathbb{H}", 'ℍ')
, ("\\Planckconst", 'ℎ')
, ("\\hslash", 'ℏ')
, ("\\mathcal{I}", 'ℐ')
, ("\\Im", 'ℑ')
, ("\\mathcal{L}", 'ℒ')
, ("\\ell", 'ℓ')
, ("\\mathbb{N}", 'ℕ')
, ("\\wp", '℘')
, ("\\mathbb{P}", 'ℙ')
, ("\\mathbb{Q}", 'ℚ')
, ("\\mathcal{R}", 'ℛ')
, ("\\Re", 'ℜ')
, ("\\mathbb{R}", 'ℝ')
, ("\\mathbb{Z}", 'ℤ')
, ("\\tcohm", 'Ω')
, ("\\mho", '℧')
, ("\\mathfrak{Z}", 'ℨ')
, ("\\turnediota", '℩')
, ("\\Angstroem", 'Å')
, ("\\mathcal{B}", 'ℬ')
, ("\\mathfrak{C}", 'ℭ')
, ("\\mathcal{e}", 'ℯ')
, ("\\mathcal{E}", 'ℰ')
, ("\\mathcal{F}", 'ℱ')
, ("\\Finv", 'Ⅎ')
, ("\\mathcal{M}", 'ℳ')
, ("\\mathcal{o}", 'ℴ')
, ("\\aleph", 'ℵ')
, ("\\beth", 'ℶ')
, ("\\gimel", 'ℷ')
, ("\\daleth", 'ℸ')
, ("\\mathbb{\\pi}", 'ℼ')
, ("\\mathbb{\\gamma}", 'ℽ')
, ("\\mathbb{\\Gamma}", 'ℾ')
, ("\\mathbb{\\Pi}", 'ℿ')
, ("\\mathbb{\\Sigma}", '⅀')
, ("\\Game", '⅁')
, ("\\sansLturned", '⅂')
, ("\\sansLmirrored", '⅃')
, ("\\Yup", '⅄')
, ("\\CapitalDifferentialD", 'ⅅ')
, ("\\DifferentialD", 'ⅆ')
, ("\\ExponetialE", 'ⅇ')
, ("\\ComplexI", 'ⅈ')
, ("\\ComplexJ", 'ⅉ')
, ("\\PropertyLine", '⅊')
, ("\\invamp", '⅋')
, ("\\leftarrow", '←')
, ("\\uparrow", '↑')
, ("\\rightarrow", '→')
, ("\\downarrow", '↓')
, ("\\leftrightarrow", '↔')
, ("\\updownarrow", '↕')
, ("\\nwarrow", '↖')
, ("\\nearrow", '↗')
, ("\\searrow", '↘')
, ("\\swarrow", '↙')
, ("\\nleftarrow", '↚')
, ("\\nrightarrow", '↛')
, ("\\leftwavearrow", '↜')
, ("\\rightwavearrow", '↝')
, ("\\twoheadleftarrow", '↞')
, ("\\twoheaduparrow", '↟')
, ("\\twoheadrightarrow", '↠')
, ("\\twoheaddownarrow", '↡')
, ("\\leftarrowtail", '↢')
, ("\\rightarrowtail", '↣')
, ("\\mapsfrom", '↤')
, ("\\MapsUp", '↥')
, ("\\mapsto", '↦')
, ("\\MapsDown", '↧')
, ("\\updownarrowbar", '↨')
, ("\\hookleftarrow", '↩')
, ("\\hookrightarrow", '↪')
, ("\\looparrowleft", '↫')
, ("\\looparrowright", '↬')
, ("\\leftrightsquigarrow", '↭')
, ("\\nleftrightarrow", '↮')
, ("\\lightning", '↯')
, ("\\Lsh", '↰')
, ("\\Rsh", '↱')
, ("\\dlsh", '↲')
, ("\\drsh", '↳')
, ("\\linefeed", '↴')
, ("\\carriagereturn", '↵')
, ("\\curvearrowleft", '↶')
, ("\\curvearrowright", '↷')
, ("\\barovernorthwestarrow", '↸')
, ("\\barleftarrowrightarrowba", '↹')
, ("\\circlearrowleft", '↺')
, ("\\circlearrowright", '↻')
, ("\\leftharpoonup", '↼')
, ("\\leftharpoondown", '↽')
, ("\\upharpoonright", '↾')
, ("\\upharpoonleft", '↿')
, ("\\rightharpoonup", '⇀')
, ("\\rightharpoondown", '⇁')
, ("\\downharpoonright", '⇂')
, ("\\downharpoonleft", '⇃')
, ("\\rightleftarrows", '⇄')
, ("\\updownarrows", '⇅')
, ("\\leftrightarrows", '⇆')
, ("\\leftleftarrows", '⇇')
, ("\\upuparrows", '⇈')
, ("\\rightrightarrows", '⇉')
, ("\\downdownarrows", '⇊')
, ("\\leftrightharpoons", '⇋')
, ("\\rightleftharpoons", '⇌')
, ("\\nLeftarrow", '⇍')
, ("\\nLeftrightarrow", '⇎')
, ("\\nRightarrow", '⇏')
, ("\\Leftarrow", '⇐')
, ("\\Uparrow", '⇑')
, ("\\Rightarrow", '⇒')
, ("\\Downarrow", '⇓')
, ("\\Leftrightarrow", '⇔')
, ("\\Updownarrow", '⇕')
, ("\\Nwarrow", '⇖')
, ("\\Nearrow", '⇗')
, ("\\Searrow", '⇘')
, ("\\Swarrow", '⇙')
, ("\\Lleftarrow", '⇚')
, ("\\Rrightarrow", '⇛')
, ("\\leftsquigarrow", '⇜')
, ("\\rightsquigarrow", '⇝')
, ("\\nHuparrow", '⇞')
, ("\\nHdownarrow", '⇟')
, ("\\dashleftarrow", '⇠')
, ("\\updasharrow", '⇡')
, ("\\dashrightarrow", '⇢')
, ("\\downdasharrow", '⇣')
, ("\\LeftArrowBar", '⇤')
, ("\\RightArrowBar", '⇥')
, ("\\leftwhitearrow", '⇦')
, ("\\upwhitearrow", '⇧')
, ("\\rightwhitearrow", '⇨')
, ("\\downwhitearrow", '⇩')
, ("\\whitearrowupfrombar", '⇪'), ("\\circleonrightarrow", '⇴')
, ("\\downuparrows", '⇵')
, ("\\rightthreearrows", '⇶')
, ("\\nvleftarrow", '⇷')
, ("\\pfun", '⇸')
, ("\\nvleftrightarrow", '⇹')
, ("\\nVleftarrow", '⇺')
, ("\\ffun", '⇻')
, ("\\nVleftrightarrow", '⇼')
, ("\\leftarrowtriangle", '⇽')
, ("\\rightarrowtriangle", '⇾')
, ("\\leftrightarrowtriangle", '⇿')
, ("\\forall", '∀')
, ("\\complement", '∁')
, ("\\partial", '∂')
, ("\\exists", '∃')
, ("\\nexists", '∄')
, ("\\varnothing", '∅')
, ("\\increment", '∆')
, ("\\nabla", '∇')
, ("\\in", '∈')
, ("\\notin", '∉')
, ("\\smallin", '∊')
, ("\\ni", '∋')
, ("\\nni", '∌')
, ("\\smallni", '∍')
, ("\\QED", '∎')
, ("\\prod", '∏')
, ("\\coprod", '∐')
, ("\\sum", '∑')
, ("-", '−')
, ("\\mp", '∓')
, ("\\dotplus", '∔')
, ("\\slash", '∕')
, ("\\smallsetminus", '∖')
, ("\\ast", '∗')
, ("\\circ", '∘')
, ("\\bullet", '∙')
, ("\\sqrt", '√')
, ("\\sqrt[3]", '∛')
, ("\\sqrt[4]", '∜')
, ("\\propto", '∝')
, ("\\infty", '∞')
, ("\\rightangle", '∟')
, ("\\angle", '∠')
, ("\\measuredangle", '∡')
, ("\\sphericalangle", '∢')
, ("\\mid", '∣')
, ("\\nmid", '∤')
, ("\\parallel", '∥')
, ("\\nparallel", '∦')
, ("\\wedge", '∧')
, ("\\vee", '∨')
, ("\\cap", '∩')
, ("\\cup", '∪')
, ("\\int", '∫')
, ("\\iint", '∬')
, ("\\iiint", '∭')
, ("\\oint", '∮')
, ("\\oiint", '∯')
, ("\\oiiint", '∰')
, ("\\intclockwise", '∱')
, ("\\varointclockwise", '∲')
, ("\\ointctrclockwise", '∳')
, ("\\therefore", '∴')
, ("\\because", '∵')
, (":", '∶')
, ("\\Proportion", '∷')
, ("\\dotminus", '∸')
, ("\\eqcolon", '∹')
, ("\\dotsminusdots", '∺')
, ("\\kernelcontraction", '∻')
, ("\\sim", '∼')
, ("\\backsim", '∽')
, ("\\invlazys", '∾')
, ("\\AC", '∿')
, ("\\wr", '≀')
, ("\\nsim", '≁')
, ("\\eqsim", '≂')
, ("\\simeq", '≃')
, ("\\nsimeq", '≄')
, ("\\cong", '≅')
, ("\\simneqq", '≆')
, ("\\ncong", '≇')
, ("\\approx", '≈')
, ("\\napprox", '≉')
, ("\\approxeq", '≊')
, ("\\approxident", '≋')
, ("\\backcong", '≌')
, ("\\asymp", '≍')
, ("\\Bumpeq", '≎')
, ("\\bumpeq", '≏')
, ("\\doteq", '≐')
, ("\\Doteq", '≑')
, ("\\fallingdotseq", '≒')
, ("\\risingdotseq", '≓')
, ("\\coloneq", '≔')
, ("\\eqcolon", '≕')
, ("\\eqcirc", '≖')
, ("\\circeq", '≗')
, ("\\arceq", '≘')
, ("\\corresponds", '≙')
, ("\\veeeq", '≚')
, ("\\stareq", '≛')
, ("\\triangleq", '≜')
, ("\\eqdef", '≝')
, ("\\measeq", '≞')
, ("\\questeq", '≟')
, ("\\neq", '≠')
, ("\\equiv", '≡')
, ("\\nequiv", '≢')
, ("\\Equiv", '≣')
, ("\\leq", '≤')
, ("\\geq", '≥')
, ("\\leqq", '≦')
, ("\\geqq", '≧')
, ("\\lneqq", '≨')
, ("\\gneqq", '≩')
, ("\\ll", '≪')
, ("\\gg", '≫')
, ("\\between", '≬')
, ("\\notasymp", '≭')
, ("\\nless", '≮')
, ("\\ngtr", '≯')
, ("\\nleq", '≰')
, ("\\ngeq", '≱')
, ("\\lesssim", '≲')
, ("\\gtrsim", '≳')
, ("\\NotLessTilde", '≴')
, ("\\NotGreaterTilde", '≵')
, ("\\lessgtr", '≶')
, ("\\gtrless", '≷')
, ("\\nlessgtr", '≸')
, ("\\NotGreaterLess", '≹')
, ("\\prec", '≺')
, ("\\succ", '≻')
, ("\\preccurlyeq", '≼')
, ("\\succcurlyeq", '≽')
, ("\\precsim", '≾')
, ("\\succsim", '≿')
, ("\\nprec", '⊀')
, ("\\nsucc", '⊁')
, ("\\subset", '⊂')
, ("\\supset", '⊃')
, ("\\nsubset", '⊄')
, ("\\nsupset", '⊅')
, ("\\subseteq", '⊆')
, ("\\supseteq", '⊇')
, ("\\nsubseteq", '⊈')
, ("\\nsupseteq", '⊉')
, ("\\subsetneq", '⊊')
, ("\\supsetneq", '⊋')
, ("\\cupleftarrow", '⊌')
, ("\\cupdot", '⊍')
, ("\\uplus", '⊎')
, ("\\sqsubset", '⊏')
, ("\\sqsupset", '⊐')
, ("\\sqsubseteq", '⊑')
, ("\\sqsupseteq", '⊒')
, ("\\sqcap", '⊓')
, ("\\sqcup", '⊔')
, ("\\oplus", '⊕')
, ("\\ominus", '⊖')
, ("\\otimes", '⊗')
, ("\\oslash", '⊘')
, ("\\odot", '⊙')
, ("\\circledcirc", '⊚')
, ("\\circledast", '⊛')
, ("\\circledequal", '⊜')
, ("\\circleddash", '⊝')
, ("\\boxplus", '⊞')
, ("\\boxminus", '⊟')
, ("\\boxtimes", '⊠')
, ("\\boxdot", '⊡')
, ("\\vdash", '⊢')
, ("\\dashv", '⊣')
, ("\\top", '⊤')
, ("\\bot", '⊥')
, ("\\assert", '⊦')
, ("\\models", '⊧')
, ("\\vDash", '⊨')
, ("\\Vdash", '⊩')
, ("\\Vvdash", '⊪')
, ("\\VDash", '⊫')
, ("\\nvdash", '⊬')
, ("\\nvDash", '⊭')
, ("\\nVdash", '⊮')
, ("\\nVDash", '⊯')
, ("\\prurel", '⊰')
, ("\\scurel", '⊱')
, ("\\vartriangleleft", '⊲')
, ("\\vartriangleright", '⊳')
, ("\\trianglelefteq", '⊴')
, ("\\trianglerighteq", '⊵')
, ("\\multimapdotbothA", '⊶')
, ("\\multimapdotbothB", '⊷')
, ("\\multimap", '⊸')
, ("\\hermitmatrix", '⊹')
, ("\\intercal", '⊺')
, ("\\veebar", '⊻')
, ("\\barwedge", '⊼')
, ("\\barvee", '⊽')
, ("\\measuredrightangle", '⊾')
, ("\\varlrtriangle", '⊿')
, ("\\bigwedge", '⋀')
, ("\\bigvee", '⋁')
, ("\\bigcap", '⋂')
, ("\\bigcup", '⋃')
, ("\\diamond", '⋄')
, ("\\cdot", '⋅')
, ("\\star", '⋆')
, ("\\divideontimes", '⋇')
, ("\\bowtie", '⋈')
, ("\\ltimes", '⋉')
, ("\\rtimes", '⋊')
, ("\\leftthreetimes", '⋋')
, ("\\rightthreetimes", '⋌')
, ("\\backsimeq", '⋍')
, ("\\curlyvee", '⋎')
, ("\\curlywedge", '⋏')
, ("\\Subset", '⋐')
, ("\\Supset", '⋑')
, ("\\Cap", '⋒')
, ("\\Cup", '⋓')
, ("\\pitchfork", '⋔')
, ("\\hash", '⋕')
, ("\\lessdot", '⋖')
, ("\\gtrdot", '⋗')
, ("\\lll", '⋘')
, ("\\ggg", '⋙')
, ("\\lesseqgtr", '⋚')
, ("\\gtreqless", '⋛')
, ("\\eqless", '⋜')
, ("\\eqgtr", '⋝')
, ("\\curlyeqprec", '⋞')
, ("\\curlyeqsucc", '⋟')
, ("\\npreceq", '⋠')
, ("\\nsucceq", '⋡')
, ("\\nsqsubseteq", '⋢')
, ("\\nsqsupseteq", '⋣')
, ("\\sqsubsetneq", '⋤')
, ("\\sqsupsetneq", '⋥')
, ("\\lnsim", '⋦')
, ("\\gnsim", '⋧')
, ("\\precnsim", '⋨')
, ("\\succnsim", '⋩')
, ("\\ntriangleleft", '⋪')
, ("\\ntriangleright", '⋫')
, ("\\ntrianglelefteq", '⋬')
, ("\\ntrianglerighteq", '⋭')
, ("\\vdots", '⋮')
, ("\\cdots", '⋯')
, ("\\iddots", '⋰')
, ("\\ddots", '⋱')
, ("\\disin", '⋲')
, ("\\varisins", '⋳')
, ("\\isins", '⋴')
, ("\\isindot", '⋵')
, ("\\barin", '⋶')
, ("\\isinobar", '⋷')
, ("\\isinvb", '⋸')
, ("\\isinE", '⋹')
, ("\\nisd", '⋺')
, ("\\varnis", '⋻')
, ("\\nis", '⋼')
, ("\\varniobar", '⋽')
, ("\\niobar", '⋾')
, ("\\bagmember", '⋿')
, ("\\diameter", '⌀')
, ("\\house", '⌂')
, ("\\varbarwedge", '⌅')
, ("\\vardoublebarwedge", '⌆')
, ("\\lceil", '⌈')
, ("\\rceil", '⌉')
, ("\\lfloor", '⌊')
, ("\\rfloor", '⌋')
, ("\\invneg", '⌐')
, ("\\wasylozenge", '⌑')
, ("\\profline", '⌒')
, ("\\profsurf", '⌓')
, ("\\viewdata", '⌗')
, ("\\turnednot", '⌙')
, ("\\ulcorner", '⌜')
, ("\\urcorner", '⌝')
, ("\\llcorner", '⌞')
, ("\\lrcorner", '⌟')
, ("\\inttop", '⌠')
, ("\\intbottom", '⌡')
, ("\\frown", '⌢')
, ("\\smile", '⌣')
, ("\\varhexagonlrbonds", '⌬')
, ("\\conictaper", '⌲')
, ("\\topbot", '⌶')
, ("\\APLinv", '⌹'), ("\\obar", '⌽'), ("\\notslash", '⌿')
, ("\\notbackslash", '⍀')
, ("\\APLleftarrowbox", '⍇')
, ("\\APLrightarrowbox", '⍈')
, ("\\invdiameter", '⍉')
, ("\\APLuparrowbox", '⍐')
, ("\\APLboxupcaret", '⍓'), ("\\APLdownarrowbox", '⍗'), ("\\APLcomment", '⍝')
, ("\\APLinput", '⍞')
, ("\\APLlog", '⍟')
, ("\\APLboxquestion", '⍰'), ("\\rangledownzigzagarrow", '⍼')
, ("\\hexagon", '⎔')
, ("\\lparenuend", '⎛')
, ("\\lparenextender", '⎜')
, ("\\lparenlend", '⎝')
, ("\\rparenuend", '⎞')
, ("\\rparenextender", '⎟')
, ("\\rparenlend", '⎠')
, ("\\lbrackuend", '⎡')
, ("\\lbrackextender", '⎢')
, ("\\lbracklend", '⎣')
, ("\\rbrackuend", '⎤')
, ("\\rbrackextender", '⎥')
, ("\\rbracklend", '⎦')
, ("\\lbraceuend", '⎧')
, ("\\lbracemid", '⎨')
, ("\\lbracelend", '⎩')
, ("\\vbraceextender", '⎪')
, ("\\rbraceuend", '⎫')
, ("\\rbracemid", '⎬')
, ("\\rbracelend", '⎭')
, ("\\intextender", '⎮')
, ("\\harrowextender", '⎯')
, ("\\lmoustache", '⎰')
, ("\\rmoustache", '⎱')
, ("\\sumtop", '⎲')
, ("\\sumbottom", '⎳')
, ("\\overbracket", '⎴')
, ("\\underbracket", '⎵')
, ("\\bbrktbrk", '⎶')
, ("\\sqrtbottom", '⎷')
, ("\\lvboxline", '⎸')
, ("\\rvboxline", '⎹')
, ("\\varcarriagereturn", '⏎'), ("\\overparen", '⏜')
, ("\\underparen", '⏝')
, ("\\overbrace", '⏞')
, ("\\underbrace", '⏟')
, ("\\obrbrak", '⏠')
, ("\\ubrbrak", '⏡')
, ("\\trapezium", '⏢')
, ("\\benzenr", '⏣')
, ("\\strns", '⏤')
, ("\\fltns", '⏥')
, ("\\accurrent", '⏦')
, ("\\elinters", '⏧'), ("\\bdtriplevdash", '┆')
, ("\\blockuphalf", '▀')
, ("\\blocklowhalf", '▄')
, ("\\blockfull", '█')
, ("\\blocklefthalf", '▌')
, ("\\blockrighthalf", '▐')
, ("\\blockqtrshaded", '░')
, ("\\blockhalfshaded", '▒')
, ("\\blockthreeqtrshaded", '▓')
, ("\\mdlgblksquare", '■')
, ("\\mdlgwhtsquare", '□')
, ("\\squoval", '▢')
, ("\\blackinwhitesquare", '▣')
, ("\\squarehfill", '▤')
, ("\\squarevfill", '▥')
, ("\\squarehvfill", '▦')
, ("\\squarenwsefill", '▧')
, ("\\squareneswfill", '▨')
, ("\\squarecrossfill", '▩')
, ("\\smblksquare", '▪')
, ("\\smwhtsquare", '▫')
, ("\\hrectangleblack", '▬')
, ("\\hrectangle", '▭')
, ("\\vrectangleblack", '▮')
, ("\\vrectangle", '▯')
, ("\\parallelogramblack", '▰')
, ("\\parallelogram", '▱')
, ("\\bigblacktriangleup", '▲')
, ("\\bigtriangleup", '△')
, ("\\blacktriangleup", '▴')
, ("\\smalltriangleup", '▵')
, ("\\RHD", '▶')
, ("\\rhd", '▷')
, ("\\blacktriangleright", '▸')
, ("\\smalltriangleright", '▹')
, ("\\blackpointerright", '►')
, ("\\whitepointerright", '▻')
, ("\\bigblacktriangledown", '▼')
, ("\\bigtriangledown", '▽')
, ("\\blacktriangledown", '▾')
, ("\\smalltriangledown", '▿')
, ("\\LHD", '◀')
, ("\\lhd", '◁')
, ("\\blacktriangleleft", '◂')
, ("\\smalltriangleleft", '◃')
, ("\\blackpointerleft", '◄')
, ("\\whitepointerleft", '◅')
, ("\\Diamondblack", '◆')
, ("\\Diamond", '◇')
, ("\\blackinwhitediamond", '◈')
, ("\\fisheye", '◉')
, ("\\lozenge", '◊')
, ("\\Circle", '○')
, ("\\dottedcircle", '◌')
, ("\\circlevertfill", '◍')
, ("\\bullseye", '◎')
, ("\\CIRCLE", '●')
, ("\\LEFTcircle", '◐')
, ("\\RIGHTcircle", '◑')
, ("\\circlebottomhalfblack", '◒')
, ("\\circletophalfblack", '◓')
, ("\\circleurquadblack", '◔')
, ("\\blackcircleulquadwhite", '◕')
, ("\\LEFTCIRCLE", '◖')
, ("\\RIGHTCIRCLE", '◗')
, ("\\inversebullet", '◘')
, ("\\inversewhitecircle", '◙')
, ("\\invwhiteupperhalfcircle", '◚')
, ("\\invwhitelowerhalfcircle", '◛')
, ("\\ularc", '◜')
, ("\\urarc", '◝')
, ("\\lrarc", '◞')
, ("\\llarc", '◟')
, ("\\topsemicircle", '◠')
, ("\\botsemicircle", '◡')
, ("\\lrblacktriangle", '◢')
, ("\\llblacktriangle", '◣')
, ("\\ulblacktriangle", '◤')
, ("\\urblacktriangle", '◥')
, ("\\smwhtcircle", '◦')
, ("\\squareleftblack", '◧')
, ("\\squarerightblack", '◨')
, ("\\squareulblack", '◩')
, ("\\squarelrblack", '◪')
, ("\\boxbar", '◫')
, ("\\trianglecdot", '◬')
, ("\\triangleleftblack", '◭')
, ("\\trianglerightblack", '◮')
, ("\\lgwhtcircle", '◯')
, ("\\squareulquad", '◰')
, ("\\squarellquad", '◱')
, ("\\squarelrquad", '◲')
, ("\\squareurquad", '◳')
, ("\\circleulquad", '◴')
, ("\\circlellquad", '◵')
, ("\\circlelrquad", '◶')
, ("\\circleurquad", '◷')
, ("\\ultriangle", '◸')
, ("\\urtriangle", '◹')
, ("\\lltriangle", '◺')
, ("\\square", '◻')
, ("\\blacksquare", '◼')
, ("\\mdsmwhtsquare", '◽')
, ("\\mdsmblksquare", '◾')
, ("\\lrtriangle", '◿')
, ("\\bigstar", '★')
, ("\\bigwhitestar", '☆')
, ("\\Sun", '☉'), ("\\Square", '☐')
, ("\\CheckedBox", '☑')
, ("\\XBox", '☒')
, ("\\steaming", '☕')
, ("\\pointright", '☞')
, ("\\skull", '☠')
, ("\\danger", '☡')
, ("\\radiation", '☢')
, ("\\biohazard", '☣')
, ("\\yinyang", '☯')
, ("\\frownie", '☹')
, ("\\smiley", '☺')
, ("\\blacksmiley", '☻')
, ("\\sun", '☼')
, ("\\rightmoon", '☽')
, ("\\leftmoon", '☾')
, ("\\mercury", '☿')
, ("\\female", '♀')
, ("\\earth", '♁')
, ("\\male", '♂')
, ("\\jupiter", '♃')
, ("\\saturn", '♄')
, ("\\uranus", '♅')
, ("\\neptune", '♆')
, ("\\pluto", '♇')
, ("\\aries", '♈')
, ("\\taurus", '♉')
, ("\\gemini", '♊')
, ("\\cancer", '♋')
, ("\\leo", '♌')
, ("\\virgo", '♍')
, ("\\libra", '♎')
, ("\\scorpio", '♏')
, ("\\sagittarius", '♐')
, ("\\capricornus", '♑')
, ("\\aquarius", '♒')
, ("\\pisces", '♓')
, ("\\spadesuit", '♠')
, ("\\heartsuit", '♡')
, ("\\diamondsuit", '♢')
, ("\\clubsuit", '♣')
, ("\\varspadesuit", '♤')
, ("\\varheartsuit", '♥')
, ("\\vardiamondsuit", '♦')
, ("\\varclubsuit", '♧')
, ("\\quarternote", '♩')
, ("\\eighthnote", '♪')
, ("\\twonotes", '♫')
, ("\\sixteenthnote", '♬')
, ("\\flat", '♭')
, ("\\natural", '♮')
, ("\\sharp", '♯')
, ("\\recycle", '♻')
, ("\\acidfree", '♾')
, ("\\dicei", '⚀')
, ("\\diceii", '⚁')
, ("\\diceiii", '⚂')
, ("\\diceiv", '⚃')
, ("\\dicev", '⚄')
, ("\\dicevi", '⚅')
, ("\\circledrightdot", '⚆')
, ("\\circledtwodots", '⚇')
, ("\\blackcircledrightdot", '⚈')
, ("\\blackcircledtwodots", '⚉')
, ("\\anchor", '⚓')
, ("\\swords", '⚔')
, ("\\warning", '⚠')
, ("\\Hermaphrodite", '⚥')
, ("\\medcirc", '⚪')
, ("\\medbullet", '⚫')
, ("\\mdsmwhtcircle", '⚬')
, ("\\neuter", '⚲')
, ("\\pencil", '✎')
, ("\\checkmark", '✓')
, ("\\ballotx", '✗')
, ("\\maltese", '✠')
, ("\\circledstar", '✪')
, ("\\varstar", '✶')
, ("\\dingasterisk", '✽')
, ("\\lbrbrak", '❲')
, ("\\rbrbrak", '❳')
, ("\\draftingarrow", '➛')
, ("\\arrowbullet", '➢')
, ("\\threedangle", '⟀')
, ("\\whiteinwhitetriangle", '⟁')
, ("\\perp", '⟂')
, ("\\subsetcirc", '⟃')
, ("\\supsetcirc", '⟄')
, ("\\Lbag", '⟅')
, ("\\Rbag", '⟆')
, ("\\veedot", '⟇')
, ("\\bsolhsub", '⟈')
, ("\\suphsol", '⟉'), ("\\longdivision", '⟌')
, ("\\Diamonddot", '⟐')
, ("\\wedgedot", '⟑')
, ("\\upin", '⟒')
, ("\\pullback", '⟓')
, ("\\pushout", '⟔')
, ("\\leftouterjoin", '⟕')
, ("\\rightouterjoin", '⟖')
, ("\\fullouterjoin", '⟗')
, ("\\bigbot", '⟘')
, ("\\bigtop", '⟙')
, ("\\DashVDash", '⟚')
, ("\\dashVdash", '⟛')
, ("\\multimapinv", '⟜')
, ("\\vlongdash", '⟝')
, ("\\longdashv", '⟞')
, ("\\cirbot", '⟟')
, ("\\lozengeminus", '⟠')
, ("\\concavediamond", '⟡')
, ("\\concavediamondtickleft", '⟢')
, ("\\concavediamondtickright", '⟣')
, ("\\whitesquaretickleft", '⟤')
, ("\\whitesquaretickright", '⟥')
, ("\\llbracket", '⟦')
, ("\\rrbracket", '⟧')
, ("\\langle", '⟨')
, ("\\rangle", '⟩')
, ("\\lang", '⟪')
, ("\\rang", '⟫')
, ("\\Lbrbrak", '⟬')
, ("\\Rbrbrak", '⟭')
, ("\\lgroup", '⟮')
, ("\\rgroup", '⟯')
, ("\\UUparrow", '⟰')
, ("\\DDownarrow", '⟱')
, ("\\acwgapcirclearrow", '⟲')
, ("\\cwgapcirclearrow", '⟳')
, ("\\rightarrowonoplus", '⟴')
, ("\\longleftarrow", '⟵')
, ("\\longrightarrow", '⟶')
, ("\\longleftrightarrow", '⟷')
, ("\\Longleftarrow", '⟸')
, ("\\Longrightarrow", '⟹')
, ("\\Longleftrightarrow", '⟺')
, ("\\longmapsfrom", '⟻')
, ("\\longmapsto", '⟼')
, ("\\Longmapsfrom", '⟽')
, ("\\Longmapsto", '⟾')
, ("\\longrightsquigarrow", '⟿')
, ("\\psur", '⤀')
, ("\\nVtwoheadrightarrow", '⤁')
, ("\\nvLeftarrow", '⤂')
, ("\\nvRightarrow", '⤃')
, ("\\nvLeftrightarrow", '⤄')
, ("\\twoheadmapsto", '⤅')
, ("\\Mapsfrom", '⤆')
, ("\\Mapsto", '⤇')
, ("\\downarrowbarred", '⤈')
, ("\\uparrowbarred", '⤉')
, ("\\Uuparrow", '⤊')
, ("\\Ddownarrow", '⤋')
, ("\\leftbkarrow", '⤌')
, ("\\rightbkarrow", '⤍')
, ("\\leftdbkarrow", '⤎')
, ("\\dbkarow", '⤏')
, ("\\drbkarow", '⤐')
, ("\\rightdotarrow", '⤑')
, ("\\UpArrowBar", '⤒')
, ("\\DownArrowBar", '⤓')
, ("\\pinj", '⤔')
, ("\\finj", '⤕')
, ("\\bij", '⤖')
, ("\\nvtwoheadrightarrowtail", '⤗')
, ("\\nVtwoheadrightarrowtail", '⤘')
, ("\\lefttail", '⤙')
, ("\\righttail", '⤚')
, ("\\leftdbltail", '⤛')
, ("\\rightdbltail", '⤜')
, ("\\diamondleftarrow", '⤝')
, ("\\rightarrowdiamond", '⤞')
, ("\\diamondleftarrowbar", '⤟')
, ("\\barrightarrowdiamond", '⤠')
, ("\\nwsearrow", '⤡')
, ("\\neswarrow", '⤢')
, ("\\hknwarrow", '⤣')
, ("\\hknearrow", '⤤')
, ("\\hksearow", '⤥')
, ("\\hkswarow", '⤦')
, ("\\tona", '⤧')
, ("\\toea", '⤨')
, ("\\tosa", '⤩')
, ("\\towa", '⤪')
, ("\\rdiagovfdiag", '⤫')
, ("\\fdiagovrdiag", '⤬')
, ("\\seovnearrow", '⤭')
, ("\\neovsearrow", '⤮')
, ("\\fdiagovnearrow", '⤯')
, ("\\rdiagovsearrow", '⤰')
, ("\\neovnwarrow", '⤱')
, ("\\nwovnearrow", '⤲')
, ("\\leadsto", '⤳')
, ("\\uprightcurvearrow", '⤴')
, ("\\downrightcurvedarrow", '⤵')
, ("\\leftdowncurvedarrow", '⤶')
, ("\\rightdowncurvedarrow", '⤷')
, ("\\cwrightarcarrow", '⤸')
, ("\\acwleftarcarrow", '⤹')
, ("\\acwoverarcarrow", '⤺')
, ("\\acwunderarcarrow", '⤻')
, ("\\curvearrowrightminus", '⤼')
, ("\\curvearrowleftplus", '⤽')
, ("\\cwundercurvearrow", '⤾')
, ("\\ccwundercurvearrow", '⤿')
, ("\\acwcirclearrow", '⥀')
, ("\\cwcirclearrow", '⥁')
, ("\\rightarrowshortleftarrow", '⥂')
, ("\\leftarrowshortrightarrow", '⥃')
, ("\\shortrightarrowleftarrow", '⥄')
, ("\\rightarrowplus", '⥅')
, ("\\leftarrowplus", '⥆')
, ("\\rightarrowx", '⥇')
, ("\\leftrightarrowcircle", '⥈')
, ("\\twoheaduparrowcircle", '⥉')
, ("\\leftrightharpoon", '⥊')
, ("\\rightleftharpoon", '⥋')
, ("\\updownharpoonrightleft", '⥌')
, ("\\updownharpoonleftright", '⥍')
, ("\\leftrightharpoonup", '⥎')
, ("\\rightupdownharpoon", '⥏')
, ("\\leftrightharpoondown", '⥐')
, ("\\leftupdownharpoon", '⥑')
, ("\\LeftVectorBar", '⥒')
, ("\\RightVectorBar", '⥓')
, ("\\RightUpVectorBar", '⥔')
, ("\\RightDownVectorBar", '⥕')
, ("\\DownLeftVectorBar", '⥖')
, ("\\DownRightVectorBar", '⥗')
, ("\\LeftUpVectorBar", '⥘')
, ("\\LeftDownVectorBar", '⥙')
, ("\\LeftTeeVector", '⥚')
, ("\\RightTeeVector", '⥛')
, ("\\RightUpTeeVector", '⥜')
, ("\\RightDownTeeVector", '⥝')
, ("\\DownLeftTeeVector", '⥞')
, ("\\DownRightTeeVector", '⥟')
, ("\\LeftUpTeeVector", '⥠')
, ("\\LeftDownTeeVector", '⥡')
, ("\\leftleftharpoons", '⥢')
, ("\\upupharpoons", '⥣')
, ("\\rightrightharpoons", '⥤')
, ("\\downdownharpoons", '⥥')
, ("\\leftrightharpoonsup", '⥦')
, ("\\leftrightharpoonsdown", '⥧')
, ("\\rightleftharpoonsup", '⥨')
, ("\\rightleftharpoonsdown", '⥩')
, ("\\leftbarharpoon", '⥪')
, ("\\barleftharpoon", '⥫')
, ("\\rightbarharpoon", '⥬')
, ("\\barrightharpoon", '⥭')
, ("\\updownharpoons", '⥮')
, ("\\downupharpoons", '⥯')
, ("\\rightimply", '⥰')
, ("\\equalrightarrow", '⥱')
, ("\\similarrightarrow", '⥲')
, ("\\leftarrowsimilar", '⥳')
, ("\\rightarrowsimilar", '⥴')
, ("\\rightarrowapprox", '⥵')
, ("\\ltlarr", '⥶')
, ("\\leftarrowless", '⥷')
, ("\\gtrarr", '⥸')
, ("\\subrarr", '⥹')
, ("\\leftarrowsubset", '⥺')
, ("\\suplarr", '⥻')
, ("\\strictfi", '⥼')
, ("\\strictif", '⥽')
, ("\\upfishtail", '⥾')
, ("\\downfishtail", '⥿')
, ("\\VERT", '⦀')
, ("\\spot", '⦁')
, ("\\typecolon", '⦂')
, ("\\lBrace", '⦃')
, ("\\rBrace", '⦄')
, ("\\Lparen", '⦅')
, ("\\Rparen", '⦆')
, ("\\limg", '⦇')
, ("\\rimg", '⦈')
, ("\\lblot", '⦉')
, ("\\rblot", '⦊')
, ("\\lbrackubar", '⦋')
, ("\\rbrackubar", '⦌')
, ("\\lbrackultick", '⦍')
, ("\\rbracklrtick", '⦎')
, ("\\lbracklltick", '⦏')
, ("\\rbrackurtick", '⦐')
, ("\\langledot", '⦑')
, ("\\rangledot", '⦒')
, ("\\lparenless", '⦓')
, ("\\rparengtr", '⦔')
, ("\\Lparengtr", '⦕')
, ("\\Rparenless", '⦖')
, ("\\lblkbrbrak", '⦗')
, ("\\rblkbrbrak", '⦘')
, ("\\fourvdots", '⦙')
, ("\\vzigzag", '⦚')
, ("\\measuredangleleft", '⦛')
, ("\\rightanglesqr", '⦜')
, ("\\rightanglemdot", '⦝')
, ("\\angles", '⦞')
, ("\\angdnr", '⦟')
, ("\\gtlpar", '⦠')
, ("\\sphericalangleup", '⦡')
, ("\\turnangle", '⦢')
, ("\\revangle", '⦣')
, ("\\angleubar", '⦤')
, ("\\revangleubar", '⦥')
, ("\\wideangledown", '⦦')
, ("\\wideangleup", '⦧')
, ("\\measanglerutone", '⦨')
, ("\\measanglelutonw", '⦩')
, ("\\measanglerdtose", '⦪')
, ("\\measangleldtosw", '⦫')
, ("\\measangleurtone", '⦬')
, ("\\measangleultonw", '⦭')
, ("\\measangledrtose", '⦮')
, ("\\measangledltosw", '⦯')
, ("\\revemptyset", '⦰')
, ("\\emptysetobar", '⦱')
, ("\\emptysetocirc", '⦲')
, ("\\emptysetoarr", '⦳')
, ("\\emptysetoarrl", '⦴')
, ("\\circlehbar", '⦵')
, ("\\circledvert", '⦶')
, ("\\circledparallel", '⦷')
, ("\\circledbslash", '⦸')
, ("\\operp", '⦹')
, ("\\obot", '⦺')
, ("\\olcross", '⦻')
, ("\\odotslashdot", '⦼')
, ("\\uparrowoncircle", '⦽')
, ("\\circledwhitebullet", '⦾')
, ("\\circledbullet", '⦿')
, ("\\circledless", '⧀')
, ("\\circledgtr", '⧁')
, ("\\cirscir", '⧂')
, ("\\cirE", '⧃')
, ("\\boxslash", '⧄')
, ("\\boxbslash", '⧅')
, ("\\boxast", '⧆')
, ("\\boxcircle", '⧇')
, ("\\boxbox", '⧈')
, ("\\boxonbox", '⧉')
, ("\\triangleodot", '⧊')
, ("\\triangleubar", '⧋')
, ("\\triangles", '⧌')
, ("\\triangleserifs", '⧍')
, ("\\rtriltri", '⧎')
, ("\\LeftTriangleBar", '⧏')
, ("\\RightTriangleBar", '⧐')
, ("\\lfbowtie", '⧑')
, ("\\rfbowtie", '⧒')
, ("\\fbowtie", '⧓')
, ("\\lftimes", '⧔')
, ("\\rftimes", '⧕')
, ("\\hourglass", '⧖')
, ("\\blackhourglass", '⧗')
, ("\\lvzigzag", '⧘')
, ("\\rvzigzag", '⧙')
, ("\\Lvzigzag", '⧚')
, ("\\Rvzigzag", '⧛')
, ("\\iinfin", '⧜')
, ("\\tieinfty", '⧝')
, ("\\nvinfty", '⧞')
, ("\\multimapboth", '⧟')
, ("\\laplac", '⧠')
, ("\\lrtriangleeq", '⧡')
, ("\\shuffle", '⧢')
, ("\\eparsl", '⧣')
, ("\\smeparsl", '⧤')
, ("\\eqvparsl", '⧥')
, ("\\gleichstark", '⧦')
, ("\\thermod", '⧧')
, ("\\downtriangleleftblack", '⧨')
, ("\\downtrianglerightblack", '⧩')
, ("\\blackdiamonddownarrow", '⧪')
, ("\\blacklozenge", '⧫')
, ("\\circledownarrow", '⧬')
, ("\\blackcircledownarrow", '⧭')
, ("\\errbarsquare", '⧮')
, ("\\errbarblacksquare", '⧯')
, ("\\errbardiamond", '⧰')
, ("\\errbarblackdiamond", '⧱')
, ("\\errbarcircle", '⧲')
, ("\\errbarblackcircle", '⧳')
, ("\\ruledelayed", '⧴')
, ("\\setminus", '⧵')
, ("\\dsol", '⧶')
, ("\\rsolbar", '⧷')
, ("\\xsol", '⧸')
, ("\\zhide", '⧹')
, ("\\doubleplus", '⧺')
, ("\\tripleplus", '⧻')
, ("\\lcurvyangle", '⧼')
, ("\\rcurvyangle", '⧽')
, ("\\tplus", '⧾')
, ("\\tminus", '⧿')
, ("\\bigodot", '⨀')
, ("\\bigoplus", '⨁')
, ("\\bigotimes", '⨂')
, ("\\bigcupdot", '⨃')
, ("\\biguplus", '⨄')
, ("\\bigsqcap", '⨅')
, ("\\bigsqcup", '⨆')
, ("\\conjquant", '⨇')
, ("\\disjquant", '⨈')
, ("\\varprod", '⨉')
, ("\\modtwosum", '⨊')
, ("\\sumint", '⨋')
, ("\\iiiint", '⨌')
, ("\\intbar", '⨍')
, ("\\intBar", '⨎')
, ("\\fint", '⨏')
, ("\\cirfnint", '⨐')
, ("\\awint", '⨑')
, ("\\rppolint", '⨒')
, ("\\scpolint", '⨓')
, ("\\npolint", '⨔')
, ("\\pointint", '⨕')
, ("\\sqint", '⨖')
, ("\\intlarhk", '⨗')
, ("\\intx", '⨘')
, ("\\intcap", '⨙')
, ("\\intcup", '⨚')
, ("\\upint", '⨛')
, ("\\lowint", '⨜')
, ("\\Join", '⨝')
, ("\\bigtriangleleft", '⨞')
, ("\\zcmp", '⨟')
, ("\\zpipe", '⨠')
, ("\\zproject", '⨡')
, ("\\ringplus", '⨢')
, ("\\plushat", '⨣')
, ("\\simplus", '⨤')
, ("\\plusdot", '⨥')
, ("\\plussim", '⨦')
, ("\\plussubtwo", '⨧')
, ("\\plustrif", '⨨')
, ("\\commaminus", '⨩')
, ("\\minusdot", '⨪')
, ("\\minusfdots", '⨫')
, ("\\minusrdots", '⨬')
, ("\\opluslhrim", '⨭')
, ("\\oplusrhrim", '⨮')
, ("\\vectimes", '⨯')
, ("\\dottimes", '⨰')
, ("\\timesbar", '⨱')
, ("\\btimes", '⨲')
, ("\\smashtimes", '⨳')
, ("\\otimeslhrim", '⨴')
, ("\\otimesrhrim", '⨵')
, ("\\otimeshat", '⨶')
, ("\\Otimes", '⨷')
, ("\\odiv", '⨸')
, ("\\triangleplus", '⨹')
, ("\\triangleminus", '⨺')
, ("\\triangletimes", '⨻')
, ("\\intprod", '⨼')
, ("\\intprodr", '⨽')
, ("\\fcmp", '⨾')
, ("\\amalg", '⨿')
, ("\\capdot", '⩀')
, ("\\uminus", '⩁')
, ("\\barcup", '⩂')
, ("\\barcap", '⩃')
, ("\\capwedge", '⩄')
, ("\\cupvee", '⩅')
, ("\\cupovercap", '⩆')
, ("\\capovercup", '⩇')
, ("\\cupbarcap", '⩈')
, ("\\capbarcup", '⩉')
, ("\\twocups", '⩊')
, ("\\twocaps", '⩋')
, ("\\closedvarcup", '⩌')
, ("\\closedvarcap", '⩍')
, ("\\Sqcap", '⩎')
, ("\\Sqcup", '⩏')
, ("\\closedvarcupsmashprod", '⩐')
, ("\\wedgeodot", '⩑')
, ("\\veeodot", '⩒')
, ("\\Wedge", '⩓')
, ("\\Vee", '⩔')
, ("\\wedgeonwedge", '⩕')
, ("\\veeonvee", '⩖')
, ("\\bigslopedvee", '⩗')
, ("\\bigslopedwedge", '⩘')
, ("\\veeonwedge", '⩙')
, ("\\wedgemidvert", '⩚')
, ("\\veemidvert", '⩛')
, ("\\midbarwedge", '⩜')
, ("\\midbarvee", '⩝')
, ("\\doublebarwedge", '⩞')
, ("\\wedgebar", '⩟')
, ("\\wedgedoublebar", '⩠')
, ("\\varveebar", '⩡')
, ("\\doublebarvee", '⩢')
, ("\\veedoublebar", '⩣')
, ("\\dsub", '⩤')
, ("\\rsub", '⩥')
, ("\\eqdot", '⩦')
, ("\\dotequiv", '⩧')
, ("\\equivVert", '⩨')
, ("\\equivVvert", '⩩')
, ("\\dotsim", '⩪')
, ("\\simrdots", '⩫')
, ("\\simminussim", '⩬')
, ("\\congdot", '⩭')
, ("\\asteq", '⩮')
, ("\\hatapprox", '⩯')
, ("\\approxeqq", '⩰')
, ("\\eqqplus", '⩱')
, ("\\pluseqq", '⩲')
, ("\\eqqsim", '⩳')
, ("\\Coloneqq", '⩴')
, ("\\Equal", '⩵')
, ("\\Same", '⩶')
, ("\\ddotseq", '⩷')
, ("\\equivDD", '⩸')
, ("\\ltcir", '⩹')
, ("\\gtcir", '⩺')
, ("\\ltquest", '⩻')
, ("\\gtquest", '⩼')
, ("\\leqslant", '⩽')
, ("\\geqslant", '⩾')
, ("\\lesdot", '⩿')
, ("\\gesdot", '⪀')
, ("\\lesdoto", '⪁')
, ("\\gesdoto", '⪂')
, ("\\lesdotor", '⪃')
, ("\\gesdotol", '⪄')
, ("\\lessapprox", '⪅')
, ("\\gtrapprox", '⪆')
, ("\\lneq", '⪇')
, ("\\gneq", '⪈')
, ("\\lnapprox", '⪉')
, ("\\gnapprox", '⪊')
, ("\\lesseqqgtr", '⪋')
, ("\\gtreqqless", '⪌')
, ("\\lsime", '⪍')
, ("\\gsime", '⪎')
, ("\\lsimg", '⪏')
, ("\\gsiml", '⪐')
, ("\\lgE", '⪑')
, ("\\glE", '⪒')
, ("\\lesges", '⪓')
, ("\\gesles", '⪔')
, ("\\eqslantless", '⪕')
, ("\\eqslantgtr", '⪖')
, ("\\elsdot", '⪗')
, ("\\egsdot", '⪘')
, ("\\eqqless", '⪙')
, ("\\eqqgtr", '⪚')
, ("\\eqqslantless", '⪛')
, ("\\eqqslantgtr", '⪜')
, ("\\simless", '⪝')
, ("\\simgtr", '⪞')
, ("\\simlE", '⪟')
, ("\\simgE", '⪠')
, ("\\NestedLessLess", '⪡')
, ("\\NestedGreaterGreater", '⪢')
, ("\\partialmeetcontraction", '⪣')
, ("\\glj", '⪤')
, ("\\gla", '⪥')
, ("\\leftslice", '⪦')
, ("\\rightslice", '⪧')
, ("\\lescc", '⪨')
, ("\\gescc", '⪩')
, ("\\smt", '⪪')
, ("\\lat", '⪫')
, ("\\smte", '⪬')
, ("\\late", '⪭')
, ("\\bumpeqq", '⪮')
, ("\\preceq", '⪯')
, ("\\succeq", '⪰')
, ("\\precneq", '⪱')
, ("\\succneq", '⪲')
, ("\\preceqq", '⪳')
, ("\\succeqq", '⪴')
, ("\\precneqq", '⪵')
, ("\\succneqq", '⪶')
, ("\\precapprox", '⪷')
, ("\\succapprox", '⪸')
, ("\\precnapprox", '⪹')
, ("\\succnapprox", '⪺')
, ("\\llcurly", '⪻')
, ("\\ggcurly", '⪼')
, ("\\subsetdot", '⪽')
, ("\\supsetdot", '⪾')
, ("\\subsetplus", '⪿')
, ("\\supsetplus", '⫀')
, ("\\submult", '⫁')
, ("\\supmult", '⫂')
, ("\\subedot", '⫃')
, ("\\supedot", '⫄')
, ("\\subseteqq", '⫅')
, ("\\supseteqq", '⫆')
, ("\\subsim", '⫇')
, ("\\supsim", '⫈')
, ("\\subsetapprox", '⫉')
, ("\\supsetapprox", '⫊')
, ("\\subsetneqq", '⫋')
, ("\\supsetneqq", '⫌')
, ("\\lsqhook", '⫍')
, ("\\rsqhook", '⫎')
, ("\\csub", '⫏')
, ("\\csup", '⫐')
, ("\\csube", '⫑')
, ("\\csupe", '⫒')
, ("\\subsup", '⫓')
, ("\\supsub", '⫔')
, ("\\subsub", '⫕')
, ("\\supsup", '⫖')
, ("\\suphsub", '⫗')
, ("\\supdsub", '⫘')
, ("\\forkv", '⫙')
, ("\\topfork", '⫚')
, ("\\mlcp", '⫛')
, ("\\forks", '⫝̸')
, ("\\forksnot", '⫝')
, ("\\shortlefttack", '⫞')
, ("\\shortdowntack", '⫟')
, ("\\shortuptack", '⫠')
, ("\\perps", '⫡')
, ("\\vDdash", '⫢')
, ("\\dashV", '⫣')
, ("\\Dashv", '⫤')
, ("\\DashV", '⫥')
, ("\\varVdash", '⫦')
, ("\\Barv", '⫧')
, ("\\vBar", '⫨')
, ("\\vBarv", '⫩')
, ("\\Top", '⫪')
, ("\\Bot", '⫫')
, ("\\Not", '⫬')
, ("\\bNot", '⫭')
, ("\\revnmid", '⫮')
, ("\\cirmid", '⫯')
, ("\\midcir", '⫰')
, ("\\topcir", '⫱')
, ("\\nhpar", '⫲')
, ("\\parsim", '⫳')
, ("\\interleave", '⫴')
, ("\\nhVvert", '⫵')
, ("\\threedotcolon", '⫶')
, ("\\lllnest", '⫷')
, ("\\gggnest", '⫸')
, ("\\leqqslant", '⫹')
, ("\\geqqslant", '⫺')
, ("\\trslash", '⫻')
, ("\\biginterleave", '⫼')
, ("\\sslash", '⫽')
, ("\\talloblong", '⫾')
, ("\\bigtalloblong", '⫿')
, ("\\squaretopblack", '⬒')
, ("\\squarebotblack", '⬓')
, ("\\squareurblack", '⬔')
, ("\\squarellblack", '⬕')
, ("\\diamondleftblack", '⬖')
, ("\\diamondrightblack", '⬗')
, ("\\diamondtopblack", '⬘')
, ("\\diamondbotblack", '⬙')
, ("\\dottedsquare", '⬚')
, ("\\blacksquare", '⬛')
, ("\\square", '⬜')
, ("\\vysmblksquare", '⬝')
, ("\\vysmwhtsquare", '⬞')
, ("\\pentagonblack", '⬟')
, ("\\pentagon", '⬠')
, ("\\varhexagon", '⬡')
, ("\\varhexagonblack", '⬢')
, ("\\hexagonblack", '⬣')
, ("\\lgblkcircle", '⬤')
, ("\\mdblkdiamond", '⬥')
, ("\\mdwhtdiamond", '⬦')
, ("\\mdblklozenge", '⬧')
, ("\\mdwhtlozenge", '⬨')
, ("\\smblkdiamond", '⬩')
, ("\\smblklozenge", '⬪')
, ("\\smwhtlozenge", '⬫')
, ("\\blkhorzoval", '⬬')
, ("\\whthorzoval", '⬭')
, ("\\blkvertoval", '⬮')
, ("\\whtvertoval", '⬯')
, ("\\circleonleftarrow", '⬰')
, ("\\leftthreearrows", '⬱')
, ("\\leftarrowonoplus", '⬲')
, ("\\longleftsquigarrow", '⬳')
, ("\\nvtwoheadleftarrow", '⬴')
, ("\\nVtwoheadleftarrow", '⬵')
, ("\\twoheadmapsfrom", '⬶')
, ("\\twoheadleftdbkarrow", '⬷')
, ("\\leftdotarrow", '⬸')
, ("\\nvleftarrowtail", '⬹')
, ("\\nVleftarrowtail", '⬺')
, ("\\twoheadleftarrowtail", '⬻')
, ("\\nvtwoheadleftarrowtail", '⬼')
, ("\\nVtwoheadleftarrowtail", '⬽')
, ("\\leftarrowx", '⬾')
, ("\\leftcurvedarrow", '⬿')
, ("\\equalleftarrow", '⭀')
, ("\\bsimilarleftarrow", '⭁')
, ("\\leftarrowbackapprox", '⭂')
, ("\\rightarrowgtr", '⭃')
, ("\\rightarrowsupset", '⭄')
, ("\\LLeftarrow", '⭅')
, ("\\RRightarrow", '⭆')
, ("\\bsimilarrightarrow", '⭇')
, ("\\rightarrowbackapprox", '⭈')
, ("\\similarleftarrow", '⭉')
, ("\\leftarrowapprox", '⭊')
, ("\\leftarrowbsimilar", '⭋')
, ("\\rightarrowbsimilar", '⭌')
, ("\\medwhitestar", '⭐')
, ("\\medblackstar", '⭑')
, ("\\smwhitestar", '⭒')
, ("\\rightpentagonblack", '⭓')
, ("\\rightpentagon", '⭔')
, ("\\postalmark", '〒')
, ("\\lbrbrak", '〔')
, ("\\rbrbrak", '〕')
, ("\\Lbrbrak", '〘')
, ("\\Rbrbrak", '〙')
, ("\\hzigzag", '〰'), ("\\mathbf{A}", '𝐀')
, ("\\mathbf{B}", '𝐁')
, ("\\mathbf{C}", '𝐂')
, ("\\mathbf{D}", '𝐃')
, ("\\mathbf{E}", '𝐄')
, ("\\mathbf{F}", '𝐅')
, ("\\mathbf{G}", '𝐆')
, ("\\mathbf{H}", '𝐇')
, ("\\mathbf{I}", '𝐈')
, ("\\mathbf{J}", '𝐉')
, ("\\mathbf{K}", '𝐊')
, ("\\mathbf{L}", '𝐋')
, ("\\mathbf{M}", '𝐌')
, ("\\mathbf{N}", '𝐍')
, ("\\mathbf{O}", '𝐎')
, ("\\mathbf{P}", '𝐏')
, ("\\mathbf{Q}", '𝐐')
, ("\\mathbf{R}", '𝐑')
, ("\\mathbf{S}", '𝐒')
, ("\\mathbf{T}", '𝐓')
, ("\\mathbf{U}", '𝐔')
, ("\\mathbf{V}", '𝐕')
, ("\\mathbf{W}", '𝐖')
, ("\\mathbf{X}", '𝐗')
, ("\\mathbf{Y}", '𝐘')
, ("\\mathbf{Z}", '𝐙')
, ("\\mathbf{a}", '𝐚')
, ("\\mathbf{b}", '𝐛')
, ("\\mathbf{c}", '𝐜')
, ("\\mathbf{d}", '𝐝')
, ("\\mathbf{e}", '𝐞')
, ("\\mathbf{f}", '𝐟')
, ("\\mathbf{g}", '𝐠')
, ("\\mathbf{h}", '𝐡')
, ("\\mathbf{i}", '𝐢')
, ("\\mathbf{j}", '𝐣')
, ("\\mathbf{k}", '𝐤')
, ("\\mathbf{l}", '𝐥')
, ("\\mathbf{m}", '𝐦')
, ("\\mathbf{n}", '𝐧')
, ("\\mathbf{o}", '𝐨')
, ("\\mathbf{p}", '𝐩')
, ("\\mathbf{q}", '𝐪')
, ("\\mathbf{r}", '𝐫')
, ("\\mathbf{s}", '𝐬')
, ("\\mathbf{t}", '𝐭')
, ("\\mathbf{u}", '𝐮')
, ("\\mathbf{v}", '𝐯')
, ("\\mathbf{w}", '𝐰')
, ("\\mathbf{x}", '𝐱')
, ("\\mathbf{y}", '𝐲')
, ("\\mathbf{z}", '𝐳')
, ("\\mathbfit{A}", '𝑨')
, ("\\mathbfit{B}", '𝑩')
, ("\\mathbfit{C}", '𝑪')
, ("\\mathbfit{D}", '𝑫')
, ("\\mathbfit{E}", '𝑬')
, ("\\mathbfit{F}", '𝑭')
, ("\\mathbfit{G}", '𝑮')
, ("\\mathbfit{H}", '𝑯')
, ("\\mathbfit{I}", '𝑰')
, ("\\mathbfit{J}", '𝑱')
, ("\\mathbfit{K}", '𝑲')
, ("\\mathbfit{L}", '𝑳')
, ("\\mathbfit{M}", '𝑴')
, ("\\mathbfit{N}", '𝑵')
, ("\\mathbfit{O}", '𝑶')
, ("\\mathbfit{P}", '𝑷')
, ("\\mathbfit{Q}", '𝑸')
, ("\\mathbfit{R}", '𝑹')
, ("\\mathbfit{S}", '𝑺')
, ("\\mathbfit{T}", '𝑻')
, ("\\mathbfit{U}", '𝑼')
, ("\\mathbfit{V}", '𝑽')
, ("\\mathbfit{W}", '𝑾')
, ("\\mathbfit{X}", '𝑿')
, ("\\mathbfit{Y}", '𝒀')
, ("\\mathbfit{Z}", '𝒁')
, ("\\mathbfit{a}", '𝒂')
, ("\\mathbfit{b}", '𝒃')
, ("\\mathbfit{c}", '𝒄')
, ("\\mathbfit{d}", '𝒅')
, ("\\mathbfit{e}", '𝒆')
, ("\\mathbfit{f}", '𝒇')
, ("\\mathbfit{g}", '𝒈')
, ("\\mathbfit{h}", '𝒉')
, ("\\mathbfit{i}", '𝒊')
, ("\\mathbfit{j}", '𝒋')
, ("\\mathbfit{k}", '𝒌')
, ("\\mathbfit{l}", '𝒍')
, ("\\mathbfit{m}", '𝒎')
, ("\\mathbfit{n}", '𝒏')
, ("\\mathbfit{o}", '𝒐')
, ("\\mathbfit{p}", '𝒑')
, ("\\mathbfit{q}", '𝒒')
, ("\\mathbfit{r}", '𝒓')
, ("\\mathbfit{s}", '𝒔')
, ("\\mathbfit{t}", '𝒕')
, ("\\mathbfit{u}", '𝒖')
, ("\\mathbfit{v}", '𝒗')
, ("\\mathbfit{w}", '𝒘')
, ("\\mathbfit{x}", '𝒙')
, ("\\mathbfit{y}", '𝒚')
, ("\\mathbfit{z}", '𝒛')
, ("\\mathcal{A}", '𝒜')
, ("\\mathcal{C}", '𝒞')
, ("\\mathcal{D}", '𝒟')
, ("\\mathcal{G}", '𝒢')
, ("\\mathcal{J}", '𝒥')
, ("\\mathcal{K}", '𝒦')
, ("\\mathcal{N}", '𝒩')
, ("\\mathcal{O}", '𝒪')
, ("\\mathcal{P}", '𝒫')
, ("\\mathcal{Q}", '𝒬')
, ("\\mathcal{S}", '𝒮')
, ("\\mathcal{T}", '𝒯')
, ("\\mathcal{U}", '𝒰')
, ("\\mathcal{V}", '𝒱')
, ("\\mathcal{W}", '𝒲')
, ("\\mathcal{X}", '𝒳')
, ("\\mathcal{Y}", '𝒴')
, ("\\mathcal{Z}", '𝒵')
, ("\\mathcal{a}", '𝒶')
, ("\\mathcal{b}", '𝒷')
, ("\\mathcal{c}", '𝒸')
, ("\\mathcal{d}", '𝒹')
, ("\\mathcal{f}", '𝒻')
, ("\\mathcal{h}", '𝒽')
, ("\\mathcal{i}", '𝒾')
, ("\\mathcal{j}", '𝒿')
, ("\\mathcal{k}", '𝓀')
, ("\\mathcal{l}", '𝓁')
, ("\\mathcal{m}", '𝓂')
, ("\\mathcal{n}", '𝓃')
, ("\\mathcal{p}", '𝓅')
, ("\\mathcal{q}", '𝓆')
, ("\\mathcal{r}", '𝓇')
, ("\\mathcal{s}", '𝓈')
, ("\\mathcal{t}", '𝓉')
, ("\\mathcal{u}", '𝓊')
, ("\\mathcal{v}", '𝓋')
, ("\\mathcal{w}", '𝓌')
, ("\\mathcal{x}", '𝓍')
, ("\\mathcal{y}", '𝓎')
, ("\\mathcal{z}", '𝓏')
, ("\\mbfscrA", '𝓐')
, ("\\mbfscrB", '𝓑')
, ("\\mbfscrC", '𝓒')
, ("\\mbfscrD", '𝓓')
, ("\\mbfscrE", '𝓔')
, ("\\mbfscrF", '𝓕')
, ("\\mbfscrG", '𝓖')
, ("\\mbfscrH", '𝓗')
, ("\\mbfscrI", '𝓘')
, ("\\mbfscrJ", '𝓙')
, ("\\mbfscrK", '𝓚')
, ("\\mbfscrL", '𝓛')
, ("\\mbfscrM", '𝓜')
, ("\\mbfscrN", '𝓝')
, ("\\mbfscrO", '𝓞')
, ("\\mbfscrP", '𝓟')
, ("\\mbfscrQ", '𝓠')
, ("\\mbfscrR", '𝓡')
, ("\\mbfscrS", '𝓢')
, ("\\mbfscrT", '𝓣')
, ("\\mbfscrU", '𝓤')
, ("\\mbfscrV", '𝓥')
, ("\\mbfscrW", '𝓦')
, ("\\mbfscrX", '𝓧')
, ("\\mbfscrY", '𝓨')
, ("\\mbfscrZ", '𝓩')
, ("\\mbfscra", '𝓪')
, ("\\mbfscrb", '𝓫')
, ("\\mbfscrc", '𝓬')
, ("\\mbfscrd", '𝓭')
, ("\\mbfscre", '𝓮')
, ("\\mbfscrf", '𝓯')
, ("\\mbfscrg", '𝓰')
, ("\\mbfscrh", '𝓱')
, ("\\mbfscri", '𝓲')
, ("\\mbfscrj", '𝓳')
, ("\\mbfscrk", '𝓴')
, ("\\mbfscrl", '𝓵')
, ("\\mbfscrm", '𝓶')
, ("\\mbfscrn", '𝓷')
, ("\\mbfscro", '𝓸')
, ("\\mbfscrp", '𝓹')
, ("\\mbfscrq", '𝓺')
, ("\\mbfscrr", '𝓻')
, ("\\mbfscrs", '𝓼')
, ("\\mbfscrt", '𝓽')
, ("\\mbfscru", '𝓾')
, ("\\mbfscrv", '𝓿')
, ("\\mbfscrw", '𝔀')
, ("\\mbfscrx", '𝔁')
, ("\\mbfscry", '𝔂')
, ("\\mbfscrz", '𝔃')
, ("\\mathfrak{A}", '𝔄')
, ("\\mathfrak{B}", '𝔅')
, ("\\mathfrak{D}", '𝔇')
, ("\\mathfrak{E}", '𝔈')
, ("\\mathfrak{F}", '𝔉')
, ("\\mathfrak{G}", '𝔊')
, ("\\mathfrak{J}", '𝔍')
, ("\\mathfrak{K}", '𝔎')
, ("\\mathfrak{L}", '𝔏')
, ("\\mathfrak{M}", '𝔐')
, ("\\mathfrak{N}", '𝔑')
, ("\\mathfrak{O}", '𝔒')
, ("\\mathfrak{P}", '𝔓')
, ("\\mathfrak{Q}", '𝔔')
, ("\\mathfrak{S}", '𝔖')
, ("\\mathfrak{T}", '𝔗')
, ("\\mathfrak{U}", '𝔘')
, ("\\mathfrak{V}", '𝔙')
, ("\\mathfrak{W}", '𝔚')
, ("\\mathfrak{X}", '𝔛')
, ("\\mathfrak{Y}", '𝔜')
, ("\\mathfrak{a}", '𝔞')
, ("\\mathfrak{b}", '𝔟')
, ("\\mathfrak{c}", '𝔠')
, ("\\mathfrak{d}", '𝔡')
, ("\\mathfrak{e}", '𝔢')
, ("\\mathfrak{f}", '𝔣')
, ("\\mathfrak{g}", '𝔤')
, ("\\mathfrak{h}", '𝔥')
, ("\\mathfrak{i}", '𝔦')
, ("\\mathfrak{j}", '𝔧')
, ("\\mathfrak{k}", '𝔨')
, ("\\mathfrak{l}", '𝔩')
, ("\\mathfrak{m}", '𝔪')
, ("\\mathfrak{n}", '𝔫')
, ("\\mathfrak{o}", '𝔬')
, ("\\mathfrak{p}", '𝔭')
, ("\\mathfrak{q}", '𝔮')
, ("\\mathfrak{r}", '𝔯')
, ("\\mathfrak{s}", '𝔰')
, ("\\mathfrak{t}", '𝔱')
, ("\\mathfrak{u}", '𝔲')
, ("\\mathfrak{v}", '𝔳')
, ("\\mathfrak{w}", '𝔴')
, ("\\mathfrak{x}", '𝔵')
, ("\\mathfrak{y}", '𝔶')
, ("\\mathfrak{z}", '𝔷')
, ("\\mathbb{A}", '𝔸')
, ("\\mathbb{B}", '𝔹')
, ("\\mathbb{D}", '𝔻')
, ("\\mathbb{E}", '𝔼')
, ("\\mathbb{F}", '𝔽')
, ("\\mathbb{G}", '𝔾')
, ("\\mathbb{I}", '𝕀')
, ("\\mathbb{J}", '𝕁')
, ("\\mathbb{K}", '𝕂')
, ("\\mathbb{L}", '𝕃')
, ("\\mathbb{M}", '𝕄')
, ("\\mathbb{O}", '𝕆')
, ("\\mathbb{S}", '𝕊')
, ("\\mathbb{T}", '𝕋')
, ("\\mathbb{U}", '𝕌')
, ("\\mathbb{V}", '𝕍')
, ("\\mathbb{W}", '𝕎')
, ("\\mathbb{X}", '𝕏')
, ("\\mathbb{Y}", '𝕐')
, ("\\mathbb{a}", '𝕒')
, ("\\mathbb{b}", '𝕓')
, ("\\mathbb{c}", '𝕔')
, ("\\mathbb{d}", '𝕕')
, ("\\mathbb{e}", '𝕖')
, ("\\mathbb{f}", '𝕗')
, ("\\mathbb{g}", '𝕘')
, ("\\mathbb{h}", '𝕙')
, ("\\mathbb{i}", '𝕚')
, ("\\mathbb{j}", '𝕛')
, ("\\mathbb{k}", '𝕜')
, ("\\mathbb{l}", '𝕝')
, ("\\mathbb{m}", '𝕞')
, ("\\mathbb{n}", '𝕟')
, ("\\mathbb{o}", '𝕠')
, ("\\mathbb{p}", '𝕡')
, ("\\mathbb{q}", '𝕢')
, ("\\mathbb{r}", '𝕣')
, ("\\mathbb{s}", '𝕤')
, ("\\mathbb{t}", '𝕥')
, ("\\mathbb{u}", '𝕦')
, ("\\mathbb{v}", '𝕧')
, ("\\mathbb{w}", '𝕨')
, ("\\mathbb{x}", '𝕩')
, ("\\mathbb{y}", '𝕪')
, ("\\mathbb{z}", '𝕫')
, ("\\mbffrakA", '𝕬')
, ("\\mbffrakB", '𝕭')
, ("\\mbffrakC", '𝕮')
, ("\\mbffrakD", '𝕯')
, ("\\mbffrakE", '𝕰')
, ("\\mbffrakF", '𝕱')
, ("\\mbffrakG", '𝕲')
, ("\\mbffrakH", '𝕳')
, ("\\mbffrakI", '𝕴')
, ("\\mbffrakJ", '𝕵')
, ("\\mbffrakK", '𝕶')
, ("\\mbffrakL", '𝕷')
, ("\\mbffrakM", '𝕸')
, ("\\mbffrakN", '𝕹')
, ("\\mbffrakO", '𝕺')
, ("\\mbffrakP", '𝕻')
, ("\\mbffrakQ", '𝕼')
, ("\\mbffrakR", '𝕽')
, ("\\mbffrakS", '𝕾')
, ("\\mbffrakT", '𝕿')
, ("\\mbffrakU", '𝖀')
, ("\\mbffrakV", '𝖁')
, ("\\mbffrakW", '𝖂')
, ("\\mbffrakX", '𝖃')
, ("\\mbffrakY", '𝖄')
, ("\\mbffrakZ", '𝖅')
, ("\\mbffraka", '𝖆')
, ("\\mbffrakb", '𝖇')
, ("\\mbffrakc", '𝖈')
, ("\\mbffrakd", '𝖉')
, ("\\mbffrake", '𝖊')
, ("\\mbffrakf", '𝖋')
, ("\\mbffrakg", '𝖌')
, ("\\mbffrakh", '𝖍')
, ("\\mbffraki", '𝖎')
, ("\\mbffrakj", '𝖏')
, ("\\mbffrakk", '𝖐')
, ("\\mbffrakl", '𝖑')
, ("\\mbffrakm", '𝖒')
, ("\\mbffrakn", '𝖓')
, ("\\mbffrako", '𝖔')
, ("\\mbffrakp", '𝖕')
, ("\\mbffrakq", '𝖖')
, ("\\mbffrakr", '𝖗')
, ("\\mbffraks", '𝖘')
, ("\\mbffrakt", '𝖙')
, ("\\mbffraku", '𝖚')
, ("\\mbffrakv", '𝖛')
, ("\\mbffrakw", '𝖜')
, ("\\mbffrakx", '𝖝')
, ("\\mbffraky", '𝖞')
, ("\\mbffrakz", '𝖟')
, ("\\mathsf{A}", '𝖠')
, ("\\mathsf{B}", '𝖡')
, ("\\mathsf{C}", '𝖢')
, ("\\mathsf{D}", '𝖣')
, ("\\mathsf{E}", '𝖤')
, ("\\mathsf{F}", '𝖥')
, ("\\mathsf{G}", '𝖦')
, ("\\mathsf{H}", '𝖧')
, ("\\mathsf{I}", '𝖨')
, ("\\mathsf{J}", '𝖩')
, ("\\mathsf{K}", '𝖪')
, ("\\mathsf{L}", '𝖫')
, ("\\mathsf{M}", '𝖬')
, ("\\mathsf{N}", '𝖭')
, ("\\mathsf{O}", '𝖮')
, ("\\mathsf{P}", '𝖯')
, ("\\mathsf{Q}", '𝖰')
, ("\\mathsf{R}", '𝖱')
, ("\\mathsf{S}", '𝖲')
, ("\\mathsf{T}", '𝖳')
, ("\\mathsf{U}", '𝖴')
, ("\\mathsf{V}", '𝖵')
, ("\\mathsf{W}", '𝖶')
, ("\\mathsf{X}", '𝖷')
, ("\\mathsf{Y}", '𝖸')
, ("\\mathsf{Z}", '𝖹')
, ("\\mathsf{a}", '𝖺')
, ("\\mathsf{b}", '𝖻')
, ("\\mathsf{c}", '𝖼')
, ("\\mathsf{d}", '𝖽')
, ("\\mathsf{e}", '𝖾')
, ("\\mathsf{f}", '𝖿')
, ("\\mathsf{g}", '𝗀')
, ("\\mathsf{h}", '𝗁')
, ("\\mathsf{i}", '𝗂')
, ("\\mathsf{j}", '𝗃')
, ("\\mathsf{k}", '𝗄')
, ("\\mathsf{l}", '𝗅')
, ("\\mathsf{m}", '𝗆')
, ("\\mathsf{n}", '𝗇')
, ("\\mathsf{o}", '𝗈')
, ("\\mathsf{p}", '𝗉')
, ("\\mathsf{q}", '𝗊')
, ("\\mathsf{r}", '𝗋')
, ("\\mathsf{s}", '𝗌')
, ("\\mathsf{t}", '𝗍')
, ("\\mathsf{u}", '𝗎')
, ("\\mathsf{v}", '𝗏')
, ("\\mathsf{w}", '𝗐')
, ("\\mathsf{x}", '𝗑')
, ("\\mathsf{y}", '𝗒')
, ("\\mathsf{z}", '𝗓')
, ("\\mathsfbf{A}", '𝗔')
, ("\\mathsfbf{B}", '𝗕')
, ("\\mathsfbf{C}", '𝗖')
, ("\\mathsfbf{D}", '𝗗')
, ("\\mathsfbf{E}", '𝗘')
, ("\\mathsfbf{F}", '𝗙')
, ("\\mathsfbf{G}", '𝗚')
, ("\\mathsfbf{H}", '𝗛')
, ("\\mathsfbf{I}", '𝗜')
, ("\\mathsfbf{J}", '𝗝')
, ("\\mathsfbf{K}", '𝗞')
, ("\\mathsfbf{L}", '𝗟')
, ("\\mathsfbf{M}", '𝗠')
, ("\\mathsfbf{N}", '𝗡')
, ("\\mathsfbf{O}", '𝗢')
, ("\\mathsfbf{P}", '𝗣')
, ("\\mathsfbf{Q}", '𝗤')
, ("\\mathsfbf{R}", '𝗥')
, ("\\mathsfbf{S}", '𝗦')
, ("\\mathsfbf{T}", '𝗧')
, ("\\mathsfbf{U}", '𝗨')
, ("\\mathsfbf{V}", '𝗩')
, ("\\mathsfbf{W}", '𝗪')
, ("\\mathsfbf{X}", '𝗫')
, ("\\mathsfbf{Y}", '𝗬')
, ("\\mathsfbf{Z}", '𝗭')
, ("\\mathsfbf{a}", '𝗮')
, ("\\mathsfbf{b}", '𝗯')
, ("\\mathsfbf{c}", '𝗰')
, ("\\mathsfbf{d}", '𝗱')
, ("\\mathsfbf{e}", '𝗲')
, ("\\mathsfbf{f}", '𝗳')
, ("\\mathsfbf{g}", '𝗴')
, ("\\mathsfbf{h}", '𝗵')
, ("\\mathsfbf{i}", '𝗶')
, ("\\mathsfbf{j}", '𝗷')
, ("\\mathsfbf{k}", '𝗸')
, ("\\mathsfbf{l}", '𝗹')
, ("\\mathsfbf{m}", '𝗺')
, ("\\mathsfbf{n}", '𝗻')
, ("\\mathsfbf{o}", '𝗼')
, ("\\mathsfbf{p}", '𝗽')
, ("\\mathsfbf{q}", '𝗾')
, ("\\mathsfbf{r}", '𝗿')
, ("\\mathsfbf{s}", '𝘀')
, ("\\mathsfbf{t}", '𝘁')
, ("\\mathsfbf{u}", '𝘂')
, ("\\mathsfbf{v}", '𝘃')
, ("\\mathsfbf{w}", '𝘄')
, ("\\mathsfbf{x}", '𝘅')
, ("\\mathsfbf{y}", '𝘆')
, ("\\mathsfbf{z}", '𝘇')
, ("\\mathsfit{A}", '𝘈')
, ("\\mathsfit{B}", '𝘉')
, ("\\mathsfit{C}", '𝘊')
, ("\\mathsfit{D}", '𝘋')
, ("\\mathsfit{E}", '𝘌')
, ("\\mathsfit{F}", '𝘍')
, ("\\mathsfit{G}", '𝘎')
, ("\\mathsfit{H}", '𝘏')
, ("\\mathsfit{I}", '𝘐')
, ("\\mathsfit{J}", '𝘑')
, ("\\mathsfit{K}", '𝘒')
, ("\\mathsfit{L}", '𝘓')
, ("\\mathsfit{M}", '𝘔')
, ("\\mathsfit{N}", '𝘕')
, ("\\mathsfit{O}", '𝘖')
, ("\\mathsfit{P}", '𝘗')
, ("\\mathsfit{Q}", '𝘘')
, ("\\mathsfit{R}", '𝘙')
, ("\\mathsfit{S}", '𝘚')
, ("\\mathsfit{T}", '𝘛')
, ("\\mathsfit{U}", '𝘜')
, ("\\mathsfit{V}", '𝘝')
, ("\\mathsfit{W}", '𝘞')
, ("\\mathsfit{X}", '𝘟')
, ("\\mathsfit{Y}", '𝘠')
, ("\\mathsfit{Z}", '𝘡')
, ("\\mathsfit{a}", '𝘢')
, ("\\mathsfit{b}", '𝘣')
, ("\\mathsfit{c}", '𝘤')
, ("\\mathsfit{d}", '𝘥')
, ("\\mathsfit{e}", '𝘦')
, ("\\mathsfit{f}", '𝘧')
, ("\\mathsfit{g}", '𝘨')
, ("\\mathsfit{h}", '𝘩')
, ("\\mathsfit{i}", '𝘪')
, ("\\mathsfit{j}", '𝘫')
, ("\\mathsfit{k}", '𝘬')
, ("\\mathsfit{l}", '𝘭')
, ("\\mathsfit{m}", '𝘮')
, ("\\mathsfit{n}", '𝘯')
, ("\\mathsfit{o}", '𝘰')
, ("\\mathsfit{p}", '𝘱')
, ("\\mathsfit{q}", '𝘲')
, ("\\mathsfit{r}", '𝘳')
, ("\\mathsfit{s}", '𝘴')
, ("\\mathsfit{t}", '𝘵')
, ("\\mathsfit{u}", '𝘶')
, ("\\mathsfit{v}", '𝘷')
, ("\\mathsfit{w}", '𝘸')
, ("\\mathsfit{x}", '𝘹')
, ("\\mathsfit{y}", '𝘺')
, ("\\mathsfit{z}", '𝘻')
, ("\\mathsfbfit{A}", '𝘼')
, ("\\mathsfbfit{B}", '𝘽')
, ("\\mathsfbfit{C}", '𝘾')
, ("\\mathsfbfit{D}", '𝘿')
, ("\\mathsfbfit{E}", '𝙀')
, ("\\mathsfbfit{F}", '𝙁')
, ("\\mathsfbfit{G}", '𝙂')
, ("\\mathsfbfit{H}", '𝙃')
, ("\\mathsfbfit{I}", '𝙄')
, ("\\mathsfbfit{J}", '𝙅')
, ("\\mathsfbfit{K}", '𝙆')
, ("\\mathsfbfit{L}", '𝙇')
, ("\\mathsfbfit{M}", '𝙈')
, ("\\mathsfbfit{N}", '𝙉')
, ("\\mathsfbfit{O}", '𝙊')
, ("\\mathsfbfit{P}", '𝙋')
, ("\\mathsfbfit{Q}", '𝙌')
, ("\\mathsfbfit{R}", '𝙍')
, ("\\mathsfbfit{S}", '𝙎')
, ("\\mathsfbfit{T}", '𝙏')
, ("\\mathsfbfit{U}", '𝙐')
, ("\\mathsfbfit{V}", '𝙑')
, ("\\mathsfbfit{W}", '𝙒')
, ("\\mathsfbfit{X}", '𝙓')
, ("\\mathsfbfit{Y}", '𝙔')
, ("\\mathsfbfit{Z}", '𝙕')
, ("\\mathsfbfit{a}", '𝙖')
, ("\\mathsfbfit{b}", '𝙗')
, ("\\mathsfbfit{c}", '𝙘')
, ("\\mathsfbfit{d}", '𝙙')
, ("\\mathsfbfit{e}", '𝙚')
, ("\\mathsfbfit{f}", '𝙛')
, ("\\mathsfbfit{g}", '𝙜')
, ("\\mathsfbfit{h}", '𝙝')
, ("\\mathsfbfit{i}", '𝙞')
, ("\\mathsfbfit{j}", '𝙟')
, ("\\mathsfbfit{k}", '𝙠')
, ("\\mathsfbfit{l}", '𝙡')
, ("\\mathsfbfit{m}", '𝙢')
, ("\\mathsfbfit{n}", '𝙣')
, ("\\mathsfbfit{o}", '𝙤')
, ("\\mathsfbfit{p}", '𝙥')
, ("\\mathsfbfit{q}", '𝙦')
, ("\\mathsfbfit{r}", '𝙧')
, ("\\mathsfbfit{s}", '𝙨')
, ("\\mathsfbfit{t}", '𝙩')
, ("\\mathsfbfit{u}", '𝙪')
, ("\\mathsfbfit{v}", '𝙫')
, ("\\mathsfbfit{w}", '𝙬')
, ("\\mathsfbfit{x}", '𝙭')
, ("\\mathsfbfit{y}", '𝙮')
, ("\\mathsfbfit{z}", '𝙯')
, ("\\mathtt{A}", '𝙰')
, ("\\mathtt{B}", '𝙱')
, ("\\mathtt{C}", '𝙲')
, ("\\mathtt{D}", '𝙳')
, ("\\mathtt{E}", '𝙴')
, ("\\mathtt{F}", '𝙵')
, ("\\mathtt{G}", '𝙶')
, ("\\mathtt{H}", '𝙷')
, ("\\mathtt{I}", '𝙸')
, ("\\mathtt{J}", '𝙹')
, ("\\mathtt{K}", '𝙺')
, ("\\mathtt{L}", '𝙻')
, ("\\mathtt{M}", '𝙼')
, ("\\mathtt{N}", '𝙽')
, ("\\mathtt{O}", '𝙾')
, ("\\mathtt{P}", '𝙿')
, ("\\mathtt{Q}", '𝚀')
, ("\\mathtt{R}", '𝚁')
, ("\\mathtt{S}", '𝚂')
, ("\\mathtt{T}", '𝚃')
, ("\\mathtt{U}", '𝚄')
, ("\\mathtt{V}", '𝚅')
, ("\\mathtt{W}", '𝚆')
, ("\\mathtt{X}", '𝚇')
, ("\\mathtt{Y}", '𝚈')
, ("\\mathtt{Z}", '𝚉')
, ("\\mathtt{a}", '𝚊')
, ("\\mathtt{b}", '𝚋')
, ("\\mathtt{c}", '𝚌')
, ("\\mathtt{d}", '𝚍')
, ("\\mathtt{e}", '𝚎')
, ("\\mathtt{f}", '𝚏')
, ("\\mathtt{g}", '𝚐')
, ("\\mathtt{h}", '𝚑')
, ("\\mathtt{i}", '𝚒')
, ("\\mathtt{j}", '𝚓')
, ("\\mathtt{k}", '𝚔')
, ("\\mathtt{l}", '𝚕')
, ("\\mathtt{m}", '𝚖')
, ("\\mathtt{n}", '𝚗')
, ("\\mathtt{o}", '𝚘')
, ("\\mathtt{p}", '𝚙')
, ("\\mathtt{q}", '𝚚')
, ("\\mathtt{r}", '𝚛')
, ("\\mathtt{s}", '𝚜')
, ("\\mathtt{t}", '𝚝')
, ("\\mathtt{u}", '𝚞')
, ("\\mathtt{v}", '𝚟')
, ("\\mathtt{w}", '𝚠')
, ("\\mathtt{x}", '𝚡')
, ("\\mathtt{y}", '𝚢')
, ("\\mathtt{z}", '𝚣')
, ("\\imath", '𝚤')
, ("\\jmath", '𝚥')
, ("\\mbfAlpha", '𝚨')
, ("\\mbfBeta", '𝚩')
, ("\\mathbf{\\Gamma}", '𝚪')
, ("\\mathbf{\\Delta}", '𝚫')
, ("\\mbfEpsilon", '𝚬')
, ("\\mbfZeta", '𝚭')
, ("\\mbfEta", '𝚮')
, ("\\mathbf{\\Theta}", '𝚯')
, ("\\mbfIota", '𝚰')
, ("\\mbfKappa", '𝚱')
, ("\\mathbf{\\Lambda}", '𝚲')
, ("\\mbfMu", '𝚳')
, ("\\mbfNu", '𝚴')
, ("\\mathbf{\\Xi}", '𝚵')
, ("\\mbfOmicron", '𝚶')
, ("\\mathbf{\\Pi}", '𝚷')
, ("\\mbfRho", '𝚸')
, ("\\mbfvarTheta", '𝚹')
, ("\\mathbf{\\Sigma}", '𝚺')
, ("\\mbfTau", '𝚻')
, ("\\mathbf{\\Upsilon}", '𝚼')
, ("\\mathbf{\\Phi}", '𝚽')
, ("\\mbfChi", '𝚾')
, ("\\mathbf{\\Psi}", '𝚿')
, ("\\mathbf{\\Omega}", '𝛀')
, ("\\mbfnabla", '𝛁')
, ("\\mathbf{\\alpha}", '𝛂')
, ("\\mathbf{\\beta}", '𝛃')
, ("\\mathbf{\\gamma}", '𝛄')
, ("\\mathbf{\\delta}", '𝛅')
, ("\\mathbf{\\varepsilon}", '𝛆')
, ("\\mathbf{\\zeta}", '𝛇')
, ("\\mathbf{\\eta}", '𝛈')
, ("\\mathbf{\\theta}", '𝛉')
, ("\\mathbf{\\iota}", '𝛊')
, ("\\mathbf{\\kappa}", '𝛋')
, ("\\mathbf{\\lambda}", '𝛌')
, ("\\mathbf{\\mu}", '𝛍')
, ("\\mathbf{\\nu}", '𝛎')
, ("\\mathbf{\\xi}", '𝛏')
, ("\\mbfomicron", '𝛐')
, ("\\mathbf{\\pi}", '𝛑')
, ("\\mathbf{\\rho}", '𝛒')
, ("\\mathbf{\\varsigma}", '𝛓')
, ("\\mathbf{\\sigma}", '𝛔')
, ("\\mathbf{\\tau}", '𝛕')
, ("\\mathbf{\\upsilon}", '𝛖')
, ("\\mathbf{\\varphi}", '𝛗')
, ("\\mathbf{\\chi}", '𝛘')
, ("\\mathbf{\\psi}", '𝛙')
, ("\\mathbf{\\omega}", '𝛚')
, ("\\mbfpartial", '𝛛')
, ("\\mathbf{\\epsilon}", '𝛜')
, ("\\mathbf{\\vartheta}", '𝛝')
, ("\\mbfvarkappa", '𝛞')
, ("\\mathbf{\\phi}", '𝛟')
, ("\\mathbf{\\varrho}", '𝛠')
, ("\\mathbf{\\varpi}", '𝛡')
, ("\\mbfitAlpha", '𝜜')
, ("\\mbfitBeta", '𝜝')
, ("\\mathbfit{\\Gamma}", '𝜞')
, ("\\mathbfit{\\Delta}", '𝜟')
, ("\\mbfitEpsilon", '𝜠')
, ("\\mbfitZeta", '𝜡')
, ("\\mbfitEta", '𝜢')
, ("\\mathbfit{\\Theta}", '𝜣')
, ("\\mbfitIota", '𝜤')
, ("\\mbfitKappa", '𝜥')
, ("\\mathbfit{\\Lambda}", '𝜦')
, ("\\mbfitMu", '𝜧')
, ("\\mbfitNu", '𝜨')
, ("\\mathbfit{\\Xi}", '𝜩')
, ("\\mbfitOmicron", '𝜪')
, ("\\mathbfit{\\Pi}", '𝜫')
, ("\\mbfitRho", '𝜬')
, ("\\mbfitvarTheta", '𝜭')
, ("\\mathbfit{\\Sigma}", '𝜮')
, ("\\mbfitTau", '𝜯')
, ("\\mathbfit{\\Upsilon}", '𝜰')
, ("\\mathbfit{\\Phi}", '𝜱')
, ("\\mbfitChi", '𝜲')
, ("\\mathbfit{\\Psi}", '𝜳')
, ("\\mathbfit{\\Omega}", '𝜴')
, ("\\mbfitnabla", '𝜵')
, ("\\mathbfit{\\alpha}", '𝜶')
, ("\\mathbfit{\\beta}", '𝜷')
, ("\\mathbfit{\\gamma}", '𝜸')
, ("\\mathbfit{\\delta}", '𝜹')
, ("\\mathbfit{\\varepsilon}", '𝜺')
, ("\\mathbfit{\\zeta}", '𝜻')
, ("\\mathbfit{\\eta}", '𝜼')
, ("\\mathbfit{\\theta}", '𝜽')
, ("\\mathbfit{\\iota}", '𝜾')
, ("\\mathbfit{\\kappa}", '𝜿')
, ("\\mathbfit{\\lambda}", '𝝀')
, ("\\mathbfit{\\mu}", '𝝁')
, ("\\mathbfit{\\nu}", '𝝂')
, ("\\mathbfit{\\xi}", '𝝃')
, ("\\mbfitomicron", '𝝄')
, ("\\mathbfit{\\pi}", '𝝅')
, ("\\mathbfit{\\rho}", '𝝆')
, ("\\mathbfit{\\varsigma}", '𝝇')
, ("\\mathbfit{\\sigma}", '𝝈')
, ("\\mathbfit{\\tau}", '𝝉')
, ("\\mathbfit{\\upsilon}", '𝝊')
, ("\\mathbfit{\\varphi}", '𝝋')
, ("\\mathbfit{\\chi}", '𝝌')
, ("\\mathbfit{\\psi}", '𝝍')
, ("\\mathbfit{\\omega}", '𝝎')
, ("\\mbfitpartial", '𝝏')
, ("\\mathbfit{\\epsilon}", '𝝐')
, ("\\mathbfit{\\vartheta}", '𝝑')
, ("\\mbfitvarkappa", '𝝒')
, ("\\mathbfit{\\phi}", '𝝓')
, ("\\mathbfit{\\varrho}", '𝝔')
, ("\\mathbfit{\\varpi}", '𝝕')
, ("\\mbfsansAlpha", '𝝖')
, ("\\mbfsansBeta", '𝝗')
, ("\\mathsfbf{\\Gamma}", '𝝘')
, ("\\mathsfbf{\\Delta}", '𝝙')
, ("\\mbfsansEpsilon", '𝝚')
, ("\\mbfsansZeta", '𝝛')
, ("\\mbfsansEta", '𝝜')
, ("\\mathsfbf{\\Theta}", '𝝝')
, ("\\mbfsansIota", '𝝞')
, ("\\mbfsansKappa", '𝝟')
, ("\\mathsfbf{\\Lambda}", '𝝠')
, ("\\mbfsansMu", '𝝡')
, ("\\mbfsansNu", '𝝢')
, ("\\mathsfbf{\\Xi}", '𝝣')
, ("\\mbfsansOmicron", '𝝤')
, ("\\mathsfbf{\\Pi}", '𝝥')
, ("\\mbfsansRho", '𝝦')
, ("\\mbfsansvarTheta", '𝝧')
, ("\\mathsfbf{\\Sigma}", '𝝨')
, ("\\mbfsansTau", '𝝩')
, ("\\mathsfbf{\\Upsilon}", '𝝪')
, ("\\mathsfbf{\\Phi}", '𝝫')
, ("\\mbfsansChi", '𝝬')
, ("\\mathsfbf{\\Psi}", '𝝭')
, ("\\mathsfbf{\\Omega}", '𝝮')
, ("\\mbfsansnabla", '𝝯')
, ("\\mathsfbf{\\alpha}", '𝝰')
, ("\\mathsfbf{\\beta}", '𝝱')
, ("\\mathsfbf{\\gamma}", '𝝲')
, ("\\mathsfbf{\\delta}", '𝝳')
, ("\\mathsfbf{\\varepsilon}", '𝝴')
, ("\\mathsfbf{\\zeta}", '𝝵')
, ("\\mathsfbf{\\eta}", '𝝶')
, ("\\mathsfbf{\\theta}", '𝝷')
, ("\\mathsfbf{\\iota}", '𝝸')
, ("\\mathsfbf{\\kappa}", '𝝹')
, ("\\mathsfbf{\\lambda}", '𝝺')
, ("\\mathsfbf{\\mu}", '𝝻')
, ("\\mathsfbf{\\nu}", '𝝼')
, ("\\mathsfbf{\\xi}", '𝝽')
, ("\\mbfsansomicron", '𝝾')
, ("\\mathsfbf{\\pi}", '𝝿')
, ("\\mathsfbf{\\rho}", '𝞀')
, ("\\mathsfbf{\\varsigma}", '𝞁')
, ("\\mathsfbf{\\sigma}", '𝞂')
, ("\\mathsfbf{\\tau}", '𝞃')
, ("\\mathsfbf{\\upsilon}", '𝞄')
, ("\\mathsfbf{\\varphi}", '𝞅')
, ("\\mathsfbf{\\chi}", '𝞆')
, ("\\mathsfbf{\\psi}", '𝞇')
, ("\\mathsfbf{\\omega}", '𝞈')
, ("\\mbfsanspartial", '𝞉')
, ("\\mathsfbf{\\epsilon}", '𝞊')
, ("\\mathsfbf{\\vartheta}", '𝞋')
, ("\\mbfsansvarkappa", '𝞌')
, ("\\mathsfbf{\\phi}", '𝞍')
, ("\\mathsfbf{\\varrho}", '𝞎')
, ("\\mathsfbf{\\varpi}", '𝞏')
, ("\\mbfitsansAlpha", '𝞐')
, ("\\mbfitsansBeta", '𝞑')
, ("\\mathsfbfit{\\Gamma}", '𝞒')
, ("\\mathsfbfit{\\Delta}", '𝞓')
, ("\\mbfitsansEpsilon", '𝞔')
, ("\\mbfitsansZeta", '𝞕')
, ("\\mbfitsansEta", '𝞖')
, ("\\mathsfbfit{\\Theta}", '𝞗')
, ("\\mbfitsansIota", '𝞘')
, ("\\mbfitsansKappa", '𝞙')
, ("\\mathsfbfit{\\Lambda}", '𝞚')
, ("\\mbfitsansMu", '𝞛')
, ("\\mbfitsansNu", '𝞜')
, ("\\mathsfbfit{\\Xi}", '𝞝')
, ("\\mbfitsansOmicron", '𝞞')
, ("\\mathsfbfit{\\Pi}", '𝞟')
, ("\\mbfitsansRho", '𝞠')
, ("\\mbfitsansvarTheta", '𝞡')
, ("\\mathsfbfit{\\Sigma}", '𝞢')
, ("\\mbfitsansTau", '𝞣')
, ("\\mathsfbfit{\\Upsilon}", '𝞤')
, ("\\mathsfbfit{\\Phi}", '𝞥')
, ("\\mbfitsansChi", '𝞦')
, ("\\mathsfbfit{\\Psi}", '𝞧')
, ("\\mathsfbfit{\\Omega}", '𝞨')
, ("\\mbfitsansnabla", '𝞩')
, ("\\mathsfbfit{\\alpha}", '𝞪')
, ("\\mathsfbfit{\\beta}", '𝞫')
, ("\\mathsfbfit{\\gamma}", '𝞬')
, ("\\mathsfbfit{\\delta}", '𝞭')
, ("\\mathsfbfit{\\varepsilon}", '𝞮')
, ("\\mathsfbfit{\\zeta}", '𝞯')
, ("\\mathsfbfit{\\eta}", '𝞰')
, ("\\mathsfbfit{\\theta}", '𝞱')
, ("\\mathsfbfit{\\iota}", '𝞲')
, ("\\mathsfbfit{\\kappa}", '𝞳')
, ("\\mathsfbfit{\\lambda}", '𝞴')
, ("\\mathsfbfit{\\mu}", '𝞵')
, ("\\mathsfbfit{\\nu}", '𝞶')
, ("\\mathsfbfit{\\xi}", '𝞷')
, ("\\mbfitsansomicron", '𝞸')
, ("\\mathsfbfit{\\pi}", '𝞹')
, ("\\mathsfbfit{\\rho}", '𝞺')
, ("\\mathsfbfit{\\varsigma}", '𝞻')
, ("\\mathsfbfit{\\sigma}", '𝞼')
, ("\\mathsfbfit{\\tau}", '𝞽')
, ("\\mathsfbfit{\\upsilon}", '𝞾')
, ("\\mathsfbfit{\\varphi}", '𝞿')
, ("\\mathsfbfit{\\chi}", '𝟀')
, ("\\mathsfbfit{\\psi}", '𝟁')
, ("\\mathsfbfit{\\omega}", '𝟂')
, ("\\mbfitsanspartial", '𝟃')
, ("\\mathsfbfit{\\epsilon}", '𝟄')
, ("\\mathsfbfit{\\vartheta}", '𝟅')
, ("\\mbfitsansvarkappa", '𝟆')
, ("\\mathsfbfit{\\phi}", '𝟇')
, ("\\mathsfbfit{\\varrho}", '𝟈')
, ("\\mathsfbfit{\\varpi}", '𝟉')
, ("\\mbfDigamma", '𝟊')
, ("\\mbfdigamma", '𝟋')
, ("\\mathbf{0}", '𝟎')
, ("\\mathbf{1}", '𝟏')
, ("\\mathbf{2}", '𝟐')
, ("\\mathbf{3}", '𝟑')
, ("\\mathbf{4}", '𝟒')
, ("\\mathbf{5}", '𝟓')
, ("\\mathbf{6}", '𝟔')
, ("\\mathbf{7}", '𝟕')
, ("\\mathbf{8}", '𝟖')
, ("\\mathbf{9}", '𝟗')
, ("\\mathbb{0}", '𝟘')
, ("\\mathbb{1}", '𝟙')
, ("\\mathbb{2}", '𝟚')
, ("\\mathbb{3}", '𝟛')
, ("\\mathbb{4}", '𝟜')
, ("\\mathbb{5}", '𝟝')
, ("\\mathbb{6}", '𝟞')
, ("\\mathbb{7}", '𝟟')
, ("\\mathbb{8}", '𝟠')
, ("\\mathbb{9}", '𝟡')
, ("\\mathsf{0}", '𝟢')
, ("\\mathsf{1}", '𝟣')
, ("\\mathsf{2}", '𝟤')
, ("\\mathsf{3}", '𝟥')
, ("\\mathsf{4}", '𝟦')
, ("\\mathsf{5}", '𝟧')
, ("\\mathsf{6}", '𝟨')
, ("\\mathsf{7}", '𝟩')
, ("\\mathsf{8}", '𝟪')
, ("\\mathsf{9}", '𝟫')
, ("\\mathsfbf{0}", '𝟬')
, ("\\mathsfbf{1}", '𝟭')
, ("\\mathsfbf{2}", '𝟮')
, ("\\mathsfbf{3}", '𝟯')
, ("\\mathsfbf{4}", '𝟰')
, ("\\mathsfbf{5}", '𝟱')
, ("\\mathsfbf{6}", '𝟲')
, ("\\mathsfbf{7}", '𝟳')
, ("\\mathsfbf{8}", '𝟴')
, ("\\mathsfbf{9}", '𝟵')
, ("\\mathtt{0}", '𝟶')
, ("\\mathtt{1}", '𝟷')
, ("\\mathtt{2}", '𝟸')
, ("\\mathtt{3}", '𝟹')
, ("\\mathtt{4}", '𝟺')
, ("\\mathtt{5}", '𝟻')
, ("\\mathtt{6}", '𝟼')
, ("\\mathtt{7}", '𝟽')
, ("\\mathtt{8}", '𝟾')
, ("\\mathtt{9}", '𝟿')
]
|
siddharthist/reed-thesis
|
thesis/unicode/Table.hs
|
mpl-2.0
| 67,689 | 0 | 6 | 12,053 | 21,764 | 14,509 | 7,255 | 2,403 | 1 |
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- Module : Network.AWS.DynamoDB.Scan
-- Copyright : (c) 2013-2014 Brendan Hay <[email protected]>
-- License : This Source Code Form is subject to the terms of
-- the Mozilla Public License, v. 2.0.
-- A copy of the MPL can be found in the LICENSE file or
-- you can obtain it at http://mozilla.org/MPL/2.0/.
-- Maintainer : Brendan Hay <[email protected]>
-- Stability : experimental
-- Portability : non-portable (GHC extensions)
--
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- | The /Scan/ operation returns one or more items and item attributes by accessing
-- every item in a table or a secondary index. To have DynamoDB return fewer
-- items, you can provide a /ScanFilter/ operation.
--
-- If the total number of scanned items exceeds the maximum data set size limit
-- of 1 MB, the scan stops and results are returned to the user as a /LastEvaluatedKey/ value to continue the scan in a subsequent operation. The results also
-- include the number of items exceeding the limit. A scan can result in no
-- table data meeting the filter criteria.
--
-- The result set is eventually consistent.
--
-- By default, /Scan/ operations proceed sequentially; however, for faster
-- performance on a large table or secondary index, applications can request a
-- parallel /Scan/ operation by providing the /Segment/ and /TotalSegments/
-- parameters. For more information, see <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#QueryAndScanParallelScan Parallel Scan> in the /Amazon DynamoDBDeveloper Guide/.
--
-- <http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Scan.html>
module Network.AWS.DynamoDB.Scan
(
-- * Request
Scan
-- ** Request constructor
, scan
-- ** Request lenses
, sAttributesToGet
, sConditionalOperator
, sExclusiveStartKey
, sExpressionAttributeNames
, sExpressionAttributeValues
, sFilterExpression
, sIndexName
, sLimit
, sProjectionExpression
, sReturnConsumedCapacity
, sScanFilter
, sSegment
, sSelect
, sTableName
, sTotalSegments
-- * Response
, ScanResponse
-- ** Response constructor
, scanResponse
-- ** Response lenses
, srConsumedCapacity
, srCount
, srItems
, srLastEvaluatedKey
, srScannedCount
) where
import Network.AWS.Prelude
import Network.AWS.Request.JSON
import Network.AWS.DynamoDB.Types
import qualified GHC.Exts
data Scan = Scan
{ _sAttributesToGet :: List1 "AttributesToGet" Text
, _sConditionalOperator :: Maybe ConditionalOperator
, _sExclusiveStartKey :: Map Text AttributeValue
, _sExpressionAttributeNames :: Map Text Text
, _sExpressionAttributeValues :: Map Text AttributeValue
, _sFilterExpression :: Maybe Text
, _sIndexName :: Maybe Text
, _sLimit :: Maybe Nat
, _sProjectionExpression :: Maybe Text
, _sReturnConsumedCapacity :: Maybe ReturnConsumedCapacity
, _sScanFilter :: Map Text Condition
, _sSegment :: Maybe Nat
, _sSelect :: Maybe Select
, _sTableName :: Text
, _sTotalSegments :: Maybe Nat
} deriving (Eq, Read, Show)
-- | 'Scan' constructor.
--
-- The fields accessible through corresponding lenses are:
--
-- * 'sAttributesToGet' @::@ 'NonEmpty' 'Text'
--
-- * 'sConditionalOperator' @::@ 'Maybe' 'ConditionalOperator'
--
-- * 'sExclusiveStartKey' @::@ 'HashMap' 'Text' 'AttributeValue'
--
-- * 'sExpressionAttributeNames' @::@ 'HashMap' 'Text' 'Text'
--
-- * 'sExpressionAttributeValues' @::@ 'HashMap' 'Text' 'AttributeValue'
--
-- * 'sFilterExpression' @::@ 'Maybe' 'Text'
--
-- * 'sIndexName' @::@ 'Maybe' 'Text'
--
-- * 'sLimit' @::@ 'Maybe' 'Natural'
--
-- * 'sProjectionExpression' @::@ 'Maybe' 'Text'
--
-- * 'sReturnConsumedCapacity' @::@ 'Maybe' 'ReturnConsumedCapacity'
--
-- * 'sScanFilter' @::@ 'HashMap' 'Text' 'Condition'
--
-- * 'sSegment' @::@ 'Maybe' 'Natural'
--
-- * 'sSelect' @::@ 'Maybe' 'Select'
--
-- * 'sTableName' @::@ 'Text'
--
-- * 'sTotalSegments' @::@ 'Maybe' 'Natural'
--
scan :: Text -- ^ 'sTableName'
-> NonEmpty Text -- ^ 'sAttributesToGet'
-> Scan
scan p1 p2 = Scan
{ _sTableName = p1
, _sAttributesToGet = withIso _List1 (const id) p2
, _sIndexName = Nothing
, _sLimit = Nothing
, _sSelect = Nothing
, _sScanFilter = mempty
, _sConditionalOperator = Nothing
, _sExclusiveStartKey = mempty
, _sReturnConsumedCapacity = Nothing
, _sTotalSegments = Nothing
, _sSegment = Nothing
, _sProjectionExpression = Nothing
, _sFilterExpression = Nothing
, _sExpressionAttributeNames = mempty
, _sExpressionAttributeValues = mempty
}
-- | There is a newer parameter available. Use /ProjectionExpression/ instead. Note
-- that if you use /AttributesToGet/ and /ProjectionExpression/ at the same time,
-- DynamoDB will return a /ValidationException/ exception.
--
-- This parameter allows you to retrieve attributes of type List or Map;
-- however, it cannot retrieve individual elements within a List or a Map.
--
-- The names of one or more attributes to retrieve. If no attribute names are
-- provided, then all attributes will be returned. If any of the requested
-- attributes are not found, they will not appear in the result.
--
-- Note that /AttributesToGet/ has no effect on provisioned throughput
-- consumption. DynamoDB determines capacity units consumed based on item size,
-- not on the amount of data that is returned to an application.
sAttributesToGet :: Lens' Scan (NonEmpty Text)
sAttributesToGet = lens _sAttributesToGet (\s a -> s { _sAttributesToGet = a }) . _List1
-- | There is a newer parameter available. Use /ConditionExpression/ instead. Note
-- that if you use /ConditionalOperator/ and / ConditionExpression / at the same
-- time, DynamoDB will return a /ValidationException/ exception.
--
-- A logical operator to apply to the conditions in a /ScanFilter/ map:
--
-- 'AND' - If all of the conditions evaluate to true, then the entire map
-- evaluates to true.
--
-- 'OR' - If at least one of the conditions evaluate to true, then the entire map
-- evaluates to true.
--
-- If you omit /ConditionalOperator/, then 'AND' is the default.
--
-- The operation will succeed only if the entire map evaluates to true.
--
-- This parameter does not support attributes of type List or Map.
--
sConditionalOperator :: Lens' Scan (Maybe ConditionalOperator)
sConditionalOperator =
lens _sConditionalOperator (\s a -> s { _sConditionalOperator = a })
-- | The primary key of the first item that this operation will evaluate. Use the
-- value that was returned for /LastEvaluatedKey/ in the previous operation.
--
-- The data type for /ExclusiveStartKey/ must be String, Number or Binary. No set
-- data types are allowed.
--
-- In a parallel scan, a /Scan/ request that includes /ExclusiveStartKey/ must
-- specify the same segment whose previous /Scan/ returned the corresponding value
-- of /LastEvaluatedKey/.
sExclusiveStartKey :: Lens' Scan (HashMap Text AttributeValue)
sExclusiveStartKey =
lens _sExclusiveStartKey (\s a -> s { _sExclusiveStartKey = a })
. _Map
-- | One or more substitution tokens for attribute names in an expression. The
-- following are some use cases for using /ExpressionAttributeNames/:
--
-- To access an attribute whose name conflicts with a DynamoDB reserved word.
--
-- To create a placeholder for repeating occurrences of an attribute name in
-- an expression.
--
-- To prevent special characters in an attribute name from being
-- misinterpreted in an expression.
--
-- Use the # character in an expression to dereference an attribute name. For
-- example, consider the following attribute name:
--
-- 'Percentile'
--
-- The name of this attribute conflicts with a reserved word, so it cannot be
-- used directly in an expression. (For the complete list of reserved words, go
-- to <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ReservedWords.html Reserved Words> in the /Amazon DynamoDB Developer Guide/). To work around
-- this, you could specify the following for /ExpressionAttributeNames/:
--
-- '{"#P":"Percentile"}'
--
-- You could then use this substitution in an expression, as in this example:
--
-- '#P = :val'
--
-- Tokens that begin with the : character are /expression attribute values/,
-- which are placeholders for the actual value at runtime.
--
-- For more information on expression attribute names, go to <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing ItemAttributes> in the /Amazon DynamoDB Developer Guide/.
sExpressionAttributeNames :: Lens' Scan (HashMap Text Text)
sExpressionAttributeNames =
lens _sExpressionAttributeNames
(\s a -> s { _sExpressionAttributeNames = a })
. _Map
-- | One or more values that can be substituted in an expression.
--
-- Use the : (colon) character in an expression to dereference an attribute
-- value. For example, suppose that you wanted to check whether the value of the /ProductStatus/ attribute was one of the following:
--
-- 'Available | Backordered | Discontinued'
--
-- You would first need to specify /ExpressionAttributeValues/ as follows:
--
-- '{ ":avail":{"S":"Available"}, ":back":{"S":"Backordered"},":disc":{"S":"Discontinued"} }'
--
-- You could then use these values in an expression, such as this:
--
-- 'ProductStatus IN (:avail, :back, :disc)'
--
-- For more information on expression attribute values, go to <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.SpecifyingConditions.html SpecifyingConditions> in the /Amazon DynamoDB Developer Guide/.
sExpressionAttributeValues :: Lens' Scan (HashMap Text AttributeValue)
sExpressionAttributeValues =
lens _sExpressionAttributeValues
(\s a -> s { _sExpressionAttributeValues = a })
. _Map
-- | A string that contains conditions that DynamoDB applies after the /Scan/
-- operation, but before the data is returned to you. Items that do not satisfy
-- the /FilterExpression/ criteria are not returned.
--
-- A /FilterExpression/ is applied after the items have already been read; the
-- process of filtering does not consume any additional read capacity units.
--
-- For more information, go to <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#FilteringResults Filter Expressions> in the /Amazon DynamoDBDeveloper Guide/.
sFilterExpression :: Lens' Scan (Maybe Text)
sFilterExpression =
lens _sFilterExpression (\s a -> s { _sFilterExpression = a })
-- | The name of a secondary index to scan. This index can be any local secondary
-- index or global secondary index. Note that if you use the 'IndexName'
-- parameter, you must also provide 'TableName'.
sIndexName :: Lens' Scan (Maybe Text)
sIndexName = lens _sIndexName (\s a -> s { _sIndexName = a })
-- | The maximum number of items to evaluate (not necessarily the number of
-- matching items). If DynamoDB processes the number of items up to the limit
-- while processing the results, it stops the operation and returns the matching
-- values up to that point, and a key in /LastEvaluatedKey/ to apply in a
-- subsequent operation, so that you can pick up where you left off. Also, if
-- the processed data set size exceeds 1 MB before DynamoDB reaches this limit,
-- it stops the operation and returns the matching values up to the limit, and a
-- key in /LastEvaluatedKey/ to apply in a subsequent operation to continue the
-- operation. For more information, see <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html Query and Scan> in the /Amazon DynamoDBDeveloper Guide/.
sLimit :: Lens' Scan (Maybe Natural)
sLimit = lens _sLimit (\s a -> s { _sLimit = a }) . mapping _Nat
-- | A string that identifies one or more attributes to retrieve from the
-- specified table or index. These attributes can include scalars, sets, or
-- elements of a JSON document. The attributes in the expression must be
-- separated by commas.
--
-- If no attribute names are specified, then all attributes will be returned.
-- If any of the requested attributes are not found, they will not appear in the
-- result.
--
-- For more information, go to <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.AccessingItemAttributes.html Accessing Item Attributes> in the /Amazon DynamoDBDeveloper Guide/.
sProjectionExpression :: Lens' Scan (Maybe Text)
sProjectionExpression =
lens _sProjectionExpression (\s a -> s { _sProjectionExpression = a })
sReturnConsumedCapacity :: Lens' Scan (Maybe ReturnConsumedCapacity)
sReturnConsumedCapacity =
lens _sReturnConsumedCapacity (\s a -> s { _sReturnConsumedCapacity = a })
-- | There is a newer parameter available. Use /FilterExpression/ instead. Note
-- that if you use /ScanFilter/ and /FilterExpression/ at the same time, DynamoDB
-- will return a /ValidationException/ exception.
--
-- A condition that evaluates the scan results and returns only the desired
-- values.
--
-- This parameter does not support attributes of type List or Map.
--
-- If you specify more than one condition in the /ScanFilter/ map, then by
-- default all of the conditions must evaluate to true. In other words, the
-- conditions are ANDed together. (You can use the /ConditionalOperator/ parameter
-- to OR the conditions instead. If you do this, then at least one of the
-- conditions must evaluate to true, rather than all of them.)
--
-- Each /ScanFilter/ element consists of an attribute name to compare, along with
-- the following:
--
-- /AttributeValueList/ - One or more values to evaluate against the supplied
-- attribute. The number of values in the list depends on the operator specified
-- in /ComparisonOperator/ .
--
-- For type Number, value comparisons are numeric.
--
-- String value comparisons for greater than, equals, or less than are based on
-- ASCII character code values. For example, 'a' is greater than 'A', and 'a' is
-- greater than 'B'. For a list of code values, see <http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters>.
--
-- For Binary, DynamoDB treats each byte of the binary data as unsigned when it
-- compares binary values.
--
-- For information on specifying data types in JSON, see <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataFormat.html JSON Data Format> in
-- the /Amazon DynamoDB Developer Guide/.
--
-- /ComparisonOperator/ - A comparator for evaluating attributes. For example,
-- equals, greater than, less than, etc.
--
-- The following comparison operators are available:
--
-- 'EQ | NE | LE | LT | GE | GT | NOT_NULL | NULL | CONTAINS | NOT_CONTAINS |BEGINS_WITH | IN | BETWEEN'
--
-- For complete descriptions of all comparison operators, see <http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html Condition>.
--
--
sScanFilter :: Lens' Scan (HashMap Text Condition)
sScanFilter = lens _sScanFilter (\s a -> s { _sScanFilter = a }) . _Map
-- | For a parallel /Scan/ request, /Segment/ identifies an individual segment to be
-- scanned by an application worker.
--
-- Segment IDs are zero-based, so the first segment is always 0. For example,
-- if you want to use four application threads to scan a table or an index, then
-- the first thread specifies a /Segment/ value of 0, the second thread specifies
-- 1, and so on.
--
-- The value of /LastEvaluatedKey/ returned from a parallel /Scan/ request must be
-- used as /ExclusiveStartKey/ with the same segment ID in a subsequent /Scan/
-- operation.
--
-- The value for /Segment/ must be greater than or equal to 0, and less than the
-- value provided for /TotalSegments/.
--
-- If you provide /Segment/, you must also provide /TotalSegments/.
sSegment :: Lens' Scan (Maybe Natural)
sSegment = lens _sSegment (\s a -> s { _sSegment = a }) . mapping _Nat
-- | The attributes to be returned in the result. You can retrieve all item
-- attributes, specific item attributes, or the count of matching items.
--
-- 'ALL_ATTRIBUTES' - Returns all of the item attributes.
--
-- 'COUNT' - Returns the number of matching items, rather than the matching
-- items themselves.
--
-- 'SPECIFIC_ATTRIBUTES' - Returns only the attributes listed in /AttributesToGet/. This return value is equivalent to specifying /AttributesToGet/ without
-- specifying any value for /Select/.
--
-- If neither /Select/ nor /AttributesToGet/ are specified, DynamoDB defaults to 'ALL_ATTRIBUTES'. You cannot use both /AttributesToGet/ and /Select/ together in a single
-- request, unless the value for /Select/ is 'SPECIFIC_ATTRIBUTES'. (This usage is
-- equivalent to specifying /AttributesToGet/ without any value for /Select/.)
sSelect :: Lens' Scan (Maybe Select)
sSelect = lens _sSelect (\s a -> s { _sSelect = a })
-- | The name of the table containing the requested items; or, if you provide 'IndexName', the name of the table to which that index belongs.
sTableName :: Lens' Scan Text
sTableName = lens _sTableName (\s a -> s { _sTableName = a })
-- | For a parallel /Scan/ request, /TotalSegments/ represents the total number of
-- segments into which the /Scan/ operation will be divided. The value of /TotalSegments/ corresponds to the number of application workers that will perform the
-- parallel scan. For example, if you want to use four application threads to
-- scan a table or an index, specify a /TotalSegments/ value of 4.
--
-- The value for /TotalSegments/ must be greater than or equal to 1, and less
-- than or equal to 1000000. If you specify a /TotalSegments/ value of 1, the /Scan/
-- operation will be sequential rather than parallel.
--
-- If you specify /TotalSegments/, you must also specify /Segment/.
sTotalSegments :: Lens' Scan (Maybe Natural)
sTotalSegments = lens _sTotalSegments (\s a -> s { _sTotalSegments = a }) . mapping _Nat
data ScanResponse = ScanResponse
{ _srConsumedCapacity :: Maybe ConsumedCapacity
, _srCount :: Maybe Int
, _srItems :: List "Items" (Map Text AttributeValue)
, _srLastEvaluatedKey :: Map Text AttributeValue
, _srScannedCount :: Maybe Int
} deriving (Eq, Read, Show)
-- | 'ScanResponse' constructor.
--
-- The fields accessible through corresponding lenses are:
--
-- * 'srConsumedCapacity' @::@ 'Maybe' 'ConsumedCapacity'
--
-- * 'srCount' @::@ 'Maybe' 'Int'
--
-- * 'srItems' @::@ ['HashMap' 'Text' 'AttributeValue']
--
-- * 'srLastEvaluatedKey' @::@ 'HashMap' 'Text' 'AttributeValue'
--
-- * 'srScannedCount' @::@ 'Maybe' 'Int'
--
scanResponse :: ScanResponse
scanResponse = ScanResponse
{ _srItems = mempty
, _srCount = Nothing
, _srScannedCount = Nothing
, _srLastEvaluatedKey = mempty
, _srConsumedCapacity = Nothing
}
srConsumedCapacity :: Lens' ScanResponse (Maybe ConsumedCapacity)
srConsumedCapacity =
lens _srConsumedCapacity (\s a -> s { _srConsumedCapacity = a })
-- | The number of items in the response.
--
-- If you set /ScanFilter/ in the request, then /Count/ is the number of items
-- returned after the filter was applied, and /ScannedCount/ is the number of
-- matching items before the filter was applied.
--
-- If you did not use a filter in the request, then /Count/ is the same as /ScannedCount/.
srCount :: Lens' ScanResponse (Maybe Int)
srCount = lens _srCount (\s a -> s { _srCount = a })
-- | An array of item attributes that match the scan criteria. Each element in
-- this array consists of an attribute name and the value for that attribute.
srItems :: Lens' ScanResponse [HashMap Text AttributeValue]
srItems = lens _srItems (\s a -> s { _srItems = a }) . _List
-- | The primary key of the item where the operation stopped, inclusive of the
-- previous result set. Use this value to start a new operation, excluding this
-- value in the new request.
--
-- If /LastEvaluatedKey/ is empty, then the "last page" of results has been
-- processed and there is no more data to be retrieved.
--
-- If /LastEvaluatedKey/ is not empty, it does not necessarily mean that there is
-- more data in the result set. The only way to know when you have reached the
-- end of the result set is when /LastEvaluatedKey/ is empty.
srLastEvaluatedKey :: Lens' ScanResponse (HashMap Text AttributeValue)
srLastEvaluatedKey =
lens _srLastEvaluatedKey (\s a -> s { _srLastEvaluatedKey = a })
. _Map
-- | The number of items evaluated, before any /ScanFilter/ is applied. A high /ScannedCount/ value with few, or no, /Count/ results indicates an inefficient /Scan/
-- operation. For more information, see <http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html#Count Count and ScannedCount> in the /AmazonDynamoDB Developer Guide/.
--
-- If you did not use a filter in the request, then /ScannedCount/ is the same as /Count/.
srScannedCount :: Lens' ScanResponse (Maybe Int)
srScannedCount = lens _srScannedCount (\s a -> s { _srScannedCount = a })
instance ToPath Scan where
toPath = const "/"
instance ToQuery Scan where
toQuery = const mempty
instance ToHeaders Scan
instance ToJSON Scan where
toJSON Scan{..} = object
[ "TableName" .= _sTableName
, "IndexName" .= _sIndexName
, "AttributesToGet" .= _sAttributesToGet
, "Limit" .= _sLimit
, "Select" .= _sSelect
, "ScanFilter" .= _sScanFilter
, "ConditionalOperator" .= _sConditionalOperator
, "ExclusiveStartKey" .= _sExclusiveStartKey
, "ReturnConsumedCapacity" .= _sReturnConsumedCapacity
, "TotalSegments" .= _sTotalSegments
, "Segment" .= _sSegment
, "ProjectionExpression" .= _sProjectionExpression
, "FilterExpression" .= _sFilterExpression
, "ExpressionAttributeNames" .= _sExpressionAttributeNames
, "ExpressionAttributeValues" .= _sExpressionAttributeValues
]
instance AWSRequest Scan where
type Sv Scan = DynamoDB
type Rs Scan = ScanResponse
request = post "Scan"
response = jsonResponse
instance FromJSON ScanResponse where
parseJSON = withObject "ScanResponse" $ \o -> ScanResponse
<$> o .:? "ConsumedCapacity"
<*> o .:? "Count"
<*> o .:? "Items" .!= mempty
<*> o .:? "LastEvaluatedKey" .!= mempty
<*> o .:? "ScannedCount"
instance AWSPager Scan where
page rq rs
| stop (rs ^. srLastEvaluatedKey) = Nothing
| otherwise = Just $ rq
& sExclusiveStartKey .~ rs ^. srLastEvaluatedKey
|
dysinger/amazonka
|
amazonka-dynamodb/gen/Network/AWS/DynamoDB/Scan.hs
|
mpl-2.0
| 23,573 | 0 | 19 | 4,714 | 2,123 | 1,319 | 804 | 184 | 1 |
{-# LANGUAGE OverloadedStrings #-}
{- |
Module : $Header$
Description : Property tests for timespans.
Copyright : (c) plaimi 2014
License : AGPL-3
Maintainer : [email protected]
-} module Tempuhs.Props.Timespan.Props where
import Data.Maybe
(
isJust,
)
import Test.QuickCheck
(
NonNegative,
NonEmptyList,
Property,
(===),
getNonEmpty,
getNonNegative,
)
import Tempuhs.Chronology
import Tempuhs.Server.Database
(
mkKey,
)
import Tempuhs.Server.Laws.Props
(
beginMinProp,
endMaxProp,
isFlexibleProp,
isFlexProp,
parentCycleProp,
)
isFlexibleTest :: Timespan -> Property
isFlexibleTest t = isJust (timespanRubbish t) === isFlexibleProp t
isFlexTest :: Clock -> Property
isFlexTest c = (clockName c == "<~>") === isFlexProp c
beginMinTest :: NonEmptyList ProperTime -> Property
beginMinTest bms =
beginMinProp (map f (getNonEmpty bms)) === minimum (getNonEmpty bms)
where f bm = Timespan Nothing (mkKey 1) bm 0 0 0 0 Nothing
endMaxTest :: NonEmptyList ProperTime -> Property
endMaxTest ems =
endMaxProp (map f (getNonEmpty ems)) === maximum (getNonEmpty ems)
where f em = Timespan Nothing (mkKey 1) 0 0 0 em 0 Nothing
notDescParentTest :: Integer -> [NonNegative Integer] -> Property
notDescParentTest t ps = notElem t qs === parentCycleProp t qs
where qs = map getNonNegative ps
notSelfParentTest :: NonNegative Integer -> Property
notSelfParentTest t = parentCycleProp u [u] === False
where u = getNonNegative t
|
plaimi/tempuhs-server
|
prop/Tempuhs/Props/Timespan/Props.hs
|
agpl-3.0
| 1,492 | 0 | 10 | 279 | 421 | 223 | 198 | 42 | 1 |
{-# LANGUAGE ScopedTypeVariables, OverloadedStrings #-}
module Cortex.G23.Alive (runAlive) where
import Control.Concurrent.Lifted (fork, threadDelay)
import Control.Monad (forM_, when)
import Control.Monad.State (evalStateT, get)
import Control.Monad.Error (catchError, throwError)
import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.Maybe (isNothing, fromJust)
import Cortex.G23.GrandMonadStack
import qualified Cortex.G23.Config as Config
import Cortex.Common.ErrorIO (iConnectTo, iPrintLog)
import Cortex.Common.LazyIO
import Cortex.Common.Error
import Cortex.Common.Event
import Cortex.Common.MaybeRead
import Cortex.Common.Miranda
-----
runAlive :: String -> Int -> LesserMonadStack ()
runAlive host port = do
mi <- newMirandaInfo host port
mirandaUpdateInfo mi
evalStateT runAlive' mi
runAlive' :: GrandMonadStack ()
runAlive' = do
periodicTimer Config.aliveCheckTime aliveCheck
eventLoop
-----
aliveCheck :: GrandMonadStack ()
aliveCheck = do
{ mi <- get
; hdl <- mirandaConnect mi
; lPutStrLn hdl "lookup all"
; lPutStrLn hdl "app::instance"
; lFlush hdl
; instances <- lGetLines hdl
; lClose hdl
; forM_ instances (\i -> fork $ checkInstance i)
} `catchError` reportError
-----
checkInstance :: LBS.ByteString -> GrandMonadStack ()
checkInstance i = do
-- Remove the 'appName::' prefix.
{ let hp = LBS.drop 2 $ LBS.dropWhile (/= ':') i
; let host = LBS.unpack $ LBS.takeWhile (/= ':') hp
; let (port' :: Maybe Int) = maybeRead $ LBS.unpack $ LBS.tail $
LBS.dropWhile (/= ':') hp
; when (isNothing port') $ throwError "Malformed host:port line"
; let port = fromJust port'
; catchError (connect host port) (\_ -> remove i)
} `catchError` reportError
-----
connect :: String -> Int -> GrandMonadStack ()
connect host port = do
-- Try not to kill new instances that aren't properly up yet.
{ threadDelay $ round $ (10 ** 6) * Config.connectionSleep
; hdl <- iConnectTo host port
; lClose hdl
}
-----
remove :: LBS.ByteString -> GrandMonadStack ()
remove i = do
{ let key = LBS.concat ["app::instance::", i]
; mi <- get
-- Do a lookup first, we don't want to notify the user if the instance is
-- already dead, for example killed by another G23 thread.
; hdl <- mirandaConnect mi
; lPutStrLn hdl "lookup"
; lPutStrLn hdl key
; lFlush hdl
; response <- lGetLine hdl
; lClose hdl
-- Don't issue a delete if we don't have to.
; when (response /= "Nothing") $ remove' key
}
remove' :: LBS.ByteString -> GrandMonadStack ()
remove' key = do
{ mi <- get
; hdl <- mirandaConnect mi
; lPutStrLn hdl "delete"
; lPutStrLn hdl key
; lFlush hdl
; lClose hdl
; iPrintLog $ "Detected a dead instance: " ++ (LBS.unpack key)
}
-----
|
maarons/Cortex
|
G23/Alive.hs
|
agpl-3.0
| 2,852 | 0 | 14 | 623 | 847 | 445 | 402 | 71 | 1 |
-----------------------------------------------------------------------------
-- |
-- Module : Text.ParserCombinators.HuttonMeijer
-- Copyright : Graham Hutton (University of Nottingham), Erik Meijer (University of Utrecht)
-- Licence : BSD
--
-- Maintainer : Malcolm Wallace <[email protected]>
-- Stability : Stable
-- Portability : All
--
-- A LIBRARY OF MONADIC PARSER COMBINATORS
--
-- 29th July 1996
--
-- Graham Hutton Erik Meijer
-- University of Nottingham University of Utrecht
--
-- This Haskell script defines a library of parser combinators, and is
-- taken from sections 1-6 of our article "Monadic Parser Combinators".
-- Some changes to the library have been made in the move from Gofer
-- to Haskell:
--
-- * Do notation is used in place of monad comprehension notation;
--
-- * The parser datatype is defined using "newtype", to avoid the overhead
-- of tagging and untagging parsers with the P constructor.
-----------------------------------------------------------------------------
module Text.ParserCombinators.HuttonMeijer
(Parser(..), item, first, papply, (+++), sat, {-tok,-} many, many1,
sepby, sepby1, chainl,
chainl1, chainr, chainr1, ops, bracket, char, digit, lower, upper,
letter, alphanum, string, ident, nat, int, spaces, comment, junk,
skip, token, natural, integer, symbol, identifier) where
import Data.Char
import Control.Monad
import Control.Applicative hiding (many)
infixr 5 +++
type Token = Char
---------------------------------------------------------
-- | The parser monad
newtype Parser a = P ([Token] -> [(a,[Token])])
instance Functor Parser where
-- map :: (a -> b) -> (Parser a -> Parser b)
fmap f (P p) = P (\inp -> [(f v, out) | (v,out) <- p inp])
instance Applicative Parser where
pure = return
(<*>) = ap
instance Alternative Parser where
(<|>) = mplus
empty = mzero
instance Monad Parser where
-- return :: a -> Parser a
return v = P (\inp -> [(v,inp)])
-- >>= :: Parser a -> (a -> Parser b) -> Parser b
(P p) >>= f = P (\inp -> concat [papply (f v) out | (v,out) <- p inp])
-- fail :: String -> Parser a
fail _ = P (\_ -> [])
instance MonadPlus Parser where
-- mzero :: Parser a
mzero = P (\_ -> [])
-- mplus :: Parser a -> Parser a -> Parser a
(P p) `mplus` (P q) = P (\inp -> (p inp ++ q inp))
-- ------------------------------------------------------------
-- * Other primitive parser combinators
-- ------------------------------------------------------------
item :: Parser Token
item = P (\inp -> case inp of
[] -> []
(x:xs) -> [(x,xs)])
first :: Parser a -> Parser a
first (P p) = P (\inp -> case p inp of
[] -> []
(x:_) -> [x])
papply :: Parser a -> [Token] -> [(a,[Token])]
papply (P p) inp = p inp
-- ------------------------------------------------------------
-- * Derived combinators
-- ------------------------------------------------------------
(+++) :: Parser a -> Parser a -> Parser a
p +++ q = first (p `mplus` q)
sat :: (Token -> Bool) -> Parser Token
sat p = do {x <- item; if p x then return x else mzero}
--tok :: Token -> Parser Token
--tok t = do {x <- item; if t==snd x then return t else mzero}
many :: Parser a -> Parser [a]
many p = many1 p +++ return []
--many p = force (many1 p +++ return [])
many1 :: Parser a -> Parser [a]
many1 p = do {x <- p; xs <- many p; return (x:xs)}
sepby :: Parser a -> Parser b -> Parser [a]
p `sepby` sep = (p `sepby1` sep) +++ return []
sepby1 :: Parser a -> Parser b -> Parser [a]
p `sepby1` sep = do {x <- p; xs <- many (do {sep; p}); return (x:xs)}
chainl :: Parser a -> Parser (a -> a -> a) -> a -> Parser a
chainl p op v = (p `chainl1` op) +++ return v
chainl1 :: Parser a -> Parser (a -> a -> a) -> Parser a
p `chainl1` op = do {x <- p; rest x}
where
rest x = do {f <- op; y <- p; rest (f x y)}
+++ return x
chainr :: Parser a -> Parser (a -> a -> a) -> a -> Parser a
chainr p op v = (p `chainr1` op) +++ return v
chainr1 :: Parser a -> Parser (a -> a -> a) -> Parser a
p `chainr1` op = do {x <- p; rest x}
where
rest x = do {f <- op; y <- p `chainr1` op; return (f x y)}
+++ return x
ops :: [(Parser a, b)] -> Parser b
ops xs = foldr1 (+++) [do {p; return op} | (p,op) <- xs]
bracket :: Parser a -> Parser b -> Parser c -> Parser b
bracket open p close = do {open; x <- p; close; return x}
-- ------------------------------------------------------------
-- * Useful parsers
-- ------------------------------------------------------------
char :: Char -> Parser Char
char x = sat (\y -> x == y)
digit :: Parser Char
digit = sat isDigit
lower :: Parser Char
lower = sat isLower
upper :: Parser Char
upper = sat isUpper
letter :: Parser Char
letter = sat isAlpha
alphanum :: Parser Char
alphanum = sat isAlphaNum +++ char '_'
string :: String -> Parser String
string "" = return ""
string (x:xs) = do {char x; string xs; return (x:xs)}
ident :: Parser String
ident = do {x <- lower; xs <- many alphanum; return (x:xs)}
nat :: Parser Int
nat = do {x <- digit; return (fromEnum x - fromEnum '0')} `chainl1` return op
where
m `op` n = 10*m + n
int :: Parser Int
int = do {char '-'; n <- nat; return (-n)} +++ nat
-- ------------------------------------------------------------
-- * Lexical combinators
-- ------------------------------------------------------------
spaces :: Parser ()
spaces = do {many1 (sat isSpace); return ()}
comment :: Parser ()
--comment = do {string "--"; many (sat (\x -> x /= '\n')); return ()}
--comment = do
-- _ <- string "--"
-- _ <- many (sat (\x -> x /= '\n'))
-- return ()
comment = do
bracket (string "/*") (many item) (string "*/")
return ()
junk :: Parser ()
junk = do {many (spaces +++ comment); return ()}
skip :: Parser a -> Parser a
skip p = do {junk; p}
token :: Parser a -> Parser a
token p = do {v <- p; junk; return v}
-- ------------------------------------------------------------
-- * Token parsers
-- ------------------------------------------------------------
natural :: Parser Int
natural = token nat
integer :: Parser Int
integer = token int
symbol :: String -> Parser String
symbol xs = token (string xs)
identifier :: [String] -> Parser String
identifier ks = token (do {x <- ident;
if not (elem x ks) then return x
else return mzero})
------------------------------------------------------------------------------
|
Kludgy/polyparse-fork
|
src/Text/ParserCombinators/HuttonMeijer.hs
|
lgpl-2.1
| 7,849 | 0 | 13 | 2,751 | 2,240 | 1,200 | 1,040 | 109 | 2 |
module Types.AST where
import Types.Token (Token)
data AST = Function Integer AST
| NamedFunction String
| Call AST [AST]
| Literal Integer
| Dummy [AST]
deriving Show
|
shockkolate/shockklang3
|
src/Types/AST.hs
|
apache-2.0
| 217 | 0 | 7 | 76 | 58 | 35 | 23 | 8 | 0 |
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{- |
Module: Util.Hexadecimal
Description: This module contains functions for parsing and representing raw numbers
and strings as hexadecimal characters.
-}
module Util.Hexadecimal
(
ToHexadecimal(..),
maybeExtractHexBytes,
extractHexBytes,
c2w,
w2c,
hex,
hexBS,
)
where
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BSC8
import Data.Word
import Data.Maybe
import Data.Bits ((.|.))
import Text.Megaparsec (many, parseMaybe, hexDigitChar)
import Text.Printf
import qualified Data.ByteString.Internal as BS (c2w, w2c)
data HexDigit = Hex0 | Hex1 | Hex2 | Hex3 | Hex4 | Hex5 | Hex6 | Hex7
| Hex8 | Hex9 | HexA | HexB | HexC | HexD | HexE | HexF
deriving (Eq)
instance Show HexDigit where
show digit = case digit of
Hex0 -> "0"
Hex1 -> "1"
Hex2 -> "2"
Hex3 -> "3"
Hex4 -> "4"
Hex5 -> "5"
Hex6 -> "6"
Hex7 -> "7"
Hex8 -> "8"
Hex9 -> "9"
HexA -> "A"
HexB -> "B"
HexC -> "C"
HexD -> "D"
HexE -> "E"
HexF -> "F"
class ToHexDigit a where
toHexDigit :: a -> Maybe HexDigit
instance ToHexDigit Char where
toHexDigit ch =
case ch of
'0' -> Just Hex0
'1' -> Just Hex1
'2' -> Just Hex2
'3' -> Just Hex3
'4' -> Just Hex4
'5' -> Just Hex5
'6' -> Just Hex6
'7' -> Just Hex7
'8' -> Just Hex8
'9' -> Just Hex9
'A' -> Just HexA
'B' -> Just HexB
'C' -> Just HexC
'D' -> Just HexD
'E' -> Just HexE
'F' -> Just HexF
'a' -> Just HexA
'b' -> Just HexB
'c' -> Just HexC
'd' -> Just HexD
'e' -> Just HexE
'f' -> Just HexF
_ -> Nothing
instance ToHexDigit String where
toHexDigit ch =
case ch of
"0" -> Just Hex0
"1" -> Just Hex1
"2" -> Just Hex2
"3" -> Just Hex3
"4" -> Just Hex4
"5" -> Just Hex5
"6" -> Just Hex6
"7" -> Just Hex7
"8" -> Just Hex8
"9" -> Just Hex9
"A" -> Just HexA
"B" -> Just HexB
"C" -> Just HexC
"D" -> Just HexD
"E" -> Just HexE
"F" -> Just HexF
"a" -> Just HexA
"b" -> Just HexB
"c" -> Just HexC
"d" -> Just HexD
"e" -> Just HexE
"f" -> Just HexF
_ -> Nothing
data HexDigits = HexDigits { hexDigits :: [HexDigit] }
deriving (Eq)
instance Show HexDigits where
show hexVal = foldl (\acc d -> acc ++ show d) "0x" $ hexDigits hexVal
fromHexDigit :: HexDigit -> HexDigits
fromHexDigit = HexDigits . return
class HexRep a where
fromHexRep :: HexDigits -> Maybe a
instance HexRep Word8 where
fromHexRep digits = fromHexRep' $ hexDigits digits
where
fromHexRep' [digit] = Just (lowerNibble digit)
fromHexRep' [upper,lower] = Just (upperNibble upper .|. lowerNibble lower)
fromHexRep' _ = Nothing
instance HexRep [Word8] where
fromHexRep digits = Just $ fromHexRep' [] $ reverse $ hexDigits digits
where
fromHexRep' acc [] = acc
fromHexRep' acc [digit] = (lowerNibble digit .|. upperNibble Hex0) : acc
fromHexRep' acc (lower:upper:ds) = fromHexRep' ( (lowerNibble lower .|. upperNibble upper) : acc) ds
-- | The 'ToHexadecimal' class is for producing hexadecimal string representations of data.
class ToHexadecimal a where
toHex :: a -> String
toHexBS :: a -> BS.ByteString
toHexBS = BSC8.pack . toHex
instance ToHexadecimal Word8 where
toHex ch = printf "%.2x" ch :: String
instance ToHexadecimal Char where
toHex ch = printf "%.2x" ch :: String
instance ToHexadecimal String where
toHex st = concatMap toHex st :: String
instance ToHexadecimal [Word8] where
toHex st = concatMap toHex st :: String
instance ToHexadecimal BS.ByteString where
toHex bs = toHex $ BS.unpack bs
lowerNibble :: HexDigit -> Word8
lowerNibble d = case d of
Hex0 -> 0x00 :: Word8
Hex1 -> 0x01 :: Word8
Hex2 -> 0x02 :: Word8
Hex3 -> 0x03 :: Word8
Hex4 -> 0x04 :: Word8
Hex5 -> 0x05 :: Word8
Hex6 -> 0x06 :: Word8
Hex7 -> 0x07 :: Word8
Hex8 -> 0x08 :: Word8
Hex9 -> 0x09 :: Word8
HexA -> 0x0A :: Word8
HexB -> 0x0B :: Word8
HexC -> 0x0C :: Word8
HexD -> 0x0D :: Word8
HexE -> 0x0E :: Word8
HexF -> 0x0F :: Word8
upperNibble :: HexDigit -> Word8
upperNibble d = case d of
Hex0 -> 0x00 :: Word8
Hex1 -> 0x10 :: Word8
Hex2 -> 0x20 :: Word8
Hex3 -> 0x30 :: Word8
Hex4 -> 0x40 :: Word8
Hex5 -> 0x50 :: Word8
Hex6 -> 0x60 :: Word8
Hex7 -> 0x70 :: Word8
Hex8 -> 0x80 :: Word8
Hex9 -> 0x90 :: Word8
HexA -> 0xA0 :: Word8
HexB -> 0xB0 :: Word8
HexC -> 0xC0 :: Word8
HexD -> 0xD0 :: Word8
HexE -> 0xE0 :: Word8
HexF -> 0xF0 :: Word8
extractHexDigits :: String -> Maybe HexDigits
extractHexDigits s = case maybeHex s of
Just hexVal -> go hexVal
Nothing -> Nothing
where
maybeHex :: String -> Maybe String
maybeHex = parseMaybe (many hexDigitChar)
go :: String -> Maybe HexDigits
go st = HexDigits <$> mapM toHexDigit st
-- | The 'maybeExtractHexBytes' function extracts raw hexadecimal digits from a string.
maybeExtractHexBytes :: String -> Maybe [Word8]
maybeExtractHexBytes st = case extractHexDigits st of
Just hexVal -> fromHexRep hexVal
Nothing -> Nothing
-- | The 'extractHexBytes' function extracts raw hexadecimal digits from a string.
extractHexBytes :: String -> [Word8]
extractHexBytes = fromJust . maybeExtractHexBytes
-- | Convert between Char and Word8 and back.
c2w :: Char -> Word8
c2w = BS.c2w
w2c :: Word8 -> Char
w2c = BS.w2c
hex :: String -> [Word8]
hex = map c2w
hexBS :: BS.ByteString -> [Word8]
hexBS = hex . BSC8.unpack
|
stallmanifold/matasano-crypto-challenges
|
src/Util/Hexadecimal.hs
|
apache-2.0
| 6,540 | 0 | 13 | 2,358 | 1,827 | 945 | 882 | 184 | 16 |
{-# LANGUAGE OverloadedStrings #-}
module Persistence.Plan
( addPlan
, getOpenPlanOfUser
, getPlansOfUser
, updateModified
, setPlanName
, setPlanDescription
, deletePlan
) where
import Data.Text.Lazy (Text)
import qualified Database.PostgreSQL.Simple as PG
import Model.User
import Model.Plan
{-# ANN module ("HLint: ignore Use camelCase" :: String) #-}
{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}
addPlan :: User -> Text -> Maybe Text -> PG.Connection -> IO Int
addPlan user name mDescription conn = do
r <- PG.query conn "INSERT INTO \"Plan\" (user_id, name, description) VALUES (?, ?, ?) RETURNING id"
(u_user_id user, name, mDescription) :: IO [PG.Only Int]
let x =
case r of
(f:_) -> f
[] -> PG.Only 0
let (PG.Only i) = x
return i
getOpenPlanOfUser :: User -> PG.Connection -> IO (Maybe Plan)
getOpenPlanOfUser user conn = do
r <- PG.query conn "SELECT * FROM \"Plan\" WHERE id = ?" (PG.Only $ u_open_plan_id user) :: IO [Plan]
if null r
then return Nothing
else do
let plan = head r
return $ Just plan
getPlansOfUser :: User -> PG.Connection -> IO [Plan]
getPlansOfUser user conn = PG.query conn "SELECT * FROM \"Plan\" WHERE user_id = ? ORDER BY id" (PG.Only $ u_user_id user)
updateModified :: Plan -> PG.Connection -> IO Int
updateModified plan conn = do
r <- PG.execute conn "UPDATE \"Plan\" SET modified = now() WHERE id = ?" (PG.Only $ p_id plan)
return (fromIntegral r)
setPlanName :: Int -> Text -> PG.Connection -> IO Int
setPlanName planId newVal conn = do
r <- PG.execute conn "UPDATE \"Plan\" SET name = ?, modified = now() WHERE id = ?" (newVal, planId)
return (fromIntegral r)
setPlanDescription :: Int -> Text -> PG.Connection -> IO Int
setPlanDescription planId newVal conn = do
r <- PG.execute conn "UPDATE \"Plan\" SET description = ?, modified = now() WHERE id = ?" (newVal, planId)
return (fromIntegral r)
deletePlan :: Int -> PG.Connection -> IO Int
deletePlan planId conn = do
r <- PG.execute conn "DELETE FROM \"Plan\" WHERE id = ?" (PG.Only planId)
return (fromIntegral r)
|
DataStewardshipPortal/ds-wizard
|
DSServer/app/Persistence/Plan.hs
|
apache-2.0
| 2,139 | 0 | 14 | 449 | 640 | 319 | 321 | 51 | 2 |
{-# LANGUAGE TypeOperators
, MultiParamTypeClasses
, FlexibleInstances
, FlexibleContexts
, UndecidableInstances
#-}
module Network.Tragencap.IP.Ethernet where
import qualified Data.ByteString.Lazy as BS
import Data.Binary.Bits.Get
import Data.Binary.Get
import Data.Word
import Control.Applicative
import Network.Tragencap.Core
import Network.Tragencap.Prelude
import Network.Tragencap.IP.MacAddr
import Network.Tragencap.IP.Ipv4
import Network.Tragencap.IP.Arp
-- * EtherType
---------------------------------------
-- FIXME: implement these: http://en.wikipedia.org/wiki/EtherType#Examples
data EtherType
= EtherTypeIpv4
| EtherTypeArp
| OtherEtherType Word16
-- | EtherTypeWakeOnLan
-- | EtherTypeIEEEStd1722_2011
deriving (Eq, Ord, Show)
-- * Ethernet
---------------------------------------
data Ethernet
= Ethernet
{ ethernetDest :: MacAddr
, ethernetSource :: MacAddr
, ethernetEtherType :: EtherType
}
deriving (Eq, Ord, Show)
word2ett :: Word16 -> EtherType
word2ett 0x0800 = EtherTypeIpv4
word2ett 0x0806 = EtherTypeArp
word2ett other = OtherEtherType other
etherTypeGetter :: Get EtherType
etherTypeGetter = runBitGet (block (word2ett <$> word16be 16))
ethernetGetter :: Get Ethernet
ethernetGetter = Ethernet <$> macAddrGetter <*> macAddrGetter <*> etherTypeGetter
instance SimpleParser Ethernet where
simpleParser = get2parser ethernetGetter
instance ( Payload :! k
, Arp :! k
, Ipv4 :! k
) => GetEncapsulatedParser Ethernet k where
getEncapsulatedParser ethernet = case ethernetEtherType ethernet of
EtherTypeArp -> liftParser arpParser
EtherTypeIpv4 -> liftParser ipv4Parser
OtherEtherType _ -> liftParser payloadParser
ipv4Parser :: Parser Ipv4
ipv4Parser = undefined
arpParser :: Parser Arp
arpParser = undefined
instance SimpleParser Ipv4 where
simpleParser = ipv4Parser
instance SimpleParser Arp where
simpleParser = arpParser
instance GetEncapsulatedParser k Payload where
getEncapsulatedParser _ = liftParser payloadParser
test :: SimpleParser (Ethernet :< (Payload :? (Arp :< Payload) :? (Ipv4 :< Payload))) => a
test = undefined
test1 :: SimpleParser (Ethernet :< (Payload :? (Arp :< Payload))) => a
test1 = undefined
test2 :: (SimpleParser Ethernet, SimpleParser Payload, SimpleParser Ipv4) => a
test2 = undefined
test3 :: (SimpleParser (Payload :? Ipv4 :? Arp)) => a
test3 = undefined
|
kelemzol/tragencap
|
src/Network/Tragencap/IP/Ethernet.hs
|
apache-2.0
| 2,502 | 0 | 13 | 470 | 565 | 315 | 250 | 63 | 1 |
module NextClosure.AttributeExploration where
import FormalContext.FormalContext2
import NextClosure.NextClosure
import NextClosure.FormalConcepts
import NextClosure.FormalImplications
import Util
import Data.Time
data AE g m
= AE { implications :: [FormalImplication m]
, concepts :: [FormalConcept g m]
} deriving (Eq,Show)
data AEResult g m
= AEResult { pseudoIntent :: PseudoIntent m
, result :: Either (FormalImplication m) (FormalConcept g m)
} deriving (Eq)
data AEState g m
= AEState { step :: Int
, ae :: AE g m
, aer :: AEResult g m
} deriving (Eq)
explore :: (Show g,Show m,Eq g,Eq m,Ord g,Ord m) => FormalContext2 g m -> AE g m
explore cxt
= ae
where AEState _ ae _ = runState cxt
runState :: (Eq g,Eq m,Show m,Show g,Ord g,Ord m) => FormalContext2 g m -> AEState g m
runState cxt
| [] == attClosure cxt [] = nextState cxt >$$> (AEState 1 (AE [] [cpt]) (AEResult [] (Right cpt)))
| otherwise = nextState cxt >$$> (AEState 1 (AE [impl] []) (AEResult [] (Left impl)))
where cpt = toFormalConcept cxt []
impl = toFormalImplication cxt []
nextState :: FormalContext2 g m -> Iterator (AEState g m)
nextState cxt@(FormalContext2 _ cod _ _) y@(AEState i (AE impls cpts) (AEResult p x))
| p === cod = y
| otherwise = AEState (i+1) (AE impls' cpts') (AEResult p' x')
where p' = nextClosure cxt (implicationalClosure impls) p
imp@(FormalImplication _ c') = toFormalImplication cxt p'
cpt = toFormalConcept cxt p'
x' = null c' ? (Right cpt) $ (Left imp)
impls' = null c' ? impls $ imp:impls
cpts' = null c' ? (cpt:cpts) $ cpts
silentIO :: (Show g,Show m,Eq g,Eq m,Ord g,Ord m) => FormalContext2 g m -> IO String
silentIO cxt
= do
exploreIO cxt
return "done."
exploreIO :: (Show g,Show m,Eq g,Eq m,Ord g,Ord m) => FormalContext2 g m -> IO (AE g m)
exploreIO cxt
= do
state@(AEState _ _ aer@(AEResult _ result')) <- initIO cxt
(AEState _ ae _) <- runIO cxt state
return ae
runIO :: (Show g,Show m,Eq g,Eq m) => FormalContext2 g m -> AEState g m -> IO (AEState g m)
runIO cxt@(FormalContext2 _ cod _ _) state@(AEState _ _ aer@(AEResult pint _))
= if (pint === cod)
then return state
else do
state' <- nextIO cxt state
runIO cxt state'
nextIO :: (Show g,Show m,Eq g,Eq m) => FormalContext2 g m -> AEState g m -> IO (AEState g m)
nextIO cxt state@(AEState i _ aer@(AEResult _ result'))
= do
(ZonedTime (LocalTime _ time) _) <- getZonedTime
putStrLn $ show time ++ " " ++ show i ++ " " ++ show' result'
return $ nextState cxt state
initIO :: (Eq g,Eq m,Show g, Show m,Ord g,Ord m) => FormalContext2 g m -> IO (AEState g m)
initIO cxt
| [] == attClosure cxt [] = return (AEState 1 (AE [] [cpt]) (AEResult [] (Right cpt)))
| otherwise = return (AEState 1 (AE [impl] []) (AEResult [] (Left impl)))
where cpt = toFormalConcept cxt []
impl = toFormalImplication cxt []
show' :: (Show g,Show m) => Either (FormalImplication m) (FormalConcept g m) -> String
show' (Left x) = show x ++ "\n"--"Implication:\n" ++
show' (Right x) = ""--"\n\n Formal Concept:\n" ++ show x ++ "\n"
toEither :: (Ord g,Eq g,Ord m,Eq m,Show g,Show m)
=> FormalContext2 g m -> PseudoIntent m -> Either (FormalImplication m) (FormalConcept g m)
toEither cxt pint
| pint == attClosure cxt pint = Right $ toFormalConcept cxt pint
| otherwise = Left $ toFormalImplication cxt pint
|
francesco-kriegel/conexp-hs
|
src/NextClosure/AttributeExploration.hs
|
apache-2.0
| 3,638 | 0 | 13 | 978 | 1,668 | 834 | 834 | 78 | 2 |
{-|
Module : Text.ABNF.ABNF.PrettyPrinter
Description : Pretty printer for ABNF rules
Copyright : (c) Martin Zeller, 2016
License : BSD2
Maintainer : Martin Zeller <[email protected]>
Stability : experimental
Portability : portable
-}
module Text.ABNF.PrettyPrinter where
import Data.List (intersperse)
import qualified Data.Text as Text
import Text.ABNF.ABNF.Types
class Pretty a where
prettyShow :: a -> String
instance Pretty a => Pretty [a] where
prettyShow = unlines . map prettyShow
instance Pretty Rule where
prettyShow (Rule ident definedAs sumSpec) = Text.unpack ident
++ " "
++ prettyShow definedAs
++ " "
++ prettyShow sumSpec
instance Pretty DefinedAs where
prettyShow Equals = "="
prettyShow Adds = "=/"
instance Pretty SumSpec where
prettyShow (SumSpec prodspecs) = concat $
intersperse " / " (map prettyShow prodspecs)
instance Pretty ProductSpec where
prettyShow (ProductSpec reps) = concat $
intersperse " " (map prettyShow reps)
instance Pretty Repetition where
prettyShow (Repetition repeat elem) = prettyShow repeat
++ prettyShow elem
instance Pretty Repeat where
prettyShow (Repeat 1 (Just 1)) = ""
prettyShow (Repeat 0 Nothing) = "*"
prettyShow (Repeat l Nothing) = show l ++ "*"
prettyShow (Repeat l (Just h)) = show l ++ "*" ++ show h
instance Pretty Element where
prettyShow (RuleElement' ident) = Text.unpack ident
prettyShow (RuleElement rule) = prettyShow rule
prettyShow (GroupElement group) = "(" ++ prettyShow group ++ ")"
prettyShow (OptionElement option) = "[" ++ prettyShow option ++ "]"
prettyShow (LiteralElement lit) = prettyShow lit
instance Pretty Group where
prettyShow (Group sumSpec) = prettyShow sumSpec
instance Pretty Literal where
prettyShow (CharLit lit) = "\"" ++ Text.unpack lit ++ "\""
prettyShow (NumLit lit) = prettyShow lit
instance Pretty NumLit where
prettyShow (IntLit lit) = "%d" ++ concat (intersperse "." (map show lit))
prettyShow (RangeLit lit1 lit2) = "%d" ++ show lit1 ++ "-" ++ show lit2
|
Xandaros/abnf
|
src/Text/ABNF/PrettyPrinter.hs
|
bsd-2-clause
| 2,313 | 0 | 11 | 645 | 642 | 317 | 325 | 45 | 0 |
module Text.Kibr.Css where
import Preamble
import Language.CSS
import Language.CSS.Extra
import Language.CSS.YUI
master :: CSS Rule
master = do
typography
layout
skin
typography :: CSS Rule
typography = do
"*" `rule` do
lineHeight . pxToPercent $ 20
"body" `rule` do
fontFamily "'Ubuntu', sans-serif"
"pre, code, tt" `rule` do
fontFamily "'Ubuntu Mono', monospace"
"pre" `rule` do
fontSize . pxToPercent $ 14
"dt" `rule` do
fontFamily "'Stoke', serif"
fontSize . pxToPercent $ 26
layout :: CSS Rule
layout = do
"body" `rule` do
margin "auto"
padding "2em"
maxWidth "750px"
"pre" `rule` do
borderLeft "5px solid"
overflow "hidden"
padding ".5em"
"dt" `rule` do
margin "15px 0px"
"dd" `rule` do
paddingLeft "30px"
skin :: CSS Rule
skin = do
"a" `rule` do
color "#1160AC"
textDecoration "none"
"pre" `rule` do
background "#fafafa"
borderLeftColor "#eee"
|
dag/kibr
|
src/Text/Kibr/Css.hs
|
bsd-2-clause
| 957 | 0 | 11 | 234 | 310 | 149 | 161 | 45 | 1 |
{-# LANGUAGE OverloadedStrings #-}
module CommandParserSpec where
import CommandParser
import Commands
import Text.Parsec.Prim (parse)
import Test.Hspec ( Spec
, describe
, it
, shouldBe
, shouldNotBe
, context
)
-- |Required for auto-discovery
spec :: Spec
spec =
describe "Parsers" $ do
describe "Ranges" $ do
context "Single Position" $ do
it "matches current position (.)" $ do
parse parseRange "" "." `shouldBe` Right (SingleRange CurrentPosition)
it "matches end of doc ($)" $ do
parse parseRange "" "$" `shouldBe` Right (SingleRange EndOfDoc)
it "matches absolute position (2)" $ do
parse parseRange "" "2" `shouldBe` Right (SingleRange $ AbsolutePosition 2)
it "matches absolute position (234)" $ do
parse parseRange "" "234" `shouldBe` Right (SingleRange $ AbsolutePosition 234)
it "matches relative position (+1)" $ do
parse parseRange "" "+1" `shouldBe` Right (SingleRange $ RelativePosition Plus 1)
it "matches relative position (+20)" $ do
parse parseRange "" "+20" `shouldBe` Right (SingleRange $ RelativePosition Plus 20)
it "matches relative position (-1)" $ do
parse parseRange "" "-1" `shouldBe` Right (SingleRange $ RelativePosition Minus 1)
it "matches relative position (+1)" $ do
parse parseRange "" "-20" `shouldBe` Right (SingleRange $ RelativePosition Minus 20)
it "matches marked position ('a)" $ do
parse parseRange "" "'a" `shouldBe` Right (SingleRange $ MarkLocation 'a')
it "matches single relative (+)" $ do
parse parseRange "" "+" `shouldBe` Right (SingleRange $ RelativePosition Plus 1)
it "matches single relative (-)" $ do
parse parseRange "" "-" `shouldBe` Right (SingleRange $ RelativePosition Minus 1)
context "Multiple Position" $ do
it "matches current, end (.,$)" $ do
parse parseRange "" ".,$" `shouldBe` Right (DoubleRange CurrentPosition EndOfDoc)
it "matches Absolute, Absolute (12,34)" $ do
parse parseRange "" "12,34" `shouldBe` Right (DoubleRange (AbsolutePosition 12) (AbsolutePosition 34))
it "matches Relative, Relative (-12,+34)" $ do
parse parseRange "" "-12,+34" `shouldBe` Right (DoubleRange (RelativePosition Minus 12) (RelativePosition Plus 34))
it "matches marked position ('a,'b)" $ do
parse parseRange "" "'a,'b" `shouldBe` Right (DoubleRange (MarkLocation 'a') (MarkLocation 'b'))
it "matches single relatives (-,+)" $ do
parse parseRange "" "-,+" `shouldBe` Right (DoubleRange (RelativePosition Minus 1) (RelativePosition Plus 1))
it "matches with whitespace ( 123 , 45 )" $ do
parse parseRange "" " 123 , 45 " `shouldBe` Right (DoubleRange (AbsolutePosition 123) (AbsolutePosition 45))
describe "Commands" $ do
describe "append" $ do
it "matches append without range (a)" $ do
parse parseCommand "" "a" `shouldBe` Right (ParsedCommand "append" (SingleRange CurrentPosition) NoArgs)
it "matches append with range (1a)" $ do
parse parseCommand "" "1a" `shouldBe` Right (ParsedCommand "append" (SingleRange (AbsolutePosition 1)) NoArgs)
describe "change" $ do
it "changes no line (c)" $ do
parse parseCommand "" "c" `shouldBe` Right (ParsedCommand "change" (SingleRange CurrentPosition) NoArgs)
it "changes one line (.c)" $ do
parse parseCommand "" ".c" `shouldBe` Right (ParsedCommand "change" (SingleRange CurrentPosition) NoArgs)
it "changes no line (1,$c)" $ do
parse parseCommand "" "1,$c" `shouldBe` Right (ParsedCommand "change" (DoubleRange (AbsolutePosition 1) EndOfDoc) NoArgs)
describe "delete" $ do
it "deletes no line (d)" $ do
parse parseCommand "" "d" `shouldBe` Right (ParsedCommand "delete" (SingleRange CurrentPosition) NoArgs)
it "deletes one line (.d)" $ do
parse parseCommand "" ".d" `shouldBe` Right (ParsedCommand "delete" (SingleRange CurrentPosition) NoArgs)
it "deletes no line (1,$d)" $ do
parse parseCommand "" "1,$d" `shouldBe` Right (ParsedCommand "delete" (DoubleRange (AbsolutePosition 1) EndOfDoc) NoArgs)
describe "edit" $ do
it "edits simple file (e bar)" $ do
parse parseCommand "" "e bar" `shouldBe` Right (ParsedCommand "edit" NoRange $ StringArg "bar")
it "edits file (e /foo/bar.txt)" $ do
parse parseCommand "" "e /foo/bar.txt" `shouldBe` Right (ParsedCommand "edit" NoRange $ StringArg "/foo/bar.txt")
it "edits unconditional file (E /foo/bar.txt)" $ do
parse parseCommand "" "E /foo/bar.txt" `shouldBe` Right (ParsedCommand "editUncond" NoRange $ StringArg "/foo/bar.txt")
describe "default filename" $ do
it "sets default file name (f bar.txt)" $ do
parse parseCommand "" "f bar.txt" `shouldBe` Right (ParsedCommand "defaultFile" NoRange $ StringArg "bar.txt")
-- describe "global" $ do
describe "help" $ do
it "last error help (h)" $ do
parse parseCommand "" "h" `shouldBe` Right (ParsedCommand "help" NoRange NoArgs)
it "toggles help (H)" $ do
parse parseCommand "" "H" `shouldBe` Right (ParsedCommand "toggleHelp" NoRange NoArgs)
describe "insert" $ do
it "matches insert without range (a)" $ do
parse parseCommand "" "i" `shouldBe` Right (ParsedCommand "insert" (SingleRange CurrentPosition) NoArgs)
it "matches insert with range (1a)" $ do
parse parseCommand "" "1i" `shouldBe` Right (ParsedCommand "insert" (SingleRange (AbsolutePosition 1)) NoArgs)
describe "join" $ do
it "matches join without range (j)" $ do
parse parseCommand "" "j" `shouldBe` Right (ParsedCommand "join" (DoubleRange CurrentPosition (RelativePosition Plus 1)) NoArgs)
it "matches join multi range (2,4j)" $ do
parse parseCommand "" "2,4j" `shouldBe` Right (ParsedCommand "join" (DoubleRange (AbsolutePosition 2) (AbsolutePosition 4)) NoArgs)
describe "mark" $ do
it "matches no position (ka)" $ do
parse parseCommand "" "ka" `shouldBe` Right (ParsedCommand "mark" (SingleRange CurrentPosition) $ StringArg "a")
it "matches lined position (2ka)" $ do
parse parseCommand "" "2ka" `shouldBe` Right (ParsedCommand "mark" (SingleRange (AbsolutePosition 2)) $ StringArg "a")
describe "list" $ do
it "matches no position (l)" $ do
parse parseCommand "" "l" `shouldBe` Right (ParsedCommand "list" (SingleRange CurrentPosition) NoArgs)
it "matches single postion (1l)" $ do
parse parseCommand "" "1l" `shouldBe` Right (ParsedCommand "list" (SingleRange (AbsolutePosition 1)) NoArgs)
it "matches no psotion (1,2l)" $ do
parse parseCommand "" "1,2l" `shouldBe` Right (ParsedCommand "list" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) NoArgs)
describe "move" $ do
it "matches no position on both sides (m)" $ do
parse parseCommand "" "m" `shouldBe` Right (ParsedCommand "move" (SingleRange CurrentPosition) (RangeArg (SingleRange CurrentPosition)))
it "matches two single locations (1m2)" $ do
parse parseCommand "" "1m2" `shouldBe` Right (ParsedCommand "move" (SingleRange $ AbsolutePosition 1) (RangeArg $ SingleRange $ AbsolutePosition 2))
it "matches range locations (1,2m4)" $ do
parse parseCommand "" "1,2m4" `shouldBe` Right (ParsedCommand "move" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) (RangeArg $ SingleRange $ AbsolutePosition 4))
describe "numbered" $ do
it "matches no position (n)" $ do
parse parseCommand "" "n" `shouldBe` Right (ParsedCommand "numbered" (SingleRange CurrentPosition) NoArgs)
it "matches single postion (1n)" $ do
parse parseCommand "" "1n" `shouldBe` Right (ParsedCommand "numbered" (SingleRange (AbsolutePosition 1)) NoArgs)
it "matches no psotion (1,2n)" $ do
parse parseCommand "" "1,2n" `shouldBe` Right (ParsedCommand "numbered" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) NoArgs)
describe "print" $ do
it "matches no position (p)" $ do
parse parseCommand "" "p" `shouldBe` Right (ParsedCommand "print" (SingleRange CurrentPosition) NoArgs)
it "matches single postion (1p)" $ do
parse parseCommand "" "1p" `shouldBe` Right (ParsedCommand "print" (SingleRange (AbsolutePosition 1)) NoArgs)
it "matches no psotion (1,2p)" $ do
parse parseCommand "" "1,2p" `shouldBe` Right (ParsedCommand "print" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) NoArgs)
describe "togglePrompt" $ do
it "matches command (P)" $ do
parse parseCommand "" "P" `shouldBe` Right (ParsedCommand "togglePrompt" NoRange NoArgs)
describe "quit" $ do
it "matches quit (q)" $ do
parse parseCommand "" "q" `shouldBe` Right (ParsedCommand "quit" NoRange NoArgs)
it "matches quit unconditional (Q)" $ do
parse parseCommand "" "Q" `shouldBe` Right (ParsedCommand "quitUncond" NoRange NoArgs)
describe "read" $ do
it "matches no location (r /foo/bar.txt)" $ do
parse parseCommand "" "r /foo/bar.txt" `shouldBe` Right (ParsedCommand "read" (SingleRange EndOfDoc) $ StringArg "/foo/bar.txt")
it "matches location (.r /foo/bar.txt)" $ do
parse parseCommand "" ".r /foo/bar.txt" `shouldBe` Right (ParsedCommand "read" (SingleRange CurrentPosition) $ StringArg "/foo/bar.txt")
-- describe "swap" $ do
describe "copy" $ do
it "matches no location (t)" $ do
parse parseCommand "" "t" `shouldBe` Right (ParsedCommand "copy" (SingleRange CurrentPosition) $ RangeArg $ SingleRange CurrentPosition)
it "matches single locations (1t2)" $ do
parse parseCommand "" "1t2" `shouldBe` Right (ParsedCommand "copy" (SingleRange $ AbsolutePosition 1) $ RangeArg $ SingleRange $ AbsolutePosition 2)
it "matches range location (1,2t3)" $ do
parse parseCommand "" "1,2t3" `shouldBe` Right (ParsedCommand "copy" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) $ RangeArg $ SingleRange $ AbsolutePosition 3)
describe "undo" $ do
it "matches (u)" $ do
parse parseCommand "" "u" `shouldBe` Right (ParsedCommand "undo" NoRange NoArgs)
-- describe "reverseGlobal"
describe "write" $ do
it "matches no location (w /foo/bar.txt)" $ do
parse parseCommand "" "w /foo/bar.txt" `shouldBe` Right (ParsedCommand "write" (DoubleRange (AbsolutePosition 1) EndOfDoc) $ StringArg "/foo/bar.txt")
it "matches single locations (1w /foo/bar.txt)" $ do
parse parseCommand "" "1w /foo/bar.txt" `shouldBe` Right (ParsedCommand "write" (SingleRange $ AbsolutePosition 1) $ StringArg "/foo/bar.txt")
it "matches range location (1,2w /foo/bar.txt)" $ do
parse parseCommand "" "1,2w /foo/bar.txt" `shouldBe` Right (ParsedCommand "write" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) $ StringArg "/foo/bar.txt")
describe "writeQuit" $ do
it "matches no location (wq /foo/bar.txt)" $ do
parse parseCommand "" "wq /foo/bar.txt" `shouldBe` Right (ParsedCommand "writeQuit" (DoubleRange (AbsolutePosition 1) EndOfDoc) $ StringArg "/foo/bar.txt")
it "matches single locations (1wq /foo/bar.txt)" $ do
parse parseCommand "" "1wq /foo/bar.txt" `shouldBe` Right (ParsedCommand "writeQuit" (SingleRange $ AbsolutePosition 1) $ StringArg "/foo/bar.txt")
it "matches range location (1,2wq /foo/bar.txt)" $ do
parse parseCommand "" "1,2wq /foo/bar.txt" `shouldBe` Right (ParsedCommand "writeQuit" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) $ StringArg "/foo/bar.txt")
describe "appendFile" $ do
it "matches no location (W /foo/bar.txt)" $ do
parse parseCommand "" "W /foo/bar.txt" `shouldBe` Right (ParsedCommand "appendFile" (DoubleRange (AbsolutePosition 1) EndOfDoc) $ StringArg "/foo/bar.txt")
it "matches single locations (1W /foo/bar.txt)" $ do
parse parseCommand "" "1W /foo/bar.txt" `shouldBe` Right (ParsedCommand "appendFile" (SingleRange $ AbsolutePosition 1) $ StringArg "/foo/bar.txt")
it "matches range location (1,2W /foo/bar.txt)" $ do
parse parseCommand "" "1,2W /foo/bar.txt" `shouldBe` Right (ParsedCommand "appendFile" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) $ StringArg "/foo/bar.txt")
describe "puts" $ do
it "matches puts without range (x)" $ do
parse parseCommand "" "x" `shouldBe` Right (ParsedCommand "puts" (SingleRange CurrentPosition) NoArgs)
it "matches puts with range (1x)" $ do
parse parseCommand "" "1x" `shouldBe` Right (ParsedCommand "puts" (SingleRange (AbsolutePosition 1)) NoArgs)
describe "yank" $ do
it "matches no range (y)" $ do
parse parseCommand "" "y" `shouldBe` Right (ParsedCommand "yank" (SingleRange CurrentPosition) NoArgs)
it "matches one range (1y)" $ do
parse parseCommand "" "1y" `shouldBe` Right (ParsedCommand "yank" (SingleRange $ AbsolutePosition 1) NoArgs)
it "matches no range (1,2y)" $ do
parse parseCommand "" "1,2y" `shouldBe` Right (ParsedCommand "yank" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) NoArgs)
describe "scroll" $ do
it "matches no location (z2)" $ do
parse parseCommand "" "z2" `shouldBe` Right (ParsedCommand "scroll" (SingleRange $ RelativePosition Plus 1) $ NumberArg 2)
it "matches location (3z2)" $ do
parse parseCommand "" "3z2" `shouldBe` Right (ParsedCommand "scroll" (SingleRange $ AbsolutePosition 3) $ NumberArg 2)
describe "bang" $ do
it "matches command with args (!cmd --args)" $ do
parse parseCommand "" "!cmd --args" `shouldBe` Right (ParsedCommand "bang" NoRange $ StringArg "cmd --args")
describe "comment" $ do
it "matches no range and no text(#)" $ do
parse parseCommand "" "#" `shouldBe` Right (ParsedCommand "comment" (SingleRange CurrentPosition) $ StringArg "")
it "matches no range (# this is a comment)" $ do
parse parseCommand "" "# this is a comment" `shouldBe` Right (ParsedCommand "comment" (SingleRange CurrentPosition) $ StringArg " this is a comment")
it "matches one range (1#)" $ do
parse parseCommand "" "1#" `shouldBe` Right (ParsedCommand "comment" (SingleRange $ AbsolutePosition 1) $ StringArg "")
it "matches no range (1,2#)" $ do
parse parseCommand "" "1,2#" `shouldBe` Right (ParsedCommand "comment" (DoubleRange (AbsolutePosition 1) (AbsolutePosition 2)) $ StringArg "")
describe "lineNumber" $ do
it "matches no range (=)" $ do
parse parseCommand "" "=" `shouldBe` Right (ParsedCommand "lineNumber" (SingleRange EndOfDoc) NoArgs)
it "matches range (.=)" $ do
parse parseCommand "" ".=" `shouldBe` Right (ParsedCommand "lineNumber" (SingleRange CurrentPosition) NoArgs)
describe "jump" $ do
it "jumps with no range (<newline>)" $ do
parse parseCommand "" "" `shouldBe` Right (ParsedCommand "jump" NoRange NoArgs)
it "jumps with range (3<newline>)" $ do
parse parseCommand "" "3" `shouldBe` Right (ParsedCommand "jump" (SingleRange $ AbsolutePosition 3) NoArgs)
|
jecxjo/hed
|
test/CommandParserSpec.hs
|
bsd-3-clause
| 15,798 | 0 | 27 | 3,776 | 4,492 | 2,086 | 2,406 | 212 | 1 |
-----------------------------------------------------------------------------
-- |
-- Module : System.Win32
-- Copyright : (c) Alastair Reid, 1999-2003
-- License : BSD-style (see the file libraries/base/LICENSE)
--
-- Maintainer : Esa Ilari Vuokko <[email protected]>
-- Stability : provisional
-- Portability : portable
--
-- An FFI binding to the system part of the Win32 API.
--
-----------------------------------------------------------------------------
module System.Win32
( module System.Win32.DLL
, module System.Win32.File
, module System.Win32.FileMapping
, module System.Win32.Info
, module System.Win32.Mem
, module System.Win32.NLS
, module System.Win32.Process
, module System.Win32.Registry
, module System.Win32.Time
, module System.Win32.Console
, module System.Win32.Types
) where
import System.Win32.DLL
import System.Win32.File
import System.Win32.FileMapping
import System.Win32.Info
import System.Win32.Mem
import System.Win32.NLS hiding ( LCID, LANGID, SortID, SubLANGID
, PrimaryLANGID, mAKELCID, lANGIDFROMLCID
, sORTIDFROMLCID, mAKELANGID, pRIMARYLANGID
, sUBLANGID )
import System.Win32.Process
import System.Win32.Registry
import System.Win32.Time
import System.Win32.Console
import System.Win32.Types
----------------------------------------------------------------
-- End
----------------------------------------------------------------
|
FranklinChen/hugs98-plus-Sep2006
|
packages/Win32/System/Win32.hs
|
bsd-3-clause
| 1,498 | 4 | 5 | 265 | 207 | 146 | 61 | 26 | 0 |
{-# LANGUAGE
OverloadedStrings
, ScopedTypeVariables
, FlexibleContexts
#-}
module Templates.Master where
import Application.Types
import Templates.MainStyles
import Templates.MainScripts
import Data.Url
import Web.Page.Lucid
import Web.Routes.Nested hiding (FileExt (..), p_)
import qualified Network.Wai.Middleware.ContentType as FE
import qualified Data.Text as T
import Network.HTTP.Types
import Lucid
import Data.Monoid
import Data.Default
import Data.Markup
import Control.Monad.Trans
import Control.Monad.Reader.Class
-- | Render without @mainTemplate@
htmlLight :: ( MonadIO (Result m)
, UrlReader T.Text m
, MonadReader Env (Result m)
) => Status
-> HtmlT m a
-> FileExtListenerT (MiddlewareT (Result m)) (Result m) ()
htmlLight s content = do
hostname <- envHostname <$> (lift ask)
bs <- lift $ (runUrlReader $ renderBST content) $ T.pack hostname
bytestringStatus FE.Html s [("Content-Type","text/html")] bs
-- | Shortcut for rendering with a template
html :: ( MonadReader Env m
, MonadIO m
) => Maybe GlobalState
-> HtmlT (ClarkUrlT m) ()
-> FileExtListenerT (MiddlewareT m) m ()
html state content = htmlLight status200 $ mainTemplate state content
appendTitle :: WebPage (HtmlT m ()) T.Text
-> T.Text
-> WebPage (HtmlT m ()) T.Text
appendTitle page x = page { pageTitle = x <> " « " <> pageTitle page
}
masterPage :: ( Monad m
, MonadReader Env m
) => WebPage (HtmlT (ClarkUrlT m) ()) T.Text
masterPage =
let page :: (Monad m, MonadReader Env m) => WebPage (HtmlT (ClarkUrlT m) ()) T.Text
page = def
in page { afterStylesScripts = afterStylesScripts'
, bodyScripts = bodyScripts'
, styles = styles'
, pageTitle = ("Clark Mining Tech" :: T.Text)
, metaVars = do metaVars page
meta_ [httpEquiv_ "Content-Type", content_ "text/html; charset=UTF-8"]
meta_ [name_ "viewport", content_ "width=device-width, initial-scale=1.0, maximum-scale=1.0"]
meta_ [httpEquiv_ "X-UA-Compatible", content_ "IE=edge,chrome=1"]
}
where
afterStylesScripts' = renderMarkup localStylesScripts
localStylesScripts :: Monad m => LocalMarkupM (HtmlT (AbsoluteUrlT T.Text m) ())
localStylesScripts = mconcat
[ deploy JavaScript
("vendor/jquery/dist/jquery.min.js" :: T.Text)
, deploy JavaScript
("vendor/semantic-ui/dist/semantic.min.js" :: T.Text)
]
styles' = renderMarkup localStyles
<> renderMarkup inlineStyles
localStyles :: Monad m => LocalMarkupM (HtmlT (AbsoluteUrlT T.Text m) ())
localStyles = mconcat
[ deploy Css
("vendor/semantic-ui/dist/semantic.min.css" :: T.Text)
]
inlineStyles :: Monad m => InlineMarkupM (HtmlT m ())
inlineStyles = mconcat
[ deploy Css mainStyles
]
bodyScripts' = renderMarkup inlineBodyScripts
inlineBodyScripts :: Monad m => InlineMarkupM (HtmlT m ())
inlineBodyScripts = mconcat
[ deploy JavaScript mainScripts
]
masterTemplate :: ( Monad m
, MonadReader Env m
) => Maybe GlobalState
-> WebPage (HtmlT (ClarkUrlT m) ()) T.Text
-> HtmlT (ClarkUrlT m) ()
-> HtmlT (ClarkUrlT m) ()
masterTemplate state page content = template page $ do
sideBar
div_ [class_ "pusher"] $ do
navBar
div_ [ id_ "content"
, class_ "ui grid padded"] $ do
content
div_ [ id_ "footer"
, class_ "row"] $
div_ [class_ "column sixteen wide center aligned"] $
p_ [style_ "color: #fff;"] "Copyright © Lawrence R. Clark, 2015 - forever, yo"
where
sideBar = do
root <- lift $ plainUrl ""
contact <- lift $ plainUrl "contact"
about <- lift $ plainUrl "about"
nav_ [ id_ "sideBar"
, class_ "ui sidebar inverted vertical menu"] $ do
div_ [class_ "ui inverted transparent icon input item"] $ do
i_ [class_ "search link icon"] ""
input_ [placeholder_ "Search...", type_ "text", class_ "ui input"]
a_ [ class_ (appendActiveWhen state HomeNav "item")
, href_ root] $ do
i_ [class_ "home icon"] ""
"Home"
a_ [ class_ (appendActiveWhen state (AboutNav Nothing) "item")
, href_ about] $ do
i_ [class_ "asterisk icon"] ""
"About"
a_ [ class_ (appendActiveWhen state ContactNav "item")
, href_ contact] $ do
i_ [class_ "mail icon"] ""
"Contact"
navBar = do
root <- lift $ plainUrl ""
contact <- lift $ plainUrl "contact"
about <- lift $ plainUrl "about"
services <- lift $ plainUrl "services"
management <- lift $ plainUrl "about/management"
nav_ [ id_ "navBar"
, class_ "ui top fixed inverted menu"] $ do
div_ [ id_ "navBar-menu-button"
, class_ "item ui button icon"] $
i_ [class_ "icon sidebar"] ""
a_ [ class_ (appendActiveWhen state HomeNav "item")
, href_ root] "Clark Mining Tech"
div_ [ id_ "navBar-about-button"
, class_ (appendActiveWhen state (AboutNav Nothing) "ui dropdown item")] $ do
"About"
i_ [class_ "dropdown icon"] ""
div_ [ id_ "navBar-about"
, class_ "menu"] $ do
a_ [ class_ (appendActiveWhen state (AboutNav (Just ManagementNav)) "item")
, href_ management] "Management"
a_ [ id_ "navBar-services-button"
, class_ "item"
, href_ services] "Services"
div_ [class_ "right menu"] $ do
a_ [class_ (appendActiveWhen state ContactNav "item"), href_ contact] "Contact"
div_ [class_ "item"] $
div_ [class_ "ui inverted transparent icon input"] $ do
input_ [placeholder_ "Search...", type_ "text"]
i_ [class_ "search link icon"] ""
div_ [ id_ "navBar-services"
, class_ "ui fluid popup bottom left transition hidden"] $
div_ [class_ "ui four column relaxed equal height divided grid"] $ do
div_ [class_ "column"] $ do
h4_ [class_ "ui header"] "Fabrics"
div_ [class_ "ui link list"] $ do
a_ [class_ "item"] "Cashmere"
a_ [class_ "item"] "Linen"
a_ [class_ "item"] "Cotton"
a_ [class_ "item"] "Viscose"
div_ [class_ "column"] $ do
h4_ [class_ "ui header"] "Fabrics"
div_ [class_ "ui link list"] $ do
a_ [class_ "item"] "Cashmere"
a_ [class_ "item"] "Linen"
a_ [class_ "item"] "Cotton"
a_ [class_ "item"] "Viscose"
div_ [class_ "column"] $ do
h4_ [class_ "ui header"] "Fabrics"
div_ [class_ "ui link list"] $ do
a_ [class_ "item"] "Cashmere"
a_ [class_ "item"] "Linen"
a_ [class_ "item"] "Cotton"
a_ [class_ "item"] "Viscose"
div_ [class_ "column"] $ do
h4_ [class_ "ui header"] "Fabrics"
div_ [class_ "ui link list"] $ do
a_ [class_ "item"] "Cashmere"
a_ [class_ "item"] "Linen"
a_ [class_ "item"] "Cotton"
a_ [class_ "item"] "Viscose"
mainTemplate :: ( Monad m
, MonadReader Env m
) => Maybe GlobalState
-> HtmlT (ClarkUrlT m) ()
-> HtmlT (ClarkUrlT m) ()
mainTemplate state =
masterTemplate state masterPage
|
athanclark/clark-mining-tech
|
src/Templates/Master.hs
|
bsd-3-clause
| 7,812 | 0 | 26 | 2,535 | 2,293 | 1,096 | 1,197 | 180 | 1 |
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
-- | A renderer that produces pretty SVG, mostly meant for debugging purposes.
--
module Text.Blaze.Svg.Renderer.Pretty
( renderSvg
) where
import Text.Blaze.Renderer.Pretty (renderMarkup)
renderSvg = renderMarkup
|
deepakjois/blaze-svg
|
src/Text/Blaze/Svg/Renderer/Pretty.hs
|
bsd-3-clause
| 272 | 0 | 5 | 39 | 34 | 24 | 10 | 5 | 1 |
-- !!! Re-exporting qualified import.
module M (module List) where
import List as Char
|
FranklinChen/Hugs
|
tests/static/mod135.hs
|
bsd-3-clause
| 91 | 0 | 4 | 18 | 16 | 12 | 4 | 2 | 0 |
module Lfu
( Lfu(..)
) where
import qualified Cache as C
import qualified Data.HashPSQ as H (HashPSQ, alter, alterMin, empty, insert)
import Data.Maybe (isJust)
import Request
import SimpleCaches (readFromCache')
type FilePrio = Int
data Lfu = Lfu { files :: H.HashPSQ FileID FilePrio FileSize
, size :: C.CacheSize
, maxSize :: C.CacheSize
, writeStrategy :: C.WriteStrategy
}
instance C.Cache Lfu where
to = insert'
readFromCache = readFromCache' updateCache
remove = remove'
empty = Lfu H.empty 0
size = size
maxSize = maxSize
writeStrategy = writeStrategy
updateCache :: C.File -> Lfu -> (Bool, Lfu)
updateCache (fileID, _) cache =
let (itemWasInCache, files') = H.alter updateItem fileID $ files cache
in (itemWasInCache, cache {files = files'})
updateItem :: Maybe (FilePrio, FileSize) -> (Bool, Maybe (FilePrio, FileSize))
updateItem Nothing = (False, Nothing)
updateItem (Just (prio, fileSize)) = (True, Just (prio + 1, fileSize))
insert' :: C.File -> Lfu -> Lfu
insert' f@(fileID, fileSize) cache
| f `C.biggerAsMax` cache = cache
| C.fits f cache = cache {files = files', size = size cache + fileSize}
| otherwise = insert' f (removeLFU cache)
where files' = H.insert fileID 1 fileSize $ files cache
removeLFU :: Lfu -> Lfu
removeLFU cache =
let (sizeOfRemoved, files') = H.alterMin delete' $ files cache
in cache {files = files', size = size cache - sizeOfRemoved}
delete' :: Maybe (FileID, FilePrio, FileSize) -> (FileSize, Maybe (FileID, FilePrio, FileSize))
delete' Nothing = (0, Nothing)
delete' (Just (_, _, fileSize)) = (fileSize, Nothing)
remove' :: C.File -> Lfu -> Lfu
remove' (fileID, fileSize) cache =
let (removed, updatedFiles) = H.alter (\f -> (isJust f, Nothing)) fileID $ files cache
currentSize = size cache
newSize = if removed then currentSize - fileSize else currentSize
in cache {files = updatedFiles, size = newSize}
|
wochinge/CacheSimulator
|
src/Lfu.hs
|
bsd-3-clause
| 2,105 | 0 | 14 | 545 | 740 | 413 | 327 | 46 | 2 |
{-# LANGUAGE CPP #-}
#if !defined(TESTING) && __GLASGOW_HASKELL__ >= 703
{-# LANGUAGE Trustworthy #-}
#endif
#include "containers.h"
-----------------------------------------------------------------------------
-- |
-- Module : Data.Map.Strict
-- Copyright : (c) Daan Leijen 2002
-- (c) Andriy Palamarchuk 2008
-- License : BSD-style
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability : portable
--
-- An efficient implementation of ordered maps from keys to values
-- (dictionaries).
--
-- API of this module is strict in both the keys and the values.
-- If you need value-lazy maps, use "Data.Map.Lazy" instead.
-- The 'Map' type is shared between the lazy and strict modules,
-- meaning that the same 'Map' value can be passed to functions in
-- both modules (although that is rarely needed).
--
-- These modules are intended to be imported qualified, to avoid name
-- clashes with Prelude functions, e.g.
--
-- > import qualified Data.Map.Strict as Map
--
-- The implementation of 'Map' is based on /size balanced/ binary trees (or
-- trees of /bounded balance/) as described by:
--
-- * Stephen Adams, \"/Efficient sets: a balancing act/\",
-- Journal of Functional Programming 3(4):553-562, October 1993,
-- <http://www.swiss.ai.mit.edu/~adams/BB/>.
--
-- * J. Nievergelt and E.M. Reingold,
-- \"/Binary search trees of bounded balance/\",
-- SIAM journal of computing 2(1), March 1973.
--
-- Note that the implementation is /left-biased/ -- the elements of a
-- first argument are always preferred to the second, for example in
-- 'union' or 'insert'.
--
-- Operation comments contain the operation time complexity in
-- the Big-O notation (<http://en.wikipedia.org/wiki/Big_O_notation>).
--
-- Be aware that the 'Functor', 'Traversable' and 'Data' instances
-- are the same as for the "Data.Map.Lazy" module, so if they are used
-- on strict maps, the resulting maps will be lazy.
-----------------------------------------------------------------------------
-- See the notes at the beginning of Data.Map.Base.
module Data.Map.Strict
(
-- * Strictness properties
-- $strictness
-- * Map type
#if !defined(TESTING)
Map -- instance Eq,Show,Read
#else
Map(..) -- instance Eq,Show,Read
#endif
-- * Operators
, (!), (\\)
-- * Query
, null
, size
, member
, notMember
, lookup
, findWithDefault
, lookupLT
, lookupGT
, lookupLE
, lookupGE
-- * Construction
, empty
, singleton
-- ** Insertion
, insert
, insertWith
, insertWithKey
, insertLookupWithKey
-- ** Delete\/Update
, delete
, adjust
, adjustWithKey
, update
, updateWithKey
, updateLookupWithKey
, alter
-- * Combine
-- ** Union
, union
, unionWith
, unionWithKey
, unions
, unionsWith
-- ** Difference
, difference
, differenceWith
, differenceWithKey
-- ** Intersection
, intersection
, intersectionWith
, intersectionWithKey
-- ** Universal combining function
, mergeWithKey
-- * Traversal
-- ** Map
, map
, mapWithKey
, traverseWithKey
, mapAccum
, mapAccumWithKey
, mapAccumRWithKey
, mapKeys
, mapKeysWith
, mapKeysMonotonic
-- * Folds
, foldr
, foldl
, foldrWithKey
, foldlWithKey
, foldMapWithKey
-- ** Strict folds
, foldr'
, foldl'
, foldrWithKey'
, foldlWithKey'
-- * Conversion
, elems
, keys
, assocs
, keysSet
, fromSet
-- ** Lists
, toList
, fromList
, fromListWith
, fromListWithKey
-- ** Ordered lists
, toAscList
, toDescList
, fromAscList
, fromAscListWith
, fromAscListWithKey
, fromDistinctAscList
-- * Filter
, filter
, filterWithKey
, partition
, partitionWithKey
, mapMaybe
, mapMaybeWithKey
, mapEither
, mapEitherWithKey
, split
, splitLookup
, splitRoot
-- * Submap
, isSubmapOf, isSubmapOfBy
, isProperSubmapOf, isProperSubmapOfBy
-- * Indexed
, lookupIndex
, findIndex
, elemAt
, updateAt
, deleteAt
-- * Min\/Max
, findMin
, findMax
, deleteMin
, deleteMax
, deleteFindMin
, deleteFindMax
, updateMin
, updateMax
, updateMinWithKey
, updateMaxWithKey
, minView
, maxView
, minViewWithKey
, maxViewWithKey
-- * Debugging
, showTree
, showTreeWith
, valid
#if defined(TESTING)
-- * Internals
, bin
, balanced
, link
, merge
#endif
) where
import Prelude hiding (lookup,map,filter,foldr,foldl,null)
import Data.Map.Base hiding
( findWithDefault
, singleton
, insert
, insertWith
, insertWithKey
, insertLookupWithKey
, adjust
, adjustWithKey
, update
, updateWithKey
, updateLookupWithKey
, alter
, unionWith
, unionWithKey
, unionsWith
, differenceWith
, differenceWithKey
, intersectionWith
, intersectionWithKey
, mergeWithKey
, map
, mapWithKey
, mapAccum
, mapAccumWithKey
, mapAccumRWithKey
, mapKeysWith
, fromSet
, fromList
, fromListWith
, fromListWithKey
, fromAscList
, fromAscListWith
, fromAscListWithKey
, fromDistinctAscList
, mapMaybe
, mapMaybeWithKey
, mapEither
, mapEitherWithKey
, updateAt
, updateMin
, updateMax
, updateMinWithKey
, updateMaxWithKey
)
import qualified Data.Set.Base as Set
import Data.Utils.StrictFold
import Data.Utils.StrictPair
import Data.Bits (shiftL, shiftR)
#if __GLASGOW_HASKELL__ >= 709
import Data.Coerce
#endif
-- $strictness
--
-- This module satisfies the following strictness properties:
--
-- 1. Key arguments are evaluated to WHNF;
--
-- 2. Keys and values are evaluated to WHNF before they are stored in
-- the map.
--
-- Here's an example illustrating the first property:
--
-- > delete undefined m == undefined
--
-- Here are some examples that illustrate the second property:
--
-- > map (\ v -> undefined) m == undefined -- m is not empty
-- > mapKeys (\ k -> undefined) m == undefined -- m is not empty
{--------------------------------------------------------------------
Query
--------------------------------------------------------------------}
-- | /O(log n)/. The expression @('findWithDefault' def k map)@ returns
-- the value at key @k@ or returns default value @def@
-- when the key is not in the map.
--
-- > findWithDefault 'x' 1 (fromList [(5,'a'), (3,'b')]) == 'x'
-- > findWithDefault 'x' 5 (fromList [(5,'a'), (3,'b')]) == 'a'
-- See Map.Base.Note: Local 'go' functions and capturing
findWithDefault :: Ord k => a -> k -> Map k a -> a
findWithDefault def k = k `seq` go
where
go Tip = def
go (Bin _ kx x l r) = case compare k kx of
LT -> go l
GT -> go r
EQ -> x
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE findWithDefault #-}
#else
{-# INLINE findWithDefault #-}
#endif
{--------------------------------------------------------------------
Construction
--------------------------------------------------------------------}
-- | /O(1)/. A map with a single element.
--
-- > singleton 1 'a' == fromList [(1, 'a')]
-- > size (singleton 1 'a') == 1
singleton :: k -> a -> Map k a
singleton k x = x `seq` Bin 1 k x Tip Tip
{-# INLINE singleton #-}
{--------------------------------------------------------------------
Insertion
--------------------------------------------------------------------}
-- | /O(log n)/. Insert a new key and value in the map.
-- If the key is already present in the map, the associated value is
-- replaced with the supplied value. 'insert' is equivalent to
-- @'insertWith' 'const'@.
--
-- > insert 5 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'x')]
-- > insert 7 'x' (fromList [(5,'a'), (3,'b')]) == fromList [(3, 'b'), (5, 'a'), (7, 'x')]
-- > insert 5 'x' empty == singleton 5 'x'
-- See Map.Base.Note: Type of local 'go' function
insert :: Ord k => k -> a -> Map k a -> Map k a
insert = go
where
go :: Ord k => k -> a -> Map k a -> Map k a
STRICT_1_OF_3(go)
STRICT_2_OF_3(go)
go kx x Tip = singleton kx x
go kx x (Bin sz ky y l r) =
case compare kx ky of
LT -> balanceL ky y (go kx x l) r
GT -> balanceR ky y l (go kx x r)
EQ -> Bin sz kx x l r
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE insert #-}
#else
{-# INLINE insert #-}
#endif
-- | /O(log n)/. Insert with a function, combining new value and old value.
-- @'insertWith' f key value mp@
-- will insert the pair (key, value) into @mp@ if key does
-- not exist in the map. If the key does exist, the function will
-- insert the pair @(key, f new_value old_value)@.
--
-- > insertWith (++) 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "xxxa")]
-- > insertWith (++) 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
-- > insertWith (++) 5 "xxx" empty == singleton 5 "xxx"
insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
insertWith f = insertWithKey (\_ x' y' -> f x' y')
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE insertWith #-}
#else
{-# INLINE insertWith #-}
#endif
-- | /O(log n)/. Insert with a function, combining key, new value and old value.
-- @'insertWithKey' f key value mp@
-- will insert the pair (key, value) into @mp@ if key does
-- not exist in the map. If the key does exist, the function will
-- insert the pair @(key,f key new_value old_value)@.
-- Note that the key passed to f is the same key passed to 'insertWithKey'.
--
-- > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
-- > insertWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:xxx|a")]
-- > insertWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "xxx")]
-- > insertWithKey f 5 "xxx" empty == singleton 5 "xxx"
-- See Map.Base.Note: Type of local 'go' function
insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
insertWithKey = go
where
go :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
STRICT_2_OF_4(go)
go _ kx x Tip = singleton kx x
go f kx x (Bin sy ky y l r) =
case compare kx ky of
LT -> balanceL ky y (go f kx x l) r
GT -> balanceR ky y l (go f kx x r)
EQ -> let x' = f kx x y
in x' `seq` Bin sy kx x' l r
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE insertWithKey #-}
#else
{-# INLINE insertWithKey #-}
#endif
-- | /O(log n)/. Combines insert operation with old value retrieval.
-- The expression (@'insertLookupWithKey' f k x map@)
-- is a pair where the first element is equal to (@'lookup' k map@)
-- and the second element equal to (@'insertWithKey' f k x map@).
--
-- > let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value
-- > insertLookupWithKey f 5 "xxx" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "5:xxx|a")])
-- > insertLookupWithKey f 7 "xxx" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "xxx")])
-- > insertLookupWithKey f 5 "xxx" empty == (Nothing, singleton 5 "xxx")
--
-- This is how to define @insertLookup@ using @insertLookupWithKey@:
--
-- > let insertLookup kx x t = insertLookupWithKey (\_ a _ -> a) kx x t
-- > insertLookup 5 "x" (fromList [(5,"a"), (3,"b")]) == (Just "a", fromList [(3, "b"), (5, "x")])
-- > insertLookup 7 "x" (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a"), (7, "x")])
-- See Map.Base.Note: Type of local 'go' function
insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a
-> (Maybe a, Map k a)
insertLookupWithKey f0 kx0 x0 t0 = toPair $ go f0 kx0 x0 t0
where
go :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> StrictPair (Maybe a) (Map k a)
STRICT_2_OF_4(go)
go _ kx x Tip = Nothing :*: singleton kx x
go f kx x (Bin sy ky y l r) =
case compare kx ky of
LT -> let (found :*: l') = go f kx x l
in found :*: balanceL ky y l' r
GT -> let (found :*: r') = go f kx x r
in found :*: balanceR ky y l r'
EQ -> let x' = f kx x y
in x' `seq` (Just y :*: Bin sy kx x' l r)
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE insertLookupWithKey #-}
#else
{-# INLINE insertLookupWithKey #-}
#endif
{--------------------------------------------------------------------
Deletion
--------------------------------------------------------------------}
-- | /O(log n)/. Update a value at a specific key with the result of the provided function.
-- When the key is not
-- a member of the map, the original map is returned.
--
-- > adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
-- > adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
-- > adjust ("new " ++) 7 empty == empty
adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a
adjust f = adjustWithKey (\_ x -> f x)
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE adjust #-}
#else
{-# INLINE adjust #-}
#endif
-- | /O(log n)/. Adjust a value at a specific key. When the key is not
-- a member of the map, the original map is returned.
--
-- > let f key x = (show key) ++ ":new " ++ x
-- > adjustWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
-- > adjustWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
-- > adjustWithKey f 7 empty == empty
adjustWithKey :: Ord k => (k -> a -> a) -> k -> Map k a -> Map k a
adjustWithKey f = updateWithKey (\k' x' -> Just (f k' x'))
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE adjustWithKey #-}
#else
{-# INLINE adjustWithKey #-}
#endif
-- | /O(log n)/. The expression (@'update' f k map@) updates the value @x@
-- at @k@ (if it is in the map). If (@f x@) is 'Nothing', the element is
-- deleted. If it is (@'Just' y@), the key @k@ is bound to the new value @y@.
--
-- > let f x = if x == "a" then Just "new a" else Nothing
-- > update f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")]
-- > update f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
-- > update f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a
update f = updateWithKey (\_ x -> f x)
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE update #-}
#else
{-# INLINE update #-}
#endif
-- | /O(log n)/. The expression (@'updateWithKey' f k map@) updates the
-- value @x@ at @k@ (if it is in the map). If (@f k x@) is 'Nothing',
-- the element is deleted. If it is (@'Just' y@), the key @k@ is bound
-- to the new value @y@.
--
-- > let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
-- > updateWithKey f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "5:new a")]
-- > updateWithKey f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
-- > updateWithKey f 3 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
-- See Map.Base.Note: Type of local 'go' function
updateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a
updateWithKey = go
where
go :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a
STRICT_2_OF_3(go)
go _ _ Tip = Tip
go f k(Bin sx kx x l r) =
case compare k kx of
LT -> balanceR kx x (go f k l) r
GT -> balanceL kx x l (go f k r)
EQ -> case f kx x of
Just x' -> x' `seq` Bin sx kx x' l r
Nothing -> glue l r
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE updateWithKey #-}
#else
{-# INLINE updateWithKey #-}
#endif
-- | /O(log n)/. Lookup and update. See also 'updateWithKey'.
-- The function returns changed value, if it is updated.
-- Returns the original key value if the map entry is deleted.
--
-- > let f k x = if x == "a" then Just ((show k) ++ ":new a") else Nothing
-- > updateLookupWithKey f 5 (fromList [(5,"a"), (3,"b")]) == (Just "5:new a", fromList [(3, "b"), (5, "5:new a")])
-- > updateLookupWithKey f 7 (fromList [(5,"a"), (3,"b")]) == (Nothing, fromList [(3, "b"), (5, "a")])
-- > updateLookupWithKey f 3 (fromList [(5,"a"), (3,"b")]) == (Just "b", singleton 5 "a")
-- See Map.Base.Note: Type of local 'go' function
updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a,Map k a)
updateLookupWithKey f0 k0 t0 = toPair $ go f0 k0 t0
where
go :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> StrictPair (Maybe a) (Map k a)
STRICT_2_OF_3(go)
go _ _ Tip = (Nothing :*: Tip)
go f k (Bin sx kx x l r) =
case compare k kx of
LT -> let (found :*: l') = go f k l
in found :*: balanceR kx x l' r
GT -> let (found :*: r') = go f k r
in found :*: balanceL kx x l r'
EQ -> case f kx x of
Just x' -> x' `seq` (Just x' :*: Bin sx kx x' l r)
Nothing -> (Just x :*: glue l r)
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE updateLookupWithKey #-}
#else
{-# INLINE updateLookupWithKey #-}
#endif
-- | /O(log n)/. The expression (@'alter' f k map@) alters the value @x@ at @k@, or absence thereof.
-- 'alter' can be used to insert, delete, or update a value in a 'Map'.
-- In short : @'lookup' k ('alter' f k m) = f ('lookup' k m)@.
--
-- > let f _ = Nothing
-- > alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")]
-- > alter f 5 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
-- >
-- > let f _ = Just "c"
-- > alter f 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a"), (7, "c")]
-- > alter f 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "c")]
-- See Map.Base.Note: Type of local 'go' function
alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a
alter = go
where
go :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a
STRICT_2_OF_3(go)
go f k Tip = case f Nothing of
Nothing -> Tip
Just x -> singleton k x
go f k (Bin sx kx x l r) = case compare k kx of
LT -> balance kx x (go f k l) r
GT -> balance kx x l (go f k r)
EQ -> case f (Just x) of
Just x' -> x' `seq` Bin sx kx x' l r
Nothing -> glue l r
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE alter #-}
#else
{-# INLINE alter #-}
#endif
{--------------------------------------------------------------------
Indexing
--------------------------------------------------------------------}
-- | /O(log n)/. Update the element at /index/. Calls 'error' when an
-- invalid index is used.
--
-- > updateAt (\ _ _ -> Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")]
-- > updateAt (\ _ _ -> Just "x") 1 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")]
-- > updateAt (\ _ _ -> Just "x") 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
-- > updateAt (\ _ _ -> Just "x") (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range
-- > updateAt (\_ _ -> Nothing) 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
-- > updateAt (\_ _ -> Nothing) 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
-- > updateAt (\_ _ -> Nothing) 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
-- > updateAt (\_ _ -> Nothing) (-1) (fromList [(5,"a"), (3,"b")]) Error: index out of range
updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a
updateAt f i t = i `seq`
case t of
Tip -> error "Map.updateAt: index out of range"
Bin sx kx x l r -> case compare i sizeL of
LT -> balanceR kx x (updateAt f i l) r
GT -> balanceL kx x l (updateAt f (i-sizeL-1) r)
EQ -> case f kx x of
Just x' -> x' `seq` Bin sx kx x' l r
Nothing -> glue l r
where
sizeL = size l
{--------------------------------------------------------------------
Minimal, Maximal
--------------------------------------------------------------------}
-- | /O(log n)/. Update the value at the minimal key.
--
-- > updateMin (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "Xb"), (5, "a")]
-- > updateMin (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
updateMin :: (a -> Maybe a) -> Map k a -> Map k a
updateMin f m
= updateMinWithKey (\_ x -> f x) m
-- | /O(log n)/. Update the value at the maximal key.
--
-- > updateMax (\ a -> Just ("X" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "Xa")]
-- > updateMax (\ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
updateMax :: (a -> Maybe a) -> Map k a -> Map k a
updateMax f m
= updateMaxWithKey (\_ x -> f x) m
-- | /O(log n)/. Update the value at the minimal key.
--
-- > updateMinWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"3:b"), (5,"a")]
-- > updateMinWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
updateMinWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
updateMinWithKey _ Tip = Tip
updateMinWithKey f (Bin sx kx x Tip r) = case f kx x of
Nothing -> r
Just x' -> x' `seq` Bin sx kx x' Tip r
updateMinWithKey f (Bin _ kx x l r) = balanceR kx x (updateMinWithKey f l) r
-- | /O(log n)/. Update the value at the maximal key.
--
-- > updateMaxWithKey (\ k a -> Just ((show k) ++ ":" ++ a)) (fromList [(5,"a"), (3,"b")]) == fromList [(3,"b"), (5,"5:a")]
-- > updateMaxWithKey (\ _ _ -> Nothing) (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
updateMaxWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
updateMaxWithKey _ Tip = Tip
updateMaxWithKey f (Bin sx kx x l Tip) = case f kx x of
Nothing -> l
Just x' -> x' `seq` Bin sx kx x' l Tip
updateMaxWithKey f (Bin _ kx x l r) = balanceL kx x l (updateMaxWithKey f r)
{--------------------------------------------------------------------
Union.
--------------------------------------------------------------------}
-- | The union of a list of maps, with a combining operation:
-- (@'unionsWith' f == 'Prelude.foldl' ('unionWith' f) 'empty'@).
--
-- > unionsWith (++) [(fromList [(5, "a"), (3, "b")]), (fromList [(5, "A"), (7, "C")]), (fromList [(5, "A3"), (3, "B3")])]
-- > == fromList [(3, "bB3"), (5, "aAA3"), (7, "C")]
unionsWith :: Ord k => (a->a->a) -> [Map k a] -> Map k a
unionsWith f ts
= foldlStrict (unionWith f) empty ts
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE unionsWith #-}
#endif
{--------------------------------------------------------------------
Union with a combining function
--------------------------------------------------------------------}
-- | /O(n+m)/. Union with a combining function. The implementation uses the efficient /hedge-union/ algorithm.
--
-- > unionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "aA"), (7, "C")]
unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
unionWith f m1 m2
= unionWithKey (\_ x y -> f x y) m1 m2
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE unionWith #-}
#endif
-- | /O(n+m)/.
-- Union with a combining function. The implementation uses the efficient /hedge-union/ algorithm.
--
-- > let f key left_value right_value = (show key) ++ ":" ++ left_value ++ "|" ++ right_value
-- > unionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == fromList [(3, "b"), (5, "5:a|A"), (7, "C")]
unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a
unionWithKey f t1 t2 = mergeWithKey (\k x1 x2 -> Just $ f k x1 x2) id id t1 t2
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE unionWithKey #-}
#endif
{--------------------------------------------------------------------
Difference
--------------------------------------------------------------------}
-- | /O(n+m)/. Difference with a combining function.
-- When two equal keys are
-- encountered, the combining function is applied to the values of these keys.
-- If it returns 'Nothing', the element is discarded (proper set difference). If
-- it returns (@'Just' y@), the element is updated with a new value @y@.
-- The implementation uses an efficient /hedge/ algorithm comparable with /hedge-union/.
--
-- > let f al ar = if al == "b" then Just (al ++ ":" ++ ar) else Nothing
-- > differenceWith f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (7, "C")])
-- > == singleton 3 "b:B"
differenceWith :: Ord k => (a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
differenceWith f m1 m2
= differenceWithKey (\_ x y -> f x y) m1 m2
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE differenceWith #-}
#endif
-- | /O(n+m)/. Difference with a combining function. When two equal keys are
-- encountered, the combining function is applied to the key and both values.
-- If it returns 'Nothing', the element is discarded (proper set difference). If
-- it returns (@'Just' y@), the element is updated with a new value @y@.
-- The implementation uses an efficient /hedge/ algorithm comparable with /hedge-union/.
--
-- > let f k al ar = if al == "b" then Just ((show k) ++ ":" ++ al ++ "|" ++ ar) else Nothing
-- > differenceWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (3, "B"), (10, "C")])
-- > == singleton 3 "3:b|B"
differenceWithKey :: Ord k => (k -> a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
differenceWithKey f t1 t2 = mergeWithKey f id (const Tip) t1 t2
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE differenceWithKey #-}
#endif
{--------------------------------------------------------------------
Intersection
--------------------------------------------------------------------}
-- | /O(n+m)/. Intersection with a combining function. The implementation uses
-- an efficient /hedge/ algorithm comparable with /hedge-union/.
--
-- > intersectionWith (++) (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "aA"
intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c
intersectionWith f m1 m2
= intersectionWithKey (\_ x y -> f x y) m1 m2
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE intersectionWith #-}
#endif
-- | /O(n+m)/. Intersection with a combining function. The implementation uses
-- an efficient /hedge/ algorithm comparable with /hedge-union/.
--
-- > let f k al ar = (show k) ++ ":" ++ al ++ "|" ++ ar
-- > intersectionWithKey f (fromList [(5, "a"), (3, "b")]) (fromList [(5, "A"), (7, "C")]) == singleton 5 "5:a|A"
intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c
intersectionWithKey f t1 t2 = mergeWithKey (\k x1 x2 -> Just $ f k x1 x2) (const Tip) (const Tip) t1 t2
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE intersectionWithKey #-}
#endif
{--------------------------------------------------------------------
MergeWithKey
--------------------------------------------------------------------}
-- | /O(n+m)/. A high-performance universal combining function. This function
-- is used to define 'unionWith', 'unionWithKey', 'differenceWith',
-- 'differenceWithKey', 'intersectionWith', 'intersectionWithKey' and can be
-- used to define other custom combine functions.
--
-- Please make sure you know what is going on when using 'mergeWithKey',
-- otherwise you can be surprised by unexpected code growth or even
-- corruption of the data structure.
--
-- When 'mergeWithKey' is given three arguments, it is inlined to the call
-- site. You should therefore use 'mergeWithKey' only to define your custom
-- combining functions. For example, you could define 'unionWithKey',
-- 'differenceWithKey' and 'intersectionWithKey' as
--
-- > myUnionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) id id m1 m2
-- > myDifferenceWithKey f m1 m2 = mergeWithKey f id (const empty) m1 m2
-- > myIntersectionWithKey f m1 m2 = mergeWithKey (\k x1 x2 -> Just (f k x1 x2)) (const empty) (const empty) m1 m2
--
-- When calling @'mergeWithKey' combine only1 only2@, a function combining two
-- 'IntMap's is created, such that
--
-- * if a key is present in both maps, it is passed with both corresponding
-- values to the @combine@ function. Depending on the result, the key is either
-- present in the result with specified value, or is left out;
--
-- * a nonempty subtree present only in the first map is passed to @only1@ and
-- the output is added to the result;
--
-- * a nonempty subtree present only in the second map is passed to @only2@ and
-- the output is added to the result.
--
-- The @only1@ and @only2@ methods /must return a map with a subset (possibly empty) of the keys of the given map/.
-- The values can be modified arbitrarily. Most common variants of @only1@ and
-- @only2@ are 'id' and @'const' 'empty'@, but for example @'map' f@ or
-- @'filterWithKey' f@ could be used for any @f@.
mergeWithKey :: Ord k => (k -> a -> b -> Maybe c) -> (Map k a -> Map k c) -> (Map k b -> Map k c)
-> Map k a -> Map k b -> Map k c
mergeWithKey f g1 g2 = go
where
go Tip t2 = g2 t2
go t1 Tip = g1 t1
go t1 t2 = hedgeMerge NothingS NothingS t1 t2
hedgeMerge _ _ t1 Tip = g1 t1
hedgeMerge blo bhi Tip (Bin _ kx x l r) = g2 $ link kx x (filterGt blo l) (filterLt bhi r)
hedgeMerge blo bhi (Bin _ kx x l r) t2 = let l' = hedgeMerge blo bmi l (trim blo bmi t2)
(found, trim_t2) = trimLookupLo kx bhi t2
r' = hedgeMerge bmi bhi r trim_t2
in case found of
Nothing -> case g1 (singleton kx x) of
Tip -> merge l' r'
(Bin _ _ x' Tip Tip) -> link kx x' l' r'
_ -> error "mergeWithKey: Given function only1 does not fulfil required conditions (see documentation)"
Just x2 -> case f kx x x2 of
Nothing -> merge l' r'
Just x' -> x' `seq` link kx x' l' r'
where bmi = JustS kx
{-# INLINE mergeWithKey #-}
{--------------------------------------------------------------------
Filter and partition
--------------------------------------------------------------------}
-- | /O(n)/. Map values and collect the 'Just' results.
--
-- > let f x = if x == "a" then Just "new a" else Nothing
-- > mapMaybe f (fromList [(5,"a"), (3,"b")]) == singleton 5 "new a"
mapMaybe :: (a -> Maybe b) -> Map k a -> Map k b
mapMaybe f = mapMaybeWithKey (\_ x -> f x)
-- | /O(n)/. Map keys\/values and collect the 'Just' results.
--
-- > let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing
-- > mapMaybeWithKey f (fromList [(5,"a"), (3,"b")]) == singleton 3 "key : 3"
mapMaybeWithKey :: (k -> a -> Maybe b) -> Map k a -> Map k b
mapMaybeWithKey _ Tip = Tip
mapMaybeWithKey f (Bin _ kx x l r) = case f kx x of
Just y -> y `seq` link kx y (mapMaybeWithKey f l) (mapMaybeWithKey f r)
Nothing -> merge (mapMaybeWithKey f l) (mapMaybeWithKey f r)
-- | /O(n)/. Map values and separate the 'Left' and 'Right' results.
--
-- > let f a = if a < "c" then Left a else Right a
-- > mapEither f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
-- > == (fromList [(3,"b"), (5,"a")], fromList [(1,"x"), (7,"z")])
-- >
-- > mapEither (\ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
-- > == (empty, fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
mapEither :: (a -> Either b c) -> Map k a -> (Map k b, Map k c)
mapEither f m
= mapEitherWithKey (\_ x -> f x) m
-- | /O(n)/. Map keys\/values and separate the 'Left' and 'Right' results.
--
-- > let f k a = if k < 5 then Left (k * 2) else Right (a ++ a)
-- > mapEitherWithKey f (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
-- > == (fromList [(1,2), (3,6)], fromList [(5,"aa"), (7,"zz")])
-- >
-- > mapEitherWithKey (\_ a -> Right a) (fromList [(5,"a"), (3,"b"), (1,"x"), (7,"z")])
-- > == (empty, fromList [(1,"x"), (3,"b"), (5,"a"), (7,"z")])
mapEitherWithKey :: (k -> a -> Either b c) -> Map k a -> (Map k b, Map k c)
mapEitherWithKey f0 t0 = toPair $ go f0 t0
where
go _ Tip = (Tip :*: Tip)
go f (Bin _ kx x l r) = case f kx x of
Left y -> y `seq` (link kx y l1 r1 :*: merge l2 r2)
Right z -> z `seq` (merge l1 r1 :*: link kx z l2 r2)
where
(l1 :*: l2) = go f l
(r1 :*: r2) = go f r
{--------------------------------------------------------------------
Mapping
--------------------------------------------------------------------}
-- | /O(n)/. Map a function over all values in the map.
--
-- > map (++ "x") (fromList [(5,"a"), (3,"b")]) == fromList [(3, "bx"), (5, "ax")]
map :: (a -> b) -> Map k a -> Map k b
map _ Tip = Tip
map f (Bin sx kx x l r) = let x' = f x in x' `seq` Bin sx kx x' (map f l) (map f r)
#ifdef __GLASGOW_HASKELL__
{-# NOINLINE [1] map #-}
{-# RULES
"map/map" forall f g xs . map f (map g xs) = map (f . g) xs
#-}
#endif
#if __GLASGOW_HASKELL__ >= 709
-- Safe coercions were introduced in 7.8, but did not work well with RULES yet.
{-# RULES
"mapSeq/coerce" map coerce = coerce
#-}
#endif
-- | /O(n)/. Map a function over all values in the map.
--
-- > let f key x = (show key) ++ ":" ++ x
-- > mapWithKey f (fromList [(5,"a"), (3,"b")]) == fromList [(3, "3:b"), (5, "5:a")]
mapWithKey :: (k -> a -> b) -> Map k a -> Map k b
mapWithKey _ Tip = Tip
mapWithKey f (Bin sx kx x l r) =
let x' = f kx x
in x' `seq` Bin sx kx x' (mapWithKey f l) (mapWithKey f r)
#ifdef __GLASGOW_HASKELL__
{-# NOINLINE [1] mapWithKey #-}
{-# RULES
"mapWithKey/mapWithKey" forall f g xs . mapWithKey f (mapWithKey g xs) =
mapWithKey (\k a -> f k (g k a)) xs
"mapWithKey/map" forall f g xs . mapWithKey f (map g xs) =
mapWithKey (\k a -> f k (g a)) xs
"map/mapWithKey" forall f g xs . map f (mapWithKey g xs) =
mapWithKey (\k a -> f (g k a)) xs
#-}
#endif
-- | /O(n)/. The function 'mapAccum' threads an accumulating
-- argument through the map in ascending order of keys.
--
-- > let f a b = (a ++ b, b ++ "X")
-- > mapAccum f "Everything: " (fromList [(5,"a"), (3,"b")]) == ("Everything: ba", fromList [(3, "bX"), (5, "aX")])
mapAccum :: (a -> b -> (a,c)) -> a -> Map k b -> (a,Map k c)
mapAccum f a m
= mapAccumWithKey (\a' _ x' -> f a' x') a m
-- | /O(n)/. The function 'mapAccumWithKey' threads an accumulating
-- argument through the map in ascending order of keys.
--
-- > let f a k b = (a ++ " " ++ (show k) ++ "-" ++ b, b ++ "X")
-- > mapAccumWithKey f "Everything:" (fromList [(5,"a"), (3,"b")]) == ("Everything: 3-b 5-a", fromList [(3, "bX"), (5, "aX")])
mapAccumWithKey :: (a -> k -> b -> (a,c)) -> a -> Map k b -> (a,Map k c)
mapAccumWithKey f a t
= mapAccumL f a t
-- | /O(n)/. The function 'mapAccumL' threads an accumulating
-- argument through the map in ascending order of keys.
mapAccumL :: (a -> k -> b -> (a,c)) -> a -> Map k b -> (a,Map k c)
mapAccumL _ a Tip = (a,Tip)
mapAccumL f a (Bin sx kx x l r) =
let (a1,l') = mapAccumL f a l
(a2,x') = f a1 kx x
(a3,r') = mapAccumL f a2 r
in x' `seq` (a3,Bin sx kx x' l' r')
-- | /O(n)/. The function 'mapAccumR' threads an accumulating
-- argument through the map in descending order of keys.
mapAccumRWithKey :: (a -> k -> b -> (a,c)) -> a -> Map k b -> (a,Map k c)
mapAccumRWithKey _ a Tip = (a,Tip)
mapAccumRWithKey f a (Bin sx kx x l r) =
let (a1,r') = mapAccumRWithKey f a r
(a2,x') = f a1 kx x
(a3,l') = mapAccumRWithKey f a2 l
in x' `seq` (a3,Bin sx kx x' l' r')
-- | /O(n*log n)/.
-- @'mapKeysWith' c f s@ is the map obtained by applying @f@ to each key of @s@.
--
-- The size of the result may be smaller if @f@ maps two or more distinct
-- keys to the same new key. In this case the associated values will be
-- combined using @c@.
--
-- > mapKeysWith (++) (\ _ -> 1) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 1 "cdab"
-- > mapKeysWith (++) (\ _ -> 3) (fromList [(1,"b"), (2,"a"), (3,"d"), (4,"c")]) == singleton 3 "cdab"
mapKeysWith :: Ord k2 => (a -> a -> a) -> (k1->k2) -> Map k1 a -> Map k2 a
mapKeysWith c f = fromListWith c . foldrWithKey (\k x xs -> (f k, x) : xs) []
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE mapKeysWith #-}
#endif
{--------------------------------------------------------------------
Conversions
--------------------------------------------------------------------}
-- | /O(n)/. Build a map from a set of keys and a function which for each key
-- computes its value.
--
-- > fromSet (\k -> replicate k 'a') (Data.Set.fromList [3, 5]) == fromList [(5,"aaaaa"), (3,"aaa")]
-- > fromSet undefined Data.Set.empty == empty
fromSet :: (k -> a) -> Set.Set k -> Map k a
fromSet _ Set.Tip = Tip
fromSet f (Set.Bin sz x l r) = case f x of v -> v `seq` Bin sz x v (fromSet f l) (fromSet f r)
{--------------------------------------------------------------------
Lists
use [foldlStrict] to reduce demand on the control-stack
--------------------------------------------------------------------}
-- | /O(n*log n)/. Build a map from a list of key\/value pairs. See also 'fromAscList'.
-- If the list contains more than one value for the same key, the last value
-- for the key is retained.
--
-- If the keys of the list are ordered, linear-time implementation is used,
-- with the performance equal to 'fromDistinctAscList'.
--
-- > fromList [] == empty
-- > fromList [(5,"a"), (3,"b"), (5, "c")] == fromList [(5,"c"), (3,"b")]
-- > fromList [(5,"c"), (3,"b"), (5, "a")] == fromList [(5,"a"), (3,"b")]
-- For some reason, when 'singleton' is used in fromList or in
-- create, it is not inlined, so we inline it manually.
fromList :: Ord k => [(k,a)] -> Map k a
fromList [] = Tip
fromList [(kx, x)] = x `seq` Bin 1 kx x Tip Tip
fromList ((kx0, x0) : xs0) | not_ordered kx0 xs0 = x0 `seq` fromList' (Bin 1 kx0 x0 Tip Tip) xs0
| otherwise = x0 `seq` go (1::Int) (Bin 1 kx0 x0 Tip Tip) xs0
where
not_ordered _ [] = False
not_ordered kx ((ky,_) : _) = kx >= ky
{-# INLINE not_ordered #-}
fromList' t0 xs = foldlStrict ins t0 xs
where ins t (k,x) = insert k x t
STRICT_1_OF_3(go)
go _ t [] = t
go _ t [(kx, x)] = x `seq` insertMax kx x t
go s l xs@((kx, x) : xss) | not_ordered kx xss = fromList' l xs
| otherwise = case create s xss of
(r, ys, []) -> x `seq` go (s `shiftL` 1) (link kx x l r) ys
(r, _, ys) -> x `seq` fromList' (link kx x l r) ys
-- The create is returning a triple (tree, xs, ys). Both xs and ys
-- represent not yet processed elements and only one of them can be nonempty.
-- If ys is nonempty, the keys in ys are not ordered with respect to tree
-- and must be inserted using fromList'. Otherwise the keys have been
-- ordered so far.
STRICT_1_OF_2(create)
create _ [] = (Tip, [], [])
create s xs@(xp : xss)
| s == 1 = case xp of (kx, x) | not_ordered kx xss -> x `seq` (Bin 1 kx x Tip Tip, [], xss)
| otherwise -> x `seq` (Bin 1 kx x Tip Tip, xss, [])
| otherwise = case create (s `shiftR` 1) xs of
res@(_, [], _) -> res
(l, [(ky, y)], zs) -> y `seq` (insertMax ky y l, [], zs)
(l, ys@((ky, y):yss), _) | not_ordered ky yss -> (l, [], ys)
| otherwise -> case create (s `shiftR` 1) yss of
(r, zs, ws) -> y `seq` (link ky y l r, zs, ws)
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE fromList #-}
#endif
-- | /O(n*log n)/. Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWith'.
--
-- > fromListWith (++) [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "ab"), (5, "aba")]
-- > fromListWith (++) [] == empty
fromListWith :: Ord k => (a -> a -> a) -> [(k,a)] -> Map k a
fromListWith f xs
= fromListWithKey (\_ x y -> f x y) xs
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE fromListWith #-}
#endif
-- | /O(n*log n)/. Build a map from a list of key\/value pairs with a combining function. See also 'fromAscListWithKey'.
--
-- > let f k a1 a2 = (show k) ++ a1 ++ a2
-- > fromListWithKey f [(5,"a"), (5,"b"), (3,"b"), (3,"a"), (5,"a")] == fromList [(3, "3ab"), (5, "5a5ba")]
-- > fromListWithKey f [] == empty
fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k,a)] -> Map k a
fromListWithKey f xs
= foldlStrict ins empty xs
where
ins t (k,x) = insertWithKey f k x t
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE fromListWithKey #-}
#endif
{--------------------------------------------------------------------
Building trees from ascending/descending lists can be done in linear time.
Note that if [xs] is ascending that:
fromAscList xs == fromList xs
fromAscListWith f xs == fromListWith f xs
--------------------------------------------------------------------}
-- | /O(n)/. Build a map from an ascending list in linear time.
-- /The precondition (input list is ascending) is not checked./
--
-- > fromAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
-- > fromAscList [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "b")]
-- > valid (fromAscList [(3,"b"), (5,"a"), (5,"b")]) == True
-- > valid (fromAscList [(5,"a"), (3,"b"), (5,"b")]) == False
fromAscList :: Eq k => [(k,a)] -> Map k a
fromAscList xs
= fromAscListWithKey (\_ x _ -> x) xs
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE fromAscList #-}
#endif
-- | /O(n)/. Build a map from an ascending list in linear time with a combining function for equal keys.
-- /The precondition (input list is ascending) is not checked./
--
-- > fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")] == fromList [(3, "b"), (5, "ba")]
-- > valid (fromAscListWith (++) [(3,"b"), (5,"a"), (5,"b")]) == True
-- > valid (fromAscListWith (++) [(5,"a"), (3,"b"), (5,"b")]) == False
fromAscListWith :: Eq k => (a -> a -> a) -> [(k,a)] -> Map k a
fromAscListWith f xs
= fromAscListWithKey (\_ x y -> f x y) xs
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE fromAscListWith #-}
#endif
-- | /O(n)/. Build a map from an ascending list in linear time with a
-- combining function for equal keys.
-- /The precondition (input list is ascending) is not checked./
--
-- > let f k a1 a2 = (show k) ++ ":" ++ a1 ++ a2
-- > fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")] == fromList [(3, "b"), (5, "5:b5:ba")]
-- > valid (fromAscListWithKey f [(3,"b"), (5,"a"), (5,"b"), (5,"b")]) == True
-- > valid (fromAscListWithKey f [(5,"a"), (3,"b"), (5,"b"), (5,"b")]) == False
fromAscListWithKey :: Eq k => (k -> a -> a -> a) -> [(k,a)] -> Map k a
fromAscListWithKey f xs
= fromDistinctAscList (combineEq f xs)
where
-- [combineEq f xs] combines equal elements with function [f] in an ordered list [xs]
combineEq _ xs'
= case xs' of
[] -> []
[x] -> [x]
(x:xx) -> combineEq' x xx
combineEq' z [] = [z]
combineEq' z@(kz,zz) (x@(kx,xx):xs')
| kx==kz = let yy = f kx xx zz in yy `seq` combineEq' (kx,yy) xs'
| otherwise = z:combineEq' x xs'
#if __GLASGOW_HASKELL__ >= 700
{-# INLINABLE fromAscListWithKey #-}
#endif
-- | /O(n)/. Build a map from an ascending list of distinct elements in linear time.
-- /The precondition is not checked./
--
-- > fromDistinctAscList [(3,"b"), (5,"a")] == fromList [(3, "b"), (5, "a")]
-- > valid (fromDistinctAscList [(3,"b"), (5,"a")]) == True
-- > valid (fromDistinctAscList [(3,"b"), (5,"a"), (5,"b")]) == False
-- For some reason, when 'singleton' is used in fromDistinctAscList or in
-- create, it is not inlined, so we inline it manually.
fromDistinctAscList :: [(k,a)] -> Map k a
fromDistinctAscList [] = Tip
fromDistinctAscList ((kx0, x0) : xs0) = x0 `seq` go (1::Int) (Bin 1 kx0 x0 Tip Tip) xs0
where
STRICT_1_OF_3(go)
go _ t [] = t
go s l ((kx, x) : xs) = case create s xs of
(r, ys) -> x `seq` go (s `shiftL` 1) (link kx x l r) ys
STRICT_1_OF_2(create)
create _ [] = (Tip, [])
create s xs@(x' : xs')
| s == 1 = case x' of (kx, x) -> x `seq` (Bin 1 kx x Tip Tip, xs')
| otherwise = case create (s `shiftR` 1) xs of
res@(_, []) -> res
(l, (ky, y):ys) -> case create (s `shiftR` 1) ys of
(r, zs) -> y `seq` (link ky y l r, zs)
|
DavidAlphaFox/ghc
|
libraries/containers/Data/Map/Strict.hs
|
bsd-3-clause
| 45,335 | 0 | 17 | 11,360 | 8,301 | 4,535 | 3,766 | -1 | -1 |
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
-- | @travis.yaml@ structure.
module HaskellCI.Travis.Yaml where
import HaskellCI.Prelude
import qualified Data.Aeson as Aeson
import qualified Data.List.NonEmpty as NE
import HaskellCI.Config.Ubuntu
import HaskellCI.List
import HaskellCI.Sh
import HaskellCI.YamlSyntax
-------------------------------------------------------------------------------
-- Data
-------------------------------------------------------------------------------
data Travis = Travis
{ travisUbuntu :: !Ubuntu
, travisLanguage :: !String
, travisGit :: !TravisGit
, travisCache :: !TravisCache
, travisBranches :: !TravisBranches
, travisNotifications :: !TravisNotifications
, travisServices :: ![String]
, travisAddons :: !TravisAddons
, travisMatrix :: !TravisMatrix
, travisBeforeCache :: ![Sh]
, travisBeforeInstall :: ![Sh]
, travisInstall :: ![Sh]
, travisScript :: ![Sh]
}
deriving Show
newtype TravisGit = TravisGit
{ tgSubmodules :: Bool
}
deriving Show
newtype TravisCache = TravisCache
{ tcDirectories :: [FilePath]
}
deriving Show
newtype TravisBranches = TravisBranches
{ tbOnly :: [String]
}
deriving Show
data TravisNotifications = TravisNotifications
{ tnIRC :: Maybe TravisIRC
, tnEmail :: Bool
}
deriving Show
data TravisIRC = TravisIRC
{ tiChannels :: [String]
, tiSkipJoin :: Bool
, tiTemplate :: [String]
, tiNick :: Maybe String
, tiPassword :: Maybe String
}
deriving Show
data TravisMatrix = TravisMatrix
{ tmInclude :: [TravisJob]
, tmAllowFailures :: [TravisAllowFailure]
}
deriving Show
data TravisJob = TravisJob
{ tjCompiler :: String
, tjEnv :: Maybe String
, tjAddons :: TravisAddons
, tjOS :: String
}
deriving Show
data TravisAddons = TravisAddons
{ taApt :: TravisApt
, taPostgres :: Maybe String
, taGoogleChrome :: Bool
}
deriving Show
data TravisApt = TravisApt
{ taPackages :: [String]
, taSources :: [TravisAptSource]
}
deriving Show
data TravisAptSource
= TravisAptSource String
| TravisAptSourceLine String (Maybe String) -- ^ sourceline with optional key
deriving Show
newtype TravisAllowFailure = TravisAllowFailure
{ tafCompiler :: String
}
deriving Show
-------------------------------------------------------------------------------
-- Serialisation helpers (move to Travis.Yaml?)
-------------------------------------------------------------------------------
(^^^) :: ([String], String, Yaml [String]) -> String -> ([String], String, Yaml [String])
(a,b,c) ^^^ d = (d : a, b, c)
shListToYaml :: [Sh] -> Yaml [String]
shListToYaml shs = YList [] $ concat
[ YString cs x : map fromString xs
| (cs, x :| xs) <- gr shs
]
where
gr :: [Sh] -> [([String], NonEmpty String)]
gr [] = []
gr (Sh x : rest) = case gr rest of
([], xs) : xss -> ([], NE.cons x xs) : xss
xss -> ([], pure x) : xss
gr (Comment c : rest) = case gr rest of
(cs, xs) : xss -> (c : cs, xs) : xss
[] -> [] -- end of comments are lost
-------------------------------------------------------------------------------
-- ToYaml
-------------------------------------------------------------------------------
instance ToYaml Travis where
toYaml Travis {..} = ykeyValuesFilt []
-- version forces validation
-- https://blog.travis-ci.com/2019-10-24-build-config-validation
[ "version" ~> fromString "~> 1.0"
, "language" ~> fromString travisLanguage
, "os" ~> fromString "linux"
, "dist" ~> fromString (showUbuntu travisUbuntu)
, "git" ~> toYaml travisGit
, "branches" ~> toYaml travisBranches
, "notifications" ~> toYaml travisNotifications
, "services" ~> YList [] (map fromString travisServices)
, "addons" ~> toYaml travisAddons
, "cache" ~> toYaml travisCache
, "before_cache" ~> shListToYaml travisBeforeCache
, "jobs" ~> toYaml travisMatrix
, "before_install" ~> shListToYaml travisBeforeInstall
, "install" ~> shListToYaml travisInstall
, "script" ~> shListToYaml travisScript
]
instance ToYaml TravisGit where
toYaml TravisGit {..} = ykeyValuesFilt []
[ "submodules" ~> toYaml tgSubmodules
^^^ "whether to recursively clone submodules"
]
instance ToYaml TravisBranches where
toYaml TravisBranches {..} = ykeyValuesFilt []
[ "only" ~> ylistFilt [] (map fromString tbOnly)
]
instance ToYaml TravisNotifications where
toYaml TravisNotifications {..} = ykeyValuesFilt [] $ buildList $ do
for_ tnIRC $ \y -> item $ "irc" ~> toYaml y
unless tnEmail $ item $ "email" ~> toYaml False
instance ToYaml TravisIRC where
toYaml TravisIRC {..} = ykeyValuesFilt [] $ buildList $ do
item $ "channels" ~> YList [] (map fromString tiChannels)
item $ "skip_join" ~> toYaml tiSkipJoin
item $ "template" ~> YList [] (map fromString tiTemplate)
for_ tiNick $ \n ->
item $ "nick" ~> fromString n
for_ tiPassword $ \p ->
item $ "password" ~> fromString p
instance ToYaml TravisCache where
toYaml TravisCache {..} = ykeyValuesFilt []
[ "directories" ~> ylistFilt []
[ fromString d
| d <- tcDirectories
]
]
instance ToYaml TravisMatrix where
toYaml TravisMatrix {..} = ykeyValuesFilt []
[ "include" ~> ylistFilt [] (map toYaml tmInclude)
, "allow_failures" ~> ylistFilt [] (map toYaml tmAllowFailures)
]
instance ToYaml TravisJob where
toYaml TravisJob {..} = ykeyValuesFilt [] $ buildList $ do
item $ "compiler" ~> fromString tjCompiler
item $ "addons" ~> toYaml (Aeson.toJSON tjAddons)
for_ tjEnv $ \e ->
item $ "env" ~> fromString e
item $ "os" ~> fromString tjOS
instance ToYaml TravisAllowFailure where
toYaml TravisAllowFailure {..} = ykeyValuesFilt []
[ "compiler" ~> fromString tafCompiler
]
instance ToYaml TravisAddons where
toYaml TravisAddons {..} = ykeyValuesFilt [] $ buildList $ do
-- no apt on purpose
for_ taPostgres $ \p ->
item $ "postgresql" ~> fromString p
when taGoogleChrome $
item $ "google" ~> fromString "stable"
-------------------------------------------------------------------------------
-- ToJSON
-------------------------------------------------------------------------------
instance Aeson.ToJSON TravisAddons where
-- no postgresql on purpose
toJSON TravisAddons {..} = Aeson.object
[ "apt" Aeson..= taApt
]
instance Aeson.ToJSON TravisApt where
toJSON TravisApt {..} = Aeson.object
[ "packages" Aeson..= taPackages
, "sources" Aeson..= taSources
]
instance Aeson.ToJSON TravisAptSource where
toJSON (TravisAptSource s) = Aeson.toJSON s
toJSON (TravisAptSourceLine sl Nothing) = Aeson.object
[ "sourceline" Aeson..= sl
]
toJSON (TravisAptSourceLine sl (Just key_url)) = Aeson.object
[ "sourceline" Aeson..= sl
, "key_url" Aeson..= key_url
]
|
hvr/multi-ghc-travis
|
src/HaskellCI/Travis/Yaml.hs
|
bsd-3-clause
| 7,607 | 0 | 13 | 2,050 | 1,924 | 1,026 | 898 | 188 | 5 |
module Data.Time.Generators where
import Test.QuickCheck
import Data.Time
import Control.Monad
day :: Gen Day
day = fmap ModifiedJulianDay arbitrarySizedIntegral
diffTime :: Gen DiffTime
diffTime = fmap (picosecondsToDiffTime . abs) arbitrary
uTCTime :: Gen UTCTime
uTCTime = liftM2 UTCTime day diffTime
|
massysett/barecheck
|
lib/Data/Time/Generators.hs
|
bsd-3-clause
| 308 | 0 | 7 | 43 | 85 | 46 | 39 | 10 | 1 |
{-# LANGUAGE DeriveFunctor,
FlexibleInstances,
DeriveDataTypeable #-}
module Types where
import Control.Comonad.Cofree
import Data.Data
import Data.List (intercalate)
import qualified Data.Text as T
import Data.Typeable
type Namespace = T.Text
type Var = T.Text
data SourceFile = SourceFile {
sfNs :: !Namespace
, sfRequires :: ![(Namespace, Namespace)]
, sfDefns :: ![Var]
, sfInternalUsages :: ![Var]
, sfExternalUsages :: ![(Namespace, Var)]
}
newtype CljString = CljString { unCljString :: T.Text }
deriving (Data, Typeable, Eq, Show)
newtype CljRegex = CljRegex { unCljRegex :: T.Text }
deriving (Data, Typeable, Eq, Show)
data ExprF a
= List [a]
| AnonFn [a]
| Vec [a]
| Map [(a, a)]
| Set [a]
| Quote a
| CljStringLiteral CljString
| CljRegexLiteral CljRegex
| Atom T.Text
deriving (Eq, Functor, Data, Typeable, Show)
type AST = Cofree ExprF ()
-- instance Show a => Show (ExprF a) where
-- show (Atom t1) = T.unpack t1
-- show (List xs) = surround "(" ")" xs
-- show (AnonFn xs) = surround "#(" ")" xs
-- show (Vec xs) = surround "[" "]" xs
-- show (Map xys) = surround "{" "}" xys
-- show (CljStringLiteral (CljString s)) = "\"" ++ show s ++ "\""
-- show (CljRegexLiteral (CljRegex s)) = "#\"" ++ show s ++ "\""
-- show (Set xs) = surround "#{" "}" xs
-- show (Quote x) = '\'' : show x
surround :: Show a => String -> String -> [a] -> String
surround l r xs = l ++ unwords (fmap show xs) ++ r
instance Show SourceFile where
show (SourceFile n rs ds ius eus) =
intercalate "\n" [ show n
, "Requires:"
, unlines (map show rs)
, "Defns:"
, unlines (map show ds)
, "External usages:"
, unlines (map show eus)
, "Internal usages:"
, unlines (map show ius)
, "\n"
]
|
ethercrow/unused-defns
|
Types.hs
|
bsd-3-clause
| 2,064 | 0 | 11 | 693 | 480 | 278 | 202 | 57 | 1 |
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DeriveDataTypeable #-}
import qualified System.Console.CmdArgs as A
import System.Console.CmdArgs ((&=))
import System.IO
import Search.Common
import Search.Util
import qualified Search.Collection as C
import qualified Search.Cluster as Cl
import qualified Search.SearchIndex as SI
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as MVU
import qualified Data.Vector.Algorithms.Intro as VA
import qualified Data.List as L
import Control.Monad.ST
import Data.Binary
data CompressionArgs = CompressionArgs
{ indexFile :: FilePath
, collectionDir :: FilePath
, clusterFile :: FilePath
} deriving (Eq, Show, A.Data, A.Typeable)
compressionArgs :: CompressionArgs
compressionArgs = CompressionArgs
{ indexFile = A.def &= A.typ "SEARCH_INDEX" &= A.argPos 0
, collectionDir = A.def &= A.typ "COLLECTION" &= A.argPos 1
, clusterFile = A.def &= A.typ "CLUSTER_FILE" &= A.argPos 2
}
log2 :: Integral a => a -> Double
{-# INLINE log2 #-}
log2 a = log (fromIntegral a) / log 2
intSize :: Int -> Int
intSize 0 = error "invalid number"
intSize x = 2 + (ceiling $ log2 x)
eliasGammaSize :: Int -> Int
eliasGammaSize 0 = error "invalid number"
eliasGammaSize x = 1 + 2*(floor $ log2 x)
eliasDeltaSize :: Int -> Int
eliasDeltaSize 0 = error "invalid number"
eliasDeltaSize x = 1 + 2*(floor $ log (log2 $ 2*x) / log 2) + (floor $ log2 x)
golombSize :: Int -> Int -> Int
golombSize _ 0 = error "invalid number"
golombSize b v = (q+1) + bitsr
where q = (v-1) `div` b
r = v - q*b - 1
lb = floor $ log2 b
bitsr = if (fromIntegral r) < 2^(lb-1)
then lb
else ceiling $ log2 b
listGolombSize :: Int -> VU.Vector Int -> Int
listGolombSize b = VU.sum . VU.map (golombSize b)
listEliasGammaSize :: VU.Vector Int -> Int
listEliasGammaSize = VU.sum . VU.map eliasGammaSize
listEliasDeltaSize :: VU.Vector Int -> Int
listEliasDeltaSize = VU.sum . VU.map eliasDeltaSize
listIntSize :: VU.Vector Int -> Int
listIntSize = VU.sum . VU.map intSize
golombFactor :: Int -> Int -> Int
golombFactor _ 0 = 2
golombFactor n l = max 2 (round $ (n'/l')*log 2)
where n' :: Double
n' = fromIntegral n
l' = fromIntegral l
hybridSize :: Int -> VU.Vector Int -> Int
hybridSize blocksize v =
if totalLength == 0
then 0
else go 0 0
where go !o !s
| o < totalLength =
let l = min blocksize (totalLength - o)
v' = VU.unsafeSlice o l v
n = VU.sum v'
b = golombFactor n l
blockBits = (eliasGammaSize (b-1)) + (listGolombSize b v')
in go (o+l) (s+blockBits)
| otherwise = s
totalLength = VU.length v
toDeltas :: VU.Vector DocId -> VU.Vector Int
toDeltas v
| VU.length v == 0 = VU.empty
| otherwise = runST $
do mv <- VU.thaw $ VU.map (fromIntegral . unDocId) v
VA.sort mv
let go !i
| i > 0 =
do v1 <- mv `MVU.unsafeRead` i
v2 <- mv `MVU.unsafeRead` (i-1)
MVU.unsafeWrite mv i (v1-v2)
go (i-1)
| otherwise = return ()
go ((MVU.length mv)-1)
v0 <- mv `MVU.unsafeRead` 0
MVU.unsafeWrite mv 0 (v0+1)
VU.freeze mv
{-
postingListSize :: VU.Vector DocId -> Int
postingListSize x = fst $ L.foldl' accum (0,0) $ L.sort $ VU.toList x
where accum (!size, !last) (DocId cur) = (size + gSize (cur+1-last), cur+1)
me = fromIntegral $ unDocId $ VU.maximum x
l = fromIntegral $ VU.length x
gSize = intSize
{-gSize = if l > 0
then golombSize (max 2 (round $ (me/l)*log 2))
else golombSize 2 -}
-}
outputTabbed :: [String] -> IO ()
outputTabbed = putStrLn . L.intercalate "\t"
type Config = (String, VU.Vector Int -> Int)
outputPostingListSizes :: FilePath -> C.DocCollection a -> [Config] -> (Cl.Clustering DocId) -> IO ()
outputPostingListSizes fp coll cfgs cl =
SI.withSearchIndexFile fp $ \h ->
do hSetBuffering stdout LineBuffering
putStrLn $ L.intercalate "\t" $
["Size"]
++ (map (cfgToHeader "Normal") cfgs)
++ (map (cfgToHeader "Cluster") cfgs)
mapM_ (output h remap) $ SI.handleIndexedTokens h
where output h r1 t = do l <- SI.readPostingList h t
let filtered = VU.filter useDocId l
deltasNormal = toDeltas filtered
deltasCluster = toDeltas $ VU.map r1 filtered
funcs = map snd cfgs
applyFuncs v = map (\f -> f v) funcs
sizesNormal = map show $ applyFuncs deltasNormal
sizesCluster = map show $ applyFuncs deltasCluster
outputTabbed ((show $ VU.length filtered):(sizesNormal ++ sizesCluster))
useDocId = Cl.contains cl
remap = Cl.unsafeRemap cl
cfgToHeader prefix (cfgName,_) = prefix ++ "-" ++ cfgName
main :: IO ()
main = do
args <- A.cmdArgs compressionArgs
putInfo "Loading Document collection..."
!coll <- C.loadDocCollection (collectionDir args)
putInfo "Loading clustering..."
!cl <- decodeFile $ clusterFile args
putInfo "Finished loading"
let cfgs = [ ("Approx", listIntSize)
, ("Elias-Gamma", listEliasGammaSize)
, ("Elias-Delta", listEliasDeltaSize)
, ("Golomb", \v -> listGolombSize (golombFactor (VU.sum v) (VU.length v)) v)
, ("Hybrid-8", hybridSize 8)
, ("Hybrid-16", hybridSize 16)
, ("Hybrid-32", hybridSize 32)
, ("Hybrid-64", hybridSize 64)
]
outputPostingListSizes (indexFile args) coll cfgs cl
putInfo "Done..."
|
jdimond/diplomarbeit
|
tools/Compression.hs
|
bsd-3-clause
| 6,100 | 0 | 18 | 1,953 | 1,913 | 980 | 933 | 135 | 2 |
{-# LANGUAGE
GADTs
, FlexibleContexts
#-}
module Data.Build where
import Data.Tree.Rose
import Control.Monad.State
newNode :: ( MonadState Int m
, RoseTree t
, Head (t Int) ~ Int
) => Tail (t Int)
-> m (t Int)
newNode xs = do
x <- get
modify (+1)
return $ x @-> xs
makeWith :: ( MonadState Int m
, Head (t Int) ~ Int
, RoseTree t
) => Int -- Depth
-> Int -- Width
-> Int -- Ratio
-> Tail (t Int)
-> ([t Int] -> Tail (t Int))
-> m (t Int)
makeWith d w r empty fromList
| d <= 1 = newNode empty
| otherwise = do
xs <- replicateM w $
makeWith (d-1) (floor $ (fromIntegral w :: Float)
/ fromIntegral r) r empty fromList
newNode $ fromList xs
|
athanclark/rose-trees
|
bench/Data/Build.hs
|
bsd-3-clause
| 878 | 0 | 15 | 374 | 321 | 160 | 161 | 31 | 1 |
{-
This file is part of the Haskell package distinfo. It is subject to
the license terms in the LICENSE file found in the top-level directory
of this distribution and at git://pmade.com/distinfo/LICENSE. No part
of the distinfo package, including this file, may be copied, modified,
propagated, or distributed except according to the terms contained in
the LICENSE file.
-}
--------------------------------------------------------------------------------
module DistInfo.Messages
( NodeRequest (..)
, NodeReply (..)
) where
--------------------------------------------------------------------------------
import Data.Binary
import Data.Typeable
import DistInfo.Node (Node)
import GHC.Generics (Generic)
--------------------------------------------------------------------------------
newtype NodeRequest = NodeRequest Node deriving (Typeable, Generic)
instance Binary NodeRequest
--------------------------------------------------------------------------------
newtype NodeReply = NodeReply Node deriving (Typeable, Generic)
instance Binary NodeReply
|
devalot/distinfo
|
src/DistInfo/Messages.hs
|
bsd-3-clause
| 1,087 | 0 | 6 | 141 | 109 | 66 | 43 | 11 | 0 |
module Yhc.Core.Firstify.Mitchell.Template where
import Control.Monad.State
import Data.List
import Data.Maybe
import Debug.Trace
import Yhc.Core hiding (uniqueBoundVarsCore, uniqueBoundVars)
import Yhc.Core.FreeVar3
import Yhc.Core.UniqueId
import Yhc.Core.Util
-- all templates must be at least: CoreApp (CoreFun _) _
type Template = CoreExpr
templateNone :: Template
templateNone = CoreVar "_"
-- given an expression, what would be the matching template
-- must be careful to avoid if there is an inner template not redoing it
templateCreate :: (CoreFuncName -> Bool) -> (CoreFuncName -> Bool) -> CoreExpr -> Template
templateCreate isPrim isHO o@(CoreApp (CoreFun x) xs)
| any ((/=) templateNone . templateCheck isHO) $ tail $ universe o = templateNone
| isPrim x && res /= templateNone = trace ("Warning: primitive HO call, " ++ x) templateNone
| otherwise = res
where
res = templateNorm $ templateCheck isHO o
templateCreate _ _ _ = templateNone
templateNorm :: Template -> Template
templateNorm = flip evalState (1 :: Int) . uniqueBoundVars
templateCheck :: (CoreFuncName -> Bool) -> CoreExpr -> Template
templateCheck isHO o@(CoreApp (CoreFun x) xs) = join (CoreApp (CoreFun x)) (map f xs)
where
free = collectFreeVars o
f (CoreLam vs x) = CoreLam vs (f x)
f (CoreFun x) | isHO x = CoreFun x
f (CoreApp (CoreFun x) xs) | isHO x = CoreApp (CoreFun x) (map f xs)
f (CoreVar x) | x `notElem` free = CoreVar x
f (CoreApp x xs) | isCoreCon x || isCoreFun x = join (CoreApp x) (map f xs)
f x = join generate (map f children)
where (children,generate) = uniplate x
join g xs | any (/= templateNone) xs = g xs
| otherwise = templateNone
templateCheck _ _ = templateNone
-- pick a human readable name for a template result
templateName :: Template -> String
templateName (CoreApp (CoreFun name) xs) = concat $ intersperse "_" $ map short $ name :
[x | CoreFun x <- map (fst . fromCoreApp . snd . fromCoreLam) xs, '_' `notElem` x]
where short = reverse . takeWhile (/= ';') . reverse
templateName _ = "template"
-- for each CoreVar "_", get the associated expression
templateHoles :: CoreExpr -> Template -> [CoreExpr]
templateHoles x y | y == templateNone = [x]
| otherwise = concat $ zipWith templateHoles (children x) (children y)
templateExpand :: (CoreFuncName -> Maybe Template) -> Template -> Template
templateExpand mp = transform f
where
f (CoreFun x) = case mp x of
Just y -> transform f y
Nothing -> CoreFun x
f x = x
templateGenerate :: UniqueIdM m => (CoreFuncName -> CoreFunc) -> CoreFuncName -> Template -> m CoreFunc
templateGenerate ask newname o@(CoreApp (CoreFun name) xs) = do
let fun = ask name
CoreFunc _ args body | isCoreFunc fun = fun
| otherwise = error $ "Tried specialising on a primitve: " ++ show o
x <- duplicateExpr $ coreLam args body
xs <- mapM duplicateExpr xs
count1 <- getIdM
xs <- mapM (transformM f) xs
count2 <- getIdM
putIdM count1
vs <- getVars (count2-count1)
return $ CoreFunc newname vs (coreApp x xs)
where
f x | x == templateNone = liftM CoreVar getVar
f x = return x
-- given an expand function, and an existing template, and a new template
-- return a new template, based on the original, but only if there is an embedding
--
-- cannot weaken the head of an application without blurring the entire app
-- must remove a chunk which is variable consistent
-- remove lambdas if you can
templateWeaken :: (Template -> Template) -> Template -> Template -> Template
templateWeaken expand bad new =
case f new of
Just (CoreApp x xs) | all (== templateNone) xs -> new
Just x -> x
Nothing -> new
where
res = f new
bad2 = blurVar bad
free = collectFreeVars new
safe x = null (collectFreeVars x \\ free)
-- return Nothing to indicate remove but not safe
f x | die x || any isNothing cs2 = if safe x then Just templateNone else Nothing
| otherwise = Just $ gen $ map fromJust cs2
where
(cs,gen) = uniplate x
cs2 = map f cs
-- do you want to remove this subexpression
die (CoreLam _ x) | die x = True
die (CoreApp x xs) | die x = True
die x = blurVar (expand x) == bad2
|
ndmitchell/firstify
|
Yhc/Core/Firstify/Mitchell/Template.hs
|
bsd-3-clause
| 4,511 | 0 | 13 | 1,220 | 1,478 | 729 | 749 | 80 | 6 |
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
-- Module : GHC.TopHandler
-- Copyright : (c) The University of Glasgow, 2001-2002
-- License : see libraries/base/LICENSE
--
-- Maintainer : [email protected]
-- Stability : internal
-- Portability : non-portable (GHC Extensions)
--
-- Support for catching exceptions raised during top-level computations
-- (e.g. @Main.main@, 'Control.Concurrent.forkIO', and foreign exports)
--
-----------------------------------------------------------------------------
module GHC.TopHandler (
runMainIO, runIO, runNonIO,
reportStackOverflow, reportError,
flushStdHandles
) where
import Control.Exception
import Java.Exception
import Data.Maybe
import Foreign
import Foreign.C
import GHC.Base
import GHC.Conc hiding (throwTo)
import GHC.Real
import GHC.IO
import GHC.IO.Handle.FD
import GHC.IO.Handle
import GHC.IO.Exception
import GHC.Weak
-- | 'runMainIO' is wrapped around 'Main.main' (or whatever main is
-- called in the program). It catches otherwise uncaught exceptions,
-- and also flushes stdout\/stderr before exiting.
runMainIO :: IO a -> IO a
runMainIO main = main
-- | 'runIO' is wrapped around every @foreign export@ and @foreign
-- import \"wrapper\"@ to mop up any uncaught exceptions. Thus, the
-- result of running 'System.Exit.exitWith' in a foreign-exported
-- function is the same as in the main thread: it terminates the
-- program.
--
runIO :: IO a -> IO a
runIO main = main
-- | The same as 'runIO', but for non-IO computations. Used for
-- wrapping @foreign export@ and @foreign import \"wrapper\"@ when these
-- are used to export Haskell functions with non-IO types.
--
runNonIO :: a -> IO a
runNonIO a = a `seq` return a
-- try to flush stdout/stderr, but don't worry if we fail
-- (these handles might have errors, and we don't want to go into
-- an infinite loop).
flushStdHandles :: IO ()
flushStdHandles = do
hFlush stdout `catchAny` \_ -> return ()
hFlush stderr `catchAny` \_ -> return ()
|
pparkkin/eta
|
libraries/base/GHC/TopHandler.hs
|
bsd-3-clause
| 2,153 | 0 | 10 | 360 | 266 | 163 | 103 | 30 | 1 |
module ArpSpoof (spoofSwitchArp, main) where
import Control.Concurrent
import Data.ByteString.Lazy (ByteString)
import Frenetic.NetCore
import Frenetic.NetworkFrames (arpReply)
-- Heartbeat --
-- Give the server an Ip address by monitoring ARP requests and
-- spoofing replies.
isArp = DlTyp 0x806
isQuery = isArp <&&> NwProto 1
isReply = isArp <&&> NwProto 2
-- Mac and Ip addresses assigned to the server.
serverMac = ethernetAddress 0x00 0x00 0x00 0x00 0x00 0x11
serverIp = ipAddress 10 0 0 101
-- Return a policy that queries all ARP request packets
-- destined for serverIp and, upon receiving such a packet,
-- injects an appropriate response.
spoofSwitchArp :: Switch -> EthernetAddress -> IPAddress -> IO (Policy)
spoofSwitchArp switchId serverMac serverIp = do
(arpQueryChan, arpAct) <- getPkts
packetOutChan <- newChan
let pol = isQuery <&&> NwDst (IPAddressPrefix serverIp 32) ==> arpAct <+> SendPackets packetOutChan
let loop a = do
arpQueryPkt <- readChan arpQueryChan
case generateReply arpQueryPkt of
Nothing -> loop a
Just replyPkt -> do
writeChan packetOutChan replyPkt
loop a
forkIO $ loop True
return $ pol <%> Switch switchId
where
-- Given an ARP query packet asking for the server, generate a response. If
-- the located packet is malformed---eg. without a valid nwSrc field---return
-- Nothing.
generateReply :: LocPacket -> Maybe (Loc, ByteString)
generateReply (Loc switch port, Packet {..}) =
case pktNwSrc of
Nothing -> Nothing
Just fromIp -> Just (Loc switch port,
arpReply
serverMac (ipAddressToWord32 serverIp)
pktDlSrc (ipAddressToWord32 fromIp))
main addr = do
arpSpoof <- spoofSwitchArp 1 serverMac serverIp
controller addr $ arpSpoof <+> Any ==> allPorts unmodified
|
frenetic-lang/netcore-1.0
|
examples/ArpSpoof.hs
|
bsd-3-clause
| 1,917 | 0 | 17 | 470 | 437 | 218 | 219 | -1 | -1 |
{-# LANGUAGE GADTs #-}
{-# LANGUAGE CPP #-}
module Main
( main
) where
-- #define BENCH_SMALL
-- #define BENCH_ESSENTIALS
--------------------------------------------------------------------------------
import Control.DeepSeq (NFData(..))
import Control.Exception.Base (evaluate)
import Control.Monad.Trans (liftIO)
--------------------------------------------------------------------------------
import Data.List
import qualified Data.Map.Strict as Data.Map
--------------------------------------------------------------------------------
import qualified Criterion.Config as C
import qualified Criterion.Main as C
--------------------------------------------------------------------------------
import qualified DS.B01
import qualified TS.B01
import qualified IS.B01
--------------------------------------------------------------------------------
import Common
--------------------------------------------------------------------------------
data RNF where
RNF :: NFData a => a -> RNF
instance NFData RNF where
rnf (RNF x) = rnf x
main :: IO ()
main = C.defaultMainWith C.defaultConfig (liftIO . evaluate $ rnf
[
RNF elems200000
, RNF map200000
, RNF ds200000
, RNF is200000
, RNF ts200000
#ifdef BENCH_SMALL
, RNF elems50000
, RNF elems100000
, RNF ds50000
, RNF ds100000
, RNF map50000
, RNF map100000
, RNF is50000
, RNF is100000
, RNF ts50000
, RNF ts100000
#endif
, RNF elem9999999
, RNF elem2500
])
-- Insert 1 element into a store of size N. No collisions.
[
#ifdef BENCH_SMALL
C.bgroup "insertLookup (Int) 01 100000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.insertLookup 9999999 9999999 9999999) ds100000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.insertLookup 9999999 9999999 9999999) is100000
, C.bench "TS" $ C.whnf (forceList . TS.B01.insertLookup 9999999 9999999 9999999) ts100000
#endif
]
] ,
#endif
C.bgroup "insertLookup (Int) 01 200000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.insertLookup 9999999 9999999 9999999) ds200000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.insertLookup 9999999 9999999 9999999) is200000
, C.bench "TS" $ C.whnf (forceList . TS.B01.insertLookup 9999999 9999999 9999999) ts200000
#endif
]
]
#ifdef BENCH_SMALL
, C.bgroup "insertLookup-collision(1) (Int) 01 100000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.insertLookup 20000 9999999 9999999) ds100000
#ifndef BENCH_DS
, C.bench "TS" $ C.whnf (forceList . TS.B01.insertLookup 20000 9999999 9999999) ts100000
#endif
]
]
#endif
, C.bgroup "insertLookup-collision(1) (Int) 01 200000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.insertLookup 20000 9999999 9999999) ds200000
#ifndef BENCH_DS
, C.bench "TS" $ C.whnf (forceList . TS.B01.insertLookup 20000 9999999 9999999) ts200000
#endif
]
]
#ifdef BENCH_SMALL
, C.bgroup "insert (Int) 01 100000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (DS.B01.insert elem9999999) ds100000
#ifndef BENCH_DS
, C.bench "Map" $ C.whnf (insertMap elem9999999) map100000
#endif
]
]
#endif
, C.bgroup "insert (Int) 01 200000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (DS.B01.insert elem9999999) ds200000
#ifndef BENCH_DS
, C.bench "Map" $ C.whnf (insertMap elem9999999) map200000
#endif
]
]
#ifdef BENCH_SMALL
, C.bgroup "lookup OO EQ (Int) 01 50000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOOEQ 10000) ds50000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOOEQLens 10000) ds50000
#ifndef BENCH_DS
, C.bench "Map" $ C.nf (Data.Map.lookup 10000) map50000
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOOEQ 10000) is50000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOOEQ 10000) ts50000
#endif
]
]
, C.bgroup "lookup OO GE (Int) 01 50000 (500)"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOOGE 49500) ds50000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOOGELens 99500) ds50000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOOGE 49500) is50000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOOGE 49500) ts50000
#endif
]
]
, C.bgroup "lookup OM EQ (Int) 01 50000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOMEQ 200) ds50000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOMEQLens 200) ds50000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOMEQ 200) is50000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOMEQ 200) ts50000
#endif
]
]
, C.bgroup "lookup OM GE (Int) 01 50000 (500)"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOMGE 9900) ds50000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOMGELens 9900) ds50000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOMGE 9900) is50000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOMGE 9900) ts50000
#endif
]
]
, C.bgroup "lookup MM EQ (Int) 01 50000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupMMEQ 200) ds50000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupMMEQLens 200) ds50000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupMMEQ 200) is50000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupMMEQ 200) ts50000
#endif
]
]
, C.bgroup "lookup OO EQ (Int) 01 100000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOOEQ 10000) ds100000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOOEQLens 10000) ds100000
#ifndef BENCH_DS
, C.bench "Map" $ C.nf (Data.Map.lookup 10000) map100000
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOOEQ 10000) is100000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOOEQ 10000) ts100000
#endif
]
]
, C.bgroup "lookup OO GE (Int) 01 100000 (500)"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOOGE 99500) ds100000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOOGELens 99500) ds100000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOOGE 99500) is100000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOOGE 99500) ts100000
#endif
]
]
, C.bgroup "lookup OM EQ (Int) 01 100000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOMEQ 200) ds100000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOMEQLens 200) ds100000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOMEQ 200) is100000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOMEQ 200) ts100000
#endif
]
]
, C.bgroup "lookup OM GE (Int) 01 100000 (500)"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOMGE 19900) ds100000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOMGELens 19900) ds100000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOMGE 19900) is100000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOMGE 19900) ts100000
#endif
]
]
, C.bgroup "lookup MM EQ (Int) 01 100000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupMMEQ 200) ds100000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupMMEQLens 200) ds100000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupMMEQ 200) is100000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupMMEQ 200) ts100000
#endif
]
]
#endif
, C.bgroup "lookup OO EQ (Int) 01 200000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOOEQ 10000) ds200000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOOEQLens 10000) ds200000
#ifndef BENCH_DS
, C.bench "Map" $ C.nf (Data.Map.lookup 10000) map200000
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOOEQ 10000) is200000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOOEQ 10000) ts200000
#endif
]
]
, C.bgroup "lookup OO GE (Int) 01 200000 (500)"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOOGE 199500) ds200000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOOGELens 199500) ds200000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOOGE 199500) is200000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOOGE 199500) ts200000
#endif
]
]
, C.bgroup "lookup OM EQ (Int) 01 200000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOMEQ 200) ds200000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOMEQLens 200) ds200000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOMEQ 200) is200000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOMEQ 200) ts200000
#endif
]
]
, C.bgroup "lookup OM GE (Int) 01 200000 (500)"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupOMGE 39900) ds200000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupOMGELens 39900) ds200000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupOMGE 39900) is200000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupOMGE 39900) ts200000
#endif
]
]
, C.bgroup "lookup MM EQ (Int) 01 200000"
[ C.bcompare
[ C.bench "DS" $ C.whnf (forceList . DS.B01.lookupMMEQ 200) ds200000
--, C.bench "DS (Lens)" $ C.whnf (forceList . DS.B01.lookupMMEQLens 200) ds200000
#ifndef BENCH_DS
, C.bench "IS" $ C.whnf (forceList . IS.B01.lookupMMEQ 200) is200000
, C.bench "TS" $ C.whnf (forceList . TS.B01.lookupMMEQ 200) ts200000
#endif
]
]
]
---
insertListDS :: [C01] -> DS.B01.DS -> DS.B01.DS
insertListDS xs s0 = foldl' (flip DS.B01.insert) s0 xs
insertListTS :: [C01] -> TS.B01.TS -> TS.B01.TS
insertListTS xs s0 = snd $!
foldl' (\(n, acc) x -> if n == t
then rnf acc `seq` (0, TS.B01.insert x acc)
else (n + 1, TS.B01.insert x acc)
) (0 :: Int, s0) xs
where t = 10000
insertListIS :: [C01] -> IS.B01.IS -> IS.B01.IS
insertListIS xs s0 = snd $!
foldl' (\(n, acc) x -> if n == t
then rnf acc `seq` (0, IS.B01.insert x acc)
else (n + 1, IS.B01.insert x acc)
) (0 :: Int, s0) xs
where t = 10000
insertListMap :: [C01] -> Data.Map.Map Int C01 -> Data.Map.Map Int C01
insertListMap xs s0 = foldl' (flip insertMap) s0 xs
insertMap :: C01 -> Data.Map.Map Int C01 -> Data.Map.Map Int C01
insertMap x@(C01 oo _ _) = Data.Map.insert oo x
-- MAP
#ifdef BENCH_SMALL
map50000 :: Data.Map.Map Int C01
map50000 = insertListMap elems50000 Data.Map.empty
map100000 :: Data.Map.Map Int C01
map100000 = insertListMap elems100000 Data.Map.empty
#endif
map200000 :: Data.Map.Map Int C01
map200000 = insertListMap elems200000 Data.Map.empty
-- IS
#ifdef BENCH_SMALL
is50000 :: IS.B01.IS
is50000 = insertListIS elems50000 IS.B01.empty
is100000 :: IS.B01.IS
is100000 = insertListIS elems100000 IS.B01.empty
#endif
is200000 :: IS.B01.IS
is200000 = insertListIS elems200000 IS.B01.empty
-- DS
#ifdef BENCH_SMALL
ds50000 :: DS.B01.DS
ds50000 = insertListDS elems50000 DS.B01.empty
ds100000 :: DS.B01.DS
ds100000 = insertListDS elems100000 DS.B01.empty
#endif
ds200000 :: DS.B01.DS
ds200000 = insertListDS elems200000 DS.B01.empty
-- TS
#ifdef BENCH_SMALL
ts50000 :: TS.B01.TS
ts50000 = insertListTS elems50000 TS.B01.empty
ts100000 :: TS.B01.TS
ts100000 = insertListTS elems100000 TS.B01.empty
#endif
ts200000 :: TS.B01.TS
ts200000 = insertListTS elems200000 TS.B01.empty
|
Palmik/data-store
|
benchmarks/src/01.hs
|
bsd-3-clause
| 11,942 | 0 | 16 | 2,626 | 3,428 | 1,814 | 1,614 | 97 | 2 |
module Test.Euler.EulerHelper where
import Prelude hiding ((.))
import MPS
-- helper
read_data n = ("data/" ++ n ++ ".txt").read_pure
input_data n = ("data/" ++ n ++ ".in").read_pure
output_data n = ("data/" ++ n ++ ".out").write_pure
process_data n f = f (input_data n) .output_data n
|
nfjinjing/bench-euler
|
src/Test/Euler/EulerHelper.hs
|
bsd-3-clause
| 289 | 1 | 8 | 47 | 110 | 61 | 49 | 7 | 1 |
module Main where
import Api (apiServer)
import Network.Wai.Handler.Warp (run)
main :: IO ()
main = putStrLn "Server started" >> run 8081 apiServer
|
thiagorp/deployments-web
|
app/Main.hs
|
bsd-3-clause
| 150 | 0 | 6 | 24 | 51 | 29 | 22 | 5 | 1 |
{-# LANGUAGE
OverloadedStrings
, ExtendedDefaultRules
, FlexibleContexts
#-}
module Pages.Home where
import Application.Types
import Data.Url
import Path.Extended
import Lucid
import Control.Monad.Trans
homePage :: ( MonadApp m
) => HtmlT m ()
homePage = do
contactsLoc <- lift $ toLocation AppContacts
contacts <- lift $ locUrl contactsLoc
p_ [] "woo"
|
athanclark/contact-logger
|
src/Pages/Home.hs
|
bsd-3-clause
| 388 | 0 | 9 | 84 | 95 | 50 | 45 | 16 | 1 |
{-# LANGUAGE OverloadedStrings, FlexibleContexts, GADTs, ScopedTypeVariables #-}
{-|
Description: Helpers for enabling graph interactitivy.
This module takes the raw data parsed from the SVG files and computes
prerequisite relationships based on the geometry.
This is currently done after the data is first inserted, when the new
SVG is generated. This work should really be done immediately after
parsing, before anything is inserted into the database.
-}
module Svg.Builder
(buildPath,
buildRect,
buildEllipses,
intersectsWithShape,
buildPathString,
sanitizeId) where
import Data.Char (toLower)
import Data.List (find)
import Database.Tables
import Database.DataType
-- * Builder functions
-- | Fills in the id and source and target nodes of the path.
-- It is debateable whether the id is necessary, but the source
-- and targets must be set after the rectangles have been parsed.
buildPath :: [Shape] -- ^ Node elements.
-> [Shape] -- ^ Ellipses.
-> Path -- ^ A path.
-> Integer -- ^ A number to use in the ID of the path.
-> Path
buildPath rects ellipses entity elementId
| pathIsRegion entity =
entity {pathId_ = pathId_ entity ++ ('p' : show elementId),
pathSource = "",
pathTarget = ""}
| otherwise =
let coords = pathPoints entity
start = head coords
end = last coords
sourceNode = getIntersectingShape start (rects ++ ellipses)
targetNode = getIntersectingShape end
(filter (\r -> shapeId_ r /= sourceNode) rects ++
ellipses)
in
entity {pathId_ = 'p' : show elementId,
pathSource = sourceNode,
pathTarget = targetNode}
-- | Builds a Rect from a database entry.
-- Fills in the text association(s) and ID.
buildRect :: [Text] -- ^ A list of shapes that may intersect with the given node.
-> Shape -- ^ A node.
-> Integer -- ^ An integer to uniquely identify the shape
-> Shape
buildRect texts entity elementId =
let rectTexts = filter (intersects
(shapeWidth entity)
(shapeHeight entity)
(shapePos entity)
9
. textPos
) texts
textString = concatMap textText rectTexts
id_ = case shapeType_ entity of
Hybrid -> 'h' : show elementId
Node -> map toLower $ sanitizeId textString
in
entity {shapeId_ = id_,
shapeText = rectTexts,
-- TODO: check if already set this one during parsing
shapeTolerance = 9}
-- | Builds an ellipse from a database entry.
-- Fills in the text association and ID.
buildEllipses :: [Text] -- ^ A list of Text elements that may or may not intersect
-- with the given ellipse.
-> Shape -- ^ An ellipse.
-> Integer -- ^ A number to use in the ID of the ellipse.
-> Shape
buildEllipses texts entity elementId =
let ellipseText = filter (intersectsEllipse
(shapeWidth entity / 2)
(shapeHeight entity / 2)
(fst (shapePos entity) - shapeWidth entity / 2,
snd (shapePos entity) - shapeHeight entity / 2)
. textPos
) texts
in
entity {shapeId_ = "bool" ++ show elementId,
shapeFill = "", -- TODO: necessary?
shapeText = ellipseText,
shapeTolerance = 20} -- TODO: necessary?
where
intersectsEllipse a b (cx, cy) (x, y) =
let dx = x - cx - 5 -- some tolerance
dy = y - cy - 5
in
(dx*dx) / (a*a) + (dy*dy) / (b*b) < 1
-- | Rebuilds a path's `d` attribute based on a list of Rational tuples.
buildPathString :: [Point] -> String
buildPathString d = unwords $ map toString d
where
toString (a, b) = show a ++ "," ++ show b
-- * Intersection helpers
-- | Determines if a point is contained in a given rectangular region.
intersects :: Double -- ^ The region's width.
-> Double -- ^ The region's height.
-> Point -- ^ The region's bottom-left coordinate.
-> Double -- ^ The tolerance for the point being outside the boundary.
-> Point -- ^ The point's coordinate.
-> Bool
intersects width height (rx, ry) offset (px, py) =
let dx = px - rx
dy = py - ry
in dx >= -1 * offset &&
dx <= width + offset &&
dy >= -1 * offset &&
dy <= height + offset;
-- | Determines if a point is contained in a shape.
intersectsWithPoint :: Point -> Shape -> Bool
intersectsWithPoint point shape
| shapeType_ shape == BoolNode =
intersects (shapeWidth shape)
(shapeHeight shape)
(fst (shapePos shape) - shapeWidth shape / 2,
snd (shapePos shape) - shapeHeight shape / 2)
(shapeTolerance shape)
point
| otherwise =
intersects (shapeWidth shape)
(shapeHeight shape)
(shapePos shape)
(shapeTolerance shape)
point
-- | Returns the ID of the first shape in a list that intersects
-- with the given point.
getIntersectingShape :: Point -> [Shape] -> String
getIntersectingShape point shapes =
maybe "" shapeId_ $ find (intersectsWithPoint point) shapes
-- | Determines if a text intersects with any shape in a list.
intersectsWithShape :: [Shape] -> Text -> Bool
intersectsWithShape shapes text =
any (intersectsWithPoint (textPos text)) shapes
-- ** Other helpers
-- | Strips disallowed characters from string for DOM id
sanitizeId :: String -> String
sanitizeId = filter (\c -> not $ elem c (",()/<>% " :: String))
|
ryanfan/courseography
|
app/Svg/Builder.hs
|
gpl-3.0
| 6,161 | 0 | 18 | 2,179 | 1,189 | 636 | 553 | 111 | 2 |
import Test.HUnit
import TransformationTests.Common
--import AnalsisTests.Stencils.TwoDimensional
main :: IO ()
main = do -- Common blcock tests
runTestTT (TestList [test toArgsIntegration, test toArgsIntegration2, test (assertEqual "FALSE" 0 1)])
-- Stencil spec tests
--runTestTT twoDimensionalTests
return ()
|
dorchard/camfort
|
tests/TestSuite.hs
|
apache-2.0
| 361 | 0 | 13 | 85 | 78 | 40 | 38 | 6 | 1 |
-------------------------------------------------------------------------------
-- |
-- Module : System.Hardware.Haskino.SamplePrograms.Deep.semExample
-- Copyright : (c) University of Kansas
-- License : BSD3
-- Stability : experimental
--
-- This is an example of using semaphores to communicate between two tasks.
-- One task gives a semaphore then delays for 2 seconds. The other task
-- waits for the semaphore then blinks the led rapidly 3 times.
-------------------------------------------------------------------------------
module System.Hardware.Haskino.SamplePrograms.Deep.SemExample where
import Prelude hiding ((<*))
import Control.Concurrent (threadDelay)
import Control.Monad.Trans (liftIO)
import Data.Boolean
import Data.Boolean.Numbers
import Data.Word
import System.Hardware.Haskino
blinkDelay :: Expr Word32
blinkDelay = 125
taskDelay :: Expr Word32
taskDelay = 2000
semId :: Expr Word8
semId = 0
myTask1 :: Expr Word8 -> Arduino ()
myTask1 led = do
setPinModeE led OUTPUT
loopE $ do
takeSemE semId
let count = lit (3::Word32)
whileE 0 (\x -> x <* count) (\x -> do
digitalWriteE led true
delayMillisE blinkDelay
digitalWriteE led false
delayMillisE blinkDelay
return $ x + 1)
return ()
myTask2 :: Arduino ()
myTask2 = do
loopCount <- newRemoteRef $ lit (0 :: Word8)
loopE $ do
giveSemE semId
t <- readRemoteRef loopCount
writeRemoteRef loopCount $ t+1
debugE $ showE t
delayMillisE taskDelay
return ()
initExample :: Arduino ()
initExample = do
let led = 13
-- Create the tasks
createTaskE 1 $ myTask1 led
createTaskE 2 myTask2
-- Schedule the tasks to start in 1 second, the second starting after the first
scheduleTaskE 1 1000
scheduleTaskE 2 1050
semExample :: IO ()
semExample = withArduino True "/dev/cu.usbmodem1421" $ do
initExample
-- Query to confirm task creation
tasks <- queryAllTasksE
liftIO $ print tasks
task1 <- queryTaskE 1
liftIO $ print task1
task2 <- queryTaskE 2
liftIO $ print task2
-- Wait for any debug messgaes from Arduino
debugListen
semExampleProg :: IO ()
semExampleProg = withArduino True "/dev/cu.usbmodem1421" $ do
initExample
-- Program the boot tasks
bootTaskE (lit [1,2])
return ()
|
ku-fpg/kansas-amber
|
legacy/Deep/SemExample.hs
|
bsd-3-clause
| 2,402 | 0 | 16 | 573 | 557 | 273 | 284 | 59 | 1 |
{-# OPTIONS -fno-warn-tabs #-}
-- The above warning supression flag is a temporary kludge.
-- While working on this module you are encouraged to remove it and
-- detab the module (please do the detabbing in a separate patch). See
-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#TabsvsSpaces
-- for details
module SPARC.AddrMode (
AddrMode(..),
addrOffset
)
where
import SPARC.Imm
import SPARC.Base
import Reg
-- addressing modes ------------------------------------------------------------
-- | Represents a memory address in an instruction.
-- Being a RISC machine, the SPARC addressing modes are very regular.
--
data AddrMode
= AddrRegReg Reg Reg -- addr = r1 + r2
| AddrRegImm Reg Imm -- addr = r1 + imm
-- | Add an integer offset to the address in an AddrMode.
--
addrOffset :: AddrMode -> Int -> Maybe AddrMode
addrOffset addr off
= case addr of
AddrRegImm r (ImmInt n)
| fits13Bits n2 -> Just (AddrRegImm r (ImmInt n2))
| otherwise -> Nothing
where n2 = n + off
AddrRegImm r (ImmInteger n)
| fits13Bits n2 -> Just (AddrRegImm r (ImmInt (fromInteger n2)))
| otherwise -> Nothing
where n2 = n + toInteger off
AddrRegReg r (RegReal (RealRegSingle 0))
| fits13Bits off -> Just (AddrRegImm r (ImmInt off))
| otherwise -> Nothing
_ -> Nothing
|
nomeata/ghc
|
compiler/nativeGen/SPARC/AddrMode.hs
|
bsd-3-clause
| 1,385 | 10 | 15 | 325 | 302 | 155 | 147 | 25 | 4 |
{-
(c) The University of Glasgow 2006
(c) The AQUA Project, Glasgow University, 1996-1998
TcTyClsDecls: Typecheck type and class declarations
-}
{-# LANGUAGE CPP, TupleSections #-}
module TcTyClsDecls (
tcTyAndClassDecls, tcAddImplicits,
-- Functions used by TcInstDcls to check
-- data/type family instance declarations
kcDataDefn, tcConDecls, dataDeclChecks, checkValidTyCon,
tcFamTyPats, tcTyFamInstEqn, famTyConShape,
tcAddTyFamInstCtxt, tcAddDataFamInstCtxt,
wrongKindOfFamily, dataConCtxt, badDataConTyCon
) where
#include "HsVersions.h"
import HsSyn
import HscTypes
import BuildTyCl
import TcRnMonad
import TcEnv
import TcValidity
import TcHsSyn
import TcBinds( tcRecSelBinds )
import TcTyDecls
import TcClassDcl
import TcHsType
import TcMType
import TcType
import TysWiredIn( unitTy )
import FamInst
import FamInstEnv( isDominatedBy, mkCoAxBranch, mkBranchedCoAxiom )
import Coercion( pprCoAxBranch, ltRole )
import Type
import TypeRep -- for checkValidRoles
import Kind
import Class
import CoAxiom
import TyCon
import DataCon
import Id
import MkCore ( rEC_SEL_ERROR_ID )
import IdInfo
import Var
import VarEnv
import VarSet
import Module
import Name
import NameSet
import NameEnv
import Outputable
import Maybes
import Unify
import Util
import SrcLoc
import ListSetOps
import Digraph
import DynFlags
import FastString
import Unique ( mkBuiltinUnique )
import BasicTypes
import Bag
import Control.Monad
import Data.List
{-
************************************************************************
* *
\subsection{Type checking for type and class declarations}
* *
************************************************************************
Note [Grouping of type and class declarations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tcTyAndClassDecls is called on a list of `TyClGroup`s. Each group is a strongly
connected component of mutually dependent types and classes. We kind check and
type check each group separately to enhance kind polymorphism. Take the
following example:
type Id a = a
data X = X (Id Int)
If we were to kind check the two declarations together, we would give Id the
kind * -> *, since we apply it to an Int in the definition of X. But we can do
better than that, since Id really is kind polymorphic, and should get kind
forall (k::BOX). k -> k. Since it does not depend on anything else, it can be
kind-checked by itself, hence getting the most general kind. We then kind check
X, which works fine because we then know the polymorphic kind of Id, and simply
instantiate k to *.
Note [Check role annotations in a second pass]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Role inference potentially depends on the types of all of the datacons declared
in a mutually recursive group. The validity of a role annotation, in turn,
depends on the result of role inference. Because the types of datacons might
be ill-formed (see #7175 and Note [Checking GADT return types]) we must check
*all* the tycons in a group for validity before checking *any* of the roles.
Thus, we take two passes over the resulting tycons, first checking for general
validity and then checking for valid role annotations.
-}
tcTyAndClassDecls :: ModDetails
-> [TyClGroup Name] -- Mutually-recursive groups in dependency order
-> TcM TcGblEnv -- Input env extended by types and classes
-- and their implicit Ids,DataCons
-- Fails if there are any errors
tcTyAndClassDecls boot_details tyclds_s
= checkNoErrs $ -- The code recovers internally, but if anything gave rise to
-- an error we'd better stop now, to avoid a cascade
fold_env tyclds_s -- Type check each group in dependency order folding the global env
where
fold_env :: [TyClGroup Name] -> TcM TcGblEnv
fold_env [] = getGblEnv
fold_env (tyclds:tyclds_s)
= do { tcg_env <- tcTyClGroup boot_details tyclds
; setGblEnv tcg_env $ fold_env tyclds_s }
-- remaining groups are typecheck in the extended global env
tcTyClGroup :: ModDetails -> TyClGroup Name -> TcM TcGblEnv
-- Typecheck one strongly-connected component of type and class decls
tcTyClGroup boot_details tyclds
= do { -- Step 1: kind-check this group and returns the final
-- (possibly-polymorphic) kind of each TyCon and Class
-- See Note [Kind checking for type and class decls]
names_w_poly_kinds <- kcTyClGroup tyclds
; traceTc "tcTyAndCl generalized kinds" (ppr names_w_poly_kinds)
-- Step 2: type-check all groups together, returning
-- the final TyCons and Classes
; let role_annots = extractRoleAnnots tyclds
decls = group_tyclds tyclds
; tyclss <- fixM $ \ rec_tyclss -> do
{ is_boot <- tcIsHsBootOrSig
; let rec_flags = calcRecFlags boot_details is_boot
role_annots rec_tyclss
-- Populate environment with knot-tied ATyCon for TyCons
-- NB: if the decls mention any ill-staged data cons
-- (see Note [Recusion and promoting data constructors]
-- we will have failed already in kcTyClGroup, so no worries here
; tcExtendRecEnv (zipRecTyClss names_w_poly_kinds rec_tyclss) $
-- Also extend the local type envt with bindings giving
-- the (polymorphic) kind of each knot-tied TyCon or Class
-- See Note [Type checking recursive type and class declarations]
tcExtendKindEnv names_w_poly_kinds $
-- Kind and type check declarations for this group
concatMapM (tcTyClDecl rec_flags) decls }
-- Step 3: Perform the validity check
-- We can do this now because we are done with the recursive knot
-- Do it before Step 4 (adding implicit things) because the latter
-- expects well-formed TyCons
; tcExtendGlobalEnv tyclss $ do
{ traceTc "Starting validity check" (ppr tyclss)
; checkNoErrs $
mapM_ (recoverM (return ()) . checkValidTyCl) tyclss
-- We recover, which allows us to report multiple validity errors
-- the checkNoErrs is necessary to fix #7175.
; mapM_ (recoverM (return ()) . checkValidRoleAnnots role_annots) tyclss
-- See Note [Check role annotations in a second pass]
-- Step 4: Add the implicit things;
-- we want them in the environment because
-- they may be mentioned in interface files
; tcExtendGlobalValEnv (mkDefaultMethodIds tyclss) $
tcAddImplicits tyclss } }
tcAddImplicits :: [TyThing] -> TcM TcGblEnv
tcAddImplicits tyclss
= tcExtendGlobalEnvImplicit implicit_things $
tcRecSelBinds rec_sel_binds
where
implicit_things = concatMap implicitTyThings tyclss
rec_sel_binds = mkRecSelBinds tyclss
zipRecTyClss :: [(Name, Kind)]
-> [TyThing] -- Knot-tied
-> [(Name,TyThing)]
-- Build a name-TyThing mapping for the things bound by decls
-- being careful not to look at the [TyThing]
-- The TyThings in the result list must have a visible ATyCon,
-- because typechecking types (in, say, tcTyClDecl) looks at this outer constructor
zipRecTyClss kind_pairs rec_things
= [ (name, ATyCon (get name)) | (name, _kind) <- kind_pairs ]
where
rec_type_env :: TypeEnv
rec_type_env = mkTypeEnv rec_things
get name = case lookupTypeEnv rec_type_env name of
Just (ATyCon tc) -> tc
other -> pprPanic "zipRecTyClss" (ppr name <+> ppr other)
{-
************************************************************************
* *
Kind checking
* *
************************************************************************
Note [Kind checking for type and class decls]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kind checking is done thus:
1. Make up a kind variable for each parameter of the *data* type, class,
and closed type family decls, and extend the kind environment (which is
in the TcLclEnv)
2. Dependency-analyse the type *synonyms* (which must be non-recursive),
and kind-check them in dependency order. Extend the kind envt.
3. Kind check the data type and class decls
We need to kind check all types in the mutually recursive group
before we know the kind of the type variables. For example:
class C a where
op :: D b => a -> b -> b
class D c where
bop :: (Monad c) => ...
Here, the kind of the locally-polymorphic type variable "b"
depends on *all the uses of class D*. For example, the use of
Monad c in bop's type signature means that D must have kind Type->Type.
However type synonyms work differently. They can have kinds which don't
just involve (->) and *:
type R = Int# -- Kind #
type S a = Array# a -- Kind * -> #
type T a b = (# a,b #) -- Kind * -> * -> (# a,b #)
and a kind variable can't unify with UnboxedTypeKind.
So we must infer the kinds of type synonyms from their right-hand
sides *first* and then use them, whereas for the mutually recursive
data types D we bring into scope kind bindings D -> k, where k is a
kind variable, and do inference.
NB: synonyms can be mutually recursive with data type declarations though!
type T = D -> D
data D = MkD Int T
Open type families
~~~~~~~~~~~~~~~~~~
This treatment of type synonyms only applies to Haskell 98-style synonyms.
General type functions can be recursive, and hence, appear in `alg_decls'.
The kind of an open type family is solely determinded by its kind signature;
hence, only kind signatures participate in the construction of the initial
kind environment (as constructed by `getInitialKind'). In fact, we ignore
instances of families altogether in the following. However, we need to include
the kinds of *associated* families into the construction of the initial kind
environment. (This is handled by `allDecls').
-}
kcTyClGroup :: TyClGroup Name -> TcM [(Name,Kind)]
-- Kind check this group, kind generalize, and return the resulting local env
-- This bindds the TyCons and Classes of the group, but not the DataCons
-- See Note [Kind checking for type and class decls]
kcTyClGroup (TyClGroup { group_tyclds = decls })
= do { mod <- getModule
; traceTc "kcTyClGroup" (ptext (sLit "module") <+> ppr mod $$ vcat (map ppr decls))
-- Kind checking;
-- 1. Bind kind variables for non-synonyms
-- 2. Kind-check synonyms, and bind kinds of those synonyms
-- 3. Kind-check non-synonyms
-- 4. Generalise the inferred kinds
-- See Note [Kind checking for type and class decls]
-- Step 1: Bind kind variables for non-synonyms
; let (syn_decls, non_syn_decls) = partition (isSynDecl . unLoc) decls
; initial_kinds <- getInitialKinds non_syn_decls
; traceTc "kcTyClGroup: initial kinds" (ppr initial_kinds)
-- Step 2: Set initial envt, kind-check the synonyms
; lcl_env <- tcExtendKindEnv2 initial_kinds $
kcSynDecls (calcSynCycles syn_decls)
-- Step 3: Set extended envt, kind-check the non-synonyms
; setLclEnv lcl_env $
mapM_ kcLTyClDecl non_syn_decls
-- Step 4: generalisation
-- Kind checking done for this group
-- Now we have to kind generalize the flexis
; res <- concatMapM (generaliseTCD (tcl_env lcl_env)) decls
; traceTc "kcTyClGroup result" (ppr res)
; return res }
where
generalise :: TcTypeEnv -> Name -> TcM (Name, Kind)
-- For polymorphic things this is a no-op
generalise kind_env name
= do { let kc_kind = case lookupNameEnv kind_env name of
Just (AThing k) -> k
_ -> pprPanic "kcTyClGroup" (ppr name $$ ppr kind_env)
; kvs <- kindGeneralize (tyVarsOfType kc_kind)
; kc_kind' <- zonkTcKind kc_kind -- Make sure kc_kind' has the final,
-- skolemised kind variables
; traceTc "Generalise kind" (vcat [ ppr name, ppr kc_kind, ppr kvs, ppr kc_kind' ])
; return (name, mkForAllTys kvs kc_kind') }
generaliseTCD :: TcTypeEnv -> LTyClDecl Name -> TcM [(Name, Kind)]
generaliseTCD kind_env (L _ decl)
| ClassDecl { tcdLName = (L _ name), tcdATs = ats } <- decl
= do { first <- generalise kind_env name
; rest <- mapM ((generaliseFamDecl kind_env) . unLoc) ats
; return (first : rest) }
| FamDecl { tcdFam = fam } <- decl
= do { res <- generaliseFamDecl kind_env fam
; return [res] }
| otherwise
= do { res <- generalise kind_env (tcdName decl)
; return [res] }
generaliseFamDecl :: TcTypeEnv -> FamilyDecl Name -> TcM (Name, Kind)
generaliseFamDecl kind_env (FamilyDecl { fdLName = L _ name })
= generalise kind_env name
mk_thing_env :: [LTyClDecl Name] -> [(Name, TcTyThing)]
mk_thing_env [] = []
mk_thing_env (decl : decls)
| L _ (ClassDecl { tcdLName = L _ nm, tcdATs = ats }) <- decl
= (nm, APromotionErr ClassPE) :
(map (, APromotionErr TyConPE) $ map (unLoc . fdLName . unLoc) ats) ++
(mk_thing_env decls)
| otherwise
= (tcdName (unLoc decl), APromotionErr TyConPE) :
(mk_thing_env decls)
getInitialKinds :: [LTyClDecl Name] -> TcM [(Name, TcTyThing)]
getInitialKinds decls
= tcExtendKindEnv2 (mk_thing_env decls) $
do { pairss <- mapM (addLocM getInitialKind) decls
; return (concat pairss) }
getInitialKind :: TyClDecl Name -> TcM [(Name, TcTyThing)]
-- Allocate a fresh kind variable for each TyCon and Class
-- For each tycon, return (tc, AThing k)
-- where k is the kind of tc, derived from the LHS
-- of the definition (and probably including
-- kind unification variables)
-- Example: data T a b = ...
-- return (T, kv1 -> kv2 -> kv3)
--
-- This pass deals with (ie incorporates into the kind it produces)
-- * The kind signatures on type-variable binders
-- * The result kinds signature on a TyClDecl
--
-- ALSO for each datacon, return (dc, APromotionErr RecDataConPE)
-- Note [ARecDataCon: Recursion and promoting data constructors]
--
-- No family instances are passed to getInitialKinds
getInitialKind decl@(ClassDecl { tcdLName = L _ name, tcdTyVars = ktvs, tcdATs = ats })
= do { (cl_kind, inner_prs) <-
kcHsTyVarBndrs (hsDeclHasCusk decl) ktvs $
do { inner_prs <- getFamDeclInitialKinds ats
; return (constraintKind, inner_prs) }
; let main_pr = (name, AThing cl_kind)
; return (main_pr : inner_prs) }
getInitialKind decl@(DataDecl { tcdLName = L _ name
, tcdTyVars = ktvs
, tcdDataDefn = HsDataDefn { dd_kindSig = m_sig
, dd_cons = cons' } })
= let cons = cons' -- AZ list monad coming
in
do { (decl_kind, _) <-
kcHsTyVarBndrs (hsDeclHasCusk decl) ktvs $
do { res_k <- case m_sig of
Just ksig -> tcLHsKind ksig
Nothing -> return liftedTypeKind
; return (res_k, ()) }
; let main_pr = (name, AThing decl_kind)
inner_prs = [ (unLoc con, APromotionErr RecDataConPE)
| L _ con' <- cons, con <- con_names con' ]
; return (main_pr : inner_prs) }
getInitialKind (FamDecl { tcdFam = decl })
= getFamDeclInitialKind decl
getInitialKind decl@(SynDecl {})
= pprPanic "getInitialKind" (ppr decl)
---------------------------------
getFamDeclInitialKinds :: [LFamilyDecl Name] -> TcM [(Name, TcTyThing)]
getFamDeclInitialKinds decls
= tcExtendKindEnv2 [ (n, APromotionErr TyConPE)
| L _ (FamilyDecl { fdLName = L _ n }) <- decls] $
concatMapM (addLocM getFamDeclInitialKind) decls
getFamDeclInitialKind :: FamilyDecl Name
-> TcM [(Name, TcTyThing)]
getFamDeclInitialKind decl@(FamilyDecl { fdLName = L _ name
, fdTyVars = ktvs
, fdKindSig = ksig })
= do { (fam_kind, _) <-
kcHsTyVarBndrs (famDeclHasCusk decl) ktvs $
do { res_k <- case ksig of
Just k -> tcLHsKind k
Nothing
| famDeclHasCusk decl -> return liftedTypeKind
| otherwise -> newMetaKindVar
; return (res_k, ()) }
; return [ (name, AThing fam_kind) ] }
----------------
kcSynDecls :: [SCC (LTyClDecl Name)]
-> TcM TcLclEnv -- Kind bindings
kcSynDecls [] = getLclEnv
kcSynDecls (group : groups)
= do { (n,k) <- kcSynDecl1 group
; lcl_env <- tcExtendKindEnv [(n,k)] (kcSynDecls groups)
; return lcl_env }
kcSynDecl1 :: SCC (LTyClDecl Name)
-> TcM (Name,TcKind) -- Kind bindings
kcSynDecl1 (AcyclicSCC (L _ decl)) = kcSynDecl decl
kcSynDecl1 (CyclicSCC decls) = do { recSynErr decls; failM }
-- Fail here to avoid error cascade
-- of out-of-scope tycons
kcSynDecl :: TyClDecl Name -> TcM (Name, TcKind)
kcSynDecl decl@(SynDecl { tcdTyVars = hs_tvs, tcdLName = L _ name
, tcdRhs = rhs })
-- Returns a possibly-unzonked kind
= tcAddDeclCtxt decl $
do { (syn_kind, _) <-
kcHsTyVarBndrs (hsDeclHasCusk decl) hs_tvs $
do { traceTc "kcd1" (ppr name <+> brackets (ppr hs_tvs))
; (_, rhs_kind) <- tcLHsType rhs
; traceTc "kcd2" (ppr name)
; return (rhs_kind, ()) }
; return (name, syn_kind) }
kcSynDecl decl = pprPanic "kcSynDecl" (ppr decl)
------------------------------------------------------------------------
kcLTyClDecl :: LTyClDecl Name -> TcM ()
-- See Note [Kind checking for type and class decls]
kcLTyClDecl (L loc decl)
= setSrcSpan loc $ tcAddDeclCtxt decl $ kcTyClDecl decl
kcTyClDecl :: TyClDecl Name -> TcM ()
-- This function is used solely for its side effect on kind variables
-- NB kind signatures on the type variables and
-- result kind signature have already been dealt with
-- by getInitialKind, so we can ignore them here.
kcTyClDecl (DataDecl { tcdLName = L _ name, tcdTyVars = hs_tvs, tcdDataDefn = defn })
| HsDataDefn { dd_cons = cons, dd_kindSig = Just _ } <- defn
= mapM_ (wrapLocM kcConDecl) cons
-- hs_tvs and dd_kindSig already dealt with in getInitialKind
-- If dd_kindSig is Just, this must be a GADT-style decl,
-- (see invariants of DataDefn declaration)
-- so (a) we don't need to bring the hs_tvs into scope, because the
-- ConDecls bind all their own variables
-- (b) dd_ctxt is not allowed for GADT-style decls, so we can ignore it
| HsDataDefn { dd_ctxt = ctxt, dd_cons = cons } <- defn
= kcTyClTyVars name hs_tvs $
do { _ <- tcHsContext ctxt
; mapM_ (wrapLocM kcConDecl) cons }
kcTyClDecl decl@(SynDecl {}) = pprPanic "kcTyClDecl" (ppr decl)
kcTyClDecl (ClassDecl { tcdLName = L _ name, tcdTyVars = hs_tvs
, tcdCtxt = ctxt, tcdSigs = sigs })
= kcTyClTyVars name hs_tvs $
do { _ <- tcHsContext ctxt
; mapM_ (wrapLocM kc_sig) sigs }
where
kc_sig (TypeSig _ op_ty _) = discardResult (tcHsLiftedType op_ty)
kc_sig (GenericSig _ op_ty) = discardResult (tcHsLiftedType op_ty)
kc_sig _ = return ()
-- closed type families look at their equations, but other families don't
-- do anything here
kcTyClDecl (FamDecl (FamilyDecl { fdLName = L _ fam_tc_name
, fdTyVars = hs_tvs
, fdInfo = ClosedTypeFamily (Just eqns) }))
= do { tc_kind <- kcLookupKind fam_tc_name
; let fam_tc_shape = ( fam_tc_name, length (hsQTvBndrs hs_tvs), tc_kind)
; mapM_ (kcTyFamInstEqn fam_tc_shape) eqns }
kcTyClDecl (FamDecl {}) = return ()
-------------------
kcConDecl :: ConDecl Name -> TcM ()
kcConDecl (ConDecl { con_names = names, con_qvars = ex_tvs
, con_cxt = ex_ctxt, con_details = details
, con_res = res })
= addErrCtxt (dataConCtxtName names) $
-- the 'False' says that the existentials don't have a CUSK, as the
-- concept doesn't really apply here. We just need to bring the variables
-- into scope!
do { _ <- kcHsTyVarBndrs False ex_tvs $
do { _ <- tcHsContext ex_ctxt
; mapM_ (tcHsOpenType . getBangType) (hsConDeclArgTys details)
; _ <- tcConRes res
; return (panic "kcConDecl", ()) }
; return () }
{-
Note [Recursion and promoting data constructors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We don't want to allow promotion in a strongly connected component
when kind checking.
Consider:
data T f = K (f (K Any))
When kind checking the `data T' declaration the local env contains the
mappings:
T -> AThing <some initial kind>
K -> ARecDataCon
ANothing is only used for DataCons, and only used during type checking
in tcTyClGroup.
************************************************************************
* *
\subsection{Type checking}
* *
************************************************************************
Note [Type checking recursive type and class declarations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At this point we have completed *kind-checking* of a mutually
recursive group of type/class decls (done in kcTyClGroup). However,
we discarded the kind-checked types (eg RHSs of data type decls);
note that kcTyClDecl returns (). There are two reasons:
* It's convenient, because we don't have to rebuild a
kinded HsDecl (a fairly elaborate type)
* It's necessary, because after kind-generalisation, the
TyCons/Classes may now be kind-polymorphic, and hence need
to be given kind arguments.
Example:
data T f a = MkT (f a) (T f a)
During kind-checking, we give T the kind T :: k1 -> k2 -> *
and figure out constraints on k1, k2 etc. Then we generalise
to get T :: forall k. (k->*) -> k -> *
So now the (T f a) in the RHS must be elaborated to (T k f a).
However, during tcTyClDecl of T (above) we will be in a recursive
"knot". So we aren't allowed to look at the TyCon T itself; we are only
allowed to put it (lazily) in the returned structures. But when
kind-checking the RHS of T's decl, we *do* need to know T's kind (so
that we can correctly elaboarate (T k f a). How can we get T's kind
without looking at T? Delicate answer: during tcTyClDecl, we extend
*Global* env with T -> ATyCon (the (not yet built) TyCon for T)
*Local* env with T -> AThing (polymorphic kind of T)
Then:
* During TcHsType.kcTyVar we look in the *local* env, to get the
known kind for T.
* But in TcHsType.ds_type (and ds_var_app in particular) we look in
the *global* env to get the TyCon. But we must be careful not to
force the TyCon or we'll get a loop.
This fancy footwork (with two bindings for T) is only necesary for the
TyCons or Classes of this recursive group. Earlier, finished groups,
live in the global env only.
Note [Declarations for wired-in things]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For wired-in things we simply ignore the declaration
and take the wired-in information. That avoids complications.
e.g. the need to make the data constructor worker name for
a constraint tuple match the wired-in one
-}
tcTyClDecl :: RecTyInfo -> LTyClDecl Name -> TcM [TyThing]
tcTyClDecl rec_info (L loc decl)
| Just thing <- wiredInNameTyThing_maybe (tcdName decl)
= return [thing] -- See Note [Declarations for wired-in things]
| otherwise
= setSrcSpan loc $ tcAddDeclCtxt decl $
do { traceTc "tcTyAndCl-x" (ppr decl)
; tcTyClDecl1 NoParentTyCon rec_info decl }
-- "type family" declarations
tcTyClDecl1 :: TyConParent -> RecTyInfo -> TyClDecl Name -> TcM [TyThing]
tcTyClDecl1 parent _rec_info (FamDecl { tcdFam = fd })
= tcFamDecl1 parent fd
-- "type" synonym declaration
tcTyClDecl1 _parent rec_info
(SynDecl { tcdLName = L _ tc_name, tcdTyVars = tvs, tcdRhs = rhs })
= ASSERT( isNoParent _parent )
tcTyClTyVars tc_name tvs $ \ tvs' kind ->
tcTySynRhs rec_info tc_name tvs' kind rhs
-- "data/newtype" declaration
tcTyClDecl1 _parent rec_info
(DataDecl { tcdLName = L _ tc_name, tcdTyVars = tvs, tcdDataDefn = defn })
= ASSERT( isNoParent _parent )
tcTyClTyVars tc_name tvs $ \ tvs' kind ->
tcDataDefn rec_info tc_name tvs' kind defn
tcTyClDecl1 _parent rec_info
(ClassDecl { tcdLName = L _ class_name, tcdTyVars = tvs
, tcdCtxt = ctxt, tcdMeths = meths
, tcdFDs = fundeps, tcdSigs = sigs
, tcdATs = ats, tcdATDefs = at_defs })
= ASSERT( isNoParent _parent )
do { (clas, tvs', gen_dm_env) <- fixM $ \ ~(clas,_,_) ->
tcTyClTyVars class_name tvs $ \ tvs' kind ->
do { MASSERT( isConstraintKind kind )
-- This little knot is just so we can get
-- hold of the name of the class TyCon, which we
-- need to look up its recursiveness
; let tycon_name = tyConName (classTyCon clas)
tc_isrec = rti_is_rec rec_info tycon_name
roles = rti_roles rec_info tycon_name
; ctxt' <- tcHsContext ctxt
; ctxt' <- zonkTcTypeToTypes emptyZonkEnv ctxt'
-- Squeeze out any kind unification variables
; fds' <- mapM (addLocM tc_fundep) fundeps
; (sig_stuff, gen_dm_env) <- tcClassSigs class_name sigs meths
; at_stuff <- tcClassATs class_name (AssocFamilyTyCon clas) ats at_defs
; mindef <- tcClassMinimalDef class_name sigs sig_stuff
; clas <- buildClass
class_name tvs' roles ctxt' fds' at_stuff
sig_stuff mindef tc_isrec
; traceTc "tcClassDecl" (ppr fundeps $$ ppr tvs' $$ ppr fds')
; return (clas, tvs', gen_dm_env) }
; let { gen_dm_ids = [ AnId (mkExportedLocalId VanillaId gen_dm_name gen_dm_ty)
| (sel_id, GenDefMeth gen_dm_name) <- classOpItems clas
, let gen_dm_tau = expectJust "tcTyClDecl1" $
lookupNameEnv gen_dm_env (idName sel_id)
, let gen_dm_ty = mkSigmaTy tvs'
[mkClassPred clas (mkTyVarTys tvs')]
gen_dm_tau
]
; class_ats = map ATyCon (classATs clas) }
; return (ATyCon (classTyCon clas) : gen_dm_ids ++ class_ats ) }
-- NB: Order is important due to the call to `mkGlobalThings' when
-- tying the the type and class declaration type checking knot.
where
tc_fundep (tvs1, tvs2) = do { tvs1' <- mapM (tc_fd_tyvar . unLoc) tvs1 ;
; tvs2' <- mapM (tc_fd_tyvar . unLoc) tvs2 ;
; return (tvs1', tvs2') }
tc_fd_tyvar name -- Scoped kind variables are bound to unification variables
-- which are now fixed, so we can zonk
= do { tv <- tcLookupTyVar name
; ty <- zonkTyVarOcc emptyZonkEnv tv
-- Squeeze out any kind unification variables
; case getTyVar_maybe ty of
Just tv' -> return tv'
Nothing -> pprPanic "tc_fd_tyvar" (ppr name $$ ppr tv $$ ppr ty) }
tcFamDecl1 :: TyConParent -> FamilyDecl Name -> TcM [TyThing]
tcFamDecl1 parent
(FamilyDecl {fdInfo = OpenTypeFamily, fdLName = L _ tc_name, fdTyVars = tvs})
= tcTyClTyVars tc_name tvs $ \ tvs' kind -> do
{ traceTc "open type family:" (ppr tc_name)
; checkFamFlag tc_name
; tycon <- buildFamilyTyCon tc_name tvs' OpenSynFamilyTyCon kind parent
; return [ATyCon tycon] }
tcFamDecl1 parent
(FamilyDecl { fdInfo = ClosedTypeFamily mb_eqns
, fdLName = lname@(L _ tc_name), fdTyVars = tvs })
-- Closed type families are a little tricky, because they contain the definition
-- of both the type family and the equations for a CoAxiom.
= do { traceTc "closed type family:" (ppr tc_name)
-- the variables in the header have no scope:
; (tvs', kind) <- tcTyClTyVars tc_name tvs $ \ tvs' kind ->
return (tvs', kind)
; checkFamFlag tc_name -- make sure we have -XTypeFamilies
-- If Nothing, this is an abstract family in a hs-boot file;
-- but eqns might be empty in the Just case as well
; case mb_eqns of
Nothing -> do { tycon <- buildFamilyTyCon tc_name tvs'
AbstractClosedSynFamilyTyCon kind parent
; return [ATyCon tycon] }
Just eqns -> do {
-- Process the equations, creating CoAxBranches
; tc_kind <- kcLookupKind tc_name
; let fam_tc_shape = (tc_name, length (hsQTvBndrs tvs), tc_kind)
; branches <- mapM (tcTyFamInstEqn fam_tc_shape) eqns
-- we need the tycon that we will be creating, but it's in scope.
-- just look it up.
; fam_tc <- tcLookupLocatedTyCon lname
-- create a CoAxiom, with the correct src location. It is Vitally
-- Important that we do not pass the branches into
-- newFamInstAxiomName. They have types that have been zonked inside
-- the knot and we will die if we look at them. This is OK here
-- because there will only be one axiom, so we don't need to
-- differentiate names.
-- See [Zonking inside the knot] in TcHsType
; loc <- getSrcSpanM
; co_ax_name <- newFamInstAxiomName loc tc_name []
-- mkBranchedCoAxiom will fail on an empty list of branches
; let mb_co_ax
| null eqns = Nothing
| otherwise = Just $ mkBranchedCoAxiom co_ax_name fam_tc branches
-- now, finally, build the TyCon
; tycon <- buildFamilyTyCon tc_name tvs'
(ClosedSynFamilyTyCon mb_co_ax) kind parent
; return $ ATyCon tycon : maybeToList (fmap ACoAxiom mb_co_ax) } }
-- We check for instance validity later, when doing validity checking for
-- the tycon
tcFamDecl1 parent
(FamilyDecl {fdInfo = DataFamily, fdLName = L _ tc_name, fdTyVars = tvs})
= tcTyClTyVars tc_name tvs $ \ tvs' kind -> do
{ traceTc "data family:" (ppr tc_name)
; checkFamFlag tc_name
; extra_tvs <- tcDataKindSig kind
; let final_tvs = tvs' ++ extra_tvs -- we may not need these
roles = map (const Nominal) final_tvs
tycon = buildAlgTyCon tc_name final_tvs roles Nothing []
DataFamilyTyCon Recursive
False -- Not promotable to the kind level
True -- GADT syntax
parent
; return [ATyCon tycon] }
tcTySynRhs :: RecTyInfo
-> Name
-> [TyVar] -> Kind
-> LHsType Name -> TcM [TyThing]
tcTySynRhs rec_info tc_name tvs kind hs_ty
= do { env <- getLclEnv
; traceTc "tc-syn" (ppr tc_name $$ ppr (tcl_env env))
; rhs_ty <- tcCheckLHsType hs_ty kind
; rhs_ty <- zonkTcTypeToType emptyZonkEnv rhs_ty
; let roles = rti_roles rec_info tc_name
; tycon <- buildSynonymTyCon tc_name tvs roles rhs_ty kind
; return [ATyCon tycon] }
tcDataDefn :: RecTyInfo -> Name
-> [TyVar] -> Kind
-> HsDataDefn Name -> TcM [TyThing]
-- NB: not used for newtype/data instances (whether associated or not)
tcDataDefn rec_info tc_name tvs kind
(HsDataDefn { dd_ND = new_or_data, dd_cType = cType
, dd_ctxt = ctxt, dd_kindSig = mb_ksig
, dd_cons = cons' })
= let cons = cons' -- AZ List monad coming
in do { extra_tvs <- tcDataKindSig kind
; let final_tvs = tvs ++ extra_tvs
roles = rti_roles rec_info tc_name
; stupid_tc_theta <- tcHsContext ctxt
; stupid_theta <- zonkTcTypeToTypes emptyZonkEnv stupid_tc_theta
; kind_signatures <- xoptM Opt_KindSignatures
; is_boot <- tcIsHsBootOrSig -- Are we compiling an hs-boot file?
-- Check that we don't use kind signatures without Glasgow extensions
; case mb_ksig of
Nothing -> return ()
Just hs_k -> do { checkTc (kind_signatures) (badSigTyDecl tc_name)
; tc_kind <- tcLHsKind hs_k
; checkKind kind tc_kind
; return () }
; gadt_syntax <- dataDeclChecks tc_name new_or_data stupid_theta cons
; tycon <- fixM $ \ tycon -> do
{ let res_ty = mkTyConApp tycon (mkTyVarTys final_tvs)
; data_cons <- tcConDecls new_or_data tycon (final_tvs, res_ty) cons
; tc_rhs <-
if null cons && is_boot -- In a hs-boot file, empty cons means
then return totallyAbstractTyConRhs -- "don't know"; hence totally Abstract
else case new_or_data of
DataType -> return (mkDataTyConRhs data_cons)
NewType -> ASSERT( not (null data_cons) )
mkNewTyConRhs tc_name tycon (head data_cons)
; return (buildAlgTyCon tc_name final_tvs roles (fmap unLoc cType)
stupid_theta tc_rhs
(rti_is_rec rec_info tc_name)
(rti_promotable rec_info)
gadt_syntax NoParentTyCon) }
; return [ATyCon tycon] }
{-
************************************************************************
* *
Typechecking associated types (in class decls)
(including the associated-type defaults)
* *
************************************************************************
Note [Associated type defaults]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following is an example of associated type defaults:
class C a where
data D a
type F a b :: *
type F a Z = [a] -- Default
type F a (S n) = F a n -- Default
Note that:
- We can have more than one default definition for a single associated type,
as long as they do not overlap (same rules as for instances)
- We can get default definitions only for type families, not data families
-}
tcClassATs :: Name -- The class name (not knot-tied)
-> TyConParent -- The class parent of this associated type
-> [LFamilyDecl Name] -- Associated types.
-> [LTyFamDefltEqn Name] -- Associated type defaults.
-> TcM [ClassATItem]
tcClassATs class_name parent ats at_defs
= do { -- Complain about associated type defaults for non associated-types
sequence_ [ failWithTc (badATErr class_name n)
| n <- map at_def_tycon at_defs
, not (n `elemNameSet` at_names) ]
; mapM tc_at ats }
where
at_def_tycon :: LTyFamDefltEqn Name -> Name
at_def_tycon (L _ eqn) = unLoc (tfe_tycon eqn)
at_fam_name :: LFamilyDecl Name -> Name
at_fam_name (L _ decl) = unLoc (fdLName decl)
at_names = mkNameSet (map at_fam_name ats)
at_defs_map :: NameEnv [LTyFamDefltEqn Name]
-- Maps an AT in 'ats' to a list of all its default defs in 'at_defs'
at_defs_map = foldr (\at_def nenv -> extendNameEnv_C (++) nenv
(at_def_tycon at_def) [at_def])
emptyNameEnv at_defs
tc_at at = do { [ATyCon fam_tc] <- addLocM (tcFamDecl1 parent) at
; let at_defs = lookupNameEnv at_defs_map (at_fam_name at)
`orElse` []
; atd <- tcDefaultAssocDecl fam_tc at_defs
; return (ATI fam_tc atd) }
-------------------------
tcDefaultAssocDecl :: TyCon -- ^ Family TyCon
-> [LTyFamDefltEqn Name] -- ^ Defaults
-> TcM (Maybe Type) -- ^ Type checked RHS
tcDefaultAssocDecl _ []
= return Nothing -- No default declaration
tcDefaultAssocDecl _ (d1:_:_)
= failWithTc (ptext (sLit "More than one default declaration for")
<+> ppr (tfe_tycon (unLoc d1)))
tcDefaultAssocDecl fam_tc [L loc (TyFamEqn { tfe_tycon = L _ tc_name
, tfe_pats = hs_tvs
, tfe_rhs = rhs })]
= setSrcSpan loc $
tcAddFamInstCtxt (ptext (sLit "default type instance")) tc_name $
tcTyClTyVars tc_name hs_tvs $ \ tvs rhs_kind ->
do { traceTc "tcDefaultAssocDecl" (ppr tc_name)
; checkTc (isTypeFamilyTyCon fam_tc) (wrongKindOfFamily fam_tc)
; let (fam_name, fam_pat_arity, _) = famTyConShape fam_tc
; ASSERT( fam_name == tc_name )
checkTc (length (hsQTvBndrs hs_tvs) == fam_pat_arity)
(wrongNumberOfParmsErr fam_pat_arity)
; rhs_ty <- tcCheckLHsType rhs rhs_kind
; rhs_ty <- zonkTcTypeToType emptyZonkEnv rhs_ty
; let fam_tc_tvs = tyConTyVars fam_tc
subst = zipTopTvSubst tvs (mkTyVarTys fam_tc_tvs)
; return ( ASSERT( equalLength fam_tc_tvs tvs )
Just (substTy subst rhs_ty) ) }
-- We check for well-formedness and validity later, in checkValidClass
-------------------------
kcTyFamInstEqn :: FamTyConShape -> LTyFamInstEqn Name -> TcM ()
kcTyFamInstEqn fam_tc_shape
(L loc (TyFamEqn { tfe_pats = pats, tfe_rhs = hs_ty }))
= setSrcSpan loc $
discardResult $
tc_fam_ty_pats fam_tc_shape pats (discardResult . (tcCheckLHsType hs_ty))
tcTyFamInstEqn :: FamTyConShape -> LTyFamInstEqn Name -> TcM CoAxBranch
-- Needs to be here, not in TcInstDcls, because closed families
-- (typechecked here) have TyFamInstEqns
tcTyFamInstEqn fam_tc_shape@(fam_tc_name,_,_)
(L loc (TyFamEqn { tfe_tycon = L _ eqn_tc_name
, tfe_pats = pats
, tfe_rhs = hs_ty }))
= setSrcSpan loc $
tcFamTyPats fam_tc_shape pats (discardResult . (tcCheckLHsType hs_ty)) $
\tvs' pats' res_kind ->
do { checkTc (fam_tc_name == eqn_tc_name)
(wrongTyFamName fam_tc_name eqn_tc_name)
; rhs_ty <- tcCheckLHsType hs_ty res_kind
; rhs_ty <- zonkTcTypeToType emptyZonkEnv rhs_ty
; traceTc "tcTyFamInstEqn" (ppr fam_tc_name <+> ppr tvs')
-- don't print out the pats here, as they might be zonked inside the knot
; return (mkCoAxBranch tvs' pats' rhs_ty loc) }
kcDataDefn :: HsDataDefn Name -> TcKind -> TcM ()
-- Used for 'data instance' only
-- Ordinary 'data' is handled by kcTyClDec
kcDataDefn (HsDataDefn { dd_ctxt = ctxt, dd_cons = cons, dd_kindSig = mb_kind }) res_k
= do { _ <- tcHsContext ctxt
; checkNoErrs $ mapM_ (wrapLocM kcConDecl) cons
-- See Note [Failing early in kcDataDefn]
; kcResultKind mb_kind res_k }
------------------
kcResultKind :: Maybe (LHsKind Name) -> Kind -> TcM ()
kcResultKind Nothing res_k
= checkKind res_k liftedTypeKind
-- type family F a
-- defaults to type family F a :: *
kcResultKind (Just k) res_k
= do { k' <- tcLHsKind k
; checkKind k' res_k }
{-
Kind check type patterns and kind annotate the embedded type variables.
type instance F [a] = rhs
* Here we check that a type instance matches its kind signature, but we do
not check whether there is a pattern for each type index; the latter
check is only required for type synonym instances.
Note [tc_fam_ty_pats vs tcFamTyPats]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tc_fam_ty_pats does the type checking of the patterns, but it doesn't
zonk or generate any desugaring. It is used when kind-checking closed
type families.
tcFamTyPats type checks the patterns, zonks, and then calls thing_inside
to generate a desugaring. It is used during type-checking (not kind-checking).
Note [Type-checking type patterns]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When typechecking the patterns of a family instance declaration, we can't
rely on using the family TyCon, because this is sometimes called
from within a type-checking knot. (Specifically for closed type families.)
The type FamTyConShape gives just enough information to do the job.
The "arity" field of FamTyConShape is the *visible* arity of the family
type constructor, i.e. what the users sees and writes, not including kind
arguments.
See also Note [tc_fam_ty_pats vs tcFamTyPats]
Note [Failing early in kcDataDefn]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We need to use checkNoErrs when calling kcConDecl. This is because kcConDecl
calls tcConDecl, which checks that the return type of a GADT-like constructor
is actually an instance of the type head. Without the checkNoErrs, potentially
two bad things could happen:
1) Duplicate error messages, because tcConDecl will be called again during
*type* checking (as opposed to kind checking)
2) If we just keep blindly forging forward after both kind checking and type
checking, we can get a panic in rejigConRes. See Trac #8368.
-}
-----------------
type FamTyConShape = (Name, Arity, Kind) -- See Note [Type-checking type patterns]
famTyConShape :: TyCon -> FamTyConShape
famTyConShape fam_tc
= ( tyConName fam_tc
, length (filterOut isKindVar (tyConTyVars fam_tc))
, tyConKind fam_tc )
tc_fam_ty_pats :: FamTyConShape
-> HsWithBndrs Name [LHsType Name] -- Patterns
-> (TcKind -> TcM ()) -- Kind checker for RHS
-- result is ignored
-> TcM ([Kind], [Type], Kind)
-- Check the type patterns of a type or data family instance
-- type instance F <pat1> <pat2> = <type>
-- The 'tyvars' are the free type variables of pats
--
-- NB: The family instance declaration may be an associated one,
-- nested inside an instance decl, thus
-- instance C [a] where
-- type F [a] = ...
-- In that case, the type variable 'a' will *already be in scope*
-- (and, if C is poly-kinded, so will its kind parameter).
tc_fam_ty_pats (name, arity, kind)
(HsWB { hswb_cts = arg_pats, hswb_kvs = kvars, hswb_tvs = tvars })
kind_checker
= do { let (fam_kvs, fam_body) = splitForAllTys kind
-- We wish to check that the pattern has the right number of arguments
-- in checkValidFamPats (in TcValidity), so we can do the check *after*
-- we're done with the knot. But, the splitKindFunTysN below will panic
-- if there are *too many* patterns. So, we do a preliminary check here.
-- Note that we don't have enough information at hand to do a full check,
-- as that requires the full declared arity of the family, which isn't
-- nearby.
; checkTc (length arg_pats == arity) $
wrongNumberOfParmsErr arity
-- Instantiate with meta kind vars
; fam_arg_kinds <- mapM (const newMetaKindVar) fam_kvs
; loc <- getSrcSpanM
; let (arg_kinds, res_kind)
= splitKindFunTysN (length arg_pats) $
substKiWith fam_kvs fam_arg_kinds fam_body
hs_tvs = HsQTvs { hsq_kvs = kvars
, hsq_tvs = userHsTyVarBndrs loc tvars }
-- Kind-check and quantify
-- See Note [Quantifying over family patterns]
; typats <- tcHsTyVarBndrs hs_tvs $ \ _ ->
do { kind_checker res_kind
; tcHsArgTys (quotes (ppr name)) arg_pats arg_kinds }
; return (fam_arg_kinds, typats, res_kind) }
-- See Note [tc_fam_ty_pats vs tcFamTyPats]
tcFamTyPats :: FamTyConShape
-> HsWithBndrs Name [LHsType Name] -- patterns
-> (TcKind -> TcM ()) -- kind-checker for RHS
-> ([TKVar] -- Kind and type variables
-> [TcType] -- Kind and type arguments
-> Kind -> TcM a)
-> TcM a
tcFamTyPats fam_shape@(name,_,_) pats kind_checker thing_inside
= do { (fam_arg_kinds, typats, res_kind)
<- tc_fam_ty_pats fam_shape pats kind_checker
; let all_args = fam_arg_kinds ++ typats
-- Find free variables (after zonking) and turn
-- them into skolems, so that we don't subsequently
-- replace a meta kind var with AnyK
-- Very like kindGeneralize
; qtkvs <- quantifyTyVars emptyVarSet (tyVarsOfTypes all_args)
-- Zonk the patterns etc into the Type world
; (ze, qtkvs') <- zonkTyBndrsX emptyZonkEnv qtkvs
; all_args' <- zonkTcTypeToTypes ze all_args
; res_kind' <- zonkTcTypeToType ze res_kind
; traceTc "tcFamTyPats" (ppr name)
-- don't print out too much, as we might be in the knot
; tcExtendTyVarEnv qtkvs' $
thing_inside qtkvs' all_args' res_kind' }
{-
Note [Quantifying over family patterns]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We need to quantify over two different lots of kind variables:
First, the ones that come from the kinds of the tyvar args of
tcTyVarBndrsKindGen, as usual
data family Dist a
-- Proxy :: forall k. k -> *
data instance Dist (Proxy a) = DP
-- Generates data DistProxy = DP
-- ax8 k (a::k) :: Dist * (Proxy k a) ~ DistProxy k a
-- The 'k' comes from the tcTyVarBndrsKindGen (a::k)
Second, the ones that come from the kind argument of the type family
which we pick up using the (tyVarsOfTypes typats) in the result of
the thing_inside of tcHsTyvarBndrsGen.
-- Any :: forall k. k
data instance Dist Any = DA
-- Generates data DistAny k = DA
-- ax7 k :: Dist k (Any k) ~ DistAny k
-- The 'k' comes from kindGeneralizeKinds (Any k)
Note [Quantified kind variables of a family pattern]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider type family KindFam (p :: k1) (q :: k1)
data T :: Maybe k1 -> k2 -> *
type instance KindFam (a :: Maybe k) b = T a b -> Int
The HsBSig for the family patterns will be ([k], [a])
Then in the family instance we want to
* Bring into scope [ "k" -> k:BOX, "a" -> a:k ]
* Kind-check the RHS
* Quantify the type instance over k and k', as well as a,b, thus
type instance [k, k', a:Maybe k, b:k']
KindFam (Maybe k) k' a b = T k k' a b -> Int
Notice that in the third step we quantify over all the visibly-mentioned
type variables (a,b), but also over the implicitly mentioned kind variables
(k, k'). In this case one is bound explicitly but often there will be
none. The role of the kind signature (a :: Maybe k) is to add a constraint
that 'a' must have that kind, and to bring 'k' into scope.
************************************************************************
* *
Data types
* *
************************************************************************
-}
dataDeclChecks :: Name -> NewOrData -> ThetaType -> [LConDecl Name] -> TcM Bool
dataDeclChecks tc_name new_or_data stupid_theta cons
= do { -- Check that we don't use GADT syntax in H98 world
gadtSyntax_ok <- xoptM Opt_GADTSyntax
; let gadt_syntax = consUseGadtSyntax cons
; checkTc (gadtSyntax_ok || not gadt_syntax) (badGadtDecl tc_name)
-- Check that the stupid theta is empty for a GADT-style declaration
; checkTc (null stupid_theta || not gadt_syntax) (badStupidTheta tc_name)
-- Check that a newtype has exactly one constructor
-- Do this before checking for empty data decls, so that
-- we don't suggest -XEmptyDataDecls for newtypes
; checkTc (new_or_data == DataType || isSingleton cons)
(newtypeConError tc_name (length cons))
-- Check that there's at least one condecl,
-- or else we're reading an hs-boot file, or -XEmptyDataDecls
; empty_data_decls <- xoptM Opt_EmptyDataDecls
; is_boot <- tcIsHsBootOrSig -- Are we compiling an hs-boot file?
; checkTc (not (null cons) || empty_data_decls || is_boot)
(emptyConDeclsErr tc_name)
; return gadt_syntax }
-----------------------------------
consUseGadtSyntax :: [LConDecl a] -> Bool
consUseGadtSyntax (L _ (ConDecl { con_res = ResTyGADT _ _ }) : _) = True
consUseGadtSyntax _ = False
-- All constructors have same shape
-----------------------------------
tcConDecls :: NewOrData -> TyCon -> ([TyVar], Type)
-> [LConDecl Name] -> TcM [DataCon]
tcConDecls new_or_data rep_tycon (tmpl_tvs, res_tmpl) cons
= concatMapM (addLocM $ tcConDecl new_or_data rep_tycon tmpl_tvs res_tmpl)
cons
tcConDecl :: NewOrData
-> TyCon -- Representation tycon
-> [TyVar] -> Type -- Return type template (with its template tyvars)
-- (tvs, T tys), where T is the family TyCon
-> ConDecl Name
-> TcM [DataCon]
tcConDecl new_or_data rep_tycon tmpl_tvs res_tmpl -- Data types
(ConDecl { con_names = names
, con_qvars = hs_tvs, con_cxt = hs_ctxt
, con_details = hs_details, con_res = hs_res_ty })
= addErrCtxt (dataConCtxtName names) $
do { traceTc "tcConDecl 1" (ppr names)
; (ctxt, arg_tys, res_ty, field_lbls, stricts)
<- tcHsTyVarBndrs hs_tvs $ \ _ ->
do { ctxt <- tcHsContext hs_ctxt
; details <- tcConArgs new_or_data hs_details
; res_ty <- tcConRes hs_res_ty
; let (field_lbls, btys) = details
(arg_tys, stricts) = unzip btys
; return (ctxt, arg_tys, res_ty, field_lbls, stricts)
}
-- Generalise the kind variables (returning quantified TcKindVars)
-- and quantify the type variables (substituting their kinds)
-- REMEMBER: 'tkvs' are:
-- ResTyH98: the *existential* type variables only
-- ResTyGADT: *all* the quantified type variables
-- c.f. the comment on con_qvars in HsDecls
; tkvs <- case res_ty of
ResTyH98 -> quantifyTyVars (mkVarSet tmpl_tvs)
(tyVarsOfTypes (ctxt++arg_tys))
ResTyGADT _ res_ty -> quantifyTyVars emptyVarSet
(tyVarsOfTypes (res_ty:ctxt++arg_tys))
-- Zonk to Types
; (ze, qtkvs) <- zonkTyBndrsX emptyZonkEnv tkvs
; arg_tys <- zonkTcTypeToTypes ze arg_tys
; ctxt <- zonkTcTypeToTypes ze ctxt
; res_ty <- case res_ty of
ResTyH98 -> return ResTyH98
ResTyGADT ls ty -> ResTyGADT ls <$> zonkTcTypeToType ze ty
; let (univ_tvs, ex_tvs, eq_preds, res_ty') = rejigConRes tmpl_tvs res_tmpl qtkvs res_ty
; fam_envs <- tcGetFamInstEnvs
; let
buildOneDataCon (L _ name) = do
{ is_infix <- tcConIsInfix name hs_details res_ty
; buildDataCon fam_envs name is_infix
stricts field_lbls
univ_tvs ex_tvs eq_preds ctxt arg_tys
res_ty' rep_tycon
-- NB: we put data_tc, the type constructor gotten from the
-- constructor type signature into the data constructor;
-- that way checkValidDataCon can complain if it's wrong.
}
; mapM buildOneDataCon names
}
tcConIsInfix :: Name
-> HsConDetails (LHsType Name) (Located [LConDeclField Name])
-> ResType Type
-> TcM Bool
tcConIsInfix _ details ResTyH98
= case details of
InfixCon {} -> return True
_ -> return False
tcConIsInfix con details (ResTyGADT _ _)
= case details of
InfixCon {} -> return True
RecCon {} -> return False
PrefixCon arg_tys -- See Note [Infix GADT cons]
| isSymOcc (getOccName con)
, [_ty1,_ty2] <- arg_tys
-> do { fix_env <- getFixityEnv
; return (con `elemNameEnv` fix_env) }
| otherwise -> return False
tcConArgs :: NewOrData -> HsConDeclDetails Name
-> TcM ([Name], [(TcType, HsSrcBang)])
tcConArgs new_or_data (PrefixCon btys)
= do { btys' <- mapM (tcConArg new_or_data) btys
; return ([], btys') }
tcConArgs new_or_data (InfixCon bty1 bty2)
= do { bty1' <- tcConArg new_or_data bty1
; bty2' <- tcConArg new_or_data bty2
; return ([], [bty1', bty2']) }
tcConArgs new_or_data (RecCon fields)
= do { btys' <- mapM (tcConArg new_or_data) btys
; return (field_names, btys') }
where
-- We need a one-to-one mapping from field_names to btys
combined = map (\(L _ f) -> (cd_fld_names f,cd_fld_type f)) (unLoc fields)
explode (ns,ty) = zip (map unLoc ns) (repeat ty)
exploded = concatMap explode combined
(field_names,btys) = unzip exploded
tcConArg :: NewOrData -> LHsType Name -> TcM (TcType, HsSrcBang)
tcConArg new_or_data bty
= do { traceTc "tcConArg 1" (ppr bty)
; arg_ty <- tcHsConArgType new_or_data bty
; traceTc "tcConArg 2" (ppr bty)
; return (arg_ty, getBangStrictness bty) }
tcConRes :: ResType (LHsType Name) -> TcM (ResType Type)
tcConRes ResTyH98 = return ResTyH98
tcConRes (ResTyGADT ls res_ty) = do { res_ty' <- tcHsLiftedType res_ty
; return (ResTyGADT ls res_ty') }
{-
Note [Infix GADT constructors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We do not currently have syntax to declare an infix constructor in GADT syntax,
but it makes a (small) difference to the Show instance. So as a slightly
ad-hoc solution, we regard a GADT data constructor as infix if
a) it is an operator symbol
b) it has two arguments
c) there is a fixity declaration for it
For example:
infix 6 (:--:)
data T a where
(:--:) :: t1 -> t2 -> T Int
Note [Checking GADT return types]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is a delicacy around checking the return types of a datacon. The
central problem is dealing with a declaration like
data T a where
MkT :: a -> Q a
Note that the return type of MkT is totally bogus. When creating the T
tycon, we also need to create the MkT datacon, which must have a "rejigged"
return type. That is, the MkT datacon's type must be transformed to have
a uniform return type with explicit coercions for GADT-like type parameters.
This rejigging is what rejigConRes does. The problem is, though, that checking
that the return type is appropriate is much easier when done over *Type*,
not *HsType*.
So, we want to make rejigConRes lazy and then check the validity of the return
type in checkValidDataCon. But, if the return type is bogus, rejigConRes can't
work -- it will have a failed pattern match. Luckily, if we run
checkValidDataCon before ever looking at the rejigged return type
(checkValidDataCon checks the dataConUserType, which is not rejigged!), we
catch the error before forcing the rejigged type and panicking.
-}
-- Example
-- data instance T (b,c) where
-- TI :: forall e. e -> T (e,e)
--
-- The representation tycon looks like this:
-- data :R7T b c where
-- TI :: forall b1 c1. (b1 ~ c1) => b1 -> :R7T b1 c1
-- In this case orig_res_ty = T (e,e)
rejigConRes :: [TyVar] -> Type -- Template for result type; e.g.
-- data instance T [a] b c = ...
-- gives template ([a,b,c], T [a] b c)
-> [TyVar] -- where MkT :: forall x y z. ...
-> ResType Type
-> ([TyVar], -- Universal
[TyVar], -- Existential (distinct OccNames from univs)
[(TyVar,Type)], -- Equality predicates
Type) -- Typechecked return type
-- We don't check that the TyCon given in the ResTy is
-- the same as the parent tycon, because checkValidDataCon will do it
rejigConRes tmpl_tvs res_ty dc_tvs ResTyH98
= (tmpl_tvs, dc_tvs, [], res_ty)
-- In H98 syntax the dc_tvs are the existential ones
-- data T a b c = forall d e. MkT ...
-- The universals {a,b,c} are tc_tvs, and the existentials {d,e} are dc_tvs
rejigConRes tmpl_tvs res_tmpl dc_tvs (ResTyGADT _ res_ty)
-- E.g. data T [a] b c where
-- MkT :: forall x y z. T [(x,y)] z z
-- The {a,b,c} are the tmpl_tvs, and the {x,y,z} are the dc_tvs
-- (NB: unlike the H98 case, the dc_tvs are not all existential)
-- Then we generate
-- Univ tyvars Eq-spec
-- a a~(x,y)
-- b b~z
-- z
-- Existentials are the leftover type vars: [x,y]
-- So we return ([a,b,z], [x,y], [a~(x,y),b~z], T [(x,y)] z z)
= (univ_tvs, ex_tvs, eq_spec, res_ty)
where
Just subst = tcMatchTy (mkVarSet tmpl_tvs) res_tmpl res_ty
-- This 'Just' pattern is sure to match, because if not
-- checkValidDataCon will complain first.
-- But care: this only works if the result of rejigConRes
-- is not demanded until checkValidDataCon has
-- first succeeded
-- See Note [Checking GADT return types]
-- /Lazily/ figure out the univ_tvs etc
-- Each univ_tv is either a dc_tv or a tmpl_tv
(univ_tvs, eq_spec) = foldr choose ([], []) tmpl_tvs
choose tmpl (univs, eqs)
| Just ty <- lookupTyVar subst tmpl
= case tcGetTyVar_maybe ty of
Just tv | not (tv `elem` univs)
-> (tv:univs, eqs)
_other -> (new_tmpl:univs, (new_tmpl,ty):eqs)
where -- see Note [Substitution in template variables kinds]
new_tmpl = updateTyVarKind (substTy subst) tmpl
| otherwise = pprPanic "tcResultType" (ppr res_ty)
ex_tvs = dc_tvs `minusList` univ_tvs
{-
Note [Substitution in template variables kinds]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
data List a = Nil | Cons a (List a)
data SList s as where
SNil :: SList s Nil
We call tcResultType with
tmpl_tvs = [(k :: BOX), (s :: k -> *), (as :: List k)]
res_tmpl = SList k s as
res_ty = ResTyGADT (SList k1 (s1 :: k1 -> *) (Nil k1))
We get subst:
k -> k1
s -> s1
as -> Nil k1
Now we want to find out the universal variables and the equivalences
between some of them and types (GADT).
In this example, k and s are mapped to exactly variables which are not
already present in the universal set, so we just add them without any
coercion.
But 'as' is mapped to 'Nil k1', so we add 'as' to the universal set,
and add the equivalence with 'Nil k1' in 'eqs'.
The problem is that with kind polymorphism, as's kind may now contain
kind variables, and we have to apply the template substitution to it,
which is why we create new_tmpl.
The template substitution only maps kind variables to kind variables,
since GADTs are not kind indexed.
************************************************************************
* *
Validity checking
* *
************************************************************************
Validity checking is done once the mutually-recursive knot has been
tied, so we can look at things freely.
-}
checkClassCycleErrs :: Class -> TcM ()
checkClassCycleErrs cls = mapM_ recClsErr (calcClassCycles cls)
checkValidTyCl :: TyThing -> TcM ()
checkValidTyCl thing
= setSrcSpan (getSrcSpan thing) $
addTyThingCtxt thing $
case thing of
ATyCon tc -> checkValidTyCon tc
AnId _ -> return () -- Generic default methods are checked
-- with their parent class
ACoAxiom _ -> return () -- Axioms checked with their parent
-- closed family tycon
_ -> pprTrace "checkValidTyCl" (ppr thing) $ return ()
-------------------------
-- For data types declared with record syntax, we require
-- that each constructor that has a field 'f'
-- (a) has the same result type
-- (b) has the same type for 'f'
-- module alpha conversion of the quantified type variables
-- of the constructor.
--
-- Note that we allow existentials to match because the
-- fields can never meet. E.g
-- data T where
-- T1 { f1 :: b, f2 :: a, f3 ::Int } :: T
-- T2 { f1 :: c, f2 :: c, f3 ::Int } :: T
-- Here we do not complain about f1,f2 because they are existential
checkValidTyCon :: TyCon -> TcM ()
checkValidTyCon tc
| isPrimTyCon tc -- Happens when Haddock'ing GHC.Prim
= return ()
| Just cl <- tyConClass_maybe tc
= checkValidClass cl
| Just syn_rhs <- synTyConRhs_maybe tc
= checkValidType syn_ctxt syn_rhs
| Just fam_flav <- famTyConFlav_maybe tc
= case fam_flav of
{ ClosedSynFamilyTyCon (Just ax) -> checkValidClosedCoAxiom ax
; ClosedSynFamilyTyCon Nothing -> return ()
; AbstractClosedSynFamilyTyCon ->
do { hsBoot <- tcIsHsBootOrSig
; checkTc hsBoot $
ptext (sLit "You may define an abstract closed type family") $$
ptext (sLit "only in a .hs-boot file") }
; OpenSynFamilyTyCon -> return ()
; BuiltInSynFamTyCon _ -> return () }
| otherwise
= do { -- Check the context on the data decl
traceTc "cvtc1" (ppr tc)
; checkValidTheta (DataTyCtxt name) (tyConStupidTheta tc)
; traceTc "cvtc2" (ppr tc)
; dflags <- getDynFlags
; existential_ok <- xoptM Opt_ExistentialQuantification
; gadt_ok <- xoptM Opt_GADTs
; let ex_ok = existential_ok || gadt_ok -- Data cons can have existential context
; mapM_ (checkValidDataCon dflags ex_ok tc) data_cons
-- Check that fields with the same name share a type
; mapM_ check_fields groups }
where
syn_ctxt = TySynCtxt name
name = tyConName tc
data_cons = tyConDataCons tc
groups = equivClasses cmp_fld (concatMap get_fields data_cons)
cmp_fld (f1,_) (f2,_) = f1 `compare` f2
get_fields con = dataConFieldLabels con `zip` repeat con
-- dataConFieldLabels may return the empty list, which is fine
-- See Note [GADT record selectors] in MkId.hs
-- We must check (a) that the named field has the same
-- type in each constructor
-- (b) that those constructors have the same result type
--
-- However, the constructors may have differently named type variable
-- and (worse) we don't know how the correspond to each other. E.g.
-- C1 :: forall a b. { f :: a, g :: b } -> T a b
-- C2 :: forall d c. { f :: c, g :: c } -> T c d
--
-- So what we do is to ust Unify.tcMatchTys to compare the first candidate's
-- result type against other candidates' types BOTH WAYS ROUND.
-- If they magically agrees, take the substitution and
-- apply them to the latter ones, and see if they match perfectly.
check_fields ((label, con1) : other_fields)
-- These fields all have the same name, but are from
-- different constructors in the data type
= recoverM (return ()) $ mapM_ checkOne other_fields
-- Check that all the fields in the group have the same type
-- NB: this check assumes that all the constructors of a given
-- data type use the same type variables
where
(tvs1, _, _, res1) = dataConSig con1
ts1 = mkVarSet tvs1
fty1 = dataConFieldType con1 label
checkOne (_, con2) -- Do it bothways to ensure they are structurally identical
= do { checkFieldCompat label con1 con2 ts1 res1 res2 fty1 fty2
; checkFieldCompat label con2 con1 ts2 res2 res1 fty2 fty1 }
where
(tvs2, _, _, res2) = dataConSig con2
ts2 = mkVarSet tvs2
fty2 = dataConFieldType con2 label
check_fields [] = panic "checkValidTyCon/check_fields []"
checkValidClosedCoAxiom :: CoAxiom Branched -> TcM ()
checkValidClosedCoAxiom (CoAxiom { co_ax_branches = branches, co_ax_tc = tc })
= tcAddClosedTypeFamilyDeclCtxt tc $
do { brListFoldlM_ check_accessibility [] branches
; void $ brListMapM (checkValidTyFamInst Nothing tc) branches }
where
check_accessibility :: [CoAxBranch] -- prev branches (in reverse order)
-> CoAxBranch -- cur branch
-> TcM [CoAxBranch] -- cur : prev
-- Check whether the branch is dominated by earlier
-- ones and hence is inaccessible
check_accessibility prev_branches cur_branch
= do { when (cur_branch `isDominatedBy` prev_branches) $
addWarnAt (coAxBranchSpan cur_branch) $
inaccessibleCoAxBranch tc cur_branch
; return (cur_branch : prev_branches) }
checkFieldCompat :: Name -> DataCon -> DataCon -> TyVarSet
-> Type -> Type -> Type -> Type -> TcM ()
checkFieldCompat fld con1 con2 tvs1 res1 res2 fty1 fty2
= do { checkTc (isJust mb_subst1) (resultTypeMisMatch fld con1 con2)
; checkTc (isJust mb_subst2) (fieldTypeMisMatch fld con1 con2) }
where
mb_subst1 = tcMatchTy tvs1 res1 res2
mb_subst2 = tcMatchTyX tvs1 (expectJust "checkFieldCompat" mb_subst1) fty1 fty2
-------------------------------
checkValidDataCon :: DynFlags -> Bool -> TyCon -> DataCon -> TcM ()
checkValidDataCon dflags existential_ok tc con
= setSrcSpan (srcLocSpan (getSrcLoc con)) $
addErrCtxt (dataConCtxt con) $
do { -- Check that the return type of the data constructor
-- matches the type constructor; eg reject this:
-- data T a where { MkT :: Bogus a }
-- c.f. Note [Check role annotations in a second pass]
-- and Note [Checking GADT return types]
let tc_tvs = tyConTyVars tc
res_ty_tmpl = mkFamilyTyConApp tc (mkTyVarTys tc_tvs)
orig_res_ty = dataConOrigResTy con
; traceTc "checkValidDataCon" (vcat
[ ppr con, ppr tc, ppr tc_tvs
, ppr res_ty_tmpl <+> dcolon <+> ppr (typeKind res_ty_tmpl)
, ppr orig_res_ty <+> dcolon <+> ppr (typeKind orig_res_ty)])
; checkTc (isJust (tcMatchTy (mkVarSet tc_tvs)
res_ty_tmpl
orig_res_ty))
(badDataConTyCon con res_ty_tmpl orig_res_ty)
-- Check that the result type is a *monotype*
-- e.g. reject this: MkT :: T (forall a. a->a)
-- Reason: it's really the argument of an equality constraint
; checkValidMonoType orig_res_ty
-- Check all argument types for validity
; checkValidType ctxt (dataConUserType con)
-- Extra checks for newtype data constructors
; when (isNewTyCon tc) (checkNewDataCon con)
-- Check that UNPACK pragmas and bangs work out
-- E.g. reject data T = MkT {-# UNPACK #-} Int -- No "!"
-- data T = MkT {-# UNPACK #-} !a -- Can't unpack
; mapM_ check_bang (zip3 (dataConSrcBangs con) (dataConImplBangs con) [1..])
-- Check that existentials are allowed if they are used
; checkTc (existential_ok || isVanillaDataCon con)
(badExistential con)
-- Check that we aren't doing GADT type refinement on kind variables
-- e.g reject data T (a::k) where
-- T1 :: T Int
-- T2 :: T Maybe
; checkTc (not (any (isKindVar . fst) (dataConEqSpec con)))
(badGadtKindCon con)
; traceTc "Done validity of data con" (ppr con <+> ppr (dataConRepType con))
}
where
ctxt = ConArgCtxt (dataConName con)
check_bang (HsSrcBang _ (Just want_unpack) has_bang, rep_bang, n)
| want_unpack, not has_bang
= addWarnTc (bad_bang n (ptext (sLit "UNPACK pragma lacks '!'")))
| want_unpack
, case rep_bang of { HsUnpack {} -> False; _ -> True }
, not (gopt Opt_OmitInterfacePragmas dflags)
-- If not optimising, se don't unpack, so don't complain!
-- See MkId.dataConArgRep, the (HsBang True) case
= addWarnTc (bad_bang n (ptext (sLit "Ignoring unusable UNPACK pragma")))
check_bang _
= return ()
bad_bang n herald
= hang herald 2 (ptext (sLit "on the") <+> speakNth n
<+> ptext (sLit "argument of") <+> quotes (ppr con))
-------------------------------
checkNewDataCon :: DataCon -> TcM ()
-- Further checks for the data constructor of a newtype
checkNewDataCon con
= do { checkTc (isSingleton arg_tys) (newtypeFieldErr con (length arg_tys))
-- One argument
; check_con (null eq_spec) $
ptext (sLit "A newtype constructor must have a return type of form T a1 ... an")
-- Return type is (T a b c)
; check_con (null theta) $
ptext (sLit "A newtype constructor cannot have a context in its type")
; check_con (null ex_tvs) $
ptext (sLit "A newtype constructor cannot have existential type variables")
-- No existentials
; checkTc (not (any isBanged (dataConSrcBangs con)))
(newtypeStrictError con)
-- No strictness
}
where
(_univ_tvs, ex_tvs, eq_spec, theta, arg_tys, _res_ty) = dataConFullSig con
check_con what msg
= checkTc what (msg $$ ppr con <+> dcolon <+> ppr (dataConUserType con))
-------------------------------
checkValidClass :: Class -> TcM ()
checkValidClass cls
= do { constrained_class_methods <- xoptM Opt_ConstrainedClassMethods
; multi_param_type_classes <- xoptM Opt_MultiParamTypeClasses
; nullary_type_classes <- xoptM Opt_NullaryTypeClasses
; fundep_classes <- xoptM Opt_FunctionalDependencies
-- Check that the class is unary, unless multiparameter type classes
-- are enabled; also recognize deprecated nullary type classes
-- extension (subsumed by multiparameter type classes, Trac #8993)
; checkTc (multi_param_type_classes || cls_arity == 1 ||
(nullary_type_classes && cls_arity == 0))
(classArityErr cls_arity cls)
; checkTc (fundep_classes || null fundeps) (classFunDepsErr cls)
-- Check the super-classes
; checkValidTheta (ClassSCCtxt (className cls)) theta
-- Now check for cyclic superclasses
-- If there are superclass cycles, checkClassCycleErrs bails.
; checkClassCycleErrs cls
-- Check the class operations.
-- But only if there have been no earlier errors
-- See Note [Abort when superclass cycle is detected]
; whenNoErrs $
mapM_ (check_op constrained_class_methods) op_stuff
-- Check the associated type defaults are well-formed and instantiated
; mapM_ check_at at_stuff }
where
(tyvars, fundeps, theta, _, at_stuff, op_stuff) = classExtraBigSig cls
cls_arity = count isTypeVar tyvars -- Ignore kind variables
cls_tv_set = mkVarSet tyvars
check_op constrained_class_methods (sel_id, dm)
= setSrcSpan (getSrcSpan sel_id) $
addErrCtxt (classOpCtxt sel_id op_ty) $ do
{ traceTc "class op type" (ppr op_ty)
; checkValidType ctxt op_ty
-- This implements the ambiguity check, among other things
-- Example: tc223
-- class Error e => Game b mv e | b -> mv e where
-- newBoard :: MonadState b m => m ()
-- Here, MonadState has a fundep m->b, so newBoard is fine
; unless constrained_class_methods $
mapM_ check_constraint (tail (theta1 ++ theta2))
; case dm of
GenDefMeth dm_name -> do { dm_id <- tcLookupId dm_name
; checkValidType ctxt (idType dm_id) }
_ -> return ()
}
where
ctxt = FunSigCtxt op_name True -- Report redundant class constraints
op_name = idName sel_id
op_ty = idType sel_id
(_,theta1,tau1) = tcSplitSigmaTy op_ty
(_,theta2,_) = tcSplitSigmaTy tau1
check_constraint :: TcPredType -> TcM ()
check_constraint pred
= when (tyVarsOfType pred `subVarSet` cls_tv_set)
(addErrTc (badMethPred sel_id pred))
check_at (ATI fam_tc _)
| cls_arity > 0 -- Check that the associated type mentions at least
-- one of the class type variables
= checkTc (any (`elemVarSet` cls_tv_set) (tyConTyVars fam_tc))
(noClassTyVarErr cls fam_tc)
| otherwise -- The check is disabled for nullary type classes,
= return () -- since there is no possible ambiguity (Trac #10020)
checkFamFlag :: Name -> TcM ()
-- Check that we don't use families without -XTypeFamilies
-- The parser won't even parse them, but I suppose a GHC API
-- client might have a go!
checkFamFlag tc_name
= do { idx_tys <- xoptM Opt_TypeFamilies
; checkTc idx_tys err_msg }
where
err_msg = hang (ptext (sLit "Illegal family declaration for") <+> quotes (ppr tc_name))
2 (ptext (sLit "Use TypeFamilies to allow indexed type families"))
{-
Note [Abort when superclass cycle is detected]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We must avoid doing the ambiguity check for the methods (in
checkValidClass.check_op) when there are already errors accumulated.
This is because one of the errors may be a superclass cycle, and
superclass cycles cause canonicalization to loop. Here is a
representative example:
class D a => C a where
meth :: D a => ()
class C a => D a
This fixes Trac #9415, #9739
************************************************************************
* *
Checking role validity
* *
************************************************************************
-}
checkValidRoleAnnots :: RoleAnnots -> TyThing -> TcM ()
checkValidRoleAnnots role_annots thing
= case thing of
{ ATyCon tc
| isTypeSynonymTyCon tc -> check_no_roles
| isFamilyTyCon tc -> check_no_roles
| isAlgTyCon tc -> check_roles
where
name = tyConName tc
-- Role annotations are given only on *type* variables, but a tycon stores
-- roles for all variables. So, we drop the kind roles (which are all
-- Nominal, anyway).
tyvars = tyConTyVars tc
roles = tyConRoles tc
(kind_vars, type_vars) = span isKindVar tyvars
type_roles = dropList kind_vars roles
role_annot_decl_maybe = lookupRoleAnnots role_annots name
check_roles
= whenIsJust role_annot_decl_maybe $
\decl@(L loc (RoleAnnotDecl _ the_role_annots)) ->
addRoleAnnotCtxt name $
setSrcSpan loc $ do
{ role_annots_ok <- xoptM Opt_RoleAnnotations
; checkTc role_annots_ok $ needXRoleAnnotations tc
; checkTc (type_vars `equalLength` the_role_annots)
(wrongNumberOfRoles type_vars decl)
; _ <- zipWith3M checkRoleAnnot type_vars the_role_annots type_roles
-- Representational or phantom roles for class parameters
-- quickly lead to incoherence. So, we require
-- IncoherentInstances to have them. See #8773.
; incoherent_roles_ok <- xoptM Opt_IncoherentInstances
; checkTc ( incoherent_roles_ok
|| (not $ isClassTyCon tc)
|| (all (== Nominal) type_roles))
incoherentRoles
; lint <- goptM Opt_DoCoreLinting
; when lint $ checkValidRoles tc }
check_no_roles
= whenIsJust role_annot_decl_maybe illegalRoleAnnotDecl
; _ -> return () }
checkRoleAnnot :: TyVar -> Located (Maybe Role) -> Role -> TcM ()
checkRoleAnnot _ (L _ Nothing) _ = return ()
checkRoleAnnot tv (L _ (Just r1)) r2
= when (r1 /= r2) $
addErrTc $ badRoleAnnot (tyVarName tv) r1 r2
-- This is a double-check on the role inference algorithm. It is only run when
-- -dcore-lint is enabled. See Note [Role inference] in TcTyDecls
checkValidRoles :: TyCon -> TcM ()
-- If you edit this function, you may need to update the GHC formalism
-- See Note [GHC Formalism] in CoreLint
checkValidRoles tc
| isAlgTyCon tc
-- tyConDataCons returns an empty list for data families
= mapM_ check_dc_roles (tyConDataCons tc)
| Just rhs <- synTyConRhs_maybe tc
= check_ty_roles (zipVarEnv (tyConTyVars tc) (tyConRoles tc)) Representational rhs
| otherwise
= return ()
where
check_dc_roles datacon
= do { traceTc "check_dc_roles" (ppr datacon <+> ppr (tyConRoles tc))
; mapM_ (check_ty_roles role_env Representational) $
eqSpecPreds eq_spec ++ theta ++ arg_tys }
-- See Note [Role-checking data constructor arguments] in TcTyDecls
where
(univ_tvs, ex_tvs, eq_spec, theta, arg_tys, _res_ty) = dataConFullSig datacon
univ_roles = zipVarEnv univ_tvs (tyConRoles tc)
-- zipVarEnv uses zipEqual, but we don't want that for ex_tvs
ex_roles = mkVarEnv (zip ex_tvs (repeat Nominal))
role_env = univ_roles `plusVarEnv` ex_roles
check_ty_roles env role (TyVarTy tv)
= case lookupVarEnv env tv of
Just role' -> unless (role' `ltRole` role || role' == role) $
report_error $ ptext (sLit "type variable") <+> quotes (ppr tv) <+>
ptext (sLit "cannot have role") <+> ppr role <+>
ptext (sLit "because it was assigned role") <+> ppr role'
Nothing -> report_error $ ptext (sLit "type variable") <+> quotes (ppr tv) <+>
ptext (sLit "missing in environment")
check_ty_roles env Representational (TyConApp tc tys)
= let roles' = tyConRoles tc in
zipWithM_ (maybe_check_ty_roles env) roles' tys
check_ty_roles env Nominal (TyConApp _ tys)
= mapM_ (check_ty_roles env Nominal) tys
check_ty_roles _ Phantom ty@(TyConApp {})
= pprPanic "check_ty_roles" (ppr ty)
check_ty_roles env role (AppTy ty1 ty2)
= check_ty_roles env role ty1
>> check_ty_roles env Nominal ty2
check_ty_roles env role (FunTy ty1 ty2)
= check_ty_roles env role ty1
>> check_ty_roles env role ty2
check_ty_roles env role (ForAllTy tv ty)
= check_ty_roles (extendVarEnv env tv Nominal) role ty
check_ty_roles _ _ (LitTy {}) = return ()
maybe_check_ty_roles env role ty
= when (role == Nominal || role == Representational) $
check_ty_roles env role ty
report_error doc
= addErrTc $ vcat [ptext (sLit "Internal error in role inference:"),
doc,
ptext (sLit "Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug")]
{-
************************************************************************
* *
Building record selectors
* *
************************************************************************
-}
mkDefaultMethodIds :: [TyThing] -> [Id]
-- See Note [Default method Ids and Template Haskell]
mkDefaultMethodIds things
= [ mkExportedLocalId VanillaId dm_name (idType sel_id)
| ATyCon tc <- things
, Just cls <- [tyConClass_maybe tc]
, (sel_id, DefMeth dm_name) <- classOpItems cls ]
{-
Note [Default method Ids and Template Haskell]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this (Trac #4169):
class Numeric a where
fromIntegerNum :: a
fromIntegerNum = ...
ast :: Q [Dec]
ast = [d| instance Numeric Int |]
When we typecheck 'ast' we have done the first pass over the class decl
(in tcTyClDecls), but we have not yet typechecked the default-method
declarations (because they can mention value declarations). So we
must bring the default method Ids into scope first (so they can be seen
when typechecking the [d| .. |] quote, and typecheck them later.
-}
mkRecSelBinds :: [TyThing] -> HsValBinds Name
-- NB We produce *un-typechecked* bindings, rather like 'deriving'
-- This makes life easier, because the later type checking will add
-- all necessary type abstractions and applications
mkRecSelBinds tycons
= ValBindsOut [(NonRecursive, b) | b <- binds] sigs
where
(sigs, binds) = unzip rec_sels
rec_sels = map mkRecSelBind [ (tc,fld)
| ATyCon tc <- tycons
, fld <- tyConFields tc ]
mkRecSelBind :: (TyCon, FieldLabel) -> (LSig Name, LHsBinds Name)
mkRecSelBind (tycon, sel_name)
= (L loc (IdSig sel_id), unitBag (L loc sel_bind))
where
loc = getSrcSpan sel_name
sel_id = mkExportedLocalId rec_details sel_name sel_ty
rec_details = RecSelId { sel_tycon = tycon, sel_naughty = is_naughty }
-- Find a representative constructor, con1
all_cons = tyConDataCons tycon
cons_w_field = [ con | con <- all_cons
, sel_name `elem` dataConFieldLabels con ]
con1 = ASSERT( not (null cons_w_field) ) head cons_w_field
-- Selector type; Note [Polymorphic selectors]
field_ty = dataConFieldType con1 sel_name
data_ty = dataConOrigResTy con1
data_tvs = tyVarsOfType data_ty
is_naughty = not (tyVarsOfType field_ty `subVarSet` data_tvs)
(field_tvs, field_theta, field_tau) = tcSplitSigmaTy field_ty
sel_ty | is_naughty = unitTy -- See Note [Naughty record selectors]
| otherwise = mkForAllTys (varSetElemsKvsFirst $
data_tvs `extendVarSetList` field_tvs) $
mkPhiTy (dataConStupidTheta con1) $ -- Urgh!
mkPhiTy field_theta $ -- Urgh!
mkFunTy data_ty field_tau
-- Make the binding: sel (C2 { fld = x }) = x
-- sel (C7 { fld = x }) = x
-- where cons_w_field = [C2,C7]
sel_bind = mkTopFunBind Generated sel_lname alts
where
alts | is_naughty = [mkSimpleMatch [] unit_rhs]
| otherwise = map mk_match cons_w_field ++ deflt
mk_match con = mkSimpleMatch [L loc (mk_sel_pat con)]
(L loc (HsVar field_var))
mk_sel_pat con = ConPatIn (L loc (getName con)) (RecCon rec_fields)
rec_fields = HsRecFields { rec_flds = [rec_field], rec_dotdot = Nothing }
rec_field = noLoc (HsRecField { hsRecFieldId = sel_lname
, hsRecFieldArg = L loc (VarPat field_var)
, hsRecPun = False })
sel_lname = L loc sel_name
field_var = mkInternalName (mkBuiltinUnique 1) (getOccName sel_name) loc
-- Add catch-all default case unless the case is exhaustive
-- We do this explicitly so that we get a nice error message that
-- mentions this particular record selector
deflt | all dealt_with all_cons = []
| otherwise = [mkSimpleMatch [L loc (WildPat placeHolderType)]
(mkHsApp (L loc (HsVar (getName rEC_SEL_ERROR_ID)))
(L loc (HsLit msg_lit)))]
-- Do not add a default case unless there are unmatched
-- constructors. We must take account of GADTs, else we
-- get overlap warning messages from the pattern-match checker
-- NB: we need to pass type args for the *representation* TyCon
-- to dataConCannotMatch, hence the calculation of inst_tys
-- This matters in data families
-- data instance T Int a where
-- A :: { fld :: Int } -> T Int Bool
-- B :: { fld :: Int } -> T Int Char
dealt_with con = con `elem` cons_w_field || dataConCannotMatch inst_tys con
inst_tys = substTyVars (mkTopTvSubst (dataConEqSpec con1)) (dataConUnivTyVars con1)
unit_rhs = mkLHsTupleExpr []
msg_lit = HsStringPrim "" $ unsafeMkByteString $
occNameString (getOccName sel_name)
---------------
tyConFields :: TyCon -> [FieldLabel]
tyConFields tc
| isAlgTyCon tc = nub (concatMap dataConFieldLabels (tyConDataCons tc))
| otherwise = []
{-
Note [Polymorphic selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a record has a polymorphic field, we pull the foralls out to the front.
data T = MkT { f :: forall a. [a] -> a }
Then f :: forall a. T -> [a] -> a
NOT f :: T -> forall a. [a] -> a
This is horrid. It's only needed in deeply obscure cases, which I hate.
The only case I know is test tc163, which is worth looking at. It's far
from clear that this test should succeed at all!
Note [Naughty record selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A "naughty" field is one for which we can't define a record
selector, because an existential type variable would escape. For example:
data T = forall a. MkT { x,y::a }
We obviously can't define
x (MkT v _) = v
Nevertheless we *do* put a RecSelId into the type environment
so that if the user tries to use 'x' as a selector we can bleat
helpfully, rather than saying unhelpfully that 'x' is not in scope.
Hence the sel_naughty flag, to identify record selectors that don't really exist.
In general, a field is "naughty" if its type mentions a type variable that
isn't in the result type of the constructor. Note that this *allows*
GADT record selectors (Note [GADT record selectors]) whose types may look
like sel :: T [a] -> a
For naughty selectors we make a dummy binding
sel = ()
for naughty selectors, so that the later type-check will add them to the
environment, and they'll be exported. The function is never called, because
the tyepchecker spots the sel_naughty field.
Note [GADT record selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For GADTs, we require that all constructors with a common field 'f' have the same
result type (modulo alpha conversion). [Checked in TcTyClsDecls.checkValidTyCon]
E.g.
data T where
T1 { f :: Maybe a } :: T [a]
T2 { f :: Maybe a, y :: b } :: T [a]
T3 :: T Int
and now the selector takes that result type as its argument:
f :: forall a. T [a] -> Maybe a
Details: the "real" types of T1,T2 are:
T1 :: forall r a. (r~[a]) => a -> T r
T2 :: forall r a b. (r~[a]) => a -> b -> T r
So the selector loooks like this:
f :: forall a. T [a] -> Maybe a
f (a:*) (t:T [a])
= case t of
T1 c (g:[a]~[c]) (v:Maybe c) -> v `cast` Maybe (right (sym g))
T2 c d (g:[a]~[c]) (v:Maybe c) (w:d) -> v `cast` Maybe (right (sym g))
T3 -> error "T3 does not have field f"
Note the forall'd tyvars of the selector are just the free tyvars
of the result type; there may be other tyvars in the constructor's
type (e.g. 'b' in T2).
Note the need for casts in the result!
Note [Selector running example]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's OK to combine GADTs and type families. Here's a running example:
data instance T [a] where
T1 { fld :: b } :: T [Maybe b]
The representation type looks like this
data :R7T a where
T1 { fld :: b } :: :R7T (Maybe b)
and there's coercion from the family type to the representation type
:CoR7T a :: T [a] ~ :R7T a
The selector we want for fld looks like this:
fld :: forall b. T [Maybe b] -> b
fld = /\b. \(d::T [Maybe b]).
case d `cast` :CoR7T (Maybe b) of
T1 (x::b) -> x
The scrutinee of the case has type :R7T (Maybe b), which can be
gotten by appying the eq_spec to the univ_tvs of the data con.
************************************************************************
* *
Error messages
* *
************************************************************************
-}
tcAddTyFamInstCtxt :: TyFamInstDecl Name -> TcM a -> TcM a
tcAddTyFamInstCtxt decl
= tcAddFamInstCtxt (ptext (sLit "type instance")) (tyFamInstDeclName decl)
tcAddDataFamInstCtxt :: DataFamInstDecl Name -> TcM a -> TcM a
tcAddDataFamInstCtxt decl
= tcAddFamInstCtxt (pprDataFamInstFlavour decl <+> ptext (sLit "instance"))
(unLoc (dfid_tycon decl))
tcAddFamInstCtxt :: SDoc -> Name -> TcM a -> TcM a
tcAddFamInstCtxt flavour tycon thing_inside
= addErrCtxt ctxt thing_inside
where
ctxt = hsep [ptext (sLit "In the") <+> flavour
<+> ptext (sLit "declaration for"),
quotes (ppr tycon)]
tcAddClosedTypeFamilyDeclCtxt :: TyCon -> TcM a -> TcM a
tcAddClosedTypeFamilyDeclCtxt tc
= addErrCtxt ctxt
where
ctxt = ptext (sLit "In the equations for closed type family") <+>
quotes (ppr tc)
resultTypeMisMatch :: Name -> DataCon -> DataCon -> SDoc
resultTypeMisMatch field_name con1 con2
= vcat [sep [ptext (sLit "Constructors") <+> ppr con1 <+> ptext (sLit "and") <+> ppr con2,
ptext (sLit "have a common field") <+> quotes (ppr field_name) <> comma],
nest 2 $ ptext (sLit "but have different result types")]
fieldTypeMisMatch :: Name -> DataCon -> DataCon -> SDoc
fieldTypeMisMatch field_name con1 con2
= sep [ptext (sLit "Constructors") <+> ppr con1 <+> ptext (sLit "and") <+> ppr con2,
ptext (sLit "give different types for field"), quotes (ppr field_name)]
dataConCtxtName :: [Located Name] -> SDoc
dataConCtxtName [con]
= ptext (sLit "In the definition of data constructor") <+> quotes (ppr con)
dataConCtxtName con
= ptext (sLit "In the definition of data constructors") <+> interpp'SP con
dataConCtxt :: Outputable a => a -> SDoc
dataConCtxt con = ptext (sLit "In the definition of data constructor") <+> quotes (ppr con)
classOpCtxt :: Var -> Type -> SDoc
classOpCtxt sel_id tau = sep [ptext (sLit "When checking the class method:"),
nest 2 (pprPrefixOcc sel_id <+> dcolon <+> ppr tau)]
classArityErr :: Int -> Class -> SDoc
classArityErr n cls
| n == 0 = mkErr "No" "no-parameter"
| otherwise = mkErr "Too many" "multi-parameter"
where
mkErr howMany allowWhat =
vcat [ptext (sLit $ howMany ++ " parameters for class") <+> quotes (ppr cls),
parens (ptext (sLit $ "Use MultiParamTypeClasses to allow "
++ allowWhat ++ " classes"))]
classFunDepsErr :: Class -> SDoc
classFunDepsErr cls
= vcat [ptext (sLit "Fundeps in class") <+> quotes (ppr cls),
parens (ptext (sLit "Use FunctionalDependencies to allow fundeps"))]
badMethPred :: Id -> TcPredType -> SDoc
badMethPred sel_id pred
= vcat [ hang (ptext (sLit "Constraint") <+> quotes (ppr pred)
<+> ptext (sLit "in the type of") <+> quotes (ppr sel_id))
2 (ptext (sLit "constrains only the class type variables"))
, ptext (sLit "Use ConstrainedClassMethods to allow it") ]
noClassTyVarErr :: Class -> TyCon -> SDoc
noClassTyVarErr clas fam_tc
= sep [ ptext (sLit "The associated type") <+> quotes (ppr fam_tc)
, ptext (sLit "mentions none of the type or kind variables of the class") <+>
quotes (ppr clas <+> hsep (map ppr (classTyVars clas)))]
recSynErr :: [LTyClDecl Name] -> TcRn ()
recSynErr syn_decls
= setSrcSpan (getLoc (head sorted_decls)) $
addErr (sep [ptext (sLit "Cycle in type synonym declarations:"),
nest 2 (vcat (map ppr_decl sorted_decls))])
where
sorted_decls = sortLocated syn_decls
ppr_decl (L loc decl) = ppr loc <> colon <+> ppr decl
recClsErr :: [TyCon] -> TcRn ()
recClsErr cycles
= addErr (sep [ptext (sLit "Cycle in class declaration (via superclasses):"),
nest 2 (hsep (intersperse (text "->") (map ppr cycles)))])
badDataConTyCon :: DataCon -> Type -> Type -> SDoc
badDataConTyCon data_con res_ty_tmpl actual_res_ty
= hang (ptext (sLit "Data constructor") <+> quotes (ppr data_con) <+>
ptext (sLit "returns type") <+> quotes (ppr actual_res_ty))
2 (ptext (sLit "instead of an instance of its parent type") <+> quotes (ppr res_ty_tmpl))
badGadtKindCon :: DataCon -> SDoc
badGadtKindCon data_con
= hang (ptext (sLit "Data constructor") <+> quotes (ppr data_con)
<+> ptext (sLit "cannot be GADT-like in its *kind* arguments"))
2 (ppr data_con <+> dcolon <+> ppr (dataConUserType data_con))
badGadtDecl :: Name -> SDoc
badGadtDecl tc_name
= vcat [ ptext (sLit "Illegal generalised algebraic data declaration for") <+> quotes (ppr tc_name)
, nest 2 (parens $ ptext (sLit "Use GADTs to allow GADTs")) ]
badExistential :: DataCon -> SDoc
badExistential con
= hang (ptext (sLit "Data constructor") <+> quotes (ppr con) <+>
ptext (sLit "has existential type variables, a context, or a specialised result type"))
2 (vcat [ ppr con <+> dcolon <+> ppr (dataConUserType con)
, parens $ ptext (sLit "Use ExistentialQuantification or GADTs to allow this") ])
badStupidTheta :: Name -> SDoc
badStupidTheta tc_name
= ptext (sLit "A data type declared in GADT style cannot have a context:") <+> quotes (ppr tc_name)
newtypeConError :: Name -> Int -> SDoc
newtypeConError tycon n
= sep [ptext (sLit "A newtype must have exactly one constructor,"),
nest 2 $ ptext (sLit "but") <+> quotes (ppr tycon) <+> ptext (sLit "has") <+> speakN n ]
newtypeStrictError :: DataCon -> SDoc
newtypeStrictError con
= sep [ptext (sLit "A newtype constructor cannot have a strictness annotation,"),
nest 2 $ ptext (sLit "but") <+> quotes (ppr con) <+> ptext (sLit "does")]
newtypeFieldErr :: DataCon -> Int -> SDoc
newtypeFieldErr con_name n_flds
= sep [ptext (sLit "The constructor of a newtype must have exactly one field"),
nest 2 $ ptext (sLit "but") <+> quotes (ppr con_name) <+> ptext (sLit "has") <+> speakN n_flds]
badSigTyDecl :: Name -> SDoc
badSigTyDecl tc_name
= vcat [ ptext (sLit "Illegal kind signature") <+>
quotes (ppr tc_name)
, nest 2 (parens $ ptext (sLit "Use KindSignatures to allow kind signatures")) ]
emptyConDeclsErr :: Name -> SDoc
emptyConDeclsErr tycon
= sep [quotes (ppr tycon) <+> ptext (sLit "has no constructors"),
nest 2 $ ptext (sLit "(EmptyDataDecls permits this)")]
wrongKindOfFamily :: TyCon -> SDoc
wrongKindOfFamily family
= ptext (sLit "Wrong category of family instance; declaration was for a")
<+> kindOfFamily
where
kindOfFamily | isTypeFamilyTyCon family = text "type family"
| isDataFamilyTyCon family = text "data family"
| otherwise = pprPanic "wrongKindOfFamily" (ppr family)
wrongNumberOfParmsErr :: Arity -> SDoc
wrongNumberOfParmsErr max_args
= ptext (sLit "Number of parameters must match family declaration; expected")
<+> ppr max_args
wrongTyFamName :: Name -> Name -> SDoc
wrongTyFamName fam_tc_name eqn_tc_name
= hang (ptext (sLit "Mismatched type name in type family instance."))
2 (vcat [ ptext (sLit "Expected:") <+> ppr fam_tc_name
, ptext (sLit " Actual:") <+> ppr eqn_tc_name ])
inaccessibleCoAxBranch :: TyCon -> CoAxBranch -> SDoc
inaccessibleCoAxBranch tc fi
= ptext (sLit "Overlapped type family instance equation:") $$
(pprCoAxBranch tc fi)
badRoleAnnot :: Name -> Role -> Role -> SDoc
badRoleAnnot var annot inferred
= hang (ptext (sLit "Role mismatch on variable") <+> ppr var <> colon)
2 (sep [ ptext (sLit "Annotation says"), ppr annot
, ptext (sLit "but role"), ppr inferred
, ptext (sLit "is required") ])
wrongNumberOfRoles :: [a] -> LRoleAnnotDecl Name -> SDoc
wrongNumberOfRoles tyvars d@(L _ (RoleAnnotDecl _ annots))
= hang (ptext (sLit "Wrong number of roles listed in role annotation;") $$
ptext (sLit "Expected") <+> (ppr $ length tyvars) <> comma <+>
ptext (sLit "got") <+> (ppr $ length annots) <> colon)
2 (ppr d)
illegalRoleAnnotDecl :: LRoleAnnotDecl Name -> TcM ()
illegalRoleAnnotDecl (L loc (RoleAnnotDecl tycon _))
= setErrCtxt [] $
setSrcSpan loc $
addErrTc (ptext (sLit "Illegal role annotation for") <+> ppr tycon <> char ';' $$
ptext (sLit "they are allowed only for datatypes and classes."))
needXRoleAnnotations :: TyCon -> SDoc
needXRoleAnnotations tc
= ptext (sLit "Illegal role annotation for") <+> ppr tc <> char ';' $$
ptext (sLit "did you intend to use RoleAnnotations?")
incoherentRoles :: SDoc
incoherentRoles = (text "Roles other than" <+> quotes (text "nominal") <+>
text "for class parameters can lead to incoherence.") $$
(text "Use IncoherentInstances to allow this; bad role found")
addTyThingCtxt :: TyThing -> TcM a -> TcM a
addTyThingCtxt thing
= addErrCtxt ctxt
where
name = getName thing
flav = case thing of
ATyCon tc
| isClassTyCon tc -> ptext (sLit "class")
| isTypeFamilyTyCon tc -> ptext (sLit "type family")
| isDataFamilyTyCon tc -> ptext (sLit "data family")
| isTypeSynonymTyCon tc -> ptext (sLit "type")
| isNewTyCon tc -> ptext (sLit "newtype")
| isDataTyCon tc -> ptext (sLit "data")
_ -> pprTrace "addTyThingCtxt strange" (ppr thing)
Outputable.empty
ctxt = hsep [ ptext (sLit "In the"), flav
, ptext (sLit "declaration for"), quotes (ppr name) ]
addRoleAnnotCtxt :: Name -> TcM a -> TcM a
addRoleAnnotCtxt name
= addErrCtxt $
text "while checking a role annotation for" <+> quotes (ppr name)
|
fmthoma/ghc
|
compiler/typecheck/TcTyClsDecls.hs
|
bsd-3-clause
| 100,406 | 47 | 23 | 29,627 | 17,735 | 9,108 | 8,627 | -1 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.