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
answer = sum [1..100] ^ 2 - foldl (\x y -> y^2 + x) 0 [1..100]
tamasgal/haskell_exercises
ProjectEuler/p006.hs
mit
63
0
10
16
52
27
25
1
1
{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeOperators #-} module DirectoryAPI.API ( directoryAPIProxy , DirectoryAPI ) where import Servant import AuthAPI.API (AuthToken) import Models (File, Node, NodeId) type DirectoryAPI = "ls" :> -- List all files AuthToken :> Get '[JSON] [File] -- Listing of all files :<|> "whereis" :> -- Lookup the node for a given file path AuthToken :> ReqBody '[JSON] FilePath :> -- Path of file being looked up Post '[JSON] Node -- Node where the file is kept :<|> "roundRobinNode" :> -- Next node to use as a file primary AuthToken :> ReqBody '[JSON] FilePath :> -- Path of file that will be written Get '[JSON] Node -- Primary node of the file being stored :<|> "registerFileServer" :> -- Register a node with the directory service ReqBody '[JSON] Int :> -- Port file server node is running on Post '[JSON] NodeId -- Id of the newly created node record directoryAPIProxy :: Proxy DirectoryAPI directoryAPIProxy = Proxy
houli/distributed-file-system
dfs-shared/src/DirectoryAPI/API.hs
mit
1,213
0
20
421
198
113
85
24
1
module BlocVoting.Tally.Resolution where import qualified Data.ByteString as BS data Resolution = Resolution { rCategories :: Int , rEndTimestamp :: Int , rName :: BS.ByteString , rUrl :: BS.ByteString , rVotesFor :: Integer , rVotesTotal :: Integer , rResolved :: Bool } deriving (Show, Eq) updateResolution :: Resolution -> Integer -> Integer -> Resolution updateResolution (Resolution cats endT name url for total resolved) newForVotes newTotalVotes = Resolution cats endT name url (for + newForVotes) (total + newTotalVotes) resolved
XertroV/blocvoting
src/BlocVoting/Tally/Resolution.hs
mit
565
0
9
104
157
91
66
14
1
{-# LANGUAGE CPP #-} module Database.Orville.PostgreSQL.Plan.Explanation ( Explanation , noExplanation , explainStep , explanationSteps ) where newtype Explanation = Explanation ([String] -> [String]) #if MIN_VERSION_base(4,11,0) instance Semigroup Explanation where (<>) = appendExplanation #endif instance Monoid Explanation where mempty = noExplanation mappend = appendExplanation appendExplanation :: Explanation -> Explanation -> Explanation appendExplanation (Explanation front) (Explanation back) = Explanation (front . back) noExplanation :: Explanation noExplanation = Explanation id explainStep :: String -> Explanation explainStep str = Explanation (str:) explanationSteps :: Explanation -> [String] explanationSteps (Explanation prependTo) = prependTo []
flipstone/orville
orville-postgresql/src/Database/Orville/PostgreSQL/Plan/Explanation.hs
mit
800
0
8
121
193
110
83
23
1
import Data.List (permutations, sort) solve :: String solve = (sort $ permutations "0123456789") !! 999999 main = putStrLn $ solve
pshendry/project-euler-solutions
0024/solution.hs
mit
133
0
8
22
47
26
21
4
1
module Lesson08 where -- Now let's have some real fun: a two player, online five card stud game, -- with a full betting system. The betting system is actually the biggest -- addition versus what we've done previously, so most of our attention -- will be focused on that. Most of the other code will be very similar -- to what we had in lesson 7. import Helper import Helper.Multiplayer import Helper.Pretty import Helper.Winning import System.Random.Shuffle import Data.List import Safe -- We're going to want to keep track of multiple information per player. -- A common way to do that is to create a record data type, where each -- piece of data has its own name. We'll want to have the player and -- how much money he/she has. data PokerPlayer = PokerPlayer { player :: Player , chips :: Int , cards :: [Card] , hand :: PokerHand } data Action = Call | Raise Int | Fold askAction p allowedRaise = do str <- askPlayer (player p) "call, raise, or fold?" case str of "call" -> return Call "raise" -> askRaise p allowedRaise "fold" -> return Fold _ -> do tellPlayer (player p) "That was not a valid answer" askAction p allowedRaise askRaise p allowedRaise = do str <- askPlayer (player p) ("Enter amount to raise, up to " ++ show allowedRaise) case readMay str of Nothing -> do tellPlayer (player p) "That was an invalid raise amount" askRaise p allowedRaise Just amount | amount < 0 -> do tellPlayer (player p) "You cannot raise by a negative value" askRaise p allowedRaise | otherwise -> return (Raise amount) wager p1 p2 pot owed = do tellAllPlayers $ show (player p1) ++ " has " ++ show (chips p1) ++ " chips" tellAllPlayers $ show (player p2) ++ " has " ++ show (chips p2) ++ " chips" tellAllPlayers $ "The pot currently has " ++ show pot ++ " chips" tellAllPlayers $ "Betting is to " ++ show (player p1) ++ ", who owes " ++ show owed let allowedRaise = min (chips p2) (chips p1 - owed) action <- askAction p1 allowedRaise case action of Call -> do tellAllPlayers $ show (player p1) ++ " calls" let p1' = p1 { chips = chips p1 - owed } pot' = pot + owed finishHand p1' p2 pot' Fold -> do tellAllPlayers $ show (player p1) ++ " folds" startGame (player p1) (chips p1) (player p2) (chips p2 + pot) Raise raise -> do tellAllPlayers $ show (player p1) ++ " raises " ++ show raise let p1' = p1 { chips = chips p1 - owed - raise } wager p2 p1' (pot + owed + raise) raise finishHand p1 p2 pot = do tellAllPlayers ("All bets are in, the pot is at: " ++ show pot) tellAllPlayers (show (player p1) ++ " has " ++ prettyHand (cards p1) ++ ", " ++ show (hand p1)) tellAllPlayers (show (player p2) ++ " has " ++ prettyHand (cards p2) ++ ", " ++ show (hand p2)) (winnings1, winnings2) <- case compare (hand p1) (hand p2) of LT -> do tellAllPlayers (show (player p2) ++ " wins!") return (0, pot) EQ -> do tellAllPlayers "Tied game" let winnings1 = pot `div` 2 winnings2 = pot - winnings1 return (winnings1, winnings2) GT -> do tellAllPlayers (show (player p1) ++ " wins!") return (pot, 0) startGame (player p1) (chips p1 + winnings1) (player p2) (chips p2 + winnings2) startGame player1 0 player2 chips2 = do tellAllPlayers (show player1 ++ " is out of chips") tellAllPlayers (show player2 ++ " wins with a total of: " ++ show chips2) startGame player1 chips1 player2 0 = do tellAllPlayers (show player2 ++ " is out of chips") tellAllPlayers (show player1 ++ " wins with a total of: " ++ show chips1) startGame player1 chips1 player2 chips2 = do tellAllPlayers "Dealing..." shuffled <- shuffleM deck let (cards1, rest) = splitAt 5 shuffled hand1 = pokerHand cards1 cards2 = take 5 rest hand2 = pokerHand cards2 p1 = PokerPlayer { player = player1 , chips = chips1 , cards = cards1 , hand = hand1 } -- Always start with a 1 chip ante from player 2 pot = 1 owed = 1 p2 = PokerPlayer { player = player2 , chips = chips2 - 1 , cards = cards2 , hand = hand2 } tellPlayer player1 ("You have " ++ prettyHand cards1 ++ ", " ++ show hand1) tellPlayer player2 ("You have " ++ prettyHand cards2 ++ ", " ++ show hand2) wager p1 p2 pot owed main = playMultiplayerGame "two player five card stud" 2 $ do tellAllPlayers "Welcome to two player five card stud!" [player1, player2] <- getPlayers startGame player1 20 player2 20 -- Let's talk about the betting phase. We'll be alternating between each -- player. At each player's betting turn, he/she will be allowed to: -- -- 1. Call, which would be to match whatever bet is on the table. -- 2. Raise, which would match the current bet and add a little more. -- 3. Fold
snoyberg/haskell-impatient-poker-players
src/Lesson08.hs
mit
5,286
0
19
1,643
1,450
706
744
104
4
{- hpodder component Copyright (C) 2006 John Goerzen <[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 : FeedParser Copyright : Copyright (C) 2006 John Goerzen License : GNU GPL, version 2 or above Maintainer : John Goerzen <[email protected]> Stability : provisional Portability: portable Written by John Goerzen, jgoerzen\@complete.org -} module FeedParser where import Types import Text.XML.HaXml import Text.XML.HaXml.Parse import Text.XML.HaXml.Posn import Utils import Data.Maybe.Utils import Data.Char import Data.Either.Utils import Data.List import System.IO data Item = Item {itemtitle :: String, itemguid :: Maybe String, enclosureurl :: String, enclosuretype :: String, enclosurelength :: String } deriving (Eq, Show, Read) data Feed = Feed {channeltitle :: String, items :: [Item]} deriving (Eq, Show, Read) item2ep pc item = Episode {podcast = pc, epid = 0, eptitle = sanitize_basic (itemtitle item), epurl = sanitize_basic (enclosureurl item), epguid = fmap sanitize_basic (itemguid item), eptype = sanitize_basic (enclosuretype item), epstatus = Pending, eplength = case reads . sanitize_basic . enclosurelength $ item of [] -> 0 [(x, [])] -> x _ -> 0, epfirstattempt = Nothing, eplastattempt = Nothing, epfailedattempts = 0} parse :: FilePath -> String -> IO (Either String Feed) parse fp name = do h <- openBinaryFile fp ReadMode c <- hGetContents h case xmlParse' name (unifrob c) of Left x -> return (Left x) Right y -> do let doc = getContent y let title = getTitle doc let feeditems = getEnclosures doc return $ Right $ (Feed {channeltitle = title, items = feeditems}) where getContent (Document _ _ e _) = CElem e noPos unifrob ('\xfeff':x) = x -- Strip off unicode BOM unifrob x = x unesc = xmlUnEscape stdXmlEscaper getTitle doc = forceEither $ strofm "title" (channel doc) getEnclosures doc = concat . map procitem $ item doc where procitem i = map (procenclosure title guid) enclosure where title = case strofm "title" [i] of Left x -> "Untitled" Right x -> x guid = case strofm "guid" [i] of Left _ -> Nothing Right x -> Just x enclosure = tag "enclosure" `o` children $ i procenclosure title guid e = Item {itemtitle = title, itemguid = guid, enclosureurl = head0 $ forceMaybe $ stratt "url" e, enclosuretype = head0 $ case stratt "type" e of Nothing -> ["application/octet-stream"] Just x -> x, enclosurelength = head $ case stratt "length" e of Nothing -> ["0"] Just [] -> ["0"] Just x -> x } head0 [] = "" head0 (x:xs) = x item = tag "item" `o` children `o` channel channel = tag "channel" `o` children `o` tag "rss" -------------------------------------------------- -- Utilities -------------------------------------------------- attrofelem :: String -> Content Posn -> Maybe AttValue attrofelem attrname (CElem inelem _) = case unesc inelem of Elem name al _ -> lookup attrname al attrofelem _ _ = error "attrofelem: called on something other than a CElem" stratt :: String -> Content Posn -> Maybe [String] stratt attrname content = case attrofelem attrname content of Just (AttValue x) -> Just (concat . map mapfunc $ x) Nothing -> Nothing where mapfunc (Left x) = [x] mapfunc (Right _) = [] -- Finds the literal children of the named tag, and returns it/them tagof :: String -> CFilter Posn tagof x = keep /> tag x -- /> txt -- Retruns the literal string that tagof would find strof :: String -> Content Posn -> String strof x y = forceEither $ strof_either x y strof_either :: String -> Content Posn -> Either String String strof_either x y = case tagof x $ y of [CElem elem pos] -> Right $ verbatim $ tag x /> txt $ CElem (unesc elem) pos z -> Left $ "strof: expecting CElem in " ++ x ++ ", got " ++ verbatim z ++ " at " ++ verbatim y strofm x y = if length errors /= 0 then Left errors else Right (concat plainlist) where mapped = map (strof_either x) $ y (errors, plainlist) = conveithers mapped isright (Left _) = False isright (Right _) = True conveithers :: [Either a b] -> ([a], [b]) conveithers inp = worker inp ([], []) where worker [] y = y worker (Left x:xs) (lefts, rights) = worker xs (x:lefts, rights) worker (Right x:xs) (lefts, rights) = worker xs (lefts, x:rights)
jgoerzen/hpodder
FeedParser.hs
gpl-2.0
6,088
1
16
2,117
1,532
797
735
115
7
{- | Module : $EmptyHeader$ Description : <optional short description entry> Copyright : (c) <Authors or Affiliations> License : GPLv2 or higher, see LICENSE.txt Maintainer : <email> Stability : unstable | experimental | provisional | stable | frozen Portability : portable | non-portable (<reason>) <optional description> -} ------------------------------------------------------------------------------- -- GMP -- Copyright 2007, Lutz Schroeder and Georgel Calin ------------------------------------------------------------------------------- module Main where import Text.ParserCombinators.Parsec import System.Environment import IO import GMP.GMPAS import GMP.GMPSAT import GMP.GMPParser import GMP.ModalLogic import GMP.ModalK() import GMP.ModalKD() import GMP.GradedML() import GMP.CoalitionL() import GMP.MajorityL() import GMP.GenericML() import GMP.Lexer ------------------------------------------------------------------------------- -- Funtion to run parser & print ------------------------------------------------------------------------------- runLex :: (Ord a, Show a, ModalLogic a b) => Parser (Formula a) -> String -> IO () runLex p input = run (do whiteSpace ; x <- p ; eof ; return x ) input run :: (Ord a, Show a, ModalLogic a b) => Parser (Formula a) -> String -> IO () run p input = case (parse p "" input) of Left err -> do putStr "parse error at " print err Right x -> do putStrLn ("Input Formula: "{- ++ show x ++ " ..."-}) let sat = checkSAT x if sat then putStrLn "x ... is Satisfiable" else putStrLn "x ... is not Satisfiable" let nsat = checkSAT $ Neg x if nsat then putStrLn "~x ... is Satisfiable" else putStrLn "~x ... is not Satisfiable" let prov = not $ checkSAT $ Neg x if prov then putStrLn "x ... is Provable" else putStrLn "x ... is not Provable" ------------------------------------------------------------------------------- -- For Testing ------------------------------------------------------------------------------- runTest :: Int -> FilePath -> IO () runTest ml p = do input <- readFile (p) case ml of 1 -> runLex ((par5er parseIndex) :: Parser (Formula ModalK)) input 2 -> runLex ((par5er parseIndex) :: Parser (Formula ModalKD)) input 3 -> runLex ((par5er parseIndex) :: Parser (Formula CL)) input 4 -> runLex ((par5er parseIndex) :: Parser (Formula GML)) input 5 -> runLex ((par5er parseIndex) :: Parser (Formula ML)) input _ -> runLex ((par5er parseIndex) :: Parser (Formula Kars)) input return () help :: IO() help = do putStrLn ( "Usage:\n" ++ " ./main <ML> <path>\n\n" ++ "<ML>: 1 for K ML\n" ++ " 2 for KD ML\n" ++ " 3 for Coalition L\n" ++ " 4 for Graded ML\n" ++ " 5 for Majority L\n" ++ " _ for Generic ML\n" ++ "<path>: path to input file\n" ) ------------------------------------------------------------------------------- main :: IO() main = do args <- getArgs if (args == [])||(head args == "--help")||(length args < 2) then help else let ml = head args p = head (tail args) in runTest (read ml) p
nevrenato/Hets_Fork
GMP/versioning/gmp-0.0.1/GMP/Main.hs
gpl-2.0
3,633
3
16
1,112
822
416
406
67
6
{-# LANGUAGE ScopedTypeVariables #-} import Bench import Bench.Triangulations main = print (qVertexSolBench trs)
DanielSchuessler/hstri
scratch6.hs
gpl-3.0
115
0
7
15
24
13
11
4
1
{-# LANGUAGE OverloadedStrings #-} module Response.Export (pdfResponse) where import Happstack.Server import qualified Data.ByteString.Lazy as BS import Control.Monad.IO.Class (liftIO) import qualified Data.ByteString.Base64.Lazy as BEnc import ImageConversion import TimetableImageCreator (renderTable) import System.Random import Latex -- | Returns a PDF containing the image of the timetable -- requested by the user. pdfResponse :: String -> String -> ServerPart Response pdfResponse courses session = liftIO $ getPdf courses session getPdf :: String -> String -> IO Response getPdf courses session = do gen <- newStdGen let (rand, _) = next gen svgFilename = (show rand ++ ".svg") imageFilename = (show rand ++ ".png") texFilename = (show rand ++ ".tex") pdfFilename = (drop 4 texFilename) ++ ".pdf" renderTable svgFilename courses session returnPdfData svgFilename imageFilename pdfFilename texFilename returnPdfData :: String -> String -> String -> String -> IO Response returnPdfData svgFilename imageFilename pdfFilename texFilename = do createImageFile svgFilename imageFilename compileTex texFilename imageFilename _ <- compileTexToPdf texFilename pdfData <- BS.readFile texFilename _ <- removeImage svgFilename _ <- removeImage imageFilename _ <- removeImage pdfFilename _ <- removeImage texFilename let encodedData = BEnc.encode pdfData return $ toResponse encodedData
pkukulak/courseography
hs/Response/Export.hs
gpl-3.0
1,487
0
12
284
380
192
188
36
1
module Hazel.StringWriter where import Control.Monad.State ------------- StringState ------------- type StringState = State String (Maybe Bool) eval :: StringState -> String eval s = execState s "" newLine :: StringState append :: String -> StringState apply :: (String -> String) -> StringState newLine = append "\n" append s = apply (++s) apply f = get >>= put.(f$) >> return (Just True) --newLine :: StringState --newLine = do -- t <- get -- put $ t++"\n" -- return True -- get >>= put.(++"\n") >>= return True --append :: String -> StringState --append s = do -- t <- get -- put $ t++s -- return True -- get >>= put.(++s) >>= return True --modify :: (String -> String) -> StringState --modify f = do -- t <- get -- put $ f t -- return True
hazel-el/hazel
Hazel/StringWriter.hs
gpl-3.0
860
1
8
250
155
92
63
11
1
{-# LANGUAGE FlexibleContexts, CPP, JavaScriptFFI #-} module Carnap.GHCJS.Action.TreeDeductionCheck (treeDeductionCheckAction) where import Lib hiding (content) import Data.Tree import Data.Either import Data.Map as M (lookup,Map, toList) import Data.IORef (IORef, readIORef, newIORef, writeIORef) import Data.Typeable (Typeable) import Data.Aeson.Types import Data.Text (pack) import qualified Text.Parsec as P (parse) import Control.Monad.State (modify,get,execState,State) import Control.Lens import Control.Concurrent import Control.Monad (mplus, (>=>)) import Control.Monad.IO.Class (liftIO) import Carnap.Core.Unification.Unification (MonadVar,FirstOrder, applySub) import Carnap.Core.Unification.ACUI (ACUI) import Carnap.Core.Data.Types import Carnap.Core.Data.Classes import Carnap.Core.Data.Optics import Carnap.Languages.ClassicalSequent.Syntax import Carnap.Languages.ClassicalSequent.Parser import Carnap.Languages.PurePropositional.Syntax import Carnap.Languages.Util.LanguageClasses import Carnap.Calculi.Util import Carnap.Calculi.NaturalDeduction.Syntax import Carnap.Calculi.NaturalDeduction.Checker import Carnap.Calculi.Tableau.Data import Carnap.Languages.PurePropositional.Logic (ofPropTreeSys) import Carnap.Languages.PureFirstOrder.Logic (ofFOLTreeSys) import Carnap.GHCJS.Util.ProofJS import Carnap.GHCJS.SharedTypes import GHCJS.DOM.HTMLElement (getInnerText, castToHTMLElement) import GHCJS.DOM.Element (setInnerHTML, click, keyDown, input, setAttribute ) import GHCJS.DOM.Node (appendChild, removeChild, getParentNode, insertBefore, getParentElement) import GHCJS.DOM.Types (Element, Document, IsElement) import GHCJS.DOM.Document (createElement, getActiveElement) import GHCJS.DOM.KeyboardEvent import GHCJS.DOM.EventM import GHCJS.DOM import GHCJS.Types treeDeductionCheckAction :: IO () treeDeductionCheckAction = do initializeCallback "checkProofTreeInfo" njCheck initElements getCheckers activateChecker return () where njCheck = maybe (error "can't find PropNJ") id $ (\calc -> checkProofTree calc Nothing >=> return . fst) `ofPropTreeSys` "PropNJ" getCheckers :: IsElement self => Document -> self -> IO [Maybe (Element, Element, Map String String)] getCheckers w = genInOutElts w "div" "div" "treedeductionchecker" activateChecker :: Document -> Maybe (Element, Element, Map String String) -> IO () activateChecker _ Nothing = return () activateChecker w (Just (i, o, opts)) = case (setupWith `ofPropTreeSys` sys) `mplus` (setupWith `ofFOLTreeSys` sys) of Just io -> io Nothing -> error $ "couldn't parse tree system: " ++ sys where sys = case M.lookup "system" opts of Just s -> s Nothing -> "propNK" setupWith calc = do mgoal <- parseGoal calc let content = M.lookup "content" opts root <- case (content >>= decodeJSON, mgoal) of (Just val,_) -> let Just c = content in initRoot c o (_, Just seq) | "prepopulate" `inOpts` opts -> initRoot ("{\"label\": \"" ++ show (view rhs seq) ++ "\", \"rule\":\"\", \"forest\": []}") o _ -> initRoot "{\"label\": \"\", \"rule\":\"\", \"forest\": []}" o memo <- newIORef mempty threadRef <- newIORef (Nothing :: Maybe ThreadId) bw <- createButtonWrapper w o let submit = submitTree w memo opts calc root mgoal btStatus <- createSubmitButton w bw submit opts if "displayJSON" `inOpts` opts then do Just displayDiv <- createElement w (Just "div") setAttribute displayDiv "class" "jsonDisplay" setAttribute displayDiv "contenteditable" "true" val <- toCleanVal root setInnerHTML displayDiv . Just $ toJSONString val toggleDisplay <- newListener $ do kbe <- event isCtrl <- getCtrlKey kbe code <- liftIO $ keyString kbe liftIO $ print code if isCtrl && code == "?" then do preventDefault mparent <- getParentNode displayDiv case mparent of Just p -> removeChild o (Just displayDiv) _ -> appendChild o (Just displayDiv) return () else return () addListener o keyDown toggleDisplay False updateRoot <- newListener $ liftIO $ do Just json <- getInnerText (castToHTMLElement displayDiv) replaceRoot root json addListener displayDiv input updateRoot False root `onChange` (\_ -> do mfocus <- getActiveElement w --don't update when the display is --focussed, to avoid cursor jumping if Just displayDiv /= mfocus then do val <- toCleanVal root setInnerHTML displayDiv . Just $ toJSONString val else return ()) return () else return () initialCheck <- newListener $ liftIO $ do forkIO $ do threadDelay 500000 mr <- toCleanVal root case mr of Just r -> do (info,mseq) <- checkProofTree calc (Just memo) r decorate root info Just wrap <- getParentElement i updateInfo calc mgoal mseq wrap Nothing -> return () return () addListener i initialize initialCheck False --initial check in case we preload a tableau doOnce i mutate False $ liftIO $ btStatus Edited case M.lookup "init" opts of Just "now" -> dispatchCustom w i "initialize"; _ -> return () root `onChange` (\_ -> dispatchCustom w i "mutate") root `onChange` (\_ -> checkOnChange memo threadRef calc mgoal i root) parseGoal calc = do let seqParse = parseSeqOver $ tbParseForm calc case M.lookup "goal" opts of Just s -> case P.parse seqParse "" s of Left e -> do setInnerHTML i (Just $ "Couldn't Parse This Goal:" ++ s) error "couldn't parse goal" Right seq -> do setInnerHTML i (Just . tbNotation calc . show $ seq) return $ Just seq Nothing -> do setInnerHTML i (Just "Awaiting a proof") return Nothing updateInfo _ (Just goal) (Just seq) wrap | seq `seqSubsetUnify` goal = setAttribute wrap "class" "success" updateInfo _ (Just goal) (Just seq) wrap = setAttribute wrap "class" "failure" updateInfo calc Nothing (Just seq) wrap = setInnerHTML wrap (Just . tbNotation calc . show $ seq) updateInfo _ Nothing Nothing wrap = setInnerHTML wrap (Just "Awaiting a proof") updateInfo _ _ _ wrap = setAttribute wrap "class" "" submitTree w memo opts calc root (Just seq) l = do Just val <- liftIO $ toCleanVal root case parse parseTreeJSON val of Error s -> message $ "Something has gone wrong. Here's the error:" ++ s Success tree -> case toProofTree calc tree of Left _ | "exam" `inOpts` opts -> trySubmit w DeductionTree opts l (DeductionTreeData (pack (show seq)) tree (toList opts)) False Left _ -> message "Something is wrong with the proof... Try again?" Right prooftree -> do validation <- liftIO $ hoReduceProofTreeMemo memo (structuralRestriction prooftree) prooftree case validation of Right seq' | "exam" `inOpts` opts || (seq' `seqSubsetUnify` seq) -> trySubmit w DeductionTree opts l (DeductionTreeData (pack (show seq)) tree (toList opts)) (seq' `seqSubsetUnify` seq) _ -> message "Something is wrong with the proof... Try again?" checkOnChange :: ( ReLex lex , Sequentable lex , Inference rule lex sem , FirstOrder (ClassicalSequentOver lex) , ACUI (ClassicalSequentOver lex) , MonadVar (ClassicalSequentOver lex) (State Int) , StaticVar (ClassicalSequentOver lex) , Schematizable (lex (ClassicalSequentOver lex)) , CopulaSchema (ClassicalSequentOver lex) , Typeable sem , Show rule , PrismSubstitutionalVariable lex , FirstOrderLex (lex (ClassicalSequentOver lex)) , StructuralOverride rule (ProofTree rule lex sem) , StructuralInference rule lex (ProofTree rule lex sem) ) => ProofMemoRef lex sem rule -> IORef (Maybe ThreadId) -> TableauCalc lex sem rule -> Maybe (ClassicalSequentOver lex (Sequent sem)) -> Element -> JSVal -> IO () checkOnChange memo threadRef calc mgoal i root = do mt <- readIORef threadRef case mt of Just t -> killThread t Nothing -> return () t' <- forkIO $ do threadDelay 500000 Just changedVal <- toCleanVal root (theInfo, mseq) <- checkProofTree calc (Just memo) changedVal decorate root theInfo Just wrap <- getParentElement i updateInfo calc mgoal mseq wrap writeIORef threadRef (Just t') toProofTree :: ( Typeable sem , ReLex lex , Sequentable lex , StructuralOverride rule (ProofTree rule lex sem) , Inference rule lex sem ) => TableauCalc lex sem rule -> Tree (String,String) -> Either (TreeFeedback lex) (ProofTree rule lex sem) toProofTree calc (Node (l,r) f) | all isRight parsedForest && isRight newNode = handleOverride <$> (Node <$> newNode <*> sequence parsedForest) | isRight newNode = Left $ Node Waiting (map cleanTree parsedForest) | Left n <- newNode = Left n where parsedLabel = (SS . liftToSequent) <$> P.parse (tbParseForm calc) "" l parsedRules = P.parse (tbParseRule calc) "" r parsedForest = map (toProofTree calc) f cleanTree (Left fs) = fs cleanTree (Right fs) = fmap (const Waiting) fs newNode = case ProofLine 0 <$> parsedLabel <*> parsedRules of Right l -> Right l Left e -> Left (Node (ProofError $ NoParse e 0) (map cleanTree parsedForest)) handleOverride f@(Node l fs) = case structuralOverride f (head (rule l)) of Nothing -> f Just rs -> Node (l {rule = rs}) fs checkProofTree :: ( ReLex lex , Sequentable lex , Inference rule lex sem , FirstOrder (ClassicalSequentOver lex) , ACUI (ClassicalSequentOver lex) , MonadVar (ClassicalSequentOver lex) (State Int) , StaticVar (ClassicalSequentOver lex) , Schematizable (lex (ClassicalSequentOver lex)) , CopulaSchema (ClassicalSequentOver lex) , Typeable sem , Show rule , StructuralOverride rule (ProofTree rule lex sem) , StructuralInference rule lex (ProofTree rule lex sem) ) => TableauCalc lex sem rule -> Maybe (ProofMemoRef lex sem rule) -> Value -> IO (Value, Maybe (ClassicalSequentOver lex (Sequent sem))) checkProofTree calc mmemo v = case parse parseTreeJSON v of Success t -> case toProofTree calc t of Left feedback -> return (toInfo feedback, Nothing) Right tree -> do (val,mseq) <- validateProofTree calc mmemo tree return (toInfo val, mseq) Error s -> do print (show v) error s validateProofTree :: ( ReLex lex , Sequentable lex , Inference rule lex sem , FirstOrder (ClassicalSequentOver lex) , ACUI (ClassicalSequentOver lex) , MonadVar (ClassicalSequentOver lex) (State Int) , StaticVar (ClassicalSequentOver lex) , Schematizable (lex (ClassicalSequentOver lex)) , CopulaSchema (ClassicalSequentOver lex) , Typeable sem , Show rule , StructuralInference rule lex (ProofTree rule lex sem) ) => TableauCalc lex sem rule -> Maybe (ProofMemoRef lex sem rule) -> ProofTree rule lex sem -> IO (TreeFeedback lex, Maybe (ClassicalSequentOver lex (Sequent sem))) validateProofTree calc mmemo t@(Node _ fs) = do rslt <- case mmemo of Nothing -> return $ hoReduceProofTree (structuralRestriction t) t Just memo -> hoReduceProofTreeMemo memo (structuralRestriction t) t case rslt of Left msg -> (,) <$> (Node <$> pure (ProofError msg) <*> mapM (validateProofTree calc mmemo >=> return . fst) fs) <*> pure Nothing Right seq -> (,) <$> (Node <$> pure (ProofData (tbNotation calc . show $ seq)) <*> mapM (validateProofTree calc mmemo >=> return . fst) fs) <*> pure (Just seq)
gleachkr/Carnap
Carnap-GHCJS/src/Carnap/GHCJS/Action/TreeDeductionCheck.hs
gpl-3.0
15,280
0
25
6,177
3,919
1,946
1,973
-1
-1
-- Move generator logic module Kurt.GoEngine ( genMove , simulatePlayout , EngineState(..) , newEngineState , updateEngineState , newUctTree ) where import Control.Arrow (second) import Control.Monad (liftM) import Control.Monad.Primitive (PrimState) import Control.Monad.ST (ST, runST, stToIO) import Control.Parallel.Strategies (parMap, rdeepseq) import Data.List ((\\)) import qualified Data.Map as M (map) import Data.Maybe (fromMaybe) import Data.Time.Clock (UTCTime (..), getCurrentTime, picosecondsToDiffTime) import Data.Tree (rootLabel) import Data.Tree.Zipper (findChild, fromTree, hasChildren, tree) import System.Random.MWC (Gen, Seed, restore, save, uniform, withSystemRandom) import Data.Goban.GameState import Data.Goban.Types (Color (..), Move (..), Score, Stone (..), Vertex) import Data.Goban.Utils (rateScore, winningScore) import Kurt.Config import Data.Tree.UCT import Data.Tree.UCT.GameTree (MoveNode (..), RaveMap, UCTTreeLoc, newMoveNode, newRaveMap) import Debug.TraceOrId (trace) -- import Data.Tree (drawTree) data EngineState = EngineState { getGameState :: !GameState , getUctTree :: !(UCTTreeLoc Move) , getRaveMap :: !(RaveMap Move) , boardSize :: !Int , getKomi :: !Score , getConfig :: !KurtConfig } type LoopState = (UCTTreeLoc Move, RaveMap Move) -- result from playout: score, playedMoves, path to startnode in tree type Result = (Score, [Move], [Move]) -- request for playout: gamestate, path to startnode in tree, seed type Request = (GameState, [Move], Seed) newEngineState :: KurtConfig -> EngineState newEngineState config = EngineState { getGameState = newGameState (initialBoardsize config) (initialKomi config) , getUctTree = newUctTree , getRaveMap = newRaveMap , boardSize = initialBoardsize config , getKomi = initialKomi config , getConfig = config } newUctTree :: UCTTreeLoc Move newUctTree = fromTree $ newMoveNode (trace "UCT tree root move accessed" (Move (Stone (25,25) White))) (0.5, 1) updateEngineState :: EngineState -> Move -> EngineState updateEngineState eState move = eState { getGameState = gState', getUctTree = loc' } where gState' = updateGameState gState move gState = getGameState eState loc' = case move of (Resign _) -> loc _otherwise -> if hasChildren loc then selectSubtree loc move else newUctTree loc = getUctTree eState selectSubtree :: UCTTreeLoc Move -> Move -> UCTTreeLoc Move selectSubtree loc move = loc'' where loc'' = fromTree $ tree loc' loc' = fromMaybe newUctTree $ findChild ((move ==) . nodeMove . rootLabel) loc genMove :: EngineState -> Color -> IO (Move, EngineState) genMove eState color = do now <- getCurrentTime let deadline = UTCTime { utctDay = utctDay now , utctDayTime = thinkPicosecs + utctDayTime now } let moves = nextMoves gState color let score = scoreGameState gState (if null moves then if winningScore color score then return (Pass color, eState) else return (Resign color, eState) else (do seed <- withSystemRandom (save :: Gen (PrimState IO) -> IO Seed) (loc', raveMap') <- runUCT loc gState raveMap config deadline seed let eState' = eState { getUctTree = loc', getRaveMap = raveMap' } return (bestMoveFromLoc loc' (getState gState) score, eState'))) where config = getConfig eState gState = getGameState eState loc = getUctTree eState raveMap = M.map (second ((1 +) . (`div` 2))) $ getRaveMap eState thinkPicosecs = picosecondsToDiffTime $ fromIntegral (maxTime config) * 1000000000 bestMoveFromLoc :: UCTTreeLoc Move -> GameStateStuff -> Score -> Move bestMoveFromLoc loc state score = case principalVariation loc of [] -> error "bestMoveFromLoc: principalVariation is empty" (node : _) -> if value < 0.1 then if winningScore color score then trace ("bestMoveFromLoc pass " ++ show node) Pass color else trace ("bestMoveFromLoc resign " ++ show node) Resign color else trace ("total sims: " ++ show (nodeVisits$rootLabel$tree$loc) ++ " best: " ++ show node ++ "\n") -- ++ (drawTree $ fmap show $ tree loc) move where move = nodeMove node value = nodeValue node color = nextMoveColor state runUCT :: UCTTreeLoc Move -> GameState -> RaveMap Move -> KurtConfig -> UTCTime -> Seed -> IO LoopState runUCT initLoc rootGameState initRaveMap config deadline seed00 = do uctLoop stateStream0 0 where uctLoop :: [LoopState] -> Int -> IO LoopState uctLoop [] _ = return (initLoc, initRaveMap) uctLoop (st : stateStream) !n = do _ <- return $! st let maxRuns = n >= (maxPlayouts config) now <- getCurrentTime let timeIsUp = (now > deadline) (if maxRuns || timeIsUp then return st else uctLoop stateStream (n + 1)) stateStream0 = loop0 seed00 (initLoc, initRaveMap) loop0 :: Seed -> LoopState -> [LoopState] loop0 seed0 st0 = map (\(_, st, _) -> st) $ iterate loop (seed0, st0, []) where loop (seed, st, results0) = (seed', st'', results) where st'' = updater st' r r : results = results0 ++ (parMap rdeepseq runOne requests) (st', seed', requests) = requestor st seed reqNeeded reqNeeded = max 2 $ maxThreads config - length results0 updater :: LoopState -> Result -> LoopState updater !st !res = updateTreeResult st res requestor :: LoopState -> Seed -> Int -> (LoopState, Seed, [Request]) requestor !st0 seed0 !n = last $ take n $ iterate r (st0, seed0, []) where r :: (LoopState, Seed, [Request]) -> (LoopState, Seed, [Request]) r (!st, seed, rs) = (st', seed', request : rs) where seed' = incrSeed seed st' = (loc, raveMap) (_, raveMap) = st request = (leafGameState, path, seed) (loc, (leafGameState, path)) = nextNode st nextNode :: LoopState -> (UCTTreeLoc Move, (GameState, [Move])) nextNode (!loc, !raveMap) = (loc'', (leafGameState, path)) where loc'' = backpropagate (\_x -> 0) updateNodeVisits $ expandNode loc' slHeu moves moves = nextMoves leafGameState $ nextMoveColor $ getState leafGameState leafGameState = getLeafGameState rootGameState path (loc', path) = selectLeafPath policy loc policy = policyRaveUCB1 (uctExplorationPercent config) (raveWeight config) raveMap slHeu = makeStonesAndLibertyHeuristic leafGameState config updateTreeResult :: LoopState -> Result -> LoopState updateTreeResult (!loc, !raveMap) (!score, !playedMoves, !path) = (loc', raveMap') where raveMap' = updateRaveMap raveMap (rateScore score) $ drop (length playedMoves `div` 3) playedMoves loc' = backpropagate (rateScore score) updateNodeValue $ getLeaf loc path simulatePlayout :: GameState -> IO [Move] simulatePlayout gState = do seed <- withSystemRandom (save :: Gen (PrimState IO) -> IO Seed) let gState' = getLeafGameState gState [] (oneState, playedMoves) <- stToIO $ runOneRandom gState' seed let score = scoreGameState oneState trace ("simulatePlayout " ++ show score) $ return () return $ reverse playedMoves runOne :: Request -> Result runOne (gameState, path, seed) = (score, playedMoves, path) where score = scoreGameState endState (endState, playedMoves) = runST $ runOneRandom gameState seed runOneRandom :: GameState -> Seed -> ST s (GameState, [Move]) runOneRandom initState seed = do rGen <- restore seed run initState 0 rGen [] where run :: GameState -> Int -> Gen s -> [Move] -> ST s (GameState, [Move]) run state 1000 _ moves = return (trace ("runOneRandom not done after 1000 moves " ++ show moves) state, []) run state runCount rGen moves = do move <- genMoveRand state rGen let state' = updateGameState state move case move of (Pass passColor) -> do move' <- genMoveRand state' rGen let state'' = updateGameState state' move' case move' of (Pass _) -> return (state'', moves) sm@(Move _) -> run state'' (runCount + 1) rGen (sm : Pass passColor : moves) (Resign _) -> error "runOneRandom encountered Resign" sm@(Move _) -> run state' (runCount + 1) rGen (sm : moves) (Resign _) -> error "runOneRandom encountered Resign" genMoveRand :: GameState -> Gen s -> ST s Move genMoveRand state rGen = pickSane $ freeVertices $ getState state where pickSane [] = return $ Pass color pickSane [p] = do let stone = Stone p color let sane = isSaneMove state stone return (if sane then Move stone else Pass color) pickSane ps = do p <- pick ps rGen let stone = Stone p color let sane = isSaneMove state stone (if sane then return $ Move stone else pickSane (ps \\ [p])) color = nextMoveColor $ getState state pick :: [Vertex] -> Gen s -> ST s Vertex pick as rGen = do i <- liftM (`mod` length as) $ uniform rGen return $ as !! i incrSeed :: Seed -> Seed incrSeed !seed = runST $ do gen <- restore seed x <- uniform gen _ <- return $ x + (1 :: Int) seed' <- save gen return $! seed'
lefant/kurt
src/Kurt/GoEngine.hs
gpl-3.0
11,157
0
21
4,063
3,147
1,659
1,488
-1
-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.CloudWatchLogs.PutLogEvents -- 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. -- | Uploads a batch of log events to the specified log stream. -- -- Every PutLogEvents request must include the 'sequenceToken' obtained from the -- response of the previous request. An upload in a newly created log stream -- does not require a 'sequenceToken'. -- -- The batch of events must satisfy the following constraints: The maximum -- batch size is 32,768 bytes, and this size is calculated as the sum of all -- event messages in UTF-8, plus 26 bytes for each log event. None of the log -- events in the batch can be more than 2 hours in the future. None of the log -- events in the batch can be older than 14 days or the retention period of the -- log group. The log events in the batch must be in chronological ordered by -- their 'timestamp'. The maximum number of log events in a batch is 1,000. -- -- <http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html> module Network.AWS.CloudWatchLogs.PutLogEvents ( -- * Request PutLogEvents -- ** Request constructor , putLogEvents -- ** Request lenses , pleLogEvents , pleLogGroupName , pleLogStreamName , pleSequenceToken -- * Response , PutLogEventsResponse -- ** Response constructor , putLogEventsResponse -- ** Response lenses , plerNextSequenceToken ) where import Network.AWS.Prelude import Network.AWS.Request.JSON import Network.AWS.CloudWatchLogs.Types import qualified GHC.Exts data PutLogEvents = PutLogEvents { _pleLogEvents :: List1 "logEvents" InputLogEvent , _pleLogGroupName :: Text , _pleLogStreamName :: Text , _pleSequenceToken :: Maybe Text } deriving (Eq, Read, Show) -- | 'PutLogEvents' constructor. -- -- The fields accessible through corresponding lenses are: -- -- * 'pleLogEvents' @::@ 'NonEmpty' 'InputLogEvent' -- -- * 'pleLogGroupName' @::@ 'Text' -- -- * 'pleLogStreamName' @::@ 'Text' -- -- * 'pleSequenceToken' @::@ 'Maybe' 'Text' -- putLogEvents :: Text -- ^ 'pleLogGroupName' -> Text -- ^ 'pleLogStreamName' -> NonEmpty InputLogEvent -- ^ 'pleLogEvents' -> PutLogEvents putLogEvents p1 p2 p3 = PutLogEvents { _pleLogGroupName = p1 , _pleLogStreamName = p2 , _pleLogEvents = withIso _List1 (const id) p3 , _pleSequenceToken = Nothing } pleLogEvents :: Lens' PutLogEvents (NonEmpty InputLogEvent) pleLogEvents = lens _pleLogEvents (\s a -> s { _pleLogEvents = a }) . _List1 pleLogGroupName :: Lens' PutLogEvents Text pleLogGroupName = lens _pleLogGroupName (\s a -> s { _pleLogGroupName = a }) pleLogStreamName :: Lens' PutLogEvents Text pleLogStreamName = lens _pleLogStreamName (\s a -> s { _pleLogStreamName = a }) -- | A string token that must be obtained from the response of the previous 'PutLogEvents' request. pleSequenceToken :: Lens' PutLogEvents (Maybe Text) pleSequenceToken = lens _pleSequenceToken (\s a -> s { _pleSequenceToken = a }) newtype PutLogEventsResponse = PutLogEventsResponse { _plerNextSequenceToken :: Maybe Text } deriving (Eq, Ord, Read, Show, Monoid) -- | 'PutLogEventsResponse' constructor. -- -- The fields accessible through corresponding lenses are: -- -- * 'plerNextSequenceToken' @::@ 'Maybe' 'Text' -- putLogEventsResponse :: PutLogEventsResponse putLogEventsResponse = PutLogEventsResponse { _plerNextSequenceToken = Nothing } plerNextSequenceToken :: Lens' PutLogEventsResponse (Maybe Text) plerNextSequenceToken = lens _plerNextSequenceToken (\s a -> s { _plerNextSequenceToken = a }) instance ToPath PutLogEvents where toPath = const "/" instance ToQuery PutLogEvents where toQuery = const mempty instance ToHeaders PutLogEvents instance ToJSON PutLogEvents where toJSON PutLogEvents{..} = object [ "logGroupName" .= _pleLogGroupName , "logStreamName" .= _pleLogStreamName , "logEvents" .= _pleLogEvents , "sequenceToken" .= _pleSequenceToken ] instance AWSRequest PutLogEvents where type Sv PutLogEvents = CloudWatchLogs type Rs PutLogEvents = PutLogEventsResponse request = post "PutLogEvents" response = jsonResponse instance FromJSON PutLogEventsResponse where parseJSON = withObject "PutLogEventsResponse" $ \o -> PutLogEventsResponse <$> o .:? "nextSequenceToken"
dysinger/amazonka
amazonka-cloudwatch-logs/gen/Network/AWS/CloudWatchLogs/PutLogEvents.hs
mpl-2.0
5,362
0
10
1,135
687
412
275
76
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.GamesConfiguration.AchievementConfigurations.Get -- 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) -- -- Retrieves the metadata of the achievement configuration with the given -- ID. -- -- /See:/ <https://developers.google.com/games/ Google Play Game Services Publishing API Reference> for @gamesConfiguration.achievementConfigurations.get@. module Network.Google.Resource.GamesConfiguration.AchievementConfigurations.Get ( -- * REST Resource AchievementConfigurationsGetResource -- * Creating a Request , achievementConfigurationsGet , AchievementConfigurationsGet -- * Request Lenses , acgXgafv , acgUploadProtocol , acgAchievementId , acgAccessToken , acgUploadType , acgCallback ) where import Network.Google.GamesConfiguration.Types import Network.Google.Prelude -- | A resource alias for @gamesConfiguration.achievementConfigurations.get@ method which the -- 'AchievementConfigurationsGet' request conforms to. type AchievementConfigurationsGetResource = "games" :> "v1configuration" :> "achievements" :> Capture "achievementId" Text :> QueryParam "$.xgafv" Xgafv :> QueryParam "upload_protocol" Text :> QueryParam "access_token" Text :> QueryParam "uploadType" Text :> QueryParam "callback" Text :> QueryParam "alt" AltJSON :> Get '[JSON] AchievementConfiguration -- | Retrieves the metadata of the achievement configuration with the given -- ID. -- -- /See:/ 'achievementConfigurationsGet' smart constructor. data AchievementConfigurationsGet = AchievementConfigurationsGet' { _acgXgafv :: !(Maybe Xgafv) , _acgUploadProtocol :: !(Maybe Text) , _acgAchievementId :: !Text , _acgAccessToken :: !(Maybe Text) , _acgUploadType :: !(Maybe Text) , _acgCallback :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AchievementConfigurationsGet' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'acgXgafv' -- -- * 'acgUploadProtocol' -- -- * 'acgAchievementId' -- -- * 'acgAccessToken' -- -- * 'acgUploadType' -- -- * 'acgCallback' achievementConfigurationsGet :: Text -- ^ 'acgAchievementId' -> AchievementConfigurationsGet achievementConfigurationsGet pAcgAchievementId_ = AchievementConfigurationsGet' { _acgXgafv = Nothing , _acgUploadProtocol = Nothing , _acgAchievementId = pAcgAchievementId_ , _acgAccessToken = Nothing , _acgUploadType = Nothing , _acgCallback = Nothing } -- | V1 error format. acgXgafv :: Lens' AchievementConfigurationsGet (Maybe Xgafv) acgXgafv = lens _acgXgafv (\ s a -> s{_acgXgafv = a}) -- | Upload protocol for media (e.g. \"raw\", \"multipart\"). acgUploadProtocol :: Lens' AchievementConfigurationsGet (Maybe Text) acgUploadProtocol = lens _acgUploadProtocol (\ s a -> s{_acgUploadProtocol = a}) -- | The ID of the achievement used by this method. acgAchievementId :: Lens' AchievementConfigurationsGet Text acgAchievementId = lens _acgAchievementId (\ s a -> s{_acgAchievementId = a}) -- | OAuth access token. acgAccessToken :: Lens' AchievementConfigurationsGet (Maybe Text) acgAccessToken = lens _acgAccessToken (\ s a -> s{_acgAccessToken = a}) -- | Legacy upload protocol for media (e.g. \"media\", \"multipart\"). acgUploadType :: Lens' AchievementConfigurationsGet (Maybe Text) acgUploadType = lens _acgUploadType (\ s a -> s{_acgUploadType = a}) -- | JSONP acgCallback :: Lens' AchievementConfigurationsGet (Maybe Text) acgCallback = lens _acgCallback (\ s a -> s{_acgCallback = a}) instance GoogleRequest AchievementConfigurationsGet where type Rs AchievementConfigurationsGet = AchievementConfiguration type Scopes AchievementConfigurationsGet = '["https://www.googleapis.com/auth/androidpublisher"] requestClient AchievementConfigurationsGet'{..} = go _acgAchievementId _acgXgafv _acgUploadProtocol _acgAccessToken _acgUploadType _acgCallback (Just AltJSON) gamesConfigurationService where go = buildClient (Proxy :: Proxy AchievementConfigurationsGetResource) mempty
brendanhay/gogol
gogol-games-configuration/gen/Network/Google/Resource/GamesConfiguration/AchievementConfigurations/Get.hs
mpl-2.0
5,179
0
17
1,145
704
411
293
106
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.Storage.Objects.Update -- 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 object\'s metadata. -- -- /See:/ <https://developers.google.com/storage/docs/json_api/ Cloud Storage JSON API Reference> for @storage.objects.update@. module Network.Google.Resource.Storage.Objects.Update ( -- * REST Resource ObjectsUpdateResource -- * Creating a Request , objectsUpdate , ObjectsUpdate -- * Request Lenses , ouIfMetagenerationMatch , ouIfGenerationNotMatch , ouIfGenerationMatch , ouPredefinedACL , ouBucket , ouPayload , ouUserProject , ouIfMetagenerationNotMatch , ouObject , ouProjection , ouProvisionalUserProject , ouGeneration ) where import Network.Google.Prelude import Network.Google.Storage.Types -- | A resource alias for @storage.objects.update@ method which the -- 'ObjectsUpdate' request conforms to. type ObjectsUpdateResource = "storage" :> "v1" :> "b" :> Capture "bucket" Text :> "o" :> Capture "object" Text :> QueryParam "ifMetagenerationMatch" (Textual Int64) :> QueryParam "ifGenerationNotMatch" (Textual Int64) :> QueryParam "ifGenerationMatch" (Textual Int64) :> QueryParam "predefinedAcl" ObjectsUpdatePredefinedACL :> QueryParam "userProject" Text :> QueryParam "ifMetagenerationNotMatch" (Textual Int64) :> QueryParam "projection" ObjectsUpdateProjection :> QueryParam "provisionalUserProject" Text :> QueryParam "generation" (Textual Int64) :> QueryParam "alt" AltJSON :> ReqBody '[JSON] Object :> Put '[JSON] Object -- | Updates an object\'s metadata. -- -- /See:/ 'objectsUpdate' smart constructor. data ObjectsUpdate = ObjectsUpdate' { _ouIfMetagenerationMatch :: !(Maybe (Textual Int64)) , _ouIfGenerationNotMatch :: !(Maybe (Textual Int64)) , _ouIfGenerationMatch :: !(Maybe (Textual Int64)) , _ouPredefinedACL :: !(Maybe ObjectsUpdatePredefinedACL) , _ouBucket :: !Text , _ouPayload :: !Object , _ouUserProject :: !(Maybe Text) , _ouIfMetagenerationNotMatch :: !(Maybe (Textual Int64)) , _ouObject :: !Text , _ouProjection :: !(Maybe ObjectsUpdateProjection) , _ouProvisionalUserProject :: !(Maybe Text) , _ouGeneration :: !(Maybe (Textual Int64)) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ObjectsUpdate' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ouIfMetagenerationMatch' -- -- * 'ouIfGenerationNotMatch' -- -- * 'ouIfGenerationMatch' -- -- * 'ouPredefinedACL' -- -- * 'ouBucket' -- -- * 'ouPayload' -- -- * 'ouUserProject' -- -- * 'ouIfMetagenerationNotMatch' -- -- * 'ouObject' -- -- * 'ouProjection' -- -- * 'ouProvisionalUserProject' -- -- * 'ouGeneration' objectsUpdate :: Text -- ^ 'ouBucket' -> Object -- ^ 'ouPayload' -> Text -- ^ 'ouObject' -> ObjectsUpdate objectsUpdate pOuBucket_ pOuPayload_ pOuObject_ = ObjectsUpdate' { _ouIfMetagenerationMatch = Nothing , _ouIfGenerationNotMatch = Nothing , _ouIfGenerationMatch = Nothing , _ouPredefinedACL = Nothing , _ouBucket = pOuBucket_ , _ouPayload = pOuPayload_ , _ouUserProject = Nothing , _ouIfMetagenerationNotMatch = Nothing , _ouObject = pOuObject_ , _ouProjection = Nothing , _ouProvisionalUserProject = Nothing , _ouGeneration = Nothing } -- | Makes the operation conditional on whether the object\'s current -- metageneration matches the given value. ouIfMetagenerationMatch :: Lens' ObjectsUpdate (Maybe Int64) ouIfMetagenerationMatch = lens _ouIfMetagenerationMatch (\ s a -> s{_ouIfMetagenerationMatch = a}) . mapping _Coerce -- | Makes the operation conditional on whether the object\'s current -- generation does not match the given value. If no live object exists, the -- precondition fails. Setting to 0 makes the operation succeed only if -- there is a live version of the object. ouIfGenerationNotMatch :: Lens' ObjectsUpdate (Maybe Int64) ouIfGenerationNotMatch = lens _ouIfGenerationNotMatch (\ s a -> s{_ouIfGenerationNotMatch = a}) . mapping _Coerce -- | Makes the operation conditional on whether the object\'s current -- generation matches the given value. Setting to 0 makes the operation -- succeed only if there are no live versions of the object. ouIfGenerationMatch :: Lens' ObjectsUpdate (Maybe Int64) ouIfGenerationMatch = lens _ouIfGenerationMatch (\ s a -> s{_ouIfGenerationMatch = a}) . mapping _Coerce -- | Apply a predefined set of access controls to this object. ouPredefinedACL :: Lens' ObjectsUpdate (Maybe ObjectsUpdatePredefinedACL) ouPredefinedACL = lens _ouPredefinedACL (\ s a -> s{_ouPredefinedACL = a}) -- | Name of the bucket in which the object resides. ouBucket :: Lens' ObjectsUpdate Text ouBucket = lens _ouBucket (\ s a -> s{_ouBucket = a}) -- | Multipart request metadata. ouPayload :: Lens' ObjectsUpdate Object ouPayload = lens _ouPayload (\ s a -> s{_ouPayload = a}) -- | The project to be billed for this request. Required for Requester Pays -- buckets. ouUserProject :: Lens' ObjectsUpdate (Maybe Text) ouUserProject = lens _ouUserProject (\ s a -> s{_ouUserProject = a}) -- | Makes the operation conditional on whether the object\'s current -- metageneration does not match the given value. ouIfMetagenerationNotMatch :: Lens' ObjectsUpdate (Maybe Int64) ouIfMetagenerationNotMatch = lens _ouIfMetagenerationNotMatch (\ s a -> s{_ouIfMetagenerationNotMatch = a}) . mapping _Coerce -- | Name of the object. For information about how to URL encode object names -- to be path safe, see Encoding URI Path Parts. ouObject :: Lens' ObjectsUpdate Text ouObject = lens _ouObject (\ s a -> s{_ouObject = a}) -- | Set of properties to return. Defaults to full. ouProjection :: Lens' ObjectsUpdate (Maybe ObjectsUpdateProjection) ouProjection = lens _ouProjection (\ s a -> s{_ouProjection = a}) -- | The project to be billed for this request if the target bucket is -- requester-pays bucket. ouProvisionalUserProject :: Lens' ObjectsUpdate (Maybe Text) ouProvisionalUserProject = lens _ouProvisionalUserProject (\ s a -> s{_ouProvisionalUserProject = a}) -- | If present, selects a specific revision of this object (as opposed to -- the latest version, the default). ouGeneration :: Lens' ObjectsUpdate (Maybe Int64) ouGeneration = lens _ouGeneration (\ s a -> s{_ouGeneration = a}) . mapping _Coerce instance GoogleRequest ObjectsUpdate where type Rs ObjectsUpdate = Object type Scopes ObjectsUpdate = '["https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/devstorage.full_control"] requestClient ObjectsUpdate'{..} = go _ouBucket _ouObject _ouIfMetagenerationMatch _ouIfGenerationNotMatch _ouIfGenerationMatch _ouPredefinedACL _ouUserProject _ouIfMetagenerationNotMatch _ouProjection _ouProvisionalUserProject _ouGeneration (Just AltJSON) _ouPayload storageService where go = buildClient (Proxy :: Proxy ObjectsUpdateResource) mempty
brendanhay/gogol
gogol-storage/gen/Network/Google/Resource/Storage/Objects/Update.hs
mpl-2.0
8,463
0
24
2,060
1,290
738
552
177
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.WebProperties.Update -- 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 web property. -- -- /See:/ <https://developers.google.com/analytics/ Google Analytics API Reference> for @analytics.management.webproperties.update@. module Network.Google.Resource.Analytics.Management.WebProperties.Update ( -- * REST Resource ManagementWebPropertiesUpdateResource -- * Creating a Request , managementWebPropertiesUpdate , ManagementWebPropertiesUpdate -- * Request Lenses , mwpuWebPropertyId , mwpuPayload , mwpuAccountId ) where import Network.Google.Analytics.Types import Network.Google.Prelude -- | A resource alias for @analytics.management.webproperties.update@ method which the -- 'ManagementWebPropertiesUpdate' request conforms to. type ManagementWebPropertiesUpdateResource = "analytics" :> "v3" :> "management" :> "accounts" :> Capture "accountId" Text :> "webproperties" :> Capture "webPropertyId" Text :> QueryParam "alt" AltJSON :> ReqBody '[JSON] WebProperty :> Put '[JSON] WebProperty -- | Updates an existing web property. -- -- /See:/ 'managementWebPropertiesUpdate' smart constructor. data ManagementWebPropertiesUpdate = ManagementWebPropertiesUpdate' { _mwpuWebPropertyId :: !Text , _mwpuPayload :: !WebProperty , _mwpuAccountId :: !Text } deriving (Eq,Show,Data,Typeable,Generic) -- | Creates a value of 'ManagementWebPropertiesUpdate' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mwpuWebPropertyId' -- -- * 'mwpuPayload' -- -- * 'mwpuAccountId' managementWebPropertiesUpdate :: Text -- ^ 'mwpuWebPropertyId' -> WebProperty -- ^ 'mwpuPayload' -> Text -- ^ 'mwpuAccountId' -> ManagementWebPropertiesUpdate managementWebPropertiesUpdate pMwpuWebPropertyId_ pMwpuPayload_ pMwpuAccountId_ = ManagementWebPropertiesUpdate' { _mwpuWebPropertyId = pMwpuWebPropertyId_ , _mwpuPayload = pMwpuPayload_ , _mwpuAccountId = pMwpuAccountId_ } -- | Web property ID mwpuWebPropertyId :: Lens' ManagementWebPropertiesUpdate Text mwpuWebPropertyId = lens _mwpuWebPropertyId (\ s a -> s{_mwpuWebPropertyId = a}) -- | Multipart request metadata. mwpuPayload :: Lens' ManagementWebPropertiesUpdate WebProperty mwpuPayload = lens _mwpuPayload (\ s a -> s{_mwpuPayload = a}) -- | Account ID to which the web property belongs mwpuAccountId :: Lens' ManagementWebPropertiesUpdate Text mwpuAccountId = lens _mwpuAccountId (\ s a -> s{_mwpuAccountId = a}) instance GoogleRequest ManagementWebPropertiesUpdate where type Rs ManagementWebPropertiesUpdate = WebProperty type Scopes ManagementWebPropertiesUpdate = '["https://www.googleapis.com/auth/analytics.edit"] requestClient ManagementWebPropertiesUpdate'{..} = go _mwpuAccountId _mwpuWebPropertyId (Just AltJSON) _mwpuPayload analyticsService where go = buildClient (Proxy :: Proxy ManagementWebPropertiesUpdateResource) mempty
rueshyna/gogol
gogol-analytics/gen/Network/Google/Resource/Analytics/Management/WebProperties/Update.hs
mpl-2.0
4,070
0
16
926
466
278
188
78
1
{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} module PontariusService.Types where import Control.Applicative import Control.Lens import Control.Monad.Reader import DBus import DBus.Signal import DBus.Types import Data.ByteString (ByteString) import Data.Set (Set) import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as Text import Data.Time.Clock (UTCTime) import Data.Time.Clock.POSIX as Time import Data.Typeable import Data.UUID (UUID) import qualified Data.UUID as UUID import Data.Word import qualified Network.Xmpp as Xmpp type SSID = ByteString data BatchLink = BatchLinkIgnore | BatchLinkExisting UUID | BatchLinkNewContact Text instance Representable BatchLink where type RepType BatchLink = 'TypeStruct '[ 'DBusSimpleType 'TypeByte , 'DBusSimpleType 'TypeString] toRep BatchLinkIgnore = DBVStruct (StructCons (DBVByte 0) (StructSingleton (DBVString ""))) toRep (BatchLinkExisting uuid) = DBVStruct (StructCons (DBVByte 1) (StructSingleton (toRep uuid))) toRep (BatchLinkNewContact name) = DBVStruct (StructCons (DBVByte 2) (StructSingleton (toRep name))) fromRep (DBVStruct (StructCons (DBVByte 0) (StructSingleton _))) = Just BatchLinkIgnore fromRep (DBVStruct (StructCons (DBVByte 1) (StructSingleton uuid))) = BatchLinkExisting <$> (fromRep uuid) fromRep (DBVStruct (StructCons (DBVByte 2) (StructSingleton (DBVString name)))) = Just $ BatchLinkNewContact name data PontariusState = CredentialsUnset | IdentityNotFound | IdentitiesAvailable | CreatingIdentity | Disabled | Authenticating | Authenticated | AuthenticationDenied deriving (Show, Eq) data AccountState = AccountEnabled | AccountDisabled deriving (Show, Eq) data PeerStatus = Unavailable | Available deriving (Show, Eq) instance Representable UTCTime where type RepType UTCTime = 'DBusSimpleType 'TypeUInt32 toRep = DBVUInt32 . round . utcTimeToPOSIXSeconds fromRep (DBVUInt32 x) = Just . posixSecondsToUTCTime $ fromIntegral x instance DBus.Representable Xmpp.Jid where type RepType Xmpp.Jid = 'DBusSimpleType 'TypeString toRep = DBus.DBVString . Xmpp.jidToText fromRep (DBus.DBVString s) = Xmpp.jidFromText s instance (Ord a, DBus.Representable a) => DBus.Representable (Set a) where type RepType (Set a) = RepType [a] toRep = toRep . Set.toList fromRep = fmap Set.fromList . fromRep instance Representable (Maybe KeyID) where type RepType (Maybe KeyID) = RepType KeyID toRep Nothing = toRep Text.empty toRep (Just k) = toRep k fromRep v = case fromRep v of Nothing -> Nothing Just v' | Text.null v' -> Just Nothing | otherwise -> Just (Just v') instance Representable (Maybe UTCTime) where type RepType (Maybe UTCTime) = RepType UTCTime toRep Nothing = toRep (0 :: Word32) toRep (Just t) = toRep t fromRep v = case fromRep v of Nothing -> Nothing Just t' | t' == (0 :: Word32) -> Just Nothing | otherwise -> Just . Just $ posixSecondsToUTCTime $ fromIntegral t' type KeyID = Text type SessionID = ByteString data ConnectionStatus = Connected | Disconnected deriving (Show, Eq, Ord) data InitResponse = KeyOK | SelectKey data Ent = Ent { entityJid :: Xmpp.Jid , entityDisplayName :: Text , entityDescription :: Text } deriving (Show, Typeable) data AkeEvent = AkeEvent { akeEventStart :: UTCTime , akeEventSuccessfull :: Bool , akeEventPeerJid :: Xmpp.Jid , akeEventOurJid :: Xmpp.Jid , akeEventPeerkeyID :: KeyID , akeEventOurkeyID :: KeyID } deriving (Show, Eq) data ChallengeEvent = ChallengeEvent { challengeEventChallengeOutgoing :: Bool , challengeEventStarted :: UTCTime , challengeEventCompleted :: UTCTime , challengeEventQuestion :: Text , challengeEventResult :: Text } deriving (Show, Eq) data RevocationEvent = RevocationEvent { revocationEventKeyID :: KeyID , revocationEventTime :: UTCTime } data RevocationSignalEvent = RevocationlEvent { revocationSignalEventKeyID :: KeyID , revocationSignalEventTime :: UTCTime } makePrisms ''PontariusState makeRepresentable ''PontariusState makePrisms ''AccountState makeRepresentable ''AccountState makeRepresentable ''RevocationSignalEvent makeRepresentable ''ConnectionStatus makeRepresentable ''InitResponse makeRepresentable ''Ent makeRepresentable ''AkeEvent makeRepresentable ''ChallengeEvent makeRepresentable ''RevocationEvent makeRepresentable ''PeerStatus instance DBus.Representable UUID where type RepType UUID = RepType Text toRep = toRep . Text.pack . UUID.toString fromRep = UUID.fromString . Text.unpack <=< fromRep data AddPeerFailed = AddPeerFailed { addPeerFailedPeer :: !Xmpp.Jid , addPeerFailedReason :: !Text } deriving (Show) makeRepresentable ''AddPeerFailed makeLensesWith camelCaseFields ''AddPeerFailed data RemovePeerFailed = RemovePeerFailed { removePeerFailedPeer :: !Xmpp.Jid , removePeerFailedReason :: !Text } deriving (Show) makeRepresentable ''RemovePeerFailed makeLensesWith camelCaseFields ''RemovePeerFailed
pontarius/pontarius-service
source/PontariusService/Types.hs
agpl-3.0
6,475
0
14
1,907
1,507
798
709
-1
-1
-- | This module provides the data type and parser for a trait file module Trait ( Trait(..) , defaultTrait , trait ) where import Maker import Modifier import Scoped(Label) data Trait = Trait { trait_name :: Label , agnatic :: Bool , birth :: Double -- ^ Chance of being assigned on birth. Default 0 , cached :: Bool , cannot_inherit :: Bool , cannot_marry :: Bool , caste_tier :: Maybe Int -- ^ The trait is a caste trait, and this -- defines the order of the castes. , customizer :: Bool -- ^ Blocks the trait from being available in the Designer , education :: Bool , immortal :: Bool , in_hiding :: Bool , inbred :: Bool , incapacitating :: Bool , inherit_chance :: Double , is_epidemic :: Bool , is_health :: Bool , is_illness :: Bool , leader :: Bool , leadership_traits :: Maybe Int , lifestyle :: Bool , opposites :: [Label] , personality :: Bool , prevent_decadence :: Bool , priest :: Bool , pilgrimage :: Bool , random :: Bool , rebel_inherited :: Bool -- ^ Unknown purpose , religious :: Bool , religious_branch :: Maybe Label , ruler_designer_cost :: Maybe Int -- ^ The postive cost in the Ruler Designer , tolerates :: [Label] -- ^ A list of the religion groups tolerated by this character , modifiers :: [Modifier] } deriving (Eq, Ord, Show) trait :: Maker Trait trait = Trait <$> label key <*> boolProp "agnatic" <*> ((number ~@ "birth") `defaultingTo` 0) <*> boolProp "cached" <*> boolProp "cannot_inherit" <*> boolProp "cannot_marry" <*> intProp "caste_tier" <*> boolProp "customizer" <*> boolProp "education" <*> boolProp "immortal" <*> boolProp "in_hiding" <*> boolProp "inbred" <*> boolProp "incapacitating" <*> (number ~@ "inherit_chance") `defaultingTo` 0 <*> boolProp "is_epidemic" <*> boolProp "is_health" <*> boolProp "is_illness" <*> boolProp "leader" <*> intProp "leadership_traits" <*> boolProp "lifestyle" <*> (opposites @@ "opposites") `defaultingTo` [] <*> boolProp "personality" <*> boolProp "prevent_decadence" <*> boolProp "priest" <*> boolProp "pilgrimage" <*> boolProp "random" <*> boolProp "rebel_inherited" <*> boolProp "religious" <*> fetchString @? "religious_branch" <*> intProp "ruler_designer_cost" <*> tolerations <*> tryMap modifier where boolProp key = ((fetchBool @@ key) `defaultingTo` False) <?> key intProp :: Label β†’ Maker (Maybe Int) intProp key = fmap round <$> number ~? key <?> key opposites = error "opposite traits are not implemented" tolerations = return [] defaultTrait :: Trait defaultTrait = Trait { trait_name = undefined, agnatic = False, birth = 0, cached = False , cannot_inherit = False, cannot_marry = False, caste_tier = Nothing , customizer = False, education = False, immortal = False , in_hiding = False, inbred = False, incapacitating = False , inherit_chance = 0, is_epidemic = False, is_health = False , is_illness = False, leader = False, leadership_traits = Nothing , lifestyle = False, opposites = [], personality = False , prevent_decadence = False, priest = False, pilgrimage = False , random = False, rebel_inherited = False, religious = False , religious_branch = Nothing, ruler_designer_cost = Nothing , tolerates = [], modifiers = [] }
joelwilliamson/validator
Trait.hs
agpl-3.0
3,593
0
41
970
847
492
355
-1
-1
-- Copyright (C) 2016-2017 Red Hat, Inc. -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- -- This library 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 -- Lesser General Public License for more details. -- -- You should have received a copy of the GNU Lesser General Public -- License along with this library; if not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE OverloadedStrings #-} module BDCS.RPM.Sources(mkSource) where import Database.Esqueleto(Key) import qualified Data.Text as T import BDCS.DB(Projects, Sources(..)) import BDCS.Exceptions(DBException(..), throwIfNothing) import RPM.Tags(Tag, findStringTag) mkSource :: [Tag] -> Key Projects -> Sources mkSource tags projectId = let license = T.pack $ findStringTag "License" tags `throwIfNothing` MissingRPMTag "License" version = T.pack $ findStringTag "Version" tags `throwIfNothing` MissingRPMTag "Version" -- FIXME: Where to get this from? source_ref = "SOURCE_REF" in Sources projectId license version source_ref
dashea/bdcs
importer/BDCS/RPM/Sources.hs
lgpl-2.1
1,380
0
11
234
192
116
76
13
1
{-| Module : Main-nowx Description : ΠœΠΎΠ΄ΡƒΠ»ΡŒ с Ρ‚ΠΎΡ‡ΠΊΠΎΠΉ Π²Ρ…ΠΎΠ΄Π° для консольной вСрсии прилоТСния License : LGPLv3 -} module Main where import Kernel import PlayerConsole import DrawingConsole import Controller import AIPlayer -- | Π’ΠΎΡ‡ΠΊΠ° Π²Ρ…ΠΎΠ΄Π° для консольной вСрсии ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹ main :: IO () main = do winner <- run cfg player1 player2 [drawing] case winner of Winner color -> putStrLn $ (show color) ++ " player wins!" DrawBy color -> putStrLn $ "It's a trap for " ++ (show color) ++ " player!" return () where cfg = russianConfig game = createGame cfg player1 = createAIPlayer 1 2 player2 = createPlayerConsole drawing = createDrawingConsole
cmc-haskell-2015/checkers
src/Main-nowx.hs
lgpl-3.0
805
0
13
188
155
81
74
18
2
{-# LANGUAGE OverloadedStrings #-} module Mdb.Status ( doStatus ) where import Control.Monad ( when ) import Control.Monad.Catch (MonadMask) import Control.Monad.IO.Class ( MonadIO, liftIO ) import Control.Monad.Logger ( logWarnN, logDebugN, logInfoN ) import Control.Monad.Reader ( ask ) import qualified Database.SQLite.Simple as SQL import Data.Monoid ( (<>) ) import qualified Data.Text as T import System.IO.Error ( tryIOError ) import System.Posix.Files ( getFileStatus, modificationTimeHiRes ) import Mdb.CmdLine ( OptStatus(..) ) import Mdb.Database ( MDB, dbExecute, runMDB', withConnection ) import Mdb.Types ( FileId ) doStatus :: (MonadMask m, MonadIO m) => OptStatus -> MDB m () doStatus = withFilesSeq . checkFile type FileInfo = (FileId, FilePath) withFilesSeq :: (MonadIO m, MonadMask m) => (FileInfo -> MDB IO ()) -> MDB m () withFilesSeq f = withConnection $ \c -> do mdb <- ask liftIO $ SQL.withStatement c "SELECT file_id, file_name FROM file ORDER BY file_id" $ \stmt -> let go = SQL.nextRow stmt >>= \mfi -> case mfi of Nothing -> return () Just fi -> (runMDB' mdb $ f fi) >> go in go checkFile :: (MonadIO m, MonadMask m) => OptStatus -> FileInfo -> MDB m () checkFile op (fid, fp) = do efs <- liftIO $ tryIOError $ getFileStatus fp case efs of Left ioe -> do logWarnN $ T.pack ( show ioe ) when (removeMissing op) $ do logInfoN $ "removing file with ID " <> (T.pack $ show fid) dbExecute "DELETE FROM file WHERE file_id = ?" (SQL.Only fid) Right fs -> logDebugN $ T.pack (show $ modificationTimeHiRes fs)
waldheinz/mdb
src/lib/Mdb/Status.hs
apache-2.0
1,802
0
23
523
569
307
262
37
2
module Serf.Event where import Serf.Member import Control.Applicative import Control.Monad.IO.Class import System.Environment import System.Exit import System.IO import Text.Parsec type SerfError = String data SerfEvent = MemberJoin Member | MemberLeave Member | MemberFailed Member | MemberUpdate Member | MemberReap Member | User | Query | Unknown String getSerfEvent :: IO (Either SerfError SerfEvent) getSerfEvent = getEnv "SERF_EVENT" >>= fromString where fromString :: String -> IO (Either SerfError SerfEvent) fromString "member-join" = readMemberEvent MemberJoin fromString "member-leave" = readMemberEvent MemberLeave fromString "member-failed" = readMemberEvent MemberFailed fromString "member-update" = readMemberEvent MemberUpdate fromString "member-reap" = readMemberEvent MemberReap fromString "user" = return $ Right User fromString "query" = return $ Right Query fromString unk = return . Right $ Unknown unk readMemberEvent :: (Member -> SerfEvent) -> IO (Either SerfError SerfEvent) readMemberEvent f = addMember f <$> readMember addMember :: (Member -> SerfEvent) -> Either ParseError Member -> Either SerfError SerfEvent addMember _ (Left err) = Left $ show err addMember f (Right m) = Right $ f m readMember :: IO (Either ParseError Member) readMember = memberFromString <$> getLine isMemberEvent :: SerfEvent -> Bool isMemberEvent (MemberJoin _) = True isMemberEvent (MemberLeave _) = True isMemberEvent (MemberFailed _) = True isMemberEvent (MemberUpdate _) = True isMemberEvent (MemberReap _) = True isMemberEvent _ = False type EventHandler m = SerfEvent -> m () handleEventWith :: MonadIO m => EventHandler m -> m () handleEventWith hdlr = do evt <- liftIO getSerfEvent case evt of Left err -> liftIO $ hPutStrLn stderr err >> exitFailure Right ev -> hdlr ev
lstephen/box
src/main/ansible/roles/serf/files/Serf/Event.hs
apache-2.0
2,110
0
12
576
572
289
283
51
9
{-# LANGUAGE ExplicitForAll, Rank2Types #-} -- | An implementation of Reagents (http://www.mpi-sws.org/~turon/reagents.pdf) -- NOTE: currently this is just a very tiny core of the Reagent design. Needs -- lots of work. module Data.Concurrent.Internal.Reagent where import Data.IORef import Data.Atomics import Prelude hiding (succ, fail) type Reagent a = forall b. (a -> IO b) -> IO b -> IO b -- | Execute a Reagent. {-# INLINE react #-} react :: Reagent a -> IO a react r = try where try = r finish try finish x = return x -- | Like atomicModifyIORef, but uses CAS and permits the update action to force -- a retry by returning Nothing {-# INLINE atomicUpdate #-} atomicUpdate :: IORef a -> (a -> Maybe (a, b)) -> Reagent b atomicUpdate r f succ fail = do curTicket <- readForCAS r let cur = peekTicket curTicket case f cur of Just (new, out) -> do (done, _) <- casIORef r curTicket new if done then succ out else fail Nothing -> fail atomicUpdate_ :: IORef a -> (a -> a) -> Reagent () atomicUpdate_ r f = atomicUpdate r (\x -> Just (f x, ())) postCommit :: Reagent a -> (a -> IO b) -> Reagent b postCommit r f succ fail = r (\x -> f x >>= succ) fail choice :: Reagent a -> Reagent a -> Reagent a choice _ _ = error "TODO"
rrnewton/concurrent-skiplist
src/Data/Concurrent/Internal/Reagent.hs
apache-2.0
1,287
0
13
297
420
216
204
27
3
{-# LANGUAGE TemplateHaskell #-} -- Copyright (C) 2010-2012 John Millikin <[email protected]> -- -- 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. module DBusTests.Signature (test_Signature) where import Test.Chell import Test.Chell.QuickCheck import Test.QuickCheck hiding ((.&.), property) import DBus import DBusTests.Util test_Signature :: Suite test_Signature = suite "Signature" [ test_BuildSignature , test_ParseSignature , test_ParseInvalid , test_FormatSignature , test_IsAtom , test_ShowType ] test_BuildSignature :: Test test_BuildSignature = property "signature" prop where prop = forAll gen_SignatureTypes check check types = case signature types of Nothing -> False Just sig -> signatureTypes sig == types test_ParseSignature :: Test test_ParseSignature = property "parseSignature" prop where prop = forAll gen_SignatureString check check (s, types) = case parseSignature s of Nothing -> False Just sig -> signatureTypes sig == types test_ParseInvalid :: Test test_ParseInvalid = assertions "parse-invalid" $ do -- at most 255 characters $expect (just (parseSignature (replicate 254 'y'))) $expect (just (parseSignature (replicate 255 'y'))) $expect (nothing (parseSignature (replicate 256 'y'))) -- length also enforced by 'signature' $expect (just (signature (replicate 255 TypeWord8))) $expect (nothing (signature (replicate 256 TypeWord8))) -- struct code $expect (nothing (parseSignature "r")) -- empty struct $expect (nothing (parseSignature "()")) $expect (nothing (signature [TypeStructure []])) -- dict code $expect (nothing (parseSignature "e")) -- non-atomic dict key $expect (nothing (parseSignature "a{vy}")) $expect (nothing (signature [TypeDictionary TypeVariant TypeVariant])) test_FormatSignature :: Test test_FormatSignature = property "formatSignature" prop where prop = forAll gen_SignatureString check check (s, _) = let Just sig = parseSignature s in formatSignature sig == s test_IsAtom :: Test test_IsAtom = assertions "IsAtom" $ do let Just sig = signature [] assertAtom TypeSignature sig test_ShowType :: Test test_ShowType = assertions "show-type" $ do $expect (equal "Bool" (show TypeBoolean)) $expect (equal "Bool" (show TypeBoolean)) $expect (equal "Word8" (show TypeWord8)) $expect (equal "Word16" (show TypeWord16)) $expect (equal "Word32" (show TypeWord32)) $expect (equal "Word64" (show TypeWord64)) $expect (equal "Int16" (show TypeInt16)) $expect (equal "Int32" (show TypeInt32)) $expect (equal "Int64" (show TypeInt64)) $expect (equal "Double" (show TypeDouble)) $expect (equal "UnixFd" (show TypeUnixFd)) $expect (equal "String" (show TypeString)) $expect (equal "Signature" (show TypeSignature)) $expect (equal "ObjectPath" (show TypeObjectPath)) $expect (equal "Variant" (show TypeVariant)) $expect (equal "[Word8]" (show (TypeArray TypeWord8))) $expect (equal "Dict Word8 (Dict Word8 Word8)" (show (TypeDictionary TypeWord8 (TypeDictionary TypeWord8 TypeWord8)))) $expect (equal "(Word8, Word16)" (show (TypeStructure [TypeWord8, TypeWord16]))) gen_SignatureTypes :: Gen [Type] gen_SignatureTypes = do (_, ts) <- gen_SignatureString return ts gen_SignatureString :: Gen (String, [Type]) gen_SignatureString = gen where anyType = oneof [atom, container] atom = elements [ ("b", TypeBoolean) , ("y", TypeWord8) , ("q", TypeWord16) , ("u", TypeWord32) , ("t", TypeWord64) , ("n", TypeInt16) , ("i", TypeInt32) , ("x", TypeInt64) , ("d", TypeDouble) , ("h", TypeUnixFd) , ("s", TypeString) , ("o", TypeObjectPath) , ("g", TypeSignature) ] container = oneof [ return ("v", TypeVariant) , array , dict , struct ] array = do (tCode, tEnum) <- anyType return ('a':tCode, TypeArray tEnum) dict = do (kCode, kEnum) <- atom (vCode, vEnum) <- anyType return (concat ["a{", kCode, vCode, "}"], TypeDictionary kEnum vEnum) struct = do ts <- listOf1 (halfSized anyType) let (codes, enums) = unzip ts return ("(" ++ concat codes ++ ")", TypeStructure enums) gen = do types <- listOf anyType let (codes, enums) = unzip types let chars = concat codes if length chars > 255 then halfSized gen else return (chars, enums) instance Arbitrary Signature where arbitrary = do ts <- gen_SignatureTypes let Just sig = signature ts return sig
jmillikin/haskell-dbus
tests/DBusTests/Signature.hs
apache-2.0
4,901
16
16
860
1,580
786
794
119
2
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -Wall #-} -- TODO: Complex Numbers {-| Embeds Fortran's type system in Haskell via the 'D' GADT. == Note: Phantom Types and GADTs Lots of the data types in this module are parameterised by phantom types. These are types which appear at the type-level, but not at the value level. They are there to make things more type-safe. In addition, a lot of the data types are GADTs. In a phantom-type-indexed GADT, the phantom type often restricts which GADT constructors a particular value may be an instance of. This is very useful for restricting value-level terms based on type-level information. -} module Language.Fortran.Model.Types where import Data.Int (Int16, Int32, Int64, Int8) import Data.List (intersperse) import Data.Monoid (Endo (..)) import Data.Typeable (Typeable) import Data.Word (Word8) import Data.Singletons.TypeLits import Data.Vinyl hiding (Field) import Data.Vinyl.Functor import Language.Expression.Pretty import Language.Fortran.Model.Singletons -------------------------------------------------------------------------------- -- * Fortran Types {-| This is the main embedding of Fortran types. A value of type @D a@ represents the Fortran type which corresponds to the Haskell type @a@. @a@ is a phantom type parameter. There is at most one instance of @D a@ for each @a@. This means that a value of type @D a@ acts as a kind of proof that it possible to have a Fortran type corresponding to the Haskell type @a@ -- and that when you match on @D a@ knowing the particular @a@ you have, you know which constructor you will get. This is a nice property because it means that GHC (with @-fwarn-incomplete-patterns@) will not warn when you match on an impossible case. It eliminates situations where you'd otherwise write @error "impossible: ..."@. * @'DPrim' p :: D ('PrimS' a)@ is for primitive types. It contains a value @p@ of type @'Prim' p k a@ for some @p@, @k@, @a@. When matching on something of type @D ('PrimS' a)@, you know it can only contain a primitive type. * @'DArray' i v :: D ('Array' i v)@ is for arrays. It contains instances of @'Index' i@ and @'ArrValue' a@. @'Index' i@ is a proof that @i@ can be used as an index, and @'ArrValue' a@ is a proof that @a@ can be stored in arrays. * @'DData' s xs :: D ('Record' name fs)@ is for user-defined data types. The type has a name, represented at the type level by the type parameter @name@ of kind 'Symbol'. The constructor contains @s :: 'SSymbol' name@, which acts as a sort of value-level representation of the name. 'SSymbol' is from the @singletons@ library. It also contains @xs :: 'Rec' ('Field' D) fs@. @fs@ is a type-level list of pairs, pairing field names with field types. @'Field' D '(fname, b)@ is a value-level pair of @'SSymbol' fname@ and @D b@. The vinyl record is a list of fields, one for each pair in @fs@. -} data D a where DPrim :: Prim p k a -> D (PrimS a) DArray :: Index i -> ArrValue a -> D (Array i a) DData :: SSymbol name -> Rec (Field D) fs -> D (Record name fs) -------------------------------------------------------------------------------- -- * Semantic Types newtype Bool8 = Bool8 { getBool8 :: Int8 } deriving (Show, Num, Eq, Typeable) newtype Bool16 = Bool16 { getBool16 :: Int16 } deriving (Show, Num, Eq, Typeable) newtype Bool32 = Bool32 { getBool32 :: Int32 } deriving (Show, Num, Eq, Typeable) newtype Bool64 = Bool64 { getBool64 :: Int64 } deriving (Show, Num, Eq, Typeable) newtype Char8 = Char8 { getChar8 :: Word8 } deriving (Show, Num, Eq, Typeable) {-| This newtype wrapper is used in 'DPrim' for semantic primitive types. This means that when matching on something of type @'D' ('PrimS' a)@, we know it can't be an array or a record. -} newtype PrimS a = PrimS { getPrimS :: a } deriving (Show, Eq, Typeable) -------------------------------------------------------------------------------- -- * Primitive Types {-| Lists the allowed primitive Fortran types. For example, @'PInt8' :: 'Prim' 'P8 ''BTInt' 'Int8'@ represents 8-bit integers. 'Prim' has three phantom type parameters: precision, base type and semantic Haskell type. Precision is the number of bits used to store values of that type. The base type represents the corresponding Fortran base type, e.g. @integer@ or @real@. Constructors are only provided for those Fortran types which are semantically valid, so for example no constructor is provided for a 16-bit real. A value of type @'Prim' p k a@ can be seen as a proof that there is some Fortran primitive type with those parameters. -} data Prim p k a where PInt8 :: Prim 'P8 'BTInt Int8 PInt16 :: Prim 'P16 'BTInt Int16 PInt32 :: Prim 'P32 'BTInt Int32 PInt64 :: Prim 'P64 'BTInt Int64 PBool8 :: Prim 'P8 'BTLogical Bool8 PBool16 :: Prim 'P16 'BTLogical Bool16 PBool32 :: Prim 'P32 'BTLogical Bool32 PBool64 :: Prim 'P64 'BTLogical Bool64 PFloat :: Prim 'P32 'BTReal Float PDouble :: Prim 'P64 'BTReal Double PChar :: Prim 'P8 'BTChar Char8 -------------------------------------------------------------------------------- -- * Arrays -- | Specifies which types can be used as array indices. data Index a where Index :: Prim p 'BTInt a -> Index (PrimS a) -- | Specifies which types can be stored in arrays. Currently arrays of arrays -- are not supported. data ArrValue a where ArrPrim :: Prim p k a -> ArrValue (PrimS a) ArrData :: SSymbol name -> Rec (Field ArrValue) fs -> ArrValue (Record name fs) -- | An array with a phantom index type. Mostly used at the type-level to -- constrain instances of @'D' (Array i a)@ etc. newtype Array i a = Array [a] -------------------------------------------------------------------------------- -- * Records -- | A field over a pair of name and value type. data Field f field where Field :: SSymbol name -> f a -> Field f '(name, a) -- | A type of records with the given @name@ and @fields@. Mostly used at the -- type level to constrain instances of @'D' (Record name fields)@ etc. data Record name fields where Record :: SSymbol name -> Rec (Field Identity) fields -> Record name fields -------------------------------------------------------------------------------- -- * Combinators -- | Any Fortran index type is a valid Fortran type. dIndex :: Index i -> D i dIndex (Index p) = DPrim p -- | Anything that can be stored in Fortran arrays is a valid Fortran type. dArrValue :: ArrValue a -> D a dArrValue (ArrPrim p) = DPrim p dArrValue (ArrData nameSym fieldArrValues) = DData nameSym (rmap (overField' dArrValue) fieldArrValues) -- | Given a field with known contents, we can change the functor and value -- type. overField :: (f a -> g b) -> Field f '(name, a) -> Field g '(name, b) overField f (Field n x) = Field n (f x) -- | Given a field with unknown contents, we can change the functor but not the -- value type. overField' :: (forall a. f a -> g a) -> Field f nv -> Field g nv overField' f (Field n x) = Field n (f x) traverseField' :: (Functor t) => (forall a. f a -> t (g a)) -> Field f nv -> t (Field g nv) traverseField' f (Field n x) = Field n <$> f x -- | Combine two fields over the same name-value pair but (potentially) -- different functors. zipFieldsWith :: (forall a. f a -> g a -> h a) -> Field f nv -> Field g nv -> Field h nv zipFieldsWith f (Field _ x) (Field n y) = Field n (f x y) zip3FieldsWith :: (forall a. f a -> g a -> h a -> i a) -> Field f nv -> Field g nv -> Field h nv -> Field i nv zip3FieldsWith f (Field _ x) (Field _ y) (Field n z) = Field n (f x y z) -------------------------------------------------------------------------------- -- Pretty Printing instance Pretty1 (Prim p k) where prettys1Prec p = \case PInt8 -> showString "integer8" PInt16 -> showString "integer16" PInt32 -> showString "integer32" PInt64 -> showString "integer64" PFloat -> showString "real" PDouble -> showParen (p > 8) $ showString "double precision" PBool8 -> showString "logical8" PBool16 -> showString "logical16" PBool32 -> showString "logical32" PBool64 -> showString "logical64" PChar -> showString "character" instance Pretty1 ArrValue where prettys1Prec p = prettys1Prec p . dArrValue instance (Pretty1 f) => Pretty1 (Field f) where prettys1Prec _ = \case Field fname x -> prettys1Prec 0 x . showString " " . withKnownSymbol fname (showString (symbolVal fname)) -- | e.g. "type custom_type { character a, integer array b }" instance Pretty1 D where prettys1Prec p = \case DPrim px -> prettys1Prec p px DArray _ pv -> prettys1Prec p pv . showString " array" DData rname fields -> showParen (p > 8) $ showString "type " . withKnownSymbol rname (showString (symbolVal rname)) . showString "{ " . appEndo ( mconcat . intersperse (Endo $ showString ", ") . recordToList . rmap (Const . Endo . prettys1Prec 0) $ fields) . showString " }"
dorchard/camfort
src/Language/Fortran/Model/Types.hs
apache-2.0
9,913
0
20
2,416
1,791
939
852
114
1
{-# LANGUAGE TupleSections #-} module Arbitrary.TestModule where import Data.Integrated.TestModule import Test.QuickCheck import Data.ModulePath import Control.Applicative import Arbitrary.Properties import Test.Util import Filesystem.Path.CurrentOS import Prelude hiding (FilePath) import qualified Arbitrary.ModulePath as MP import qualified Data.Set as S testModulePath :: Gen Char -> S.Set ModulePath -> Gen ModulePath testModulePath subpath avoided = suchThat (fromModPath <$> MP.toModulePath subpath) (not . flip S.member avoided) where fromModPath :: ModulePath -> ModulePath fromModPath (ModulePath pth) = ModulePath $ take (length pth - 1) pth ++ [testFormat $ last pth] toTestModule :: ModulePath -> Gen TestModule toTestModule mp = do props <- arbitrary :: Gen Properties return $ TestModule mp (list props) -- Generate a random test file, care must be taken to avoid generating -- the same path twice toGenerated :: Gen Char -> S.Set ModulePath -> Gen (FilePath, TestModule) toGenerated subpath avoided = do mp <- testModulePath subpath avoided (relPath mp,) <$> toTestModule mp
jfeltz/tasty-integrate
tests/Arbitrary/TestModule.hs
bsd-2-clause
1,129
0
12
186
314
165
149
28
1
{-# LANGUAGE TemplateHaskell, QuasiQuotes, OverloadedStrings #-} module Handler.Root where import Foundation -- This is a handler function for the GET request method on the RootR -- resource pattern. All of your resource patterns are defined in -- config/routes -- -- The majority of the code you will write in Yesod lives in these handler -- functions. You can spread them across multiple files if you are so -- inclined, or create a single monolithic file. getRootR :: Handler RepHtml getRootR = do defaultLayout $ do h2id <- lift newIdent setTitle "TierList homepage" $(widgetFile "homepage")
periodic/Simple-Yesod-ToDo
Handler/Root.hs
bsd-2-clause
625
0
12
123
63
34
29
9
1
{-- Copyright (c) 2014-2020, Clockwork Dev Studio All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --} {-# LANGUAGE CPP #-} module Arguments where import Prelude hiding (catch) import LexerData import Common import Options import Data.Char import System.FilePath.Posix import System.Directory import System.IO import Control.Exception import System.Exit import Control.Monad.State import Control.Monad.Except import Control.Monad.Identity import Debug.Trace import qualified Data.Sequence as Seq data ConfigFile = ConfigFile { configFileVariableList :: [ConfigFileVariable] } deriving (Show,Eq) data ConfigFileVariable = ConfigFileVariable { configFileVariableName :: String, configFileVariableValue :: String } deriving (Show, Eq) loadConfigFile :: Handle -> ConfigFile -> IO ConfigFile loadConfigFile handle (ConfigFile variables) = do let endOfFile :: IOError -> IO String endOfFile e = do return "EOF" line <- catch (hGetLine handle) endOfFile if line == "EOF" then return (ConfigFile variables) else do let (variable,rest) = span (isAlpha) line if variable == [] || rest == [] || head rest /= '=' then loadConfigFile handle (ConfigFile variables) else do loadConfigFile handle (ConfigFile (variables ++ [(ConfigFileVariable variable (tail rest))])) adjustOptionsBasedOnConfigFile :: Options -> [ConfigFileVariable] -> Options adjustOptionsBasedOnConfigFile originalOptions (configFileVariable:rest) = case configFileVariableName configFileVariable of "backend" -> adjustOptionsBasedOnConfigFile (originalOptions {optionAssembler = configFileVariableValue configFileVariable}) rest adjustOptionsBasedOnConfigFile originalOptions _ = originalOptions processArguments :: CodeTransformation () processArguments = do homeDirectory <- liftIO $ getHomeDirectory let writeDefaultConfigFile :: IOError -> IO Handle writeDefaultConfigFile _ = do newConfHandle <- openFile (homeDirectory ++ "/.idlewild-lang.conf") WriteMode hPutStrLn newConfHandle "backend=nasm" hClose newConfHandle newConfHandle <- openFile (homeDirectory ++ "/.idlewild-lang.conf") ReadMode return newConfHandle confHandle <- liftIO $ (catch (openFile (homeDirectory ++ "/.idlewild-lang.conf") ReadMode) writeDefaultConfigFile) configFile <- liftIO $ loadConfigFile confHandle (ConfigFile []) let customisedOptions = adjustOptionsBasedOnConfigFile defaultOptions (configFileVariableList configFile) liftIO $ hClose confHandle arguments <- gets argumentStateArguments (options, nonOptions) <- liftIO $ processOptions customisedOptions arguments if optionShowVersion options == True then do liftIO $ putStrLn "Idlewild-Lang version 0.0.5." liftIO $ exitSuccess else return () if length nonOptions /= 1 then do liftIO $ putStrLn "Please specify one (and only one) source file name." liftIO $ exitSuccess else return () let sourceFileName = head nonOptions asmFileName = replaceExtension sourceFileName ".asm" #if LINUX==1 || MAC_OS==1 objectFileName = replaceExtension sourceFileName ".o" #elif WINDOWS==1 objectFileName = replaceExtension sourceFileName ".obj" #endif verbose = optionVerbose options fromHandle <- liftIO $ openFile sourceFileName ReadMode toHandle <- liftIO $ openFile asmFileName WriteMode code <- liftIO $ hGetContents fromHandle put LexState {lexStateID = LEX_PENDING, lexStateIncludeFileDepth = 0, lexStateIncludeFileNameStack = [sourceFileName], lexStateIncludeFileNames = [], lexStateCurrentToken = emptyToken, lexStatePendingTokens = Seq.empty, lexStateTokens = Seq.singleton (createBOFToken sourceFileName), lexStateLineNumber = 1, lexStateLineOffset = 0, lexStateCharacters = code, lexStateCompoundTokens = allCompoundTokens, lexStateConfig = Config {configInputFile = fromHandle, configOutputFile = toHandle, configSourceFileName = sourceFileName, configAsmFileName = asmFileName, configObjectFileName = objectFileName, configOptions = options}} verboseCommentary ("Program arguments okay...\n") verbose verboseCommentary ("Source file '" ++ sourceFileName ++ "'...\n") verbose
clockworkdevstudio/Idlewild-Lang
Arguments.hs
bsd-2-clause
5,916
0
22
1,368
1,000
518
482
92
3
module Convert.LRChirotope where -- standard modules import Data.List import qualified Data.Map as Map import Data.Maybe import qualified Data.Set as Set -- local modules import Basics import Calculus.FlipFlop import Helpful.General --import Debug.Trace {------------------------------------------------------------------------------ - FlipFlop to Chirotope ------------------------------------------------------------------------------} flipflopsToChirotope :: Network [String] (ARel FlipFlop) -> Maybe (Network [Int] Int) flipflopsToChirotope net | isNothing net5 || isNothing net3 = Nothing | otherwise = Just $ (fromJust net3) { nCons = fst $ Map.foldlWithKey collectOneCon (Map.empty, Map.empty) cons } where collectOneCon (consAcc, mapAcc) nodes rel = let (newMap, convertedNodes) = mapAccumL (\ m node -> let mappedNode = Map.lookup node m in case mappedNode of Nothing -> let n = (Map.size m) + 1 in (Map.insert node n m, n) otherwise -> (m, fromJust mappedNode) ) mapAcc nodes newRel = case aRel rel of R -> (-1) I -> 0 L -> 1 in ( foldl (flip $ uncurry Map.insert) consAcc $ [(x, newRel * y) | (x,y) <- kPermutationsWithParity 3 convertedNodes ] , newMap ) net5 = ffsToFF5s net net3 = ff5sToFF3s $ fromJust net5 cons = nCons $ fromJust net3
spatial-reasoning/zeno
src/Convert/LRChirotope.hs
bsd-2-clause
1,839
0
26
767
422
224
198
38
4
{-# LANGUAGE FlexibleContexts #-} module BRC.Solver.Error where import Control.Monad.Error (Error(..), MonadError(..)) -- | Solver errors, really just a container for a possibly useful error message. data SolverError = SolverError String deriving (Eq, Ord) instance Show (SolverError) where show (SolverError msg) = "Solver error: " ++ msg instance Error SolverError where strMsg = SolverError -- | Throws an error with a given message in a solver error monad. solverError :: MonadError SolverError m => String -> m a solverError = throwError . strMsg
kcharter/brc-solver
BRC/Solver/Error.hs
bsd-2-clause
565
0
8
95
124
71
53
10
1
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module NW.Monster where import NW.Stats data MonsterClass = MCFighter | MCMage deriving (Eq, Show) data Monster = Monster { mClass :: MonsterClass , mName :: String , mStatsBase :: [Stat] , mLootBonus :: Int } deriving (Eq, Show) type MonsterDB = [Monster]
listx/netherworld
src/NW/Monster.hs
bsd-2-clause
338
8
9
63
98
60
38
15
0
{-# LANGUAGE TemplateHaskell #-} {-| Contains TemplateHaskell stuff I don't want to recompile every time I make changes to other files, a pre-compiled header, so to say. Don't know if that even works. -} module FeedGipeda.THGenerated ( benchmarkClosure , stringDict , __remoteTable ) where import Control.Distributed.Process (Closure, Process, Static, liftIO) import Control.Distributed.Process.Closure (SerializableDict, functionTDict, mkClosure, remotable) import FeedGipeda.GitShell (SHA) import FeedGipeda.Repo (Repo) import qualified FeedGipeda.Slave as Slave import FeedGipeda.Types (Timeout) benchmarkProcess :: (String, Repo, SHA, Rational) -> Process String benchmarkProcess (benchmarkScript, repo, sha, timeout) = liftIO (Slave.benchmark benchmarkScript repo sha (fromRational timeout)) remotable ['benchmarkProcess] benchmarkClosure :: String -> Repo -> SHA -> Timeout -> Closure (Process String) benchmarkClosure benchmarkScript repo commit timeout = $(mkClosure 'benchmarkProcess) (benchmarkScript, repo, commit, toRational timeout) stringDict :: Static (SerializableDict String) stringDict = $(functionTDict 'benchmarkProcess)
sgraf812/feed-gipeda
src/FeedGipeda/THGenerated.hs
bsd-3-clause
1,466
0
11
454
272
156
116
24
1
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TupleSections #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Test.PGConstant ( TestPGConstant(..) , spec ) where import Data.Proxy (Proxy(..)) import Database.PostgreSQL.Simple.Bind.Parser import Test.Hspec (Spec, describe) import Test.QuickCheck (Arbitrary(..), oneof) import Test.Common (PGSql(..)) import Test.Utils (propParsingWorks) import Test.PGString (TestPGString(..)) data TestPGConstant = TPGCString TestPGString | TPGCNumeric Double deriving (Show, Eq) instance Arbitrary TestPGConstant where arbitrary = oneof [ TPGCString <$> arbitrary , TPGCNumeric <$> arbitrary] instance PGSql TestPGConstant where render (TPGCString s) = render s render (TPGCNumeric c) = show c spec :: Spec spec = do describe "pgConstant" $ do propParsingWorks pgConstant (Proxy :: Proxy TestPGConstant)
zohl/postgresql-simple-bind
tests/Test/PGConstant.hs
bsd-3-clause
1,133
0
12
177
253
149
104
36
1
{-# LANGUAGE OverloadedStrings #-} module WildBind.SeqSpec (main,spec) where import Control.Applicative ((<*>)) import Control.Monad (forM_) import Control.Monad.IO.Class (liftIO) import qualified Control.Monad.Trans.State as State import Data.Monoid ((<>)) import Data.IORef (modifyIORef, newIORef, readIORef) import Test.Hspec import WildBind.Binding ( binds, on, run, as, boundActions, actDescription, boundInputs, Binding, justBefore ) import WildBind.Description (ActionDescription) import WildBind.Seq ( prefix, toSeq, fromSeq, withPrefix, withCancel, reviseSeq ) import WildBind.ForTest ( SampleInput(..), SampleState(..), evalStateEmpty, execAll, boundDescs, curBoundInputs, curBoundDescs, curBoundDesc, checkBoundInputs, checkBoundDescs, checkBoundDesc, withRefChecker ) main :: IO () main = hspec spec spec :: Spec spec = do spec_prefix spec_SeqBinding spec_reviseSeq spec_prefix :: Spec spec_prefix = describe "prefix" $ do let base_b = binds $ do on SIa `as` "a" `run` return () on SIb `as` "b" `run` return () specify "no prefix" $ do let b = prefix [] [] base_b boundDescs b (SS "") `shouldMatchList` [ (SIa, "a"), (SIb, "b") ] specify "one prefix" $ evalStateEmpty $ do State.put $ prefix [] [SIc] base_b checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc] checkBoundDescs (SS "") [(SIa, "a"), (SIb, "b")] execAll (SS "") [SIc] checkBoundDescs (SS "") [(SIa, "a"), (SIb, "b")] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIc] specify "two prefixes" $ evalStateEmpty $ do State.put $ prefix [] [SIc, SIb] base_b checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc] checkBoundInputs (SS "") [SIb] execAll (SS "") [SIb] checkBoundDescs (SS "") [(SIa, "a"), (SIb, "b")] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIc] specify "cancel binding" $ evalStateEmpty $ do State.put $ prefix [SIa] [SIc, SIb] base_b checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc] -- there is no cancel binding at the top level. checkBoundInputs (SS "") [SIa, SIb] checkBoundDesc (SS "") SIa "cancel" execAll (SS "") [SIa] checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc, SIb] checkBoundDescs (SS "") [(SIa, "a"), (SIb, "b")] -- cancel binding should be weak and overridden. execAll (SS "") [SIb] checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc, SIb] checkBoundDescs (SS "") [(SIa, "a"), (SIb, "b")] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIc] spec_SeqBinding :: Spec spec_SeqBinding = describe "SeqBinding" $ do let b_a = binds $ on SIa `as` "a" `run` return () b_b = binds $ on SIb `as` "b" `run` return () describe "withPrefix" $ do it "should allow nesting" $ evalStateEmpty $ do State.put $ fromSeq $ withPrefix [SIb] $ withPrefix [SIc] $ withPrefix [SIa] $ toSeq (b_a <> b_b) checkBoundInputs (SS "") [SIb] execAll (SS "") [SIb] checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc] checkBoundInputs (SS "") [SIa] execAll (SS "") [SIa] checkBoundDescs (SS "") [(SIa, "a"), (SIb, "b")] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIb] describe "mappend" $ do it "should be able to combine SeqBindings with different prefixes." $ evalStateEmpty $ do State.put $ fromSeq $ withPrefix [SIc] $ ( (withPrefix [SIa, SIc] $ toSeq $ b_a) <> (withPrefix [SIa] $ toSeq $ b_b) ) checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc] checkBoundInputs (SS "") [SIa] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIc, SIb] checkBoundDesc (SS "") SIb "b" execAll (SS "") [SIb] checkBoundInputs (SS "") [SIc] execAll (SS "") [SIc, SIa] checkBoundInputs (SS "") [SIc, SIb] execAll (SS "") [SIc] checkBoundDescs (SS "") [(SIa, "a")] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIc] describe "withCancel" $ do it "should weakly add 'cancel' binding when at least one prefix is kept in the state." $ evalStateEmpty $ do State.put $ fromSeq $ withPrefix [SIa, SIc] $ withCancel [SIa, SIb, SIc] $ ( toSeq b_a <> (withPrefix [SIc] $ toSeq b_b) ) let checkPrefixOne = do checkBoundInputs (SS "") [SIa] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIa, SIb, SIc] forM_ [SIa, SIb] $ \c -> checkBoundDesc (SS "") c "cancel" checkPrefixOne execAll (SS "") [SIa] checkPrefixOne execAll (SS "") [SIc] checkBoundInputs (SS "") [SIa, SIb, SIc] checkBoundDesc (SS "") SIa "a" checkBoundDesc (SS "") SIb "cancel" execAll (SS "") [SIa] checkPrefixOne execAll (SS "") [SIc, SIb] checkPrefixOne execAll (SS "") [SIc, SIc] checkBoundDescs (SS "") [(SIa, "cancel"), (SIb, "b"), (SIc, "cancel")] execAll (SS "") [SIb] checkPrefixOne spec_reviseSeq :: Spec spec_reviseSeq = describe "reviseSeq" $ do it "should allow access to prefix keys input so far" $ evalStateEmpty $ withRefChecker [] $ \out checkOut -> do act_out <- liftIO $ newIORef ("" :: String) let sb = withCancel [SIa] $ withPrefix [SIa, SIb, SIc] $ toSeq $ base_b base_b = binds $ on SIb `as` "B" `run` modifyIORef act_out (++ "B executed") rev ps _ _ = justBefore $ modifyIORef out (++ [ps]) State.put $ fromSeq $ reviseSeq rev sb execAll (SS "") [SIa, SIa] checkOut [[], [SIa]] execAll (SS "") [SIa, SIb, SIc] checkOut [[], [SIa], [], [SIa], [SIa, SIb]] liftIO $ readIORef act_out `shouldReturn` "" execAll (SS "") [SIb] checkOut [[], [SIa], [], [SIa], [SIa, SIb], [SIa, SIb, SIc]] liftIO $ readIORef act_out `shouldReturn` "B executed" it "should allow unbinding" $ evalStateEmpty $ do let sb = withPrefix [SIa] ( toSeq ba <> (withPrefix [SIb] $ toSeq bab) <> (withPrefix [SIa] $ toSeq baa) ) ba = binds $ on SIc `as` "c on a" `run` return () bab = binds $ on SIc `as` "c on ab" `run` return () baa = binds $ do on SIc `as` "c on aa" `run` return () on SIb `as` "b on aa" `run` return () rev ps _ i act = if (ps == [SIa] && i == SIb) || (ps == [SIa,SIa] && i == SIc) then Nothing else Just act State.put $ fromSeq $ reviseSeq rev sb checkBoundInputs (SS "") [SIa] execAll (SS "") [SIa] checkBoundInputs (SS "") [SIa, SIc] -- SIb should be canceled execAll (SS "") [SIa] checkBoundDescs (SS "") [(SIb, "b on aa")] -- SIc should be canceled execAll (SS "") [SIb] checkBoundInputs (SS "") [SIa]
debug-ito/wild-bind
wild-bind/test/WildBind/SeqSpec.hs
bsd-3-clause
7,072
0
23
2,072
2,930
1,501
1,429
175
2
{-# LANGUAGE TemplateHaskell #-} module Data.Comp.Trans.DeriveUntrans ( deriveUntrans ) where import Control.Lens ( view ,(^.)) import Control.Monad ( liftM ) import Control.Monad.Trans ( lift ) import Data.Comp.Multi ( Alg, cata, (:&:)(..) ) import Language.Haskell.TH import Data.Comp.Trans.Util -------------------------------------------------------------------------------- -- | -- Creates an @untranslate@ function inverting the @translate@ function -- created by @deriveTrans@. -- -- @ -- import qualified Foo as F -- type ArithTerm = Term (Arith :+: Atom :+: Lit) -- deriveUntrans [''F.Arith, ''F.Atom, ''F.Lit] (TH.ConT ''ArithTerm) -- @ -- -- will create -- -- @ -- type family Targ l -- newtype T l = T {t :: Targ l} -- -- class Untrans f where -- untrans :: Alg f t -- -- untranslate :: ArithTerm l -> Targ l -- untranslate = t . cata untrans -- -- type instance Targ ArithL = F.Arith -- instance Untrans Arith where -- untrans (Add x y) = T $ F.Add (t x) (t y) -- -- type instance Targ AtomL = F.Atom -- instance Untrans Atom where -- untrans (Var s) = T $ F.Var s -- untrans (Const x) = T $ F.Const (t x) -- -- type instance Targ LitL = F.Lit -- instance Untrans Lit where -- untrans (Lit n) = T $ F.Lit n -- @ -- -- Note that you will need to manually provide an instance @(Untrans f, Untrans g) => Untrans (f :+: g)@ -- due to phase issues. (Or @(Untrans (f :&: p), Untrans (g :&: p)) => Untrans ((f :+: g) :&: p)@, if you -- are propagating annotations.) -- -- With annotation propagation on, it will instead produce -- `untranslate :: Term (Arith :&: Ann) l -> Targ l Ann` deriveUntrans :: [Name] -> Type -> CompTrans [Dec] deriveUntrans names term = do targDec <- mkTarg targNm wrapperDec <- mkWrapper wrapNm unwrapNm targNm fnDec <- mkFn untranslateNm term targNm unwrapNm fnNm classDec <- mkClass classNm fnNm wrapNm instances <- liftM concat $ mapM (mkInstance classNm fnNm wrapNm unwrapNm targNm) names return $ concat [ targDec , wrapperDec , fnDec , classDec , instances ] where targNm = mkName "Targ" wrapNm = mkName "T" unwrapNm = mkName "t" untranslateNm = mkName "untranslate" classNm = mkName "Untrans" fnNm = mkName "untrans" {- type family Targ l -} mkTarg :: Name -> CompTrans [Dec] mkTarg targNm = do i <- lift $ newName "i" return [FamilyD TypeFam targNm [PlainTV i] Nothing] {- newtype T l = T { t :: Targ l } -} mkWrapper :: Name -> Name -> Name -> CompTrans [Dec] mkWrapper tpNm fNm targNm = do i <- lift $ newName "i" let con = RecC tpNm [(fNm, NotStrict, AppT (ConT targNm) (VarT i))] return [NewtypeD [] tpNm [PlainTV i] con []] {- untranslate :: JavaTerm l -> Targ l untranslate = t . cata untrans -} mkFn :: Name -> Type -> Name -> Name -> Name -> CompTrans [Dec] mkFn fnNm term targNm fldNm untransNm = sequence [sig, def] where sig = do i <- lift $ newName "i" lift $ sigD fnNm (forallT [PlainTV i] (return []) (typ $ varT i)) typ :: Q Type -> Q Type typ i = [t| $term' $i -> $targ $i |] term' = return term targ = conT targNm def = lift $ valD (varP fnNm) (normalB body) [] body = [| $fld . cata $untrans |] fld = varE fldNm untrans = varE untransNm {- class Untrans f where untrans :: Alg f T -} mkClass :: Name -> Name -> Name -> CompTrans [Dec] mkClass classNm funNm newtpNm = do f <- lift $ newName "f" let funDec = SigD funNm (AppT (AppT (ConT ''Alg) (VarT f)) (ConT newtpNm)) return [ClassD [] classNm [PlainTV f] [] [funDec]] {- type instance Targ CompilationUnitL = J.CompilationUnit instance Untrans CompilationUnit where untrans (CompilationUnit x y z) = T $ J.CompilationUnit (t x) (t y) (t z) -} mkInstance :: Name -> Name -> Name -> Name -> Name -> Name -> CompTrans [Dec] mkInstance classNm funNm wrap unwrap targNm typNm = do inf <- lift $ reify typNm targTyp <- getFullyAppliedType typNm let nmTyps = simplifyDataInf inf clauses <- mapM (uncurry $ mkClause wrap unwrap) nmTyps let conTyp = ConT (transName typNm) annPropInf <- view annotationProp let instTyp = case annPropInf of Nothing -> conTyp Just api -> foldl AppT (ConT ''(:&:)) [conTyp, api ^. annTyp] return [ famInst targTyp , inst clauses instTyp ] where famInst targTyp = TySynInstD targNm (TySynEqn [ConT $ nameLab typNm] targTyp) inst clauses instTyp = InstanceD [] (AppT (ConT classNm) instTyp) [FunD funNm clauses] mapConditionallyReplacing :: [a] -> (a -> b) -> (a -> Bool) -> [b] -> [b] mapConditionallyReplacing src f p reps = go src reps where go [] _ = [] go (x:xs) (y:ys) | p x = y : go xs ys go (x:xs) l | not (p x) = f x : go xs l go (_:_ ) [] = error "mapConditionallyReplacing: Insufficiently many replacements" mkClause :: Name -> Name -> Name -> [Type] -> CompTrans Clause mkClause wrap unwrap con tps = do isAnn <- getIsAnn nms <- mapM (const $ lift $ newName "x") tps nmAnn <- lift $ newName "a" tps' <- applyCurSubstitutions tps let nmTps = zip nms tps' Clause <$> (sequence [pat isAnn nmTps nmAnn]) <*> (body nmTps nmAnn) <*> pure [] where pat :: (Type -> Bool) -> [(Name, Type)] -> Name -> CompTrans Pat pat isAnn nmTps nmAnn = do isProp <- isPropagatingAnns if isProp then return $ ConP '(:&:) [nodeP, VarP nmAnn] else return nodeP where nonAnnNms = map fst $ filter (not.isAnn.snd) nmTps nodeP = ConP (transName con) (map VarP nonAnnNms) body :: [(Name, Type)] -> Name -> CompTrans Body body nmTps nmAnn = do annPropInf <- view annotationProp args <- case annPropInf of Nothing -> return $ map atom nmTps Just api -> do isAnn <- getIsAnn let unProp = api ^. unpropAnn let annVars = filter (isAnn.snd) nmTps let annExps = unProp (VarE nmAnn) (length annVars) return $ mapConditionallyReplacing nmTps atom (isAnn.snd) annExps return $ makeRhs args where makeRhs :: [Exp] -> Body makeRhs args = NormalB $ AppE (ConE wrap) $ foldl AppE (ConE con) args atom :: (Name, Type) -> Exp atom (x, t) | elem t baseTypes = VarE x atom (x, _) = AppE (VarE unwrap) (VarE x)
jkoppel/comptrans
Data/Comp/Trans/DeriveUntrans.hs
bsd-3-clause
8,030
0
20
3,281
1,942
992
950
100
4
module Mistral.Schedule.Value ( Env , groupEnv , lookupEnv , bindType , bindValue , bindParam , NodeTags , bindNode , lookupTag, lookupTags , Value(..) , SNetwork(..), mapWhen, modifyNode , SNode(..), addTask , STask(..), hasConstraints , SConstraint(..), target ) where import Mistral.TypeCheck.AST import Mistral.Utils.PP import Mistral.Utils.Panic ( panic ) import Mistral.Utils.SCC ( Group ) import qualified Data.Foldable as Fold import qualified Data.Map as Map import Data.Monoid ( Monoid(..) ) import qualified Data.Set as Set sPanic :: [String] -> a sPanic = panic "Mistral.Schedule.Value" -- Environments ---------------------------------------------------------------- data Env = Env { envValues :: Map.Map Name Value , envTypes :: Map.Map TParam Type } instance Monoid Env where mempty = Env { envValues = mempty, envTypes = mempty } mappend l r = mconcat [l,r] -- merge the two environments, preferring things from the left mconcat envs = Env { envValues = Map.unions (map envValues envs) , envTypes = Map.unions (map envTypes envs) } lookupEnv :: Name -> Env -> Value lookupEnv n env = case Map.lookup n (envValues env) of Just v -> v Nothing -> sPanic [ "no value for: " ++ pretty n ] bindType :: TParam -> Type -> Env -> Env bindType p ty env = env { envTypes = Map.insert p ty (envTypes env) } bindValue :: Name -> Value -> Env -> Env bindValue n v env = env { envValues = Map.insert n v (envValues env) } bindParam :: Param -> Value -> Env -> Env bindParam p v env = bindValue (pName p) v env groupEnv :: (a -> Env) -> (Group a -> Env) groupEnv = Fold.foldMap -- Node Tags ------------------------------------------------------------------- newtype NodeTags = NodeTags { getNodeTags :: Map.Map Atom (Set.Set Name) } instance Monoid NodeTags where mempty = NodeTags mempty mappend l r = mconcat [l,r] mconcat nts = NodeTags (Map.unionsWith Set.union (map getNodeTags nts)) bindNode :: SNode -> NodeTags bindNode sn = mempty { getNodeTags = foldl add mempty allTags } where name = snName sn allTags = [ (tag, Set.singleton name) | tag <- snTags sn ] add nodes (tag, s) = Map.insertWith Set.union tag s nodes -- | Try to resolve a single tag to set of Node names. lookupTag :: Atom -> NodeTags -> Set.Set Name lookupTag tag env = case Map.lookup tag (getNodeTags env) of Just nodes -> nodes Nothing -> Set.empty -- | Lookup the nodes that have all of the tags given. lookupTags :: [Atom] -> NodeTags -> [Name] lookupTags tags env | null tags = [] -- XXX maybe all nodes? | otherwise = Set.toList (foldl1 Set.intersection (map (`lookupTag` env) tags)) -- Values ---------------------------------------------------------------------- data Value = VTFun (Type -> Value) -- ^ Type abstractions | VFun (Value -> Value) -- ^ Value abstractions | VCon Name [Value] -- ^ Constructor use | VLit Literal -- ^ Literals | VSched [SNetwork] -- ^ Evaluted schedules | VTopo SNetwork -- ^ Nodes and links | VNode SNode -- ^ Nodes | VLink Link -- ^ Links | VTasks (NodeTags -> [STask]) | VTask STask instance Show Value where show val = case val of VTFun _ -> "<function>" VFun _ -> "<type-function>" VCon n vs -> "(" ++ unwords (pretty n : map show vs) ++ ")" VLit lit -> "(VLit " ++ show lit ++ ")" VSched nets -> show nets VTopo net -> show net VNode n -> show n VLink l -> show l VTasks _ -> "<tasks>" VTask t -> show t -- | Scheduling network. data SNetwork = SNetwork { snNodes :: [SNode] , snLinks :: [Link] } deriving (Show) instance Monoid SNetwork where mempty = SNetwork { snNodes = [] , snLinks = [] } mappend l r = SNetwork { snNodes = Fold.foldMap snNodes [l,r] , snLinks = Fold.foldMap snLinks [l,r] } mapWhen :: (a -> Bool) -> (a -> a) -> [a] -> [a] mapWhen p f = go where go as = case as of a:rest | p a -> f a : rest | otherwise -> a : go rest [] -> [] -- | Modify the first occurrence of node n. -- -- INVARIANT: This relies on the assumption that the renamer has given fresh -- names to all nodes. modifyNode :: Name -> (SNode -> SNode) -> (SNetwork -> SNetwork) modifyNode n f net = net { snNodes = mapWhen nameMatches f (snNodes net) } where nameMatches sn = snName sn == n data SNode = SNode { snName :: Name , snSpec :: Expr , snType :: Type , snTags :: [Atom] , snTasks :: [STask] } deriving (Show) addTask :: STask -> (SNode -> SNode) addTask task sn = sn { snTasks = task : snTasks sn } data STask = STask { stName :: Name , stTask :: Task , stTags :: [Atom] , stConstraints :: [SConstraint] } deriving (Show) hasConstraints :: STask -> Bool hasConstraints t = not (null (stConstraints t)) data SConstraint = SCOn Name -- ^ On this node deriving (Show) -- XXX This won't work for constraints that specify relative information like: -- "I need to be able to communicate with X" target :: SConstraint -> Name target (SCOn n) = n
GaloisInc/mistral
src/Mistral/Schedule/Value.hs
bsd-3-clause
5,624
0
14
1,727
1,680
920
760
121
2
{-# LANGUAGE ParallelListComp #-} module OldHMM (Prob, HMM(..), train, bestSequence, sequenceProb) where import qualified Data.Map as M import Data.List (sort, groupBy, maximumBy, foldl') import Data.Maybe (fromMaybe, fromJust) import Data.Ord (comparing) import Data.Function (on) import Control.Monad import Data.Number.LogFloat type Prob = LogFloat -- | The type of Hidden Markov Models. data HMM state observation = HMM [state] [Prob] [[Prob]] (observation -> [Prob]) instance (Show state, Show observation) => Show (HMM state observation) where show (HMM states probs tpm _) = "HMM " ++ show states ++ " " ++ show probs ++ " " ++ show tpm ++ " <func>" -- | Perform a single step in the Viterbi algorithm. -- -- Takes a list of path probabilities, and an observation, and returns the updated -- list of (surviving) paths with probabilities. viterbi :: HMM state observation -> [(Prob, [state])] -> observation -> [(Prob, [state])] viterbi (HMM states _ state_transitions observations) prev x = deepSeq prev `seq` [maximumBy (comparing fst) [(transition_prob * prev_prob * observation_prob, new_state:path) | transition_prob <- transition_probs | (prev_prob, path) <- prev | observation_prob <- observation_probs] | transition_probs <- state_transitions | new_state <- states] where observation_probs = observations x deepSeq ((x, y:ys):xs) = x `seq` y `seq` (deepSeq xs) deepSeq ((x, _):xs) = x `seq` (deepSeq xs) deepSeq [] = [] -- | The initial value for the Viterbi algorithm viterbi_init :: HMM state observation -> [(Prob, [state])] viterbi_init (HMM states state_probs _ _) = zip state_probs (map (:[]) states) -- | Perform a single step of the forward algorithm -- -- Each item in the input and output list is the probability that the system -- ended in the respective state. forward :: HMM state observation -> [Prob] -> observation -> [Prob] forward (HMM _ _ state_transitions observations) prev x = last prev `seq` [sum [transition_prob * prev_prob * observation_prob | transition_prob <- transition_probs | prev_prob <- prev | observation_prob <- observation_probs] | transition_probs <- state_transitions] where observation_probs = observations x -- | The initial value for the forward algorithm forward_init :: HMM state observation -> [Prob] forward_init (HMM _ state_probs _ _) = state_probs learn_states :: (Ord state, Fractional prob) => [(observation, state)] -> M.Map state prob learn_states xs = histogram $ map snd xs learn_transitions :: (Ord state, Fractional prob) => [(observation, state)] -> M.Map (state, state) prob learn_transitions xs = let xs' = map snd xs in histogram $ zip xs' (tail xs') learn_observations :: (Ord state, Ord observation, Fractional prob) => M.Map state prob -> [(observation, state)] -> M.Map (observation, state) prob learn_observations state_prob = M.mapWithKey (\ (observation, state) prob -> prob / (fromJust $ M.lookup state state_prob)) . histogram histogram :: (Ord a, Fractional prob) => [a] -> M.Map a prob histogram xs = let hist = foldl' (flip $ flip (M.insertWith (+)) 1) M.empty xs in M.map (/ M.fold (+) 0 hist) hist -- | Calculate the parameters of an HMM from a list of observations -- and the corresponding states. train :: (Ord observation, Ord state) => [(observation, state)] -> HMM state observation train sample = model where states = learn_states sample state_list = M.keys states transitions = learn_transitions sample trans_prob_mtx = [[fromMaybe 1e-10 $ M.lookup (old_state, new_state) transitions | old_state <- state_list] | new_state <- state_list] observations = learn_observations states sample observation_probs = fromMaybe (fill state_list []) . (flip M.lookup $ M.fromList $ map (\ (e, xs) -> (e, fill state_list xs)) $ map (\ xs -> (fst $ head xs, map snd xs)) $ groupBy ((==) `on` fst) [(observation, (state, prob)) | ((observation, state), prob) <- M.toAscList observations]) initial = map (\ state -> (fromJust $ M.lookup state states, [state])) state_list model = HMM state_list (fill state_list $ M.toAscList states) trans_prob_mtx observation_probs fill :: Eq state => [state] -> [(state, Prob)] -> [Prob] fill states [] = map (const 1e-10) states fill (s:states) xs@((s', p):xs') = if s /= s' then 1e-10 : fill states xs else p : fill states xs' -- | Calculate the most likely sequence of states for a given sequence of observations -- using Viterbi's algorithm bestSequence :: (Ord observation) => HMM state observation -> [observation] -> [state] bestSequence hmm = (reverse . tail . snd . (maximumBy (comparing fst))) . (foldl' (viterbi hmm) (viterbi_init hmm)) -- | Calculate the probability of a given sequence of observations -- using the forward algorithm. sequenceProb :: (Ord observation) => HMM state observation -> [observation] -> Prob sequenceProb hmm = sum . (foldl' (forward hmm) (forward_init hmm))
mikeizbicki/hmm
OldHMM.hs
bsd-3-clause
5,845
8
16
1,773
1,640
907
733
91
3
{-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeSynonymInstances #-} module Test.Hspec.Snap ( -- * Running blocks of hspec-snap tests snap , modifySite , modifySite' , afterEval , beforeEval -- * Core data types , TestResponse(..) , SnapHspecM -- * Factory style test data generation , Factory(..) -- * Requests , delete , get , get' , post , postJson , put , put' , params -- * Helpers for dealing with TestResponses , restrictResponse -- * Dealing with session state (EXPERIMENTAL) , recordSession , HasSession(..) , sessionShouldContain , sessionShouldNotContain -- * Evaluating application code , eval -- * Unit test assertions , shouldChange , shouldEqual , shouldNotEqual , shouldBeTrue , shouldNotBeTrue -- * Response assertions , should200 , shouldNot200 , should404 , shouldNot404 , should300 , shouldNot300 , should300To , shouldNot300To , shouldHaveSelector , shouldNotHaveSelector , shouldHaveText , shouldNotHaveText -- * Form tests , FormExpectations(..) , form -- * Internal types and helpers , SnapHspecState(..) , setResult , runRequest , runHandlerSafe , evalHandlerSafe ) where import Control.Applicative ((<$>)) import Control.Concurrent.MVar (MVar, newEmptyMVar, newMVar ,putMVar, readMVar, takeMVar) import Control.Exception (SomeException, catch) import Control.Monad (void) import Control.Monad.State (StateT (..), runStateT) import qualified Control.Monad.State as S (get, put) import Control.Monad.Trans (liftIO) import Data.Aeson (encode, ToJSON) import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as LBS (ByteString) import Data.ByteString.Lazy (fromStrict, toStrict) import qualified Data.Map as M import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Encoding as T import Snap.Core (Response (..), getHeader) import qualified Snap.Core as Snap import Snap.Snaplet (Handler, Snaplet, SnapletInit, SnapletLens, with) import Snap.Snaplet.Session (SessionManager, commitSession, sessionToList, setInSession) import Snap.Snaplet.Test (InitializerState, closeSnaplet, evalHandler', getSnaplet, runHandler') import Snap.Test (RequestBuilder, getResponseBody) import qualified Snap.Test as Test import Test.Hspec import Test.Hspec.Core.Spec import qualified Text.Digestive as DF import qualified Text.HandsomeSoup as HS import qualified Text.XML.HXT.Core as HXT -- | The result of making requests against your application. Most -- assertions act against these types (for example, `should200`, -- `shouldHaveSelector`, etc). data TestResponse = Html Text | Json LBS.ByteString | NotFound | Redirect Int Text | Other Int | Empty deriving (Show, Eq) -- | The main monad that tests run inside of. This allows both access -- to the application (via requests and `eval`) and to running -- assertions (like `should404` or `shouldHaveText`). type SnapHspecM b = StateT (SnapHspecState b) IO -- | Internal state used to share site initialization across tests, and to propogate failures. -- Understanding it is completely unnecessary to use the library. -- -- The fields it contains, in order, are: -- -- > Result -- > Main handler -- > Startup state -- > Startup state -- > Session state -- > Before handler (runs before each eval) -- > After handler (runs after each eval). data SnapHspecState b = SnapHspecState Result (Handler b b ()) (Snaplet b) (InitializerState b) (MVar [(Text, Text)]) (Handler b b ()) (Handler b b ()) instance Example (SnapHspecM b ()) where type Arg (SnapHspecM b ()) = SnapHspecState b evaluateExample s _ cb _ = do mv <- newEmptyMVar cb $ \st -> do ((),SnapHspecState r' _ _ _ _ _ _) <- runStateT s st putMVar mv r' takeMVar mv -- | Factory instances allow you to easily generate test data. -- -- Essentially, you specify a default way of constructing a -- data type, and allow certain parts of it to be modified (via -- the 'fields' data structure). -- -- An example follows: -- -- > data Foo = Foo Int -- > newtype FooFields = FooFields (IO Int) -- > instance Factory App Foo FooFields where -- > fields = FooFields randomIO -- > save f = liftIO f >>= saveFoo . Foo1 -- > -- > main = do create id :: SnapHspecM App Foo -- > create (const $ FooFields (return 1)) :: SnapHspecM App Foo class Factory b a d | a -> b, a -> d, d -> a where fields :: d save :: d -> SnapHspecM b a create :: (d -> d) -> SnapHspecM b a create transform = save $ transform fields reload :: a -> SnapHspecM b a reload = return -- | The way to run a block of `SnapHspecM` tests within an `hspec` -- test suite. This takes both the top level handler (usually `route -- routes`, where `routes` are all the routes for your site) and the -- site initializer (often named `app`), and a block of tests. A test -- suite can have multiple calls to `snap`, though each one will cause -- the site initializer to run, which is often a slow operation (and -- will slow down test suites). snap :: Handler b b () -> SnapletInit b b -> SpecWith (SnapHspecState b) -> Spec snap site app spec = do snapinit <- runIO $ getSnaplet (Just "test") app mv <- runIO (newMVar []) case snapinit of Left err -> error $ show err Right (snaplet, initstate) -> afterAll (const $ closeSnaplet initstate) $ before (return (SnapHspecState Success site snaplet initstate mv (return ()) (return ()))) spec -- | This allows you to change the default handler you are running -- requests against within a block. This is most likely useful for -- setting request state (for example, logging a user in). modifySite :: (Handler b b () -> Handler b b ()) -> SpecWith (SnapHspecState b) -> SpecWith (SnapHspecState b) modifySite f = beforeWith (\(SnapHspecState r site snaplet initst sess bef aft) -> return (SnapHspecState r (f site) snaplet initst sess bef aft)) -- | This performs a similar operation to `modifySite` but in the context -- of `SnapHspecM` (which is needed if you need to `eval`, produce values, and -- hand them somewhere else (so they can't be created within `f`). modifySite' :: (Handler b b () -> Handler b b ()) -> SnapHspecM b a -> SnapHspecM b a modifySite' f a = do (SnapHspecState r site s i sess bef aft) <- S.get S.put (SnapHspecState r (f site) s i sess bef aft) a -- | Evaluate a Handler action after each test. afterEval :: Handler b b () -> SpecWith (SnapHspecState b) -> SpecWith (SnapHspecState b) afterEval h = after (\(SnapHspecState _r _site s i _ _ _) -> do res <- evalHandlerSafe h s i case res of Right _ -> return () Left msg -> liftIO $ print msg) -- | Evaluate a Handler action before each test. beforeEval :: Handler b b () -> SpecWith (SnapHspecState b) -> SpecWith (SnapHspecState b) beforeEval h = beforeWith (\state@(SnapHspecState _r _site s i _ _ _) -> do void $ evalHandlerSafe h s i return state) class HasSession b where getSessionLens :: SnapletLens b SessionManager recordSession :: HasSession b => SnapHspecM b a -> SnapHspecM b a recordSession a = do (SnapHspecState r site s i mv bef aft) <- S.get S.put (SnapHspecState r site s i mv (do ps <- liftIO $ readMVar mv with getSessionLens $ mapM_ (uncurry setInSession) ps with getSessionLens commitSession) (do ps' <- with getSessionLens sessionToList void . liftIO $ takeMVar mv liftIO $ putMVar mv ps')) res <- a (SnapHspecState r' _ _ _ _ _ _) <- S.get void . liftIO $ takeMVar mv liftIO $ putMVar mv [] S.put (SnapHspecState r' site s i mv bef aft) return res sessContents :: SnapHspecM b Text sessContents = do (SnapHspecState _ _ _ _ mv _ _) <- S.get ps <- liftIO $ readMVar mv return $ T.concat (map (uncurry T.append) ps) sessionShouldContain :: Text -> SnapHspecM b () sessionShouldContain t = do contents <- sessContents if t `T.isInfixOf` contents then setResult Success else setResult (Fail $ "Session did not contain: " ++ T.unpack t ++ "\n\nSession was:\n" ++ T.unpack contents) sessionShouldNotContain :: Text -> SnapHspecM b () sessionShouldNotContain t = do contents <- sessContents if t `T.isInfixOf` contents then setResult (Fail $ "Session should not have contained: " ++ T.unpack t ++ "\n\nSession was:\n" ++ T.unpack contents) else setResult Success -- | Runs a DELETE request delete :: Text -> SnapHspecM b TestResponse delete path = runRequest (Test.delete (T.encodeUtf8 path) M.empty) -- | Runs a GET request. get :: Text -> SnapHspecM b TestResponse get path = get' path M.empty -- | Runs a GET request, with a set of parameters. get' :: Text -> Snap.Params -> SnapHspecM b TestResponse get' path ps = runRequest (Test.get (T.encodeUtf8 path) ps) -- | A helper to construct parameters. params :: [(ByteString, ByteString)] -- ^ Pairs of parameter and value. -> Snap.Params params = M.fromList . map (\x -> (fst x, [snd x])) -- | Creates a new POST request, with a set of parameters. post :: Text -> Snap.Params -> SnapHspecM b TestResponse post path ps = runRequest (Test.postUrlEncoded (T.encodeUtf8 path) ps) -- | Creates a new POST request with a given JSON value as the request body. postJson :: ToJSON tj => Text -> tj -> SnapHspecM b TestResponse postJson path json = runRequest $ Test.postRaw (T.encodeUtf8 path) "application/json" (toStrict $ encode json) -- | Creates a new PUT request, with a set of parameters, with a default type of "application/x-www-form-urlencoded" put :: Text -> Snap.Params -> SnapHspecM b TestResponse put path params' = put' path "application/x-www-form-urlencoded" params' -- | Creates a new PUT request with a configurable MIME/type put' :: Text -> Text -> Snap.Params -> SnapHspecM b TestResponse put' path mime params' = runRequest $ do Test.put (T.encodeUtf8 path) (T.encodeUtf8 mime) "" Test.setQueryString params' -- | Restricts a response to matches for a given CSS selector. -- Does nothing to non-Html responses. restrictResponse :: Text -> TestResponse -> TestResponse restrictResponse selector (Html body) = case HXT.runLA (HXT.xshow $ HXT.hread HXT.>>> HS.css (T.unpack selector)) (T.unpack body) of [] -> Html "" matches -> Html (T.concat (map T.pack matches)) restrictResponse _ r = r -- | Runs an arbitrary stateful action from your application. eval :: Handler b b a -> SnapHspecM b a eval act = do (SnapHspecState _ _site app is _mv bef aft) <- S.get liftIO $ either (error . T.unpack) id <$> evalHandlerSafe (do bef r <- act aft return r) app is -- | Records a test Success or Fail. Only the first Fail will be -- recorded (and will cause the whole block to Fail). setResult :: Result -> SnapHspecM b () setResult r = do (SnapHspecState r' s a i sess bef aft) <- S.get case r' of Success -> S.put (SnapHspecState r s a i sess bef aft) _ -> return () -- | Asserts that a given stateful action will produce a specific different result after -- an action has been run. shouldChange :: (Show a, Eq a) => (a -> a) -> Handler b b a -> SnapHspecM b c -> SnapHspecM b () shouldChange f v act = do before' <- eval v void act after' <- eval v shouldEqual (f before') after' -- | Asserts that two values are equal. shouldEqual :: (Show a, Eq a) => a -> a -> SnapHspecM b () shouldEqual a b = if a == b then setResult Success else setResult (Fail ("Should have held: " ++ show a ++ " == " ++ show b)) -- | Asserts that two values are not equal. shouldNotEqual :: (Show a, Eq a) => a -> a -> SnapHspecM b () shouldNotEqual a b = if a == b then setResult (Fail ("Should not have held: " ++ show a ++ " == " ++ show b)) else setResult Success -- | Asserts that the value is True. shouldBeTrue :: Bool -> SnapHspecM b () shouldBeTrue True = setResult Success shouldBeTrue False = setResult (Fail "Value should have been True.") -- | Asserts that the value is not True (otherwise known as False). shouldNotBeTrue :: Bool -> SnapHspecM b () shouldNotBeTrue False = setResult Success shouldNotBeTrue True = setResult (Fail "Value should have been True.") -- | Asserts that the response is a success (either Html, or Other with status 200). should200 :: TestResponse -> SnapHspecM b () should200 (Html _) = setResult Success should200 (Other 200) = setResult Success should200 r = setResult (Fail (show r)) -- | Asserts that the response is not a normal 200. shouldNot200 :: TestResponse -> SnapHspecM b () shouldNot200 (Html _) = setResult (Fail "Got Html back.") shouldNot200 (Other 200) = setResult (Fail "Got Other with 200 back.") shouldNot200 _ = setResult Success -- | Asserts that the response is a NotFound. should404 :: TestResponse -> SnapHspecM b () should404 NotFound = setResult Success should404 r = setResult (Fail (show r)) -- | Asserts that the response is not a NotFound. shouldNot404 :: TestResponse -> SnapHspecM b () shouldNot404 NotFound = setResult (Fail "Got NotFound back.") shouldNot404 _ = setResult Success -- | Asserts that the response is a redirect. should300 :: TestResponse -> SnapHspecM b () should300 (Redirect _ _) = setResult Success should300 r = setResult (Fail (show r)) -- | Asserts that the response is not a redirect. shouldNot300 :: TestResponse -> SnapHspecM b () shouldNot300 (Redirect _ _) = setResult (Fail "Got Redirect back.") shouldNot300 _ = setResult Success -- | Asserts that the response is a redirect, and thet the url it -- redirects to starts with the given path. should300To :: Text -> TestResponse -> SnapHspecM b () should300To pth (Redirect _ to) | pth `T.isPrefixOf` to = setResult Success should300To _ r = setResult (Fail (show r)) -- | Asserts that the response is not a redirect to a given path. Note -- that it can still be a redirect for this assertion to succeed, the -- path it redirects to just can't start with the given path. shouldNot300To :: Text -> TestResponse -> SnapHspecM b () shouldNot300To pth (Redirect _ to) | pth `T.isPrefixOf` to = setResult (Fail "Got Redirect back.") shouldNot300To _ _ = setResult Success -- | Assert that a response (which should be Html) has a given selector. shouldHaveSelector :: Text -> TestResponse -> SnapHspecM b () shouldHaveSelector selector r@(Html body) = setResult $ if haveSelector' selector r then Success else Fail msg where msg = T.unpack $ T.concat ["Html should have contained selector: ", selector, "\n\n", body] shouldHaveSelector match _ = setResult (Fail (T.unpack $ T.concat ["Non-HTML body should have contained css selector: ", match])) -- | Assert that a response (which should be Html) doesn't have a given selector. shouldNotHaveSelector :: Text -> TestResponse -> SnapHspecM b () shouldNotHaveSelector selector r@(Html body) = setResult $ if haveSelector' selector r then Fail msg else Success where msg = T.unpack $ T.concat ["Html should not have contained selector: ", selector, "\n\n", body] shouldNotHaveSelector _ _ = setResult Success haveSelector' :: Text -> TestResponse -> Bool haveSelector' selector (Html body) = case HXT.runLA (HXT.hread HXT.>>> HS.css (T.unpack selector)) (T.unpack body) of [] -> False _ -> True haveSelector' _ _ = False -- | Asserts that the response (which should be Html) contains the given text. shouldHaveText :: Text -> TestResponse -> SnapHspecM b () shouldHaveText match (Html body) = if T.isInfixOf match body then setResult Success else setResult (Fail $ T.unpack $ T.concat [body, "' contains '", match, "'."]) shouldHaveText match _ = setResult (Fail (T.unpack $ T.concat ["Body contains: ", match])) -- | Asserts that the response (which should be Html) does not contain the given text. shouldNotHaveText :: Text -> TestResponse -> SnapHspecM b () shouldNotHaveText match (Html body) = if T.isInfixOf match body then setResult (Fail $ T.unpack $ T.concat [body, "' contains '", match, "'."]) else setResult Success shouldNotHaveText _ _ = setResult Success -- | A data type for tests against forms. data FormExpectations a = Value a -- ^ The value the form should take (and should be valid) | Predicate (a -> Bool) | ErrorPaths [Text] -- ^ The error paths that should be populated -- | Tests against digestive-functors forms. form :: (Eq a, Show a) => FormExpectations a -- ^ If the form should succeed, Value a is what it should produce. -- If failing, ErrorPaths should be all the errors that are triggered. -> DF.Form Text (Handler b b) a -- ^ The form to run -> M.Map Text Text -- ^ The parameters to pass -> SnapHspecM b () form expected theForm theParams = do r <- eval $ DF.postForm "form" theForm (const $ return lookupParam) case expected of Value a -> shouldEqual (snd r) (Just a) Predicate f -> case snd r of Nothing -> setResult (Fail $ T.unpack $ T.append "Expected form to validate. Resulted in errors: " (T.pack (show $ DF.viewErrors $ fst r))) Just v -> if f v then setResult Success else setResult (Fail $ T.unpack $ T.append "Expected predicate to pass on value: " (T.pack (show v))) ErrorPaths expectedPaths -> do let viewErrorPaths = map (DF.fromPath . fst) $ DF.viewErrors $ fst r if all (`elem` viewErrorPaths) expectedPaths then if length viewErrorPaths == length expectedPaths then setResult Success else setResult (Fail $ "Number of errors did not match test. Got:\n\n " ++ show viewErrorPaths ++ "\n\nBut expected:\n\n" ++ show expectedPaths) else setResult (Fail $ "Did not have all errors specified. Got:\n\n" ++ show viewErrorPaths ++ "\n\nBut expected:\n\n" ++ show expectedPaths) where lookupParam pth = case M.lookup (DF.fromPath pth) fixedParams of Nothing -> return [] Just v -> return [DF.TextInput v] fixedParams = M.mapKeys (T.append "form.") theParams -- | Runs a request (built with helpers from Snap.Test), resulting in a response. runRequest :: RequestBuilder IO () -> SnapHspecM b TestResponse runRequest req = do (SnapHspecState _ site app is _ bef aft) <- S.get res <- liftIO $ runHandlerSafe req (bef >> site >> aft) app is case res of Left err -> error $ T.unpack err Right response -> case rspStatus response of 404 -> return NotFound 200 -> liftIO $ parse200 response _ -> if rspStatus response >= 300 && rspStatus response < 400 then do let url = fromMaybe "" $ getHeader "Location" response return (Redirect (rspStatus response) (T.decodeUtf8 url)) else return (Other (rspStatus response)) parse200 :: Response -> IO TestResponse parse200 resp = let body = getResponseBody resp contentType = getHeader "content-type" resp in case contentType of Just "application/json" -> Json . fromStrict <$> body _ -> Html . T.decodeUtf8 <$> body -- | Runs a request against a given handler (often the whole site), -- with the given state. Returns any triggered exception, or the response. runHandlerSafe :: RequestBuilder IO () -> Handler b b v -> Snaplet b -> InitializerState b -> IO (Either Text Response) runHandlerSafe req site s is = catch (runHandler' s is req site) (\(e::SomeException) -> return $ Left (T.pack $ show e)) -- | Evaluates a given handler with the given state. Returns any -- triggered exception, or the value produced. evalHandlerSafe :: Handler b b v -> Snaplet b -> InitializerState b -> IO (Either Text v) evalHandlerSafe act s is = catch (evalHandler' s is (Test.get "" M.empty) act) (\(e::SomeException) -> return $ Left (T.pack $ show e)) {-# ANN put ("HLint: ignore Eta reduce"::String) #-}
bitemyapp/hspec-snap
src/Test/Hspec/Snap.hs
bsd-3-clause
22,986
0
22
7,031
5,474
2,827
2,647
387
8
{-# LANGUAGE TypeOperators, MultiParamTypeClasses, FunctionalDependencies , UndecidableInstances #-} -- For ghc 6.6 compatibility -- {-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-} ---------------------------------------------------------------------- -- | -- Module : Data.FunArr -- Copyright : (c) Conal Elliott 2007-2013 -- License : BSD3 -- -- Maintainer : [email protected] -- Stability : experimental -- Portability : portable -- -- Conversion between arrow values and wrapped functions. ---------------------------------------------------------------------- module Data.FunArr ( FunArr(..) -- , wapl ) where -- import Control.Monad.Identity import Control.Compose infixr 0 $$ -- FunArr application -- | Convert between an arrow value and a \"wrapped function\". The \"arrow\" -- doesn't really have to be an arrow. I'd appreciate ideas for names & -- uses. class FunArr ar w | ar->w , w->ar where -- | Convert a @w@-wrapped function to an arrow value toArr :: w (a->b) -> (a `ar` b) -- | Apply an arrow to a @w@-wrapped value ($$) :: (a `ar` b) -> w a -> w b -- -- | Apply a wrapped function to a wrapped value -- wapl :: FunArr ar w => w (a->b) -> w a -> w b -- wapl f a = toArr f $$ a -- The type of wapl matches <*> from Control.Applicative. What about -- "pure" from the Applicative class, with type a -> w a? -- Function/Id instance instance FunArr (->) Id where toArr (Id f) = f f $$ Id a = Id (f a) -- -- Oops! This instance can't work with the mutual functional -- dependencies. Instead, instantiate it per @h@. -- -- instance FunArr (FunA h) h where -- toArr = error "toArr: undefined for FunArr" -- Add FunArrable class & delegate -- FunA f $$ ha = f ha -- The following instance violates the "coverage condition" and so -- requires -fallow-undecidable-instances. instance (FunArr ar w, FunArr ar' w') => FunArr (ar ::*:: ar') (w :*: w') where toArr (Prod (f,f')) = Prodd (toArr f, toArr f') Prodd (f,f') $$ Prod (w,w') = Prod (f $$ w, f' $$ w')
conal/DeepArrow
src/Data/FunArr.hs
bsd-3-clause
2,075
2
10
435
310
184
126
17
0
module Main where import Build_doctests (flags, pkgs, module_sources) import Data.Foldable (traverse_) import Test.DocTest (doctest) main :: IO () main = do traverse_ putStrLn args doctest args where args = ["-XOverloadedStrings"] ++ flags ++ pkgs ++ module_sources
kazu-yamamoto/unix-time
test/doctests.hs
bsd-3-clause
282
0
10
52
89
49
40
9
1
----------------------------------------------------------------------------- -- | -- Module : Distribution.Client.Configure -- Copyright : (c) David Himmelstrup 2005, -- Duncan Coutts 2005 -- License : BSD-like -- -- Maintainer : [email protected] -- Portability : portable -- -- High level interface to configuring a package. ----------------------------------------------------------------------------- module Distribution.Client.Configure ( configure, ) where import Distribution.Client.Dependency import qualified Distribution.Client.InstallPlan as InstallPlan import Distribution.Client.InstallPlan (InstallPlan) import Distribution.Client.IndexUtils as IndexUtils ( getSourcePackages, getInstalledPackages ) import Distribution.Client.Setup ( ConfigExFlags(..), configureCommand, filterConfigureFlags ) import Distribution.Client.Types as Source import Distribution.Client.SetupWrapper ( setupWrapper, SetupScriptOptions(..), defaultSetupScriptOptions ) import Distribution.Client.Targets ( userToPackageConstraint ) import Distribution.Simple.Compiler ( CompilerId(..), Compiler(compilerId) , PackageDB(..), PackageDBStack ) import Distribution.Simple.Program (ProgramConfiguration ) import Distribution.Simple.Setup ( ConfigFlags(..), fromFlag, toFlag, flagToMaybe, fromFlagOrDefault ) import Distribution.Simple.PackageIndex (PackageIndex) import Distribution.Simple.Utils ( defaultPackageDesc ) import Distribution.Package ( Package(..), packageName, Dependency(..), thisPackageVersion ) import Distribution.PackageDescription.Parse ( readPackageDescription ) import Distribution.PackageDescription.Configuration ( finalizePackageDescription ) import Distribution.Version ( anyVersion, thisVersion ) import Distribution.Simple.Utils as Utils ( notice, info, debug, die ) import Distribution.System ( Platform, buildPlatform ) import Distribution.Verbosity as Verbosity ( Verbosity ) import Data.Monoid (Monoid(..)) -- | Configure the package found in the local directory configure :: Verbosity -> PackageDBStack -> [Repo] -> Compiler -> ProgramConfiguration -> ConfigFlags -> ConfigExFlags -> [String] -> IO () configure verbosity packageDBs repos comp conf configFlags configExFlags extraArgs = do installedPkgIndex <- getInstalledPackages verbosity comp packageDBs conf sourcePkgDb <- getSourcePackages verbosity repos progress <- planLocalPackage verbosity comp configFlags configExFlags installedPkgIndex sourcePkgDb notice verbosity "Resolving dependencies..." maybePlan <- foldProgress logMsg (return . Left) (return . Right) progress case maybePlan of Left message -> do info verbosity message setupWrapper verbosity (setupScriptOptions installedPkgIndex) Nothing configureCommand (const configFlags) extraArgs Right installPlan -> case InstallPlan.ready installPlan of [pkg@(ConfiguredPackage (SourcePackage _ _ (LocalUnpackedPackage _)) _ _ _)] -> configurePackage verbosity (InstallPlan.planPlatform installPlan) (InstallPlan.planCompiler installPlan) (setupScriptOptions installedPkgIndex) configFlags pkg extraArgs _ -> die $ "internal error: configure install plan should have exactly " ++ "one local ready package." where setupScriptOptions index = SetupScriptOptions { useCabalVersion = maybe anyVersion thisVersion (flagToMaybe (configCabalVersion configExFlags)), useCompiler = Just comp, -- Hack: we typically want to allow the UserPackageDB for finding the -- Cabal lib when compiling any Setup.hs even if we're doing a global -- install. However we also allow looking in a specific package db. usePackageDB = if UserPackageDB `elem` packageDBs then packageDBs else packageDBs ++ [UserPackageDB], usePackageIndex = if UserPackageDB `elem` packageDBs then Just index else Nothing, useProgramConfig = conf, useDistPref = fromFlagOrDefault (useDistPref defaultSetupScriptOptions) (configDistPref configFlags), useLoggingHandle = Nothing, useWorkingDir = Nothing } logMsg message rest = debug verbosity message >> rest -- | Make an 'InstallPlan' for the unpacked package in the current directory, -- and all its dependencies. -- planLocalPackage :: Verbosity -> Compiler -> ConfigFlags -> ConfigExFlags -> PackageIndex -> SourcePackageDb -> IO (Progress String String InstallPlan) planLocalPackage verbosity comp configFlags configExFlags installedPkgIndex (SourcePackageDb _ packagePrefs) = do pkg <- readPackageDescription verbosity =<< defaultPackageDesc verbosity let -- We create a local package and ask to resolve a dependency on it localPkg = SourcePackage { packageInfoId = packageId pkg, Source.packageDescription = pkg, packageSource = LocalUnpackedPackage "." } solver = fromFlag $ configSolver configExFlags testsEnabled = fromFlagOrDefault False $ configTests configFlags benchmarksEnabled = fromFlagOrDefault False $ configBenchmarks configFlags resolverParams = addPreferences -- preferences from the config file or command line [ PackageVersionPreference name ver | Dependency name ver <- configPreferences configExFlags ] . addConstraints -- version constraints from the config file or command line -- TODO: should warn or error on constraints that are not on direct deps -- or flag constraints not on the package in question. (map userToPackageConstraint (configExConstraints configExFlags)) . addConstraints -- package flags from the config file or command line [ PackageConstraintFlags (packageName pkg) (configConfigurationsFlags configFlags) ] . addConstraints -- '--enable-tests' and '--enable-benchmarks' constraints from -- command line [ PackageConstraintStanzas (packageName pkg) $ concat [ if testsEnabled then [TestStanzas] else [] , if benchmarksEnabled then [BenchStanzas] else [] ] ] $ standardInstallPolicy installedPkgIndex (SourcePackageDb mempty packagePrefs) [SpecificSourcePackage localPkg] return (resolveDependencies buildPlatform (compilerId comp) solver resolverParams) -- | Call an installer for an 'SourcePackage' but override the configure -- flags with the ones given by the 'ConfiguredPackage'. In particular the -- 'ConfiguredPackage' specifies an exact 'FlagAssignment' and exactly -- versioned package dependencies. So we ignore any previous partial flag -- assignment or dependency constraints and use the new ones. -- configurePackage :: Verbosity -> Platform -> CompilerId -> SetupScriptOptions -> ConfigFlags -> ConfiguredPackage -> [String] -> IO () configurePackage verbosity platform comp scriptOptions configFlags (ConfiguredPackage (SourcePackage _ gpkg _) flags stanzas deps) extraArgs = setupWrapper verbosity scriptOptions (Just pkg) configureCommand configureFlags extraArgs where configureFlags = filterConfigureFlags configFlags { configConfigurationsFlags = flags, configConstraints = map thisPackageVersion deps, configVerbosity = toFlag verbosity, configBenchmarks = toFlag (BenchStanzas `elem` stanzas), configTests = toFlag (TestStanzas `elem` stanzas) } pkg = case finalizePackageDescription flags (const True) platform comp [] (enableStanzas stanzas gpkg) of Left _ -> error "finalizePackageDescription ConfiguredPackage failed" Right (desc, _) -> desc
alphaHeavy/cabal
cabal-install/Distribution/Client/Configure.hs
bsd-3-clause
8,529
0
20
2,277
1,429
793
636
144
5
module Text.OpenGL.Xml.ReadRegistry ( readRegistry, parseRegistry, PreProcess ) where import Prelude hiding ((.), id) import Control.Category import Text.OpenGL.Types import Text.OpenGL.Xml.Pickle() import Text.OpenGL.Xml.PreProcess import Text.XML.HXT.Core type PreProcess = Bool -- TODO RelaxNG validation readRegistry :: FilePath -> PreProcess -> IO (Either String Registry) readRegistry fp pp = do results <- runX ( readDocument readOpts fp >>> preProcess pp >>> parseRegistryArrow ) -- TODO: error handling return $ handleResults results where readOpts :: [SysConfig] readOpts = [withValidate no, withPreserveComment no] preProcess :: (ArrowChoice a, ArrowXml a) => PreProcess -> a XmlTree XmlTree preProcess pp = if pp then preProcessRegistry else id -- | TODO: make it work (doesn't work with the <?xml ?> header. parseRegistry :: String -> PreProcess -> Either String Registry parseRegistry str pp = handleResults $ runLA ( xread >>> preProcess pp >>> parseRegistryArrow ) str handleResults :: [Either String Registry] -> Either String Registry handleResults rs = case rs of [] -> Left "No parse" (_:_:_) -> Left "Multiple parse" [rc] -> rc parseRegistryArrow :: ArrowXml a => a XmlTree (Either String Registry) parseRegistryArrow = removeAllWhiteSpace >>> -- This processing is needed for the non IO case. removeAllComment >>> arr (unpickleDoc' xpickle)
Laar/opengl-xmlspec
src/Text/OpenGL/Xml/ReadRegistry.hs
bsd-3-clause
1,468
0
12
298
395
213
182
34
3
{-# Language OverloadedStrings #-} module XMonad.Actions.XHints.Render where import XMonad hiding (drawString) import Data.Text (Text) import qualified Data.Text as T import Foreign.C import Graphics.X11.Xlib.Types import qualified Data.Text.Foreign as TF import qualified Data.ByteString as BS import Codec.Binary.UTF8.String mkUnmanagedWindow :: Display -> Screen -> Window -> Position -> Position -> Dimension -> Dimension -> IO Window mkUnmanagedWindow d s rw x y w h = do let visual = defaultVisualOfScreen s attrmask = cWOverrideRedirect allocaSetWindowAttributes $ \attributes -> do set_override_redirect attributes True createWindow d rw x y w h 0 (defaultDepthOfScreen s) inputOutput visual attrmask attributes newHintWindow :: Display -> IO (Window,GC) newHintWindow dpy = do let win = defaultRootWindow dpy blk = blackPixel dpy $ defaultScreen dpy wht = whitePixel dpy $ defaultScreen dpy scn = defaultScreenOfDisplay dpy (_,_,_,_,_,x,y,_) <- queryPointer dpy win nw <- createSimpleWindow dpy win (fromIntegral x) (fromIntegral y) 2 2 1 blk wht mapWindow dpy nw gc <- createGC dpy nw return (nw,gc)
netogallo/XHints
src/XMonad/Actions/XHints/Render.hs
bsd-3-clause
1,227
0
13
272
381
202
179
31
1
isPrime :: Integral a => a -> Bool isPrime 2 = True isPrime 3 = True isPrime n = all (\ x -> x /= 0) [n `mod` x | x <- [2..(truncate $ sqrt (fromIntegral n) + 1)]] goldbach :: (Integral t, Integral t1) => t1 -> (t, t1) goldbach n = goldbach' 3 (n - 3) where goldbach' a b | isPrime a && isPrime b = (a, b) | otherwise = goldbach' (a + 2) (b - 2)
m00nlight/99-problems
haskell/p-40.hs
bsd-3-clause
403
0
15
138
212
109
103
11
1
module UI.Widget.List ( listWidget ) where import Reactive.Banana import Reactive.Banana.Extra import Reactive.Banana.Frameworks import UI.TclTk import UI.TclTk.AST import UI.TclTk.Builder import UI.Widget -- | List widget listWidget :: Frameworks t => Event t [a] -> GUI t p (TkName, Event t (Int,a)) listWidget eList = do frame [Fill FillX] $ withPack PackLeft $ do let toEvt x (_,e) = x <$ e -- Buttons spacer e1 <- toEvt ToBegin <$> button [Text "<|" ] [] e2 <- toEvt (MoveBack 10) <$> button [Text "<<<"] [] e3 <- toEvt (MoveBack 1 ) <$> button [Text "<" ] [] -- Central area spacer Widget _ eN finiN <- entryInt [] [] _ <- label [ Text " / " ] [] labN <- label [] [] actimateTcl (length <$> eList) $ do configure labN $ LamOpt $ Text . show spacer -- More buttons e4 <- toEvt (MoveFwd 1 ) <$> button [Text ">" ] [] e5 <- toEvt (MoveFwd 10) <$> button [Text ">>>"] [] e6 <- toEvt ToEnd <$> button [Text "|>" ] [] spacer -- OOPS let events = listEvents eList (unions [JumpTo <$> eN, e1, e2, e3, e4, e5, e6]) finiN $ Bhv 0 $ fst <$> events return events -- Commands for a list data ListCmd = MoveFwd Int | MoveBack Int | JumpTo Int | ToBegin | ToEnd deriving (Show) -- Cursor for list of values data Cursor a = Cursor Int [a] Int -- Length Γ— list Γ— position | Invalid listEvents :: Event t [a] -> Event t ListCmd -> Event t (Int,a) listEvents listEvt command = filterJust $ fmap fini $ scanE acc Invalid $ listEvt `joinE` command where -- fini (Cursor _ xs i) = Just (i, xs !! i) fini Invalid = Nothing -- Accumulate data acc Invalid (Left []) = Invalid acc Invalid (Left xs) = Cursor (length xs) xs 0 acc Invalid _ = Invalid acc (Cursor _ _ n) (Left xs) = Cursor len xs $ clip len n where len = length xs acc (Cursor len xs n) (Right c) = case c of MoveFwd d -> go $ n + d MoveBack d -> go $ n - d JumpTo d -> go d ToBegin -> go 0 ToEnd -> go $ len - 1 where go = Cursor len xs . clip len -- Clip out of range indices clip len i | i < 0 = 0 | i >= len = len -1 | otherwise = i
Shimuuar/banana-tcltk
UI/Widget/List.hs
bsd-3-clause
2,401
0
17
830
963
478
485
66
10
{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DataKinds #-} module React.Flux.Mui.RadioButton.RadioButtonGroup where import Protolude import Data.Aeson import Data.Aeson.Casing import Data.String (String) import React.Flux import React.Flux.Mui.Types import React.Flux.Mui.Util data RadioButtonGroup = RadioButtonGroup { radioButtonGroupClassName :: !(Maybe Text) , radioButtonGroupLabelPosition :: !(Maybe (MuiSymbolEnum '[ "left", "right"])) , radioButtonGroupName :: !Text } deriving (Generic, Show) instance ToJSON RadioButtonGroup where toJSON = genericToJSON $ aesonDrop (length ("RadioButtonGroup" :: String)) camelCase defRadioButtonGroup :: Text -> RadioButtonGroup defRadioButtonGroup radioButtonGroupName_ = RadioButtonGroup { radioButtonGroupClassName = Nothing , radioButtonGroupLabelPosition = Nothing , radioButtonGroupName = radioButtonGroupName_ } radioButtonGroup_ :: RadioButtonGroup -> [PropertyOrHandler handler] -> ReactElementM handler () -> ReactElementM handler () radioButtonGroup_ args props = foreign_ "RadioButtonGroup" (fromMaybe [] (toProps args) ++ props)
pbogdan/react-flux-mui
react-flux-mui/src/React/Flux/Mui/RadioButton/RadioButtonGroup.hs
bsd-3-clause
1,165
0
15
161
265
150
115
38
1
-- | -- Module: Threshold -- Description: Time integrated threshold functions -- Copyright: (c) 2013 Tom Hawkins & Lee Pike -- -- Time integrated threshold functions typically used in condition monitoring. module Language.Atom.Common.Threshold ( boolThreshold , doubleThreshold ) where import Language.Atom.Expressions import Language.Atom.Language import Data.Int (Int32) -- | Boolean thresholding over time. Output is set when internal counter hits -- limit, and cleared when counter is 0. boolThreshold :: Name -> Int32 -> Bool -> E Bool -> Atom (E Bool) boolThreshold name_ num init_ input = atom name_ "" $ do --assert "positiveNumber" $ num >= 0 state <- bool "state" init_ count <- int32 "count" (if init_ then num else 0) atom "update" "" $ do cond $ value count >. Const 0 &&. value count <. Const num count <== value count + mux input (Const 1) (Const (-1)) atom "low" "" $ do cond $ value count ==. Const 0 state <== false atom "high" "" $ do cond $ value count ==. Const num state <== true return $ value state -- | Integrating threshold. Output is set with integral reaches limit, and -- cleared when integral reaches 0. doubleThreshold :: Name -> Double -> E Double -> Atom (E Bool) doubleThreshold name_ lim input = atom name_ "" $ do --assert "positiveLimit" $ lim >= 0 state <- bool "state" False sum_ <- double "sum" 0 -- TODO: Figure out what the below translates to in the newer library -- (high,low) <- priority atom "update" "" $ do sum_ <== value sum_ + input -- low atom "clear" "" $ do cond $ value sum_ <=. 0 state <== false sum_ <== 0 -- high atom "set" "" $ do cond $ value sum_ >=. Const lim state <== true sum_ <== Const lim -- high return $ value state
Copilot-Language/atom_for_copilot
Language/Atom/Common/Threshold.hs
bsd-3-clause
1,806
0
16
428
505
241
264
35
2
import Control.Monad (when) import Distribution.Simple import System.Directory (doesFileExist) import System.Process (readProcess) import Data.ByteString.Char8 as BS gitVersion :: IO () gitVersion = do let filename = "app/Internal/Version.hs" versionSh = "./version.sh" hasVersionSh <- doesFileExist versionSh when hasVersionSh $ do ver <- fmap BS.pack $ readProcess "bash" [versionSh] "" let override = BS.writeFile filename ver e <- doesFileExist filename if e then do orig_ver <- BS.readFile filename when (ver /= orig_ver) $ do override else override main :: IO () main = gitVersion >> defaultMain
da-x/fancydiff
Setup.hs
bsd-3-clause
780
0
16
260
207
103
104
20
2
module Vector where data Vec = V !Int !Int deriving (Show, Eq) instance Num Vec where V x1 y1 + V x2 y2 = V (x1+x2) (y1+y2) V x1 y1 - V x2 y2 = V (x1-x2) (y1-y2) V x1 y1 * V x2 y2 = V (x1*x2) (y1*y2) abs (V x y) = V (abs x) (abs y) signum (V x y) = V (signum x) (signum y) fromInteger x = V (fromInteger x) (fromInteger x)
cobbpg/dow
src/Vector.hs
bsd-3-clause
337
0
8
91
247
120
127
13
0
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE NoImplicitPrelude #-} module Ircbrowse.View.Template where import Ircbrowse.View import Ircbrowse.Types.Import import qualified Text.Blaze.Html5 as H import Data.Text (Text) template :: AttributeValue -> Text -> Html -> Html -> Html template name thetitle innerhead innerbody = do docType html $ do head $ do H.title $ toHtml thetitle link ! rel "stylesheet" ! type_ "text/css" ! href "/css/bootstrap.min.css" link ! rel "stylesheet" ! type_ "text/css" ! href "/css/bootstrap-responsive.css" link ! rel "stylesheet" ! type_ "text/css" ! href "/css/ircbrowse.css" meta ! httpEquiv "Content-Type" ! content "text/html; charset=UTF-8" innerhead body !# name $ do innerbody preEscapedToHtml ("<script type=\"text/javascript\"> var _gaq = _gaq \ \|| []; _gaq.push(['_setAccount', 'UA-38975161-1']);\ \ _gaq.push(['_trackPageview']); (function() {var ga\ \ = document.createElement('script'); ga.type = 'tex\ \t/javascript'; ga.async = true; ga.src = ('https:' \ \== document.location.protocol ? 'https://ssl' : \ \'http://www') + '.google-analytics.com/ga.js'; var\ \ s = document.getElementsByTagName('script')[0]; \ \s.parentNode.insertBefore(ga, s);})(); </script>" :: Text) channelNav :: Channel -> Html channelNav channel = div !. "navbar navbar-static-top navbar-inverse" $ div !. "navbar-inner" $ do div !. "container" $ do a !. "brand" ! href "/" $ "IRCBrowse" ul !. "nav" $ do li $ a ! href (toValue ("/" ++ showChan channel)) $ do (toHtml (prettyChan channel)) li $ a ! href (toValue ("/browse/" ++ showChan channel)) $ do "Browse" -- li $ a ! href (toValue ("/day/" ++ showChan channel ++ "/today/recent")) $ do -- "Recent" -- li $ a ! href (toValue ("/day/" ++ showChan channel ++ "/today")) $ do -- "Today" -- li $ a ! href (toValue ("/calendar/" ++ showChan channel)) $ do -- "Calendar" -- li $ a ! href (toValue ("/nicks/" ++ showChan channel)) $ do -- "Nicks" -- li $ a ! href (toValue ("/pdfs/" ++ showChan channel)) $ do -- "PDFs" showCount :: (Show n,Integral n) => n -> String showCount = reverse . foldr merge "" . zip ("000,00,00,00"::String) . reverse . show where merge (f,c) rest | f == ',' = "," ++ [c] ++ rest | otherwise = [c] ++ rest footer :: Html footer = div !# "footer" $ div !. "container" $ do p !. "muted credit" $ do a ! href "http://ircbrowse.net" $ "IRC Browse" " by " a ! href "http://chrisdone.com" $ "Chris Done" " | " a ! href "https://github.com/chrisdone/ircbrowse" $ "Source code" " | " a ! href "http://haskell.org/" $ "Haskell" mainHeading :: Html -> Html mainHeading inner = h1 $ do a ! href "/" $ do "IRC Browse" ": " inner
chrisdone/ircbrowse
src/Ircbrowse/View/Template.hs
bsd-3-clause
3,220
0
21
986
651
318
333
54
1
-------------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.OpenGL.Raw.Compatibility31 -- Copyright : (c) Sven Panne 2015 -- License : BSD3 -- -- Maintainer : Sven Panne <[email protected]> -- Stability : stable -- Portability : portable -- -------------------------------------------------------------------------------- module Graphics.Rendering.OpenGL.Raw.Compatibility31 ( -- * Types GLbitfield, GLboolean, GLbyte, GLchar, GLclampd, GLclampf, GLdouble, GLenum, GLfloat, GLhalf, GLint, GLintptr, GLshort, GLsizei, GLsizeiptr, GLubyte, GLuint, GLushort, GLvoid, -- * Enums gl_2D, gl_2_BYTES, gl_3D, gl_3D_COLOR, gl_3D_COLOR_TEXTURE, gl_3_BYTES, gl_4D_COLOR_TEXTURE, gl_4_BYTES, gl_ACCUM, gl_ACCUM_ALPHA_BITS, gl_ACCUM_BLUE_BITS, gl_ACCUM_BUFFER_BIT, gl_ACCUM_CLEAR_VALUE, gl_ACCUM_GREEN_BITS, gl_ACCUM_RED_BITS, gl_ACTIVE_ATTRIBUTES, gl_ACTIVE_ATTRIBUTE_MAX_LENGTH, gl_ACTIVE_TEXTURE, gl_ACTIVE_UNIFORMS, gl_ACTIVE_UNIFORM_BLOCKS, gl_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, gl_ACTIVE_UNIFORM_MAX_LENGTH, gl_ADD, gl_ADD_SIGNED, gl_ALIASED_LINE_WIDTH_RANGE, gl_ALIASED_POINT_SIZE_RANGE, gl_ALL_ATTRIB_BITS, gl_ALPHA, gl_ALPHA12, gl_ALPHA16, gl_ALPHA4, gl_ALPHA8, gl_ALPHA_BIAS, gl_ALPHA_BITS, gl_ALPHA_INTEGER, gl_ALPHA_SCALE, gl_ALPHA_TEST, gl_ALPHA_TEST_FUNC, gl_ALPHA_TEST_REF, gl_ALWAYS, gl_AMBIENT, gl_AMBIENT_AND_DIFFUSE, gl_AND, gl_AND_INVERTED, gl_AND_REVERSE, gl_ARRAY_BUFFER, gl_ARRAY_BUFFER_BINDING, gl_ATTACHED_SHADERS, gl_ATTRIB_STACK_DEPTH, gl_AUTO_NORMAL, gl_AUX0, gl_AUX1, gl_AUX2, gl_AUX3, gl_AUX_BUFFERS, gl_BACK, gl_BACK_LEFT, gl_BACK_RIGHT, gl_BGR, gl_BGRA, gl_BGRA_INTEGER, gl_BGR_INTEGER, gl_BITMAP, gl_BITMAP_TOKEN, gl_BLEND, gl_BLEND_DST, gl_BLEND_DST_ALPHA, gl_BLEND_DST_RGB, gl_BLEND_EQUATION_ALPHA, gl_BLEND_EQUATION_RGB, gl_BLEND_SRC, gl_BLEND_SRC_ALPHA, gl_BLEND_SRC_RGB, gl_BLUE, gl_BLUE_BIAS, gl_BLUE_BITS, gl_BLUE_INTEGER, gl_BLUE_SCALE, gl_BOOL, gl_BOOL_VEC2, gl_BOOL_VEC3, gl_BOOL_VEC4, gl_BUFFER_ACCESS, gl_BUFFER_ACCESS_FLAGS, gl_BUFFER_MAPPED, gl_BUFFER_MAP_LENGTH, gl_BUFFER_MAP_OFFSET, gl_BUFFER_MAP_POINTER, gl_BUFFER_SIZE, gl_BUFFER_USAGE, gl_BYTE, gl_C3F_V3F, gl_C4F_N3F_V3F, gl_C4UB_V2F, gl_C4UB_V3F, gl_CCW, gl_CLAMP, gl_CLAMP_FRAGMENT_COLOR, gl_CLAMP_READ_COLOR, gl_CLAMP_TO_BORDER, gl_CLAMP_TO_EDGE, gl_CLAMP_VERTEX_COLOR, gl_CLEAR, gl_CLIENT_ACTIVE_TEXTURE, gl_CLIENT_ALL_ATTRIB_BITS, gl_CLIENT_ATTRIB_STACK_DEPTH, gl_CLIENT_PIXEL_STORE_BIT, gl_CLIENT_VERTEX_ARRAY_BIT, gl_CLIP_DISTANCE0, gl_CLIP_DISTANCE1, gl_CLIP_DISTANCE2, gl_CLIP_DISTANCE3, gl_CLIP_DISTANCE4, gl_CLIP_DISTANCE5, gl_CLIP_DISTANCE6, gl_CLIP_DISTANCE7, gl_CLIP_PLANE0, gl_CLIP_PLANE1, gl_CLIP_PLANE2, gl_CLIP_PLANE3, gl_CLIP_PLANE4, gl_CLIP_PLANE5, gl_COEFF, gl_COLOR, gl_COLOR_ARRAY, gl_COLOR_ARRAY_BUFFER_BINDING, gl_COLOR_ARRAY_POINTER, gl_COLOR_ARRAY_SIZE, gl_COLOR_ARRAY_STRIDE, gl_COLOR_ARRAY_TYPE, gl_COLOR_ATTACHMENT0, gl_COLOR_ATTACHMENT1, gl_COLOR_ATTACHMENT10, gl_COLOR_ATTACHMENT11, gl_COLOR_ATTACHMENT12, gl_COLOR_ATTACHMENT13, gl_COLOR_ATTACHMENT14, gl_COLOR_ATTACHMENT15, gl_COLOR_ATTACHMENT2, gl_COLOR_ATTACHMENT3, gl_COLOR_ATTACHMENT4, gl_COLOR_ATTACHMENT5, gl_COLOR_ATTACHMENT6, gl_COLOR_ATTACHMENT7, gl_COLOR_ATTACHMENT8, gl_COLOR_ATTACHMENT9, gl_COLOR_BUFFER_BIT, gl_COLOR_CLEAR_VALUE, gl_COLOR_INDEX, gl_COLOR_INDEXES, gl_COLOR_LOGIC_OP, gl_COLOR_MATERIAL, gl_COLOR_MATERIAL_FACE, gl_COLOR_MATERIAL_PARAMETER, gl_COLOR_SUM, gl_COLOR_WRITEMASK, gl_COMBINE, gl_COMBINE_ALPHA, gl_COMBINE_RGB, gl_COMPARE_REF_TO_TEXTURE, gl_COMPARE_R_TO_TEXTURE, gl_COMPILE, gl_COMPILE_AND_EXECUTE, gl_COMPILE_STATUS, gl_COMPRESSED_ALPHA, gl_COMPRESSED_INTENSITY, gl_COMPRESSED_LUMINANCE, gl_COMPRESSED_LUMINANCE_ALPHA, gl_COMPRESSED_RED, gl_COMPRESSED_RED_RGTC1, gl_COMPRESSED_RG, gl_COMPRESSED_RGB, gl_COMPRESSED_RGBA, gl_COMPRESSED_RG_RGTC2, gl_COMPRESSED_SIGNED_RED_RGTC1, gl_COMPRESSED_SIGNED_RG_RGTC2, gl_COMPRESSED_SLUMINANCE, gl_COMPRESSED_SLUMINANCE_ALPHA, gl_COMPRESSED_SRGB, gl_COMPRESSED_SRGB_ALPHA, gl_COMPRESSED_TEXTURE_FORMATS, gl_CONSTANT, gl_CONSTANT_ALPHA, gl_CONSTANT_ATTENUATION, gl_CONSTANT_COLOR, gl_CONTEXT_FLAGS, gl_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, gl_COORD_REPLACE, gl_COPY, gl_COPY_INVERTED, gl_COPY_PIXEL_TOKEN, gl_COPY_READ_BUFFER, gl_COPY_WRITE_BUFFER, gl_CULL_FACE, gl_CULL_FACE_MODE, gl_CURRENT_BIT, gl_CURRENT_COLOR, gl_CURRENT_FOG_COORD, gl_CURRENT_FOG_COORDINATE, gl_CURRENT_INDEX, gl_CURRENT_NORMAL, gl_CURRENT_PROGRAM, gl_CURRENT_QUERY, gl_CURRENT_RASTER_COLOR, gl_CURRENT_RASTER_DISTANCE, gl_CURRENT_RASTER_INDEX, gl_CURRENT_RASTER_POSITION, gl_CURRENT_RASTER_POSITION_VALID, gl_CURRENT_RASTER_SECONDARY_COLOR, gl_CURRENT_RASTER_TEXTURE_COORDS, gl_CURRENT_SECONDARY_COLOR, gl_CURRENT_TEXTURE_COORDS, gl_CURRENT_VERTEX_ATTRIB, gl_CW, gl_DECAL, gl_DECR, gl_DECR_WRAP, gl_DELETE_STATUS, gl_DEPTH, gl_DEPTH24_STENCIL8, gl_DEPTH32F_STENCIL8, gl_DEPTH_ATTACHMENT, gl_DEPTH_BIAS, gl_DEPTH_BITS, gl_DEPTH_BUFFER_BIT, gl_DEPTH_CLEAR_VALUE, gl_DEPTH_COMPONENT, gl_DEPTH_COMPONENT16, gl_DEPTH_COMPONENT24, gl_DEPTH_COMPONENT32, gl_DEPTH_COMPONENT32F, gl_DEPTH_FUNC, gl_DEPTH_RANGE, gl_DEPTH_SCALE, gl_DEPTH_STENCIL, gl_DEPTH_STENCIL_ATTACHMENT, gl_DEPTH_TEST, gl_DEPTH_TEXTURE_MODE, gl_DEPTH_WRITEMASK, gl_DIFFUSE, gl_DITHER, gl_DOMAIN, gl_DONT_CARE, gl_DOT3_RGB, gl_DOT3_RGBA, gl_DOUBLE, gl_DOUBLEBUFFER, gl_DRAW_BUFFER, gl_DRAW_BUFFER0, gl_DRAW_BUFFER1, gl_DRAW_BUFFER10, gl_DRAW_BUFFER11, gl_DRAW_BUFFER12, gl_DRAW_BUFFER13, gl_DRAW_BUFFER14, gl_DRAW_BUFFER15, gl_DRAW_BUFFER2, gl_DRAW_BUFFER3, gl_DRAW_BUFFER4, gl_DRAW_BUFFER5, gl_DRAW_BUFFER6, gl_DRAW_BUFFER7, gl_DRAW_BUFFER8, gl_DRAW_BUFFER9, gl_DRAW_FRAMEBUFFER, gl_DRAW_FRAMEBUFFER_BINDING, gl_DRAW_PIXEL_TOKEN, gl_DST_ALPHA, gl_DST_COLOR, gl_DYNAMIC_COPY, gl_DYNAMIC_DRAW, gl_DYNAMIC_READ, gl_EDGE_FLAG, gl_EDGE_FLAG_ARRAY, gl_EDGE_FLAG_ARRAY_BUFFER_BINDING, gl_EDGE_FLAG_ARRAY_POINTER, gl_EDGE_FLAG_ARRAY_STRIDE, gl_ELEMENT_ARRAY_BUFFER, gl_ELEMENT_ARRAY_BUFFER_BINDING, gl_EMISSION, gl_ENABLE_BIT, gl_EQUAL, gl_EQUIV, gl_EVAL_BIT, gl_EXP, gl_EXP2, gl_EXTENSIONS, gl_EYE_LINEAR, gl_EYE_PLANE, gl_FALSE, gl_FASTEST, gl_FEEDBACK, gl_FEEDBACK_BUFFER_POINTER, gl_FEEDBACK_BUFFER_SIZE, gl_FEEDBACK_BUFFER_TYPE, gl_FILL, gl_FIXED_ONLY, gl_FLAT, gl_FLOAT, gl_FLOAT_32_UNSIGNED_INT_24_8_REV, gl_FLOAT_MAT2, gl_FLOAT_MAT2x3, gl_FLOAT_MAT2x4, gl_FLOAT_MAT3, gl_FLOAT_MAT3x2, gl_FLOAT_MAT3x4, gl_FLOAT_MAT4, gl_FLOAT_MAT4x2, gl_FLOAT_MAT4x3, gl_FLOAT_VEC2, gl_FLOAT_VEC3, gl_FLOAT_VEC4, gl_FOG, gl_FOG_BIT, gl_FOG_COLOR, gl_FOG_COORD, gl_FOG_COORDINATE, gl_FOG_COORDINATE_ARRAY, gl_FOG_COORDINATE_ARRAY_BUFFER_BINDING, gl_FOG_COORDINATE_ARRAY_POINTER, gl_FOG_COORDINATE_ARRAY_STRIDE, gl_FOG_COORDINATE_ARRAY_TYPE, gl_FOG_COORDINATE_SOURCE, gl_FOG_COORD_ARRAY, gl_FOG_COORD_ARRAY_BUFFER_BINDING, gl_FOG_COORD_ARRAY_POINTER, gl_FOG_COORD_ARRAY_STRIDE, gl_FOG_COORD_ARRAY_TYPE, gl_FOG_COORD_SRC, gl_FOG_DENSITY, gl_FOG_END, gl_FOG_HINT, gl_FOG_INDEX, gl_FOG_MODE, gl_FOG_START, gl_FRAGMENT_DEPTH, gl_FRAGMENT_SHADER, gl_FRAGMENT_SHADER_DERIVATIVE_HINT, gl_FRAMEBUFFER, gl_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, gl_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, gl_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, gl_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, gl_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, gl_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE, gl_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, gl_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, gl_FRAMEBUFFER_ATTACHMENT_RED_SIZE, gl_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, gl_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, gl_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER, gl_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, gl_FRAMEBUFFER_BINDING, gl_FRAMEBUFFER_COMPLETE, gl_FRAMEBUFFER_DEFAULT, gl_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, gl_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER, gl_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT, gl_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, gl_FRAMEBUFFER_INCOMPLETE_READ_BUFFER, gl_FRAMEBUFFER_SRGB, gl_FRAMEBUFFER_UNDEFINED, gl_FRAMEBUFFER_UNSUPPORTED, gl_FRONT, gl_FRONT_AND_BACK, gl_FRONT_FACE, gl_FRONT_LEFT, gl_FRONT_RIGHT, gl_FUNC_ADD, gl_FUNC_REVERSE_SUBTRACT, gl_FUNC_SUBTRACT, gl_GENERATE_MIPMAP, gl_GENERATE_MIPMAP_HINT, gl_GEQUAL, gl_GREATER, gl_GREEN, gl_GREEN_BIAS, gl_GREEN_BITS, gl_GREEN_INTEGER, gl_GREEN_SCALE, gl_HALF_FLOAT, gl_HINT_BIT, gl_INCR, gl_INCR_WRAP, gl_INDEX, gl_INDEX_ARRAY, gl_INDEX_ARRAY_BUFFER_BINDING, gl_INDEX_ARRAY_POINTER, gl_INDEX_ARRAY_STRIDE, gl_INDEX_ARRAY_TYPE, gl_INDEX_BITS, gl_INDEX_CLEAR_VALUE, gl_INDEX_LOGIC_OP, gl_INDEX_MODE, gl_INDEX_OFFSET, gl_INDEX_SHIFT, gl_INDEX_WRITEMASK, gl_INFO_LOG_LENGTH, gl_INT, gl_INTENSITY, gl_INTENSITY12, gl_INTENSITY16, gl_INTENSITY4, gl_INTENSITY8, gl_INTERLEAVED_ATTRIBS, gl_INTERPOLATE, gl_INT_SAMPLER_1D, gl_INT_SAMPLER_1D_ARRAY, gl_INT_SAMPLER_2D, gl_INT_SAMPLER_2D_ARRAY, gl_INT_SAMPLER_2D_RECT, gl_INT_SAMPLER_3D, gl_INT_SAMPLER_BUFFER, gl_INT_SAMPLER_CUBE, gl_INT_VEC2, gl_INT_VEC3, gl_INT_VEC4, gl_INVALID_ENUM, gl_INVALID_FRAMEBUFFER_OPERATION, gl_INVALID_INDEX, gl_INVALID_OPERATION, gl_INVALID_VALUE, gl_INVERT, gl_KEEP, gl_LEFT, gl_LEQUAL, gl_LESS, gl_LIGHT0, gl_LIGHT1, gl_LIGHT2, gl_LIGHT3, gl_LIGHT4, gl_LIGHT5, gl_LIGHT6, gl_LIGHT7, gl_LIGHTING, gl_LIGHTING_BIT, gl_LIGHT_MODEL_AMBIENT, gl_LIGHT_MODEL_COLOR_CONTROL, gl_LIGHT_MODEL_LOCAL_VIEWER, gl_LIGHT_MODEL_TWO_SIDE, gl_LINE, gl_LINEAR, gl_LINEAR_ATTENUATION, gl_LINEAR_MIPMAP_LINEAR, gl_LINEAR_MIPMAP_NEAREST, gl_LINES, gl_LINE_BIT, gl_LINE_LOOP, gl_LINE_RESET_TOKEN, gl_LINE_SMOOTH, gl_LINE_SMOOTH_HINT, gl_LINE_STIPPLE, gl_LINE_STIPPLE_PATTERN, gl_LINE_STIPPLE_REPEAT, gl_LINE_STRIP, gl_LINE_TOKEN, gl_LINE_WIDTH, gl_LINE_WIDTH_GRANULARITY, gl_LINE_WIDTH_RANGE, gl_LINK_STATUS, gl_LIST_BASE, gl_LIST_BIT, gl_LIST_INDEX, gl_LIST_MODE, gl_LOAD, gl_LOGIC_OP, gl_LOGIC_OP_MODE, gl_LOWER_LEFT, gl_LUMINANCE, gl_LUMINANCE12, gl_LUMINANCE12_ALPHA12, gl_LUMINANCE12_ALPHA4, gl_LUMINANCE16, gl_LUMINANCE16_ALPHA16, gl_LUMINANCE4, gl_LUMINANCE4_ALPHA4, gl_LUMINANCE6_ALPHA2, gl_LUMINANCE8, gl_LUMINANCE8_ALPHA8, gl_LUMINANCE_ALPHA, gl_MAJOR_VERSION, gl_MAP1_COLOR_4, gl_MAP1_GRID_DOMAIN, gl_MAP1_GRID_SEGMENTS, gl_MAP1_INDEX, gl_MAP1_NORMAL, gl_MAP1_TEXTURE_COORD_1, gl_MAP1_TEXTURE_COORD_2, gl_MAP1_TEXTURE_COORD_3, gl_MAP1_TEXTURE_COORD_4, gl_MAP1_VERTEX_3, gl_MAP1_VERTEX_4, gl_MAP2_COLOR_4, gl_MAP2_GRID_DOMAIN, gl_MAP2_GRID_SEGMENTS, gl_MAP2_INDEX, gl_MAP2_NORMAL, gl_MAP2_TEXTURE_COORD_1, gl_MAP2_TEXTURE_COORD_2, gl_MAP2_TEXTURE_COORD_3, gl_MAP2_TEXTURE_COORD_4, gl_MAP2_VERTEX_3, gl_MAP2_VERTEX_4, gl_MAP_COLOR, gl_MAP_FLUSH_EXPLICIT_BIT, gl_MAP_INVALIDATE_BUFFER_BIT, gl_MAP_INVALIDATE_RANGE_BIT, gl_MAP_READ_BIT, gl_MAP_STENCIL, gl_MAP_UNSYNCHRONIZED_BIT, gl_MAP_WRITE_BIT, gl_MATRIX_MODE, gl_MAX, gl_MAX_3D_TEXTURE_SIZE, gl_MAX_ARRAY_TEXTURE_LAYERS, gl_MAX_ATTRIB_STACK_DEPTH, gl_MAX_CLIENT_ATTRIB_STACK_DEPTH, gl_MAX_CLIP_DISTANCES, gl_MAX_CLIP_PLANES, gl_MAX_COLOR_ATTACHMENTS, gl_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, gl_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, gl_MAX_COMBINED_TEXTURE_IMAGE_UNITS, gl_MAX_COMBINED_UNIFORM_BLOCKS, gl_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, gl_MAX_CUBE_MAP_TEXTURE_SIZE, gl_MAX_DRAW_BUFFERS, gl_MAX_ELEMENTS_INDICES, gl_MAX_ELEMENTS_VERTICES, gl_MAX_EVAL_ORDER, gl_MAX_FRAGMENT_UNIFORM_BLOCKS, gl_MAX_FRAGMENT_UNIFORM_COMPONENTS, gl_MAX_GEOMETRY_UNIFORM_BLOCKS, gl_MAX_LIGHTS, gl_MAX_LIST_NESTING, gl_MAX_MODELVIEW_STACK_DEPTH, gl_MAX_NAME_STACK_DEPTH, gl_MAX_PIXEL_MAP_TABLE, gl_MAX_PROGRAM_TEXEL_OFFSET, gl_MAX_PROJECTION_STACK_DEPTH, gl_MAX_RECTANGLE_TEXTURE_SIZE, gl_MAX_RENDERBUFFER_SIZE, gl_MAX_SAMPLES, gl_MAX_TEXTURE_BUFFER_SIZE, gl_MAX_TEXTURE_COORDS, gl_MAX_TEXTURE_IMAGE_UNITS, gl_MAX_TEXTURE_LOD_BIAS, gl_MAX_TEXTURE_SIZE, gl_MAX_TEXTURE_STACK_DEPTH, gl_MAX_TEXTURE_UNITS, gl_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS, gl_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS, gl_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS, gl_MAX_UNIFORM_BLOCK_SIZE, gl_MAX_UNIFORM_BUFFER_BINDINGS, gl_MAX_VARYING_COMPONENTS, gl_MAX_VARYING_FLOATS, gl_MAX_VERTEX_ATTRIBS, gl_MAX_VERTEX_TEXTURE_IMAGE_UNITS, gl_MAX_VERTEX_UNIFORM_BLOCKS, gl_MAX_VERTEX_UNIFORM_COMPONENTS, gl_MAX_VIEWPORT_DIMS, gl_MIN, gl_MINOR_VERSION, gl_MIN_PROGRAM_TEXEL_OFFSET, gl_MIRRORED_REPEAT, gl_MODELVIEW, gl_MODELVIEW_MATRIX, gl_MODELVIEW_STACK_DEPTH, gl_MODULATE, gl_MULT, gl_MULTISAMPLE, gl_MULTISAMPLE_BIT, gl_N3F_V3F, gl_NAME_STACK_DEPTH, gl_NAND, gl_NEAREST, gl_NEAREST_MIPMAP_LINEAR, gl_NEAREST_MIPMAP_NEAREST, gl_NEVER, gl_NICEST, gl_NONE, gl_NOOP, gl_NOR, gl_NORMALIZE, gl_NORMAL_ARRAY, gl_NORMAL_ARRAY_BUFFER_BINDING, gl_NORMAL_ARRAY_POINTER, gl_NORMAL_ARRAY_STRIDE, gl_NORMAL_ARRAY_TYPE, gl_NORMAL_MAP, gl_NOTEQUAL, gl_NO_ERROR, gl_NUM_COMPRESSED_TEXTURE_FORMATS, gl_NUM_EXTENSIONS, gl_OBJECT_LINEAR, gl_OBJECT_PLANE, gl_ONE, gl_ONE_MINUS_CONSTANT_ALPHA, gl_ONE_MINUS_CONSTANT_COLOR, gl_ONE_MINUS_DST_ALPHA, gl_ONE_MINUS_DST_COLOR, gl_ONE_MINUS_SRC_ALPHA, gl_ONE_MINUS_SRC_COLOR, gl_OPERAND0_ALPHA, gl_OPERAND0_RGB, gl_OPERAND1_ALPHA, gl_OPERAND1_RGB, gl_OPERAND2_ALPHA, gl_OPERAND2_RGB, gl_OR, gl_ORDER, gl_OR_INVERTED, gl_OR_REVERSE, gl_OUT_OF_MEMORY, gl_PACK_ALIGNMENT, gl_PACK_IMAGE_HEIGHT, gl_PACK_LSB_FIRST, gl_PACK_ROW_LENGTH, gl_PACK_SKIP_IMAGES, gl_PACK_SKIP_PIXELS, gl_PACK_SKIP_ROWS, gl_PACK_SWAP_BYTES, gl_PASS_THROUGH_TOKEN, gl_PERSPECTIVE_CORRECTION_HINT, gl_PIXEL_MAP_A_TO_A, gl_PIXEL_MAP_A_TO_A_SIZE, gl_PIXEL_MAP_B_TO_B, gl_PIXEL_MAP_B_TO_B_SIZE, gl_PIXEL_MAP_G_TO_G, gl_PIXEL_MAP_G_TO_G_SIZE, gl_PIXEL_MAP_I_TO_A, gl_PIXEL_MAP_I_TO_A_SIZE, gl_PIXEL_MAP_I_TO_B, gl_PIXEL_MAP_I_TO_B_SIZE, gl_PIXEL_MAP_I_TO_G, gl_PIXEL_MAP_I_TO_G_SIZE, gl_PIXEL_MAP_I_TO_I, gl_PIXEL_MAP_I_TO_I_SIZE, gl_PIXEL_MAP_I_TO_R, gl_PIXEL_MAP_I_TO_R_SIZE, gl_PIXEL_MAP_R_TO_R, gl_PIXEL_MAP_R_TO_R_SIZE, gl_PIXEL_MAP_S_TO_S, gl_PIXEL_MAP_S_TO_S_SIZE, gl_PIXEL_MODE_BIT, gl_PIXEL_PACK_BUFFER, gl_PIXEL_PACK_BUFFER_BINDING, gl_PIXEL_UNPACK_BUFFER, gl_PIXEL_UNPACK_BUFFER_BINDING, gl_POINT, gl_POINTS, gl_POINT_BIT, gl_POINT_DISTANCE_ATTENUATION, gl_POINT_FADE_THRESHOLD_SIZE, gl_POINT_SIZE, gl_POINT_SIZE_GRANULARITY, gl_POINT_SIZE_MAX, gl_POINT_SIZE_MIN, gl_POINT_SIZE_RANGE, gl_POINT_SMOOTH, gl_POINT_SMOOTH_HINT, gl_POINT_SPRITE, gl_POINT_SPRITE_COORD_ORIGIN, gl_POINT_TOKEN, gl_POLYGON, gl_POLYGON_BIT, gl_POLYGON_MODE, gl_POLYGON_OFFSET_FACTOR, gl_POLYGON_OFFSET_FILL, gl_POLYGON_OFFSET_LINE, gl_POLYGON_OFFSET_POINT, gl_POLYGON_OFFSET_UNITS, gl_POLYGON_SMOOTH, gl_POLYGON_SMOOTH_HINT, gl_POLYGON_STIPPLE, gl_POLYGON_STIPPLE_BIT, gl_POLYGON_TOKEN, gl_POSITION, gl_PREVIOUS, gl_PRIMARY_COLOR, gl_PRIMITIVES_GENERATED, gl_PRIMITIVE_RESTART, gl_PRIMITIVE_RESTART_INDEX, gl_PROJECTION, gl_PROJECTION_MATRIX, gl_PROJECTION_STACK_DEPTH, gl_PROXY_TEXTURE_1D, gl_PROXY_TEXTURE_1D_ARRAY, gl_PROXY_TEXTURE_2D, gl_PROXY_TEXTURE_2D_ARRAY, gl_PROXY_TEXTURE_3D, gl_PROXY_TEXTURE_CUBE_MAP, gl_PROXY_TEXTURE_RECTANGLE, gl_Q, gl_QUADRATIC_ATTENUATION, gl_QUADS, gl_QUAD_STRIP, gl_QUERY_BY_REGION_NO_WAIT, gl_QUERY_BY_REGION_WAIT, gl_QUERY_COUNTER_BITS, gl_QUERY_NO_WAIT, gl_QUERY_RESULT, gl_QUERY_RESULT_AVAILABLE, gl_QUERY_WAIT, gl_R, gl_R11F_G11F_B10F, gl_R16, gl_R16F, gl_R16I, gl_R16UI, gl_R16_SNORM, gl_R32F, gl_R32I, gl_R32UI, gl_R3_G3_B2, gl_R8, gl_R8I, gl_R8UI, gl_R8_SNORM, gl_RASTERIZER_DISCARD, gl_READ_BUFFER, gl_READ_FRAMEBUFFER, gl_READ_FRAMEBUFFER_BINDING, gl_READ_ONLY, gl_READ_WRITE, gl_RED, gl_RED_BIAS, gl_RED_BITS, gl_RED_INTEGER, gl_RED_SCALE, gl_REFLECTION_MAP, gl_RENDER, gl_RENDERBUFFER, gl_RENDERBUFFER_ALPHA_SIZE, gl_RENDERBUFFER_BINDING, gl_RENDERBUFFER_BLUE_SIZE, gl_RENDERBUFFER_DEPTH_SIZE, gl_RENDERBUFFER_GREEN_SIZE, gl_RENDERBUFFER_HEIGHT, gl_RENDERBUFFER_INTERNAL_FORMAT, gl_RENDERBUFFER_RED_SIZE, gl_RENDERBUFFER_SAMPLES, gl_RENDERBUFFER_STENCIL_SIZE, gl_RENDERBUFFER_WIDTH, gl_RENDERER, gl_RENDER_MODE, gl_REPEAT, gl_REPLACE, gl_RESCALE_NORMAL, gl_RETURN, gl_RG, gl_RG16, gl_RG16F, gl_RG16I, gl_RG16UI, gl_RG16_SNORM, gl_RG32F, gl_RG32I, gl_RG32UI, gl_RG8, gl_RG8I, gl_RG8UI, gl_RG8_SNORM, gl_RGB, gl_RGB10, gl_RGB10_A2, gl_RGB12, gl_RGB16, gl_RGB16F, gl_RGB16I, gl_RGB16UI, gl_RGB16_SNORM, gl_RGB32F, gl_RGB32I, gl_RGB32UI, gl_RGB4, gl_RGB5, gl_RGB5_A1, gl_RGB8, gl_RGB8I, gl_RGB8UI, gl_RGB8_SNORM, gl_RGB9_E5, gl_RGBA, gl_RGBA12, gl_RGBA16, gl_RGBA16F, gl_RGBA16I, gl_RGBA16UI, gl_RGBA16_SNORM, gl_RGBA2, gl_RGBA32F, gl_RGBA32I, gl_RGBA32UI, gl_RGBA4, gl_RGBA8, gl_RGBA8I, gl_RGBA8UI, gl_RGBA8_SNORM, gl_RGBA_INTEGER, gl_RGBA_MODE, gl_RGB_INTEGER, gl_RGB_SCALE, gl_RG_INTEGER, gl_RIGHT, gl_S, gl_SAMPLER_1D, gl_SAMPLER_1D_ARRAY, gl_SAMPLER_1D_ARRAY_SHADOW, gl_SAMPLER_1D_SHADOW, gl_SAMPLER_2D, gl_SAMPLER_2D_ARRAY, gl_SAMPLER_2D_ARRAY_SHADOW, gl_SAMPLER_2D_RECT, gl_SAMPLER_2D_RECT_SHADOW, gl_SAMPLER_2D_SHADOW, gl_SAMPLER_3D, gl_SAMPLER_BUFFER, gl_SAMPLER_CUBE, gl_SAMPLER_CUBE_SHADOW, gl_SAMPLES, gl_SAMPLES_PASSED, gl_SAMPLE_ALPHA_TO_COVERAGE, gl_SAMPLE_ALPHA_TO_ONE, gl_SAMPLE_BUFFERS, gl_SAMPLE_COVERAGE, gl_SAMPLE_COVERAGE_INVERT, gl_SAMPLE_COVERAGE_VALUE, gl_SCISSOR_BIT, gl_SCISSOR_BOX, gl_SCISSOR_TEST, gl_SECONDARY_COLOR_ARRAY, gl_SECONDARY_COLOR_ARRAY_BUFFER_BINDING, gl_SECONDARY_COLOR_ARRAY_POINTER, gl_SECONDARY_COLOR_ARRAY_SIZE, gl_SECONDARY_COLOR_ARRAY_STRIDE, gl_SECONDARY_COLOR_ARRAY_TYPE, gl_SELECT, gl_SELECTION_BUFFER_POINTER, gl_SELECTION_BUFFER_SIZE, gl_SEPARATE_ATTRIBS, gl_SEPARATE_SPECULAR_COLOR, gl_SET, gl_SHADER_SOURCE_LENGTH, gl_SHADER_TYPE, gl_SHADE_MODEL, gl_SHADING_LANGUAGE_VERSION, gl_SHININESS, gl_SHORT, gl_SIGNED_NORMALIZED, gl_SINGLE_COLOR, gl_SLUMINANCE, gl_SLUMINANCE8, gl_SLUMINANCE8_ALPHA8, gl_SLUMINANCE_ALPHA, gl_SMOOTH, gl_SMOOTH_LINE_WIDTH_GRANULARITY, gl_SMOOTH_LINE_WIDTH_RANGE, gl_SMOOTH_POINT_SIZE_GRANULARITY, gl_SMOOTH_POINT_SIZE_RANGE, gl_SOURCE0_ALPHA, gl_SOURCE0_RGB, gl_SOURCE1_ALPHA, gl_SOURCE1_RGB, gl_SOURCE2_ALPHA, gl_SOURCE2_RGB, gl_SPECULAR, gl_SPHERE_MAP, gl_SPOT_CUTOFF, gl_SPOT_DIRECTION, gl_SPOT_EXPONENT, gl_SRC0_ALPHA, gl_SRC0_RGB, gl_SRC1_ALPHA, gl_SRC1_RGB, gl_SRC2_ALPHA, gl_SRC2_RGB, gl_SRC_ALPHA, gl_SRC_ALPHA_SATURATE, gl_SRC_COLOR, gl_SRGB, gl_SRGB8, gl_SRGB8_ALPHA8, gl_SRGB_ALPHA, gl_STACK_OVERFLOW, gl_STACK_UNDERFLOW, gl_STATIC_COPY, gl_STATIC_DRAW, gl_STATIC_READ, gl_STENCIL, gl_STENCIL_ATTACHMENT, gl_STENCIL_BACK_FAIL, gl_STENCIL_BACK_FUNC, gl_STENCIL_BACK_PASS_DEPTH_FAIL, gl_STENCIL_BACK_PASS_DEPTH_PASS, gl_STENCIL_BACK_REF, gl_STENCIL_BACK_VALUE_MASK, gl_STENCIL_BACK_WRITEMASK, gl_STENCIL_BITS, gl_STENCIL_BUFFER_BIT, gl_STENCIL_CLEAR_VALUE, gl_STENCIL_FAIL, gl_STENCIL_FUNC, gl_STENCIL_INDEX, gl_STENCIL_INDEX1, gl_STENCIL_INDEX16, gl_STENCIL_INDEX4, gl_STENCIL_INDEX8, gl_STENCIL_PASS_DEPTH_FAIL, gl_STENCIL_PASS_DEPTH_PASS, gl_STENCIL_REF, gl_STENCIL_TEST, gl_STENCIL_VALUE_MASK, gl_STENCIL_WRITEMASK, gl_STEREO, gl_STREAM_COPY, gl_STREAM_DRAW, gl_STREAM_READ, gl_SUBPIXEL_BITS, gl_SUBTRACT, gl_T, gl_T2F_C3F_V3F, gl_T2F_C4F_N3F_V3F, gl_T2F_C4UB_V3F, gl_T2F_N3F_V3F, gl_T2F_V3F, gl_T4F_C4F_N3F_V4F, gl_T4F_V4F, gl_TEXTURE, gl_TEXTURE0, gl_TEXTURE1, gl_TEXTURE10, gl_TEXTURE11, gl_TEXTURE12, gl_TEXTURE13, gl_TEXTURE14, gl_TEXTURE15, gl_TEXTURE16, gl_TEXTURE17, gl_TEXTURE18, gl_TEXTURE19, gl_TEXTURE2, gl_TEXTURE20, gl_TEXTURE21, gl_TEXTURE22, gl_TEXTURE23, gl_TEXTURE24, gl_TEXTURE25, gl_TEXTURE26, gl_TEXTURE27, gl_TEXTURE28, gl_TEXTURE29, gl_TEXTURE3, gl_TEXTURE30, gl_TEXTURE31, gl_TEXTURE4, gl_TEXTURE5, gl_TEXTURE6, gl_TEXTURE7, gl_TEXTURE8, gl_TEXTURE9, gl_TEXTURE_1D, gl_TEXTURE_1D_ARRAY, gl_TEXTURE_2D, gl_TEXTURE_2D_ARRAY, gl_TEXTURE_3D, gl_TEXTURE_ALPHA_SIZE, gl_TEXTURE_ALPHA_TYPE, gl_TEXTURE_BASE_LEVEL, gl_TEXTURE_BINDING_1D, gl_TEXTURE_BINDING_1D_ARRAY, gl_TEXTURE_BINDING_2D, gl_TEXTURE_BINDING_2D_ARRAY, gl_TEXTURE_BINDING_3D, gl_TEXTURE_BINDING_BUFFER, gl_TEXTURE_BINDING_CUBE_MAP, gl_TEXTURE_BINDING_RECTANGLE, gl_TEXTURE_BIT, gl_TEXTURE_BLUE_SIZE, gl_TEXTURE_BLUE_TYPE, gl_TEXTURE_BORDER, gl_TEXTURE_BORDER_COLOR, gl_TEXTURE_BUFFER, gl_TEXTURE_BUFFER_DATA_STORE_BINDING, gl_TEXTURE_COMPARE_FUNC, gl_TEXTURE_COMPARE_MODE, gl_TEXTURE_COMPONENTS, gl_TEXTURE_COMPRESSED, gl_TEXTURE_COMPRESSED_IMAGE_SIZE, gl_TEXTURE_COMPRESSION_HINT, gl_TEXTURE_COORD_ARRAY, gl_TEXTURE_COORD_ARRAY_BUFFER_BINDING, gl_TEXTURE_COORD_ARRAY_POINTER, gl_TEXTURE_COORD_ARRAY_SIZE, gl_TEXTURE_COORD_ARRAY_STRIDE, gl_TEXTURE_COORD_ARRAY_TYPE, gl_TEXTURE_CUBE_MAP, gl_TEXTURE_CUBE_MAP_NEGATIVE_X, gl_TEXTURE_CUBE_MAP_NEGATIVE_Y, gl_TEXTURE_CUBE_MAP_NEGATIVE_Z, gl_TEXTURE_CUBE_MAP_POSITIVE_X, gl_TEXTURE_CUBE_MAP_POSITIVE_Y, gl_TEXTURE_CUBE_MAP_POSITIVE_Z, gl_TEXTURE_DEPTH, gl_TEXTURE_DEPTH_SIZE, gl_TEXTURE_DEPTH_TYPE, gl_TEXTURE_ENV, gl_TEXTURE_ENV_COLOR, gl_TEXTURE_ENV_MODE, gl_TEXTURE_FILTER_CONTROL, gl_TEXTURE_GEN_MODE, gl_TEXTURE_GEN_Q, gl_TEXTURE_GEN_R, gl_TEXTURE_GEN_S, gl_TEXTURE_GEN_T, gl_TEXTURE_GREEN_SIZE, gl_TEXTURE_GREEN_TYPE, gl_TEXTURE_HEIGHT, gl_TEXTURE_INTENSITY_SIZE, gl_TEXTURE_INTENSITY_TYPE, gl_TEXTURE_INTERNAL_FORMAT, gl_TEXTURE_LOD_BIAS, gl_TEXTURE_LUMINANCE_SIZE, gl_TEXTURE_LUMINANCE_TYPE, gl_TEXTURE_MAG_FILTER, gl_TEXTURE_MATRIX, gl_TEXTURE_MAX_LEVEL, gl_TEXTURE_MAX_LOD, gl_TEXTURE_MIN_FILTER, gl_TEXTURE_MIN_LOD, gl_TEXTURE_PRIORITY, gl_TEXTURE_RECTANGLE, gl_TEXTURE_RED_SIZE, gl_TEXTURE_RED_TYPE, gl_TEXTURE_RESIDENT, gl_TEXTURE_SHARED_SIZE, gl_TEXTURE_STACK_DEPTH, gl_TEXTURE_STENCIL_SIZE, gl_TEXTURE_WIDTH, gl_TEXTURE_WRAP_R, gl_TEXTURE_WRAP_S, gl_TEXTURE_WRAP_T, gl_TRANSFORM_BIT, gl_TRANSFORM_FEEDBACK_BUFFER, gl_TRANSFORM_FEEDBACK_BUFFER_BINDING, gl_TRANSFORM_FEEDBACK_BUFFER_MODE, gl_TRANSFORM_FEEDBACK_BUFFER_SIZE, gl_TRANSFORM_FEEDBACK_BUFFER_START, gl_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, gl_TRANSFORM_FEEDBACK_VARYINGS, gl_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH, gl_TRANSPOSE_COLOR_MATRIX, gl_TRANSPOSE_MODELVIEW_MATRIX, gl_TRANSPOSE_PROJECTION_MATRIX, gl_TRANSPOSE_TEXTURE_MATRIX, gl_TRIANGLES, gl_TRIANGLE_FAN, gl_TRIANGLE_STRIP, gl_TRUE, gl_UNIFORM_ARRAY_STRIDE, gl_UNIFORM_BLOCK_ACTIVE_UNIFORMS, gl_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, gl_UNIFORM_BLOCK_BINDING, gl_UNIFORM_BLOCK_DATA_SIZE, gl_UNIFORM_BLOCK_INDEX, gl_UNIFORM_BLOCK_NAME_LENGTH, gl_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER, gl_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER, gl_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER, gl_UNIFORM_BUFFER, gl_UNIFORM_BUFFER_BINDING, gl_UNIFORM_BUFFER_OFFSET_ALIGNMENT, gl_UNIFORM_BUFFER_SIZE, gl_UNIFORM_BUFFER_START, gl_UNIFORM_IS_ROW_MAJOR, gl_UNIFORM_MATRIX_STRIDE, gl_UNIFORM_NAME_LENGTH, gl_UNIFORM_OFFSET, gl_UNIFORM_SIZE, gl_UNIFORM_TYPE, gl_UNPACK_ALIGNMENT, gl_UNPACK_IMAGE_HEIGHT, gl_UNPACK_LSB_FIRST, gl_UNPACK_ROW_LENGTH, gl_UNPACK_SKIP_IMAGES, gl_UNPACK_SKIP_PIXELS, gl_UNPACK_SKIP_ROWS, gl_UNPACK_SWAP_BYTES, gl_UNSIGNED_BYTE, gl_UNSIGNED_BYTE_2_3_3_REV, gl_UNSIGNED_BYTE_3_3_2, gl_UNSIGNED_INT, gl_UNSIGNED_INT_10F_11F_11F_REV, gl_UNSIGNED_INT_10_10_10_2, gl_UNSIGNED_INT_24_8, gl_UNSIGNED_INT_2_10_10_10_REV, gl_UNSIGNED_INT_5_9_9_9_REV, gl_UNSIGNED_INT_8_8_8_8, gl_UNSIGNED_INT_8_8_8_8_REV, gl_UNSIGNED_INT_SAMPLER_1D, gl_UNSIGNED_INT_SAMPLER_1D_ARRAY, gl_UNSIGNED_INT_SAMPLER_2D, gl_UNSIGNED_INT_SAMPLER_2D_ARRAY, gl_UNSIGNED_INT_SAMPLER_2D_RECT, gl_UNSIGNED_INT_SAMPLER_3D, gl_UNSIGNED_INT_SAMPLER_BUFFER, gl_UNSIGNED_INT_SAMPLER_CUBE, gl_UNSIGNED_INT_VEC2, gl_UNSIGNED_INT_VEC3, gl_UNSIGNED_INT_VEC4, gl_UNSIGNED_NORMALIZED, gl_UNSIGNED_SHORT, gl_UNSIGNED_SHORT_1_5_5_5_REV, gl_UNSIGNED_SHORT_4_4_4_4, gl_UNSIGNED_SHORT_4_4_4_4_REV, gl_UNSIGNED_SHORT_5_5_5_1, gl_UNSIGNED_SHORT_5_6_5, gl_UNSIGNED_SHORT_5_6_5_REV, gl_UPPER_LEFT, gl_V2F, gl_V3F, gl_VALIDATE_STATUS, gl_VENDOR, gl_VERSION, gl_VERTEX_ARRAY, gl_VERTEX_ARRAY_BINDING, gl_VERTEX_ARRAY_BUFFER_BINDING, gl_VERTEX_ARRAY_POINTER, gl_VERTEX_ARRAY_SIZE, gl_VERTEX_ARRAY_STRIDE, gl_VERTEX_ARRAY_TYPE, gl_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, gl_VERTEX_ATTRIB_ARRAY_ENABLED, gl_VERTEX_ATTRIB_ARRAY_INTEGER, gl_VERTEX_ATTRIB_ARRAY_NORMALIZED, gl_VERTEX_ATTRIB_ARRAY_POINTER, gl_VERTEX_ATTRIB_ARRAY_SIZE, gl_VERTEX_ATTRIB_ARRAY_STRIDE, gl_VERTEX_ATTRIB_ARRAY_TYPE, gl_VERTEX_PROGRAM_POINT_SIZE, gl_VERTEX_PROGRAM_TWO_SIDE, gl_VERTEX_SHADER, gl_VIEWPORT, gl_VIEWPORT_BIT, gl_WEIGHT_ARRAY_BUFFER_BINDING, gl_WRITE_ONLY, gl_XOR, gl_ZERO, gl_ZOOM_X, gl_ZOOM_Y, -- * Functions glAccum, glActiveTexture, glAlphaFunc, glAreTexturesResident, glArrayElement, glAttachShader, glBegin, glBeginConditionalRender, glBeginQuery, glBeginTransformFeedback, glBindAttribLocation, glBindBuffer, glBindBufferBase, glBindBufferRange, glBindFragDataLocation, glBindFramebuffer, glBindRenderbuffer, glBindTexture, glBindVertexArray, glBitmap, glBlendColor, glBlendEquation, glBlendEquationSeparate, glBlendFunc, glBlendFuncSeparate, glBlitFramebuffer, glBufferData, glBufferSubData, glCallList, glCallLists, glCheckFramebufferStatus, glClampColor, glClear, glClearAccum, glClearBufferfi, glClearBufferfv, glClearBufferiv, glClearBufferuiv, glClearColor, glClearDepth, glClearIndex, glClearStencil, glClientActiveTexture, glClipPlane, glColor3b, glColor3bv, glColor3d, glColor3dv, glColor3f, glColor3fv, glColor3i, glColor3iv, glColor3s, glColor3sv, glColor3ub, glColor3ubv, glColor3ui, glColor3uiv, glColor3us, glColor3usv, glColor4b, glColor4bv, glColor4d, glColor4dv, glColor4f, glColor4fv, glColor4i, glColor4iv, glColor4s, glColor4sv, glColor4ub, glColor4ubv, glColor4ui, glColor4uiv, glColor4us, glColor4usv, glColorMask, glColorMaski, glColorMaterial, glColorPointer, glCompileShader, glCompressedTexImage1D, glCompressedTexImage2D, glCompressedTexImage3D, glCompressedTexSubImage1D, glCompressedTexSubImage2D, glCompressedTexSubImage3D, glCopyBufferSubData, glCopyPixels, glCopyTexImage1D, glCopyTexImage2D, glCopyTexSubImage1D, glCopyTexSubImage2D, glCopyTexSubImage3D, glCreateProgram, glCreateShader, glCullFace, glDeleteBuffers, glDeleteFramebuffers, glDeleteLists, glDeleteProgram, glDeleteQueries, glDeleteRenderbuffers, glDeleteShader, glDeleteTextures, glDeleteVertexArrays, glDepthFunc, glDepthMask, glDepthRange, glDetachShader, glDisable, glDisableClientState, glDisableVertexAttribArray, glDisablei, glDrawArrays, glDrawArraysInstanced, glDrawBuffer, glDrawBuffers, glDrawElements, glDrawElementsInstanced, glDrawPixels, glDrawRangeElements, glEdgeFlag, glEdgeFlagPointer, glEdgeFlagv, glEnable, glEnableClientState, glEnableVertexAttribArray, glEnablei, glEnd, glEndConditionalRender, glEndList, glEndQuery, glEndTransformFeedback, glEvalCoord1d, glEvalCoord1dv, glEvalCoord1f, glEvalCoord1fv, glEvalCoord2d, glEvalCoord2dv, glEvalCoord2f, glEvalCoord2fv, glEvalMesh1, glEvalMesh2, glEvalPoint1, glEvalPoint2, glFeedbackBuffer, glFinish, glFlush, glFlushMappedBufferRange, glFogCoordPointer, glFogCoordd, glFogCoorddv, glFogCoordf, glFogCoordfv, glFogf, glFogfv, glFogi, glFogiv, glFramebufferRenderbuffer, glFramebufferTexture1D, glFramebufferTexture2D, glFramebufferTexture3D, glFramebufferTextureLayer, glFrontFace, glFrustum, glGenBuffers, glGenFramebuffers, glGenLists, glGenQueries, glGenRenderbuffers, glGenTextures, glGenVertexArrays, glGenerateMipmap, glGetActiveAttrib, glGetActiveUniform, glGetActiveUniformBlockName, glGetActiveUniformBlockiv, glGetActiveUniformName, glGetActiveUniformsiv, glGetAttachedShaders, glGetAttribLocation, glGetBooleani_v, glGetBooleanv, glGetBufferParameteriv, glGetBufferPointerv, glGetBufferSubData, glGetClipPlane, glGetCompressedTexImage, glGetDoublev, glGetError, glGetFloatv, glGetFragDataLocation, glGetFramebufferAttachmentParameteriv, glGetIntegeri_v, glGetIntegerv, glGetLightfv, glGetLightiv, glGetMapdv, glGetMapfv, glGetMapiv, glGetMaterialfv, glGetMaterialiv, glGetPixelMapfv, glGetPixelMapuiv, glGetPixelMapusv, glGetPointerv, glGetPolygonStipple, glGetProgramInfoLog, glGetProgramiv, glGetQueryObjectiv, glGetQueryObjectuiv, glGetQueryiv, glGetRenderbufferParameteriv, glGetShaderInfoLog, glGetShaderSource, glGetShaderiv, glGetString, glGetStringi, glGetTexEnvfv, glGetTexEnviv, glGetTexGendv, glGetTexGenfv, glGetTexGeniv, glGetTexImage, glGetTexLevelParameterfv, glGetTexLevelParameteriv, glGetTexParameterIiv, glGetTexParameterIuiv, glGetTexParameterfv, glGetTexParameteriv, glGetTransformFeedbackVarying, glGetUniformBlockIndex, glGetUniformIndices, glGetUniformLocation, glGetUniformfv, glGetUniformiv, glGetUniformuiv, glGetVertexAttribIiv, glGetVertexAttribIuiv, glGetVertexAttribPointerv, glGetVertexAttribdv, glGetVertexAttribfv, glGetVertexAttribiv, glHint, glIndexMask, glIndexPointer, glIndexd, glIndexdv, glIndexf, glIndexfv, glIndexi, glIndexiv, glIndexs, glIndexsv, glIndexub, glIndexubv, glInitNames, glInterleavedArrays, glIsBuffer, glIsEnabled, glIsEnabledi, glIsFramebuffer, glIsList, glIsProgram, glIsQuery, glIsRenderbuffer, glIsShader, glIsTexture, glIsVertexArray, glLightModelf, glLightModelfv, glLightModeli, glLightModeliv, glLightf, glLightfv, glLighti, glLightiv, glLineStipple, glLineWidth, glLinkProgram, glListBase, glLoadIdentity, glLoadMatrixd, glLoadMatrixf, glLoadName, glLoadTransposeMatrixd, glLoadTransposeMatrixf, glLogicOp, glMap1d, glMap1f, glMap2d, glMap2f, glMapBuffer, glMapBufferRange, glMapGrid1d, glMapGrid1f, glMapGrid2d, glMapGrid2f, glMaterialf, glMaterialfv, glMateriali, glMaterialiv, glMatrixMode, glMultMatrixd, glMultMatrixf, glMultTransposeMatrixd, glMultTransposeMatrixf, glMultiDrawArrays, glMultiDrawElements, glMultiTexCoord1d, glMultiTexCoord1dv, glMultiTexCoord1f, glMultiTexCoord1fv, glMultiTexCoord1i, glMultiTexCoord1iv, glMultiTexCoord1s, glMultiTexCoord1sv, glMultiTexCoord2d, glMultiTexCoord2dv, glMultiTexCoord2f, glMultiTexCoord2fv, glMultiTexCoord2i, glMultiTexCoord2iv, glMultiTexCoord2s, glMultiTexCoord2sv, glMultiTexCoord3d, glMultiTexCoord3dv, glMultiTexCoord3f, glMultiTexCoord3fv, glMultiTexCoord3i, glMultiTexCoord3iv, glMultiTexCoord3s, glMultiTexCoord3sv, glMultiTexCoord4d, glMultiTexCoord4dv, glMultiTexCoord4f, glMultiTexCoord4fv, glMultiTexCoord4i, glMultiTexCoord4iv, glMultiTexCoord4s, glMultiTexCoord4sv, glNewList, glNormal3b, glNormal3bv, glNormal3d, glNormal3dv, glNormal3f, glNormal3fv, glNormal3i, glNormal3iv, glNormal3s, glNormal3sv, glNormalPointer, glOrtho, glPassThrough, glPixelMapfv, glPixelMapuiv, glPixelMapusv, glPixelStoref, glPixelStorei, glPixelTransferf, glPixelTransferi, glPixelZoom, glPointParameterf, glPointParameterfv, glPointParameteri, glPointParameteriv, glPointSize, glPolygonMode, glPolygonOffset, glPolygonStipple, glPopAttrib, glPopClientAttrib, glPopMatrix, glPopName, glPrimitiveRestartIndex, glPrioritizeTextures, glPushAttrib, glPushClientAttrib, glPushMatrix, glPushName, glRasterPos2d, glRasterPos2dv, glRasterPos2f, glRasterPos2fv, glRasterPos2i, glRasterPos2iv, glRasterPos2s, glRasterPos2sv, glRasterPos3d, glRasterPos3dv, glRasterPos3f, glRasterPos3fv, glRasterPos3i, glRasterPos3iv, glRasterPos3s, glRasterPos3sv, glRasterPos4d, glRasterPos4dv, glRasterPos4f, glRasterPos4fv, glRasterPos4i, glRasterPos4iv, glRasterPos4s, glRasterPos4sv, glReadBuffer, glReadPixels, glRectd, glRectdv, glRectf, glRectfv, glRecti, glRectiv, glRects, glRectsv, glRenderMode, glRenderbufferStorage, glRenderbufferStorageMultisample, glRotated, glRotatef, glSampleCoverage, glScaled, glScalef, glScissor, glSecondaryColor3b, glSecondaryColor3bv, glSecondaryColor3d, glSecondaryColor3dv, glSecondaryColor3f, glSecondaryColor3fv, glSecondaryColor3i, glSecondaryColor3iv, glSecondaryColor3s, glSecondaryColor3sv, glSecondaryColor3ub, glSecondaryColor3ubv, glSecondaryColor3ui, glSecondaryColor3uiv, glSecondaryColor3us, glSecondaryColor3usv, glSecondaryColorPointer, glSelectBuffer, glShadeModel, glShaderSource, glStencilFunc, glStencilFuncSeparate, glStencilMask, glStencilMaskSeparate, glStencilOp, glStencilOpSeparate, glTexBuffer, glTexCoord1d, glTexCoord1dv, glTexCoord1f, glTexCoord1fv, glTexCoord1i, glTexCoord1iv, glTexCoord1s, glTexCoord1sv, glTexCoord2d, glTexCoord2dv, glTexCoord2f, glTexCoord2fv, glTexCoord2i, glTexCoord2iv, glTexCoord2s, glTexCoord2sv, glTexCoord3d, glTexCoord3dv, glTexCoord3f, glTexCoord3fv, glTexCoord3i, glTexCoord3iv, glTexCoord3s, glTexCoord3sv, glTexCoord4d, glTexCoord4dv, glTexCoord4f, glTexCoord4fv, glTexCoord4i, glTexCoord4iv, glTexCoord4s, glTexCoord4sv, glTexCoordPointer, glTexEnvf, glTexEnvfv, glTexEnvi, glTexEnviv, glTexGend, glTexGendv, glTexGenf, glTexGenfv, glTexGeni, glTexGeniv, glTexImage1D, glTexImage2D, glTexImage3D, glTexParameterIiv, glTexParameterIuiv, glTexParameterf, glTexParameterfv, glTexParameteri, glTexParameteriv, glTexSubImage1D, glTexSubImage2D, glTexSubImage3D, glTransformFeedbackVaryings, glTranslated, glTranslatef, glUniform1f, glUniform1fv, glUniform1i, glUniform1iv, glUniform1ui, glUniform1uiv, glUniform2f, glUniform2fv, glUniform2i, glUniform2iv, glUniform2ui, glUniform2uiv, glUniform3f, glUniform3fv, glUniform3i, glUniform3iv, glUniform3ui, glUniform3uiv, glUniform4f, glUniform4fv, glUniform4i, glUniform4iv, glUniform4ui, glUniform4uiv, glUniformBlockBinding, glUniformMatrix2fv, glUniformMatrix2x3fv, glUniformMatrix2x4fv, glUniformMatrix3fv, glUniformMatrix3x2fv, glUniformMatrix3x4fv, glUniformMatrix4fv, glUniformMatrix4x2fv, glUniformMatrix4x3fv, glUnmapBuffer, glUseProgram, glValidateProgram, glVertex2d, glVertex2dv, glVertex2f, glVertex2fv, glVertex2i, glVertex2iv, glVertex2s, glVertex2sv, glVertex3d, glVertex3dv, glVertex3f, glVertex3fv, glVertex3i, glVertex3iv, glVertex3s, glVertex3sv, glVertex4d, glVertex4dv, glVertex4f, glVertex4fv, glVertex4i, glVertex4iv, glVertex4s, glVertex4sv, glVertexAttrib1d, glVertexAttrib1dv, glVertexAttrib1f, glVertexAttrib1fv, glVertexAttrib1s, glVertexAttrib1sv, glVertexAttrib2d, glVertexAttrib2dv, glVertexAttrib2f, glVertexAttrib2fv, glVertexAttrib2s, glVertexAttrib2sv, glVertexAttrib3d, glVertexAttrib3dv, glVertexAttrib3f, glVertexAttrib3fv, glVertexAttrib3s, glVertexAttrib3sv, glVertexAttrib4Nbv, glVertexAttrib4Niv, glVertexAttrib4Nsv, glVertexAttrib4Nub, glVertexAttrib4Nubv, glVertexAttrib4Nuiv, glVertexAttrib4Nusv, glVertexAttrib4bv, glVertexAttrib4d, glVertexAttrib4dv, glVertexAttrib4f, glVertexAttrib4fv, glVertexAttrib4iv, glVertexAttrib4s, glVertexAttrib4sv, glVertexAttrib4ubv, glVertexAttrib4uiv, glVertexAttrib4usv, glVertexAttribI1i, glVertexAttribI1iv, glVertexAttribI1ui, glVertexAttribI1uiv, glVertexAttribI2i, glVertexAttribI2iv, glVertexAttribI2ui, glVertexAttribI2uiv, glVertexAttribI3i, glVertexAttribI3iv, glVertexAttribI3ui, glVertexAttribI3uiv, glVertexAttribI4bv, glVertexAttribI4i, glVertexAttribI4iv, glVertexAttribI4sv, glVertexAttribI4ubv, glVertexAttribI4ui, glVertexAttribI4uiv, glVertexAttribI4usv, glVertexAttribIPointer, glVertexAttribPointer, glVertexPointer, glViewport, glWindowPos2d, glWindowPos2dv, glWindowPos2f, glWindowPos2fv, glWindowPos2i, glWindowPos2iv, glWindowPos2s, glWindowPos2sv, glWindowPos3d, glWindowPos3dv, glWindowPos3f, glWindowPos3fv, glWindowPos3i, glWindowPos3iv, glWindowPos3s, glWindowPos3sv ) where import Graphics.Rendering.OpenGL.Raw.Types import Graphics.Rendering.OpenGL.Raw.Tokens import Graphics.Rendering.OpenGL.Raw.Functions
phaazon/OpenGLRaw
src/Graphics/Rendering/OpenGL/Raw/Compatibility31.hs
bsd-3-clause
38,287
0
4
5,537
5,503
3,676
1,827
1,822
0
module Scheme.DataType ( module Scheme.DataType.Misc, EvalError, ScmError, TryError, Expr(..), ScmCode(..), ScmFile, Var(..), Return(..), ReturnE, Name, AFunc, WAFunc, RFunc, Proc, Synt, Scm, runScm, ScmEnv, ScmStates, ScmRef, MetaInfo(..), Config(..), setConfig, setMSP, MetaData(..), setTryHeap, setStackTrace, GEnv, LEnv, MLEnv, StackTrace(..), Trace, TraceR, initStackTrace, setTraceHeap, setTraceRHeap, setTraceLength, Try(..), initTry, setDepthLimit, setLoopCount, setBinary, setCapturedDisplays, DepthLimit(..), ) where import Config import Scheme.DataType.Error (ScmError) import Scheme.DataType.Error.Eval (EvalError) import Scheme.DataType.Error.Try (TryError) import Scheme.DataType.Misc import DeepControl.Applicative import DeepControl.Monad import DeepControl.MonadTrans import DeepControl.Monad.RWS import DeepControl.Monad.Except import MonadX.Monad.Reference import qualified Data.Map as M import Data.List (intersperse) type Name = String ---------------------------------------------------------------------------------------------------------------- -- Scm ---------------------------------------------------------------------------------------------------------------- type Scm a = (ExceptT ScmError (ReferenceT Var (RWST ScmEnv () ScmStates IO))) a runScm :: Scm a -> ScmRef -- Reference -> ScmEnv -- Reader -> ScmStates -- State -> IO ((Either ScmError a, ScmRef), ScmStates, ()) runScm scm ref env states = scm >- runExceptT >- (unReferenceT >-> (|>ref)) >- (runRWST >-> (|>env) >-> (|>states)) type ScmStates = (GEnv, MetaData) -- State type ScmEnv = (MLEnv, MetaInfo) -- Reader type ScmRef = RefEnv Var -- Reference -- -- Env -- type GEnv = M.Map Name Expr -- Global Environment type LEnv = Ref Var{-Vm-} -- Local Environment type MLEnv = Maybe LEnv -- -- Variable for RefEnv -- data Var = Ve Expr | Vm (M.Map Name Expr{-REF-}) -- for LEnv deriving (Eq) instance Show Var where show (Ve e) = show e show (Vm map) = show map -------------------------------------------------- -- Eval -------------------------------------------------- -- TODO Functor data Return a = RETURN a | VOID deriving (Show, Eq) type ReturnE = Return Expr -------------------------------------------------- -- Expr -------------------------------------------------- -- Scheme Expression data Expr = NIL | INT !Integer | REAL !Double | SYM !String MSP | STR !String | CELL !Expr !Expr MSP -- | AFUNC Name AFunc -- actual function: +, -, *, /, etc. | WAFUNC Name WAFunc -- weekly actual function: length, append, etc. | RFUNC Name RFunc -- referencial function: car, cdr, cons, set!, set-car!, set-cdr!, etc. | PROC Name Proc -- procedure: display, newline, etc. | SYNT Name Synt -- syntax: quote, if, define, etc. | CLOS Expr MLEnv -- closure: Ξ» | CLOSM Expr MLEnv -- macro-closure -- for set!, set-car!, set-cdr!, car and cdr; reference manipulation | REF (Ref Var{-Ve-}) -- for lazy evaluation | THUNK (Expr, ScmEnv) instance Show Expr where show NIL = "()" show (INT x) = show x show (REAL x) = show x show (SYM x _) = x show (STR x) = show x show (CELL (SYM "quote" _) (CELL expr NIL _) _) = "'" ++ show expr show (CELL (SYM "quasiquote" _) (CELL expr NIL _) _) = "`" ++ show expr show (CELL (SYM "unquote" _) (CELL expr NIL _) _) = "," ++ show expr show (CELL (SYM "unquote-splicing" _) (CELL expr NIL _) _) = ",@" ++ show expr show c@(CELL a d _) = "(" ++ showCELL c ++ ")" where showCELL NIL = "" showCELL (CELL a d _) = show a ++ case d of NIL -> "" c@(CELL _ _ _) -> " " ++ showCELL c e -> " . " ++ show e show (AFUNC x _) = "<" ++ x ++ ">" show (WAFUNC x _) = "<" ++ x ++ ">" show (RFUNC x _) = "<" ++ x ++ ">" show (SYNT x _) = "<" ++ x ++ ">" show (PROC x _) = "<" ++ x ++ ">" show (CLOS (CELL args seq _) mlenv) = "(\\"++ show args ++" -> "++ showExprSeq seq ++")" where showExprSeq :: Expr -> String showExprSeq NIL = "" showExprSeq (CELL s NIL _) = show s showExprSeq (CELL s1 s2 _) = show s1 ++" >> "++ showExprSeq s2 showExprSeq e = show e show (CLOSM (CELL args seq _) mlenv) = "(#"++ show args ++" -> "++ showExprSeq seq ++")" where showExprSeq :: Expr -> String showExprSeq NIL = "" showExprSeq (CELL s NIL _) = show s showExprSeq (CELL s1 s2 _) = show s1 ++" >> "++ showExprSeq s2 showExprSeq e = show e show (THUNK (e, _)) = "[" ++ show e ++ "]" show (REF ref) = "_" type AFunc = Expr -> Scm Expr -- actual function type WAFunc = Expr -> Scm Expr -- weekly actual function type RFunc = Expr -> Scm Expr -- referencial function type Proc = Expr -> Scm ReturnE -- procedure type Synt = Expr -> Scm ReturnE -- syntax instance Eq Expr where NIL == NIL = True INT x == INT y = x == y REAL x == REAL y = x == y SYM x _ == SYM y _ = x == y STR x == STR y = x == y CELL l r _ == CELL l' r' _ = (l,r) == (l',r') CLOS x a == CLOS y b = (x,a) == (y,b) CLOSM x a == CLOSM y b = (x,a) == (y,b) AFUNC x a == AFUNC y b = x == y WAFUNC x a == WAFUNC y b = x == y RFUNC x a == RFUNC y b = x == y SYNT x a == SYNT y b = x == y PROC x a == PROC y b = x == y REF x == REF y = x == y THUNK x == THUNK y = x == y _ == _ = False -------------------------------------------------- -- SCode, SFile, SFiles -------------------------------------------------- data ScmCode = EXPR Expr | COMMENT String | LINEBREAK | EOF instance Show ScmCode where show (EXPR x) = show x show (COMMENT s) = s show LINEBREAK = "" type ScmFile = [ScmCode] ---------------------------------------------------------------------------------------------------------------- -- RWS ---------------------------------------------------------------------------------------------------------------- -- -- MetaInfo -- data MetaInfo = MetaInfo { config :: Config , msp :: MSP } deriving (Show, Eq) setConfig :: Config -> MetaInfo -> MetaInfo setConfig x (MetaInfo _ b) = MetaInfo x b setMSP :: MSP -> MetaInfo -> MetaInfo setMSP x (MetaInfo a _) = MetaInfo a x -- -- MetaData -- data MetaData = MetaData { tryHeap :: [Try] , stackTrace :: StackTrace } deriving (Show) setTryHeap :: [Try] -> MetaData -> MetaData setTryHeap x (MetaData _ b) = MetaData x b setStackTrace :: StackTrace -> MetaData -> MetaData setStackTrace x (MetaData a _) = MetaData a x data StackTrace = StackTrace { traceHeap :: [Trace] , traceRHeap :: [TraceR] -- trace rusult , traceLength :: Int } deriving (Show) type Trace = (String, MSP, Maybe String) type TraceR = Trace initStackTrace :: StackTrace initStackTrace = StackTrace [] [] 10 setTraceHeap :: [Trace] -> StackTrace -> StackTrace setTraceHeap x (StackTrace _ b c) = StackTrace x b c setTraceRHeap :: [TraceR] -> StackTrace -> StackTrace setTraceRHeap x (StackTrace a _ c) = StackTrace a x c setTraceLength :: Int -> StackTrace -> StackTrace setTraceLength x (StackTrace a b _) = StackTrace a b x -- TODO: ChaitinTry data Try = Try { depthLimit :: DepthLimit , loopCount :: Int , binary :: Expr , capturedDisplays :: [Expr] } deriving (Show) data DepthLimit = NOTIMELIMIT | DEPTHLIMIT Int deriving (Show, Eq) instance Ord DepthLimit where compare NOTIMELIMIT NOTIMELIMIT = EQ compare NOTIMELIMIT (DEPTHLIMIT _) = GT compare (DEPTHLIMIT _) NOTIMELIMIT = LT compare (DEPTHLIMIT n) (DEPTHLIMIT n') = compare n n' initTry :: Try initTry = Try NOTIMELIMIT 0 NIL [] setDepthLimit :: DepthLimit -> Try -> Try setDepthLimit dl (Try _ lc bn cd) = Try dl lc bn cd setLoopCount :: Int -> Try -> Try setLoopCount lc (Try dl _ bn cd) = Try dl lc bn cd setBinary :: Expr -> Try -> Try setBinary bn (Try dl lc _ cd) = Try dl lc bn cd setCapturedDisplays :: [Expr] -> Try -> Try setCapturedDisplays cd (Try dl lc bn _) = Try dl lc bn cd ---------------------------------------------------------------------------------------------------------------- -- Misc ----------------------------------------------------------------------------------------------------------------
ocean0yohsuke/Scheme
src/Scheme/DataType.hs
bsd-3-clause
9,162
0
14
2,716
2,883
1,548
1,335
202
1
{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, TypeFamilies #-} module Rubik.Turn where import Data.Array import Rubik.Negate as N import Rubik.Key data Turn = NoTurn | Clock | OneEighty | CounterClock deriving (Eq,Ord,Show,Enum,Ix) instance Negate Turn where negate NoTurn = NoTurn negate Clock = CounterClock negate OneEighty = OneEighty negate CounterClock = Clock instance Key Turn where universe = [ NoTurn, Clock, OneEighty, CounterClock ] class Rotate a where type SideOf a rotate :: SideOf a -> a -> a -- never used --instance (Negate a, Rotate a b) => Rotate a (b -> c) where -- rotate t f a = f (rotate (N.negate t) a) {- -- Split into its own module class Rotate a where type SideOf a rotate :: SideOf a -> a -> a -- can complete either turn :: a -> a turn = rotateBy Clock rotateBy :: Turn -> a -> a rotateBy Clock = turn rotateBy OneEighty = turn . turn rotateBy CounterClock = turn . turn . turn -- We invert the rotate because it is the co-varient position instance Rotate a => Rotate (a -> b) where type SideOf (a -> b) = SideOf a rotateBy t f a = f (rotateBy (N.negate t) a) instance (Rotate a,Rotate b) => Rotate (a,b) where rotateBy t (a,b) = (rotateBy t a, rotateBy t b) data Apply a b = Apply (a -> b) a apply :: Apply a b -> b apply (Apply f a) = f a instance Rotate a => Rotate (Apply a b) where turn (Apply f a) = Apply f (turn a) -}
andygill/rubik-solver
src/Rubik/Turn.hs
bsd-3-clause
1,481
0
8
377
161
92
69
17
0
{-# LANGUAGE FlexibleInstances #-} -- ghc options {-# OPTIONS_GHC -Wall #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- {-# OPTIONS_GHC -fno-warn-name-shadowing #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- {-# OPTIONS_GHC -fno-warn-missing-signatures #-} -- {-# OPTIONS_GHC -fno-warn-unused-do-bind #-} -- {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} -- {-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-} -- | -- Copyright : (c) Andreas Reuleaux 2015 -- License : BSD2 -- Maintainer: Andreas Reuleaux <[email protected]> -- Stability : experimental -- Portability: non-portable -- -- This module provides pretty printing functionality for Pire's -- abstract and concrete syntax: names module Pire.Pretty.Nm where import Pire.Syntax.Nm -- import Data.Text as T import Text.PrettyPrint as TPP import Pire.Pretty.Common import Pire.Pretty.Ws() -- instance Disp s => Disp (Nm_ s) where -- disp (Nm_ nm (Ws ws)) = do -- dnm <- disp nm -- return $ dnm <> (text $ T.unpack ws) instance Disp s => Disp (Nm1 s) where disp (Nm1 nm) = disp nm disp (Nm1_ nm ws) = do dnm <- disp nm dws <- disp ws return $ dnm <> dws instance Disp s => Disp (Nm s s) where disp (Nm nm) = disp nm disp (Nm_ nm ws) = do dnm <- disp nm dws <- disp ws return $ dnm <> dws
reuleaux/pire
src/Pire/Pretty/Nm.hs
bsd-3-clause
1,331
0
9
286
231
127
104
21
0
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -- | Converting 'MC' programs to 'MCMem'. module Futhark.Pass.ExplicitAllocations.MC (explicitAllocations) where import Futhark.IR.MC import Futhark.IR.MCMem import Futhark.Pass.ExplicitAllocations import Futhark.Pass.ExplicitAllocations.SegOp instance SizeSubst (MCOp rep op) where opSizeSubst _ _ = mempty handleSegOp :: SegOp () MC -> AllocM MC MCMem (SegOp () MCMem) handleSegOp op = do let num_threads = intConst Int64 256 -- FIXME mapSegOpM (mapper num_threads) op where scope = scopeOfSegSpace $ segSpace op mapper num_threads = identitySegOpMapper { mapOnSegOpBody = localScope scope . allocInKernelBody, mapOnSegOpLambda = allocInBinOpLambda num_threads (segSpace op) } handleMCOp :: Op MC -> AllocM MC MCMem (Op MCMem) handleMCOp (ParOp par_op op) = Inner <$> (ParOp <$> traverse handleSegOp par_op <*> handleSegOp op) handleMCOp (OtherOp soac) = error $ "Cannot allocate memory in SOAC: " ++ pretty soac -- | The pass from 'MC' to 'MCMem'. explicitAllocations :: Pass MC MCMem explicitAllocations = explicitAllocationsGeneric handleMCOp defaultExpHints
HIPERFIT/futhark
src/Futhark/Pass/ExplicitAllocations/MC.hs
isc
1,283
0
11
239
303
159
144
29
1
class X where foo :: Int -- | Y -- Y is something -- nice. class Y where bar :: Int
itchyny/vim-haskell-indent
test/comment/before_blank_line_and_class.out.hs
mit
91
0
6
28
28
15
13
-1
-1
{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE Arrows #-} module Main where import Opaleye import Data.Profunctor.Product import Data.Profunctor.Product.Default import Data.Profunctor.Product.TH (makeAdaptorAndInstance) import Database.PostgreSQL.Simple import Database.PostgreSQL.Simple.FromField (FromField(..)) import Prelude hiding (id) import Control.Arrow newtype UserId = UserId Int deriving (Show) data UserPoly id name email = User { id :: id, name :: name, email :: email } deriving (Show) type User = UserPoly UserId String String type UserPGW = UserPoly (Column PGInt4) (Column PGText) (Column PGText) type UserPGR = UserPoly (Column PGInt4) (Column PGText) (Column PGText) $(makeAdaptorAndInstance "pUser" ''UserPoly) userTable :: Table UserPGW UserPGR userTable = Table "users" (pUser User { id = required "id", name = required "name", email = required "email" } ) instance FromField UserId where fromField field bs = UserId <$> fromField field bs instance QueryRunnerColumnDefault PGInt4 UserId where queryRunnerColumnDefault = fieldQueryRunnerColumn getUserRows :: IO [User] getUserRows = do conn <- connect defaultConnectInfo { connectDatabase = "scratch"} runQuery conn $ proc () -> do user@User {name = pgName} <- queryTable userTable -< () restrict -< (pgName .== (pgStrictText "John")) returnA -< user main :: IO () main = do rows <- getUserRows putStrLn $ show rows -- Output -- [User {id = UserId 1, name = "John", email = "[email protected]"},User {id = UserId -- 2, name = "Bob", email = "[email protected]"},User {id = UserId 3, name = "Alice", -- email = "[email protected]"}]
meditans/haskell-webapps
doc/docs/opaleye/code/opaleye-select-with-records-and-restrict.hs
mit
1,804
1
15
341
455
251
204
41
1
-- TESTS (1-17 non-calendar time) {- NTest[(* 5 *) b = N[DiscountFactor[1, 9 + 28/100, Compounding -> {Linear, 1}, CompiledDF -> True], 50] , 0.9150805270863837 ] ## HQL discountFactor (InterestRate (Periodic 1) (9+28/100 :: Double)) 1.00 0.0 == 0.9150805270863837 -} {- NTest[(* 7 *) DiscountFactor[1.5, termstructure1, Compounding -> {Linear, 2}] , 0.9203271932613013 ] ## HQL (using term structure) > let termStructure x = 5 + (1/2)*sqrt(x) > let r = (termStructure 1.5) > discountFactor (InterestRate (Periodic 2) r) 1.50 0.0 == 0.9203271932613013 -- refined version -} {- NTest[(* 8 *) DiscountFactor[1.5, termstructure1, Compounding -> {Linear, 2}, CompiledDF -> True] , 0.9203271932613013 ] ## HQL > discountFactor (InterestRate (Periodic 2) (termStructure 1.5)) 1.5 0.0 == 0.9203271932613013 -} {- NTest[(* 9 *) DiscountFactor[3, 8.5, Compounding -> {Exponential, 12}] , 0.7756133702070986 ] ## HQL > discountFactor (InterestRate (Periodic 12) 8.5) 3.0 0.0 == 0.7756133702070988 -} {- NTest[(* 10 *) DiscountFactor[3, 8.5, Compounding -> {Exponential, 12}, CompiledDF -> True] , 0.7756133702070988 ] ## HQL > discountFactor (InterestRate (Periodic 12) 8.5) 3.0 0.0 == 0.7756133702070988 -} {- NTest[(* 16 *) DiscountFactor[1/2, 8.3, Compounding -> Continuous, CompiledDF -> True] , 0.9593493353414723 ] ## HQL > discountFactor (InterestRate Continuous 8.3) 0.5 0 == 0.9593493353414723 -} {- NTest[(* 11 *) DiscountFactor[4.5, termstructure1, Compounding -> {Exponential, 2}] , 0.7643885607510086 ] ## HQL > let termStructure x = 5 + (1/2)*sqrt(x) > let r = (termStructure 4.5) > discountFactor (InterestRate (Periodic 2) r) 4.50 0.0 == 0.7643885607510086 -} {- NTest[(* 12 *) DiscountFactor[4.5, termstructure1, Compounding -> {Exponential, 2}, CompiledDF -> True] , 0.7643885607510086 ] ## HQL > discountFactor (InterestRate (Periodic 2) (termStructure 4.5)) 4.5 0.0 == 0.7643885607510086 -} {- NTest[(* 13 *) DiscountFactor[1/2, 8.5, Compounding -> {LinearExponential, 1}] , 0.9592326139088729 ] ## HQL (convert periodic to continous) > discountFactor (InterestRate (Periodic 2) 8.5) 0.5 0.0 == 0.9592326139088729 -} {- NTest[(* 14 *) DiscountFactor[1/2, 8.5, Compounding -> {LinearExponential, 1}, CompiledDF -> True] , 0.9592326139088729 ] ## HQL > discountFactor (InterestRate (Periodic 2) 8.5) 0.5 0.0 == 0.9592326139088729 -} {- NTest[(* 15 *) DiscountFactor[1/2, 8.3, Compounding -> Continuous] , 0.9593493353414723 ] ## HQL > discountFactor (InterestRate Continuous 8.3) 0.5 0.0 == 0.9593493353414723 -} {- NTest[(* 16 *) DiscountFactor[1/2, 8.3, Compounding -> Continuous, CompiledDF -> True] , 0.9593493353414723 ] ## HQL > discountFactor (InterestRate Continuous 8.3) 0.5 0.0 == 0.9593493353414723 -} {- NTest[(* 17 *) N[DiscountFactor[90/360, termstructure1, Compounding -> Continuous]] , 0.9871663954590084 ] ## HQL > discountFactor (InterestRate Continuous (termStructure (90/360 :: Double))) (90/360 :: Double) 0.0 == 0.9869607572146836 -} ---- FORWARD RATE {- n = 2; theta1 = 0.25; theta2 = 1.5; interest1 = 6.65; interest2 = 7.77; Out[8]= 7.99473 ## HQL > (((discountFactor (InterestRate (Periodic 2) 6.65) 0.25 0.0)/(discountFactor (InterestRate (Periodic 2) 7.77) 1.5))**(1/(2*1.25))-1)*2*100 == 7.994727369824384 -} -- Include in tests error: abs(output - expected) / expected -- Create a new discount factor from input, where several -- ways are supported. Create DiscountFactor from: -- 1) InterestRate -- 2) TermStructure (yield curve) -- 3) Forward rates (has to be two) {- newDF :: InterestRate -> DiscountFactor Create discount factor (ie zero bond) - Interest rate (as percentage) - Time to maturity - Linear, Exponential, Continous => Periodic, Continuous -}
andreasbock/hql
testsuite/DiscountingTest.hs
gpl-2.0
3,753
0
2
575
25
24
1
1
0
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} module CO4.Example.Fib where import Language.Haskell.TH (runIO) import qualified Satchmo.Core.SAT.Minisat import qualified Satchmo.Core.Decode import CO4 import CO4.Prelude hiding (nat,uNat,Nat) $( [d| data Nat = Z | S Nat deriving Show constraint p n = eq p (fib n) fib x = case x of Z -> Z S x' -> case x' of Z -> S Z S x'' -> let f1 = fib x' f2 = fib x'' in add f1 f2 eq x y = case x of Z -> case y of Z -> True _ -> False S x' -> case y of Z -> False S y' -> eq x' y' add x y = case x of Z -> y S x' -> S (add x' y) |] >>= compile [ImportPrelude,Cache] ) uNat 0 = knownZ uNat i = union knownZ $ knownS $ uNat $ i - 1 allocator = uNat 4 nat 0 = Z nat i = S $ nat $ i - 1 result p = solveAndTestP (nat p) allocator encConstraint constraint
apunktbau/co4
test/CO4/Example/Fib.hs
gpl-3.0
1,177
0
9
448
176
101
75
37
1
main = f `x y` g
roberth/uu-helium
test/parser/BackQuoteMessage.hs
gpl-3.0
17
1
5
6
13
8
5
-1
-1
module Verifier.SAW.SATQuery ( SATQuery(..) , SATResult(..) , satQueryAsTerm ) where import Control.Monad (foldM) import Data.Map (Map) import Data.Set (Set) import Verifier.SAW.Name import Verifier.SAW.FiniteValue import Verifier.SAW.SharedTerm -- | This datatype represents a satisfiability query that might -- be dispatched to a solver. It carries a series of assertions -- to be made to a solver, together with a collection of -- variables we expect the solver to report models over, -- and a collection of @VarIndex@ values identifying -- subterms that should be considered uninterpreted. -- -- All the @ExtCns@ values in the query should -- appear either in @satVariables@ or @satUninterp@. -- Constant values for which definitions are provided -- may also appear in @satUninterp@, in which case -- they will be treated as uninterpreted. Otherwise, -- their definitions will be unfolded. -- -- Solve solvers do not support uninterpreted values -- and will fail if presented a query that requests them. data SATQuery = SATQuery { satVariables :: Map (ExtCns Term) FirstOrderType -- ^ The variables in the query, for which we -- expect the solver to find values in satisfiable -- cases. INVARIANT: The type of the @ExtCns@ keys -- should correspond to the @FirstOrderType@ values. , satUninterp :: Set VarIndex -- ^ A set indicating which variables and constant -- values should be considered uninterpreted by -- the solver. Models will not report values -- for uninterpreted values. , satAsserts :: [Term] -- ^ A collection of assertions. These should -- all be terms of type @Bool@. The overall -- query should be understood as the conjunction -- of these terms. } -- TODO, allow first-order propositions in addition to Boolean terms. -- | The result of a sat query. In the event a model is found, -- return a mapping from the @ExtCns@ variables to values. data SATResult = Unsatisfiable | Satisfiable (ExtCns Term -> IO FirstOrderValue) | Unknown -- | Compute the conjunction of all the assertions -- in this SAT query as a single term of type Bool. satQueryAsTerm :: SharedContext -> SATQuery -> IO Term satQueryAsTerm sc satq = case satAsserts satq of [] -> scBool sc True (x:xs) -> foldM (scAnd sc) x xs -- TODO, we may have to rethink this function -- once we allow first-order statements.
GaloisInc/saw-script
saw-core/src/Verifier/SAW/SATQuery.hs
bsd-3-clause
2,474
0
11
550
253
158
95
24
2
{-# LANGUAGE OverloadedStrings, TupleSections #-} -- | Parser components for the ROS message description language (@msg@ -- files). See http://wiki.ros.org/msg for reference. module Parse (parseMsg, parseSrv, simpleFieldAssoc) where import Prelude hiding (takeWhile) import Control.Applicative import Control.Arrow ((&&&)) import Data.Attoparsec.ByteString.Char8 import Data.ByteString (ByteString) import Data.ByteString.Char8 (pack, unpack) import qualified Data.ByteString.Char8 as B import Data.Char (toLower, digitToInt) import Data.Either (partitionEithers) import Data.List (foldl') import System.FilePath (dropExtension, takeFileName, splitDirectories) import Types simpleFieldTypes :: [MsgType] simpleFieldTypes = [ RBool, RInt8, RUInt8, RInt16, RUInt16, RInt32, RUInt32, RInt64, RUInt64, RFloat32, RFloat64, RString, RTime, RDuration, RByte, RChar ] simpleFieldAssoc :: [(MsgType, ByteString)] simpleFieldAssoc = map (id &&& B.pack . map toLower . tail . show) simpleFieldTypes eatLine :: Parser () eatLine = manyTill anyChar (eitherP endOfLine endOfInput) *> skipSpace parseName :: Parser ByteString parseName = skipSpace *> identifier <* eatLine <* try comment identifier :: Parser ByteString identifier = B.cons <$> letter_ascii <*> takeWhile validChar where validChar c = any ($ c) [isDigit, isAlpha_ascii, (== '_'), (== '/')] parseInt :: Parser Int parseInt = foldl' (\s x -> s*10 + digitToInt x) 0 <$> many1 digit comment :: Parser [()] comment = many $ skipSpace *> try (char '#' *> eatLine) simpleParser :: (MsgType, ByteString) -> Parser (ByteString, MsgType) simpleParser (t,b) = (, t) <$> (string b *> space *> parseName) fixedArrayParser :: (MsgType, ByteString) -> Parser (ByteString, MsgType) fixedArrayParser (t,b) = (\len name -> (name, RFixedArray len t)) <$> (string b *> char '[' *> parseInt <* char ']') <*> (space *> parseName) varArrayParser :: (MsgType, ByteString) -> Parser (ByteString, MsgType) varArrayParser (t,b) = (, RVarArray t) <$> (string b *> string "[]" *> space *> parseName) userTypeParser :: Parser (ByteString, MsgType) userTypeParser = choice [userSimple, userVarArray, userFixedArray] userSimple :: Parser (ByteString, MsgType) userSimple = (\t name -> (name, RUserType t)) <$> identifier <*> (space *> parseName) userVarArray :: Parser (ByteString, MsgType) userVarArray = (\t name -> (name, RVarArray (RUserType t))) <$> identifier <*> (string "[]" *> space *> parseName) userFixedArray :: Parser (ByteString, MsgType) userFixedArray = (\t n name -> (name, RFixedArray n (RUserType t))) <$> identifier <*> (char '[' *> parseInt <* char ']') <*> (space *> parseName) -- Parse constants defined in the message constParser :: ByteString -> MsgType -> Parser (ByteString, MsgType, ByteString) constParser s x = (,x,) <$> (string s *> space *> identifier) <*> (skipSpace *> char '=' *> skipSpace *> restOfLine <* skipSpace) where restOfLine :: Parser ByteString restOfLine = pack <$> manyTill anyChar (eitherP endOfLine endOfInput) constParsers :: [Parser (ByteString, MsgType, ByteString)] constParsers = map (uncurry constParser . swap) simpleFieldAssoc where swap (x,y) = (y,x) -- String constants are parsed somewhat differently from numeric -- constants. For numerical constants, we drop comments and trailing -- spaces. For strings, we take the whole line (so comments aren't -- stripped). sanitizeConstants :: (a, MsgType, ByteString) -> (a, MsgType, ByteString) sanitizeConstants c@(_, RString, _) = c sanitizeConstants (name, t, val) = (name, t, B.takeWhile (\c -> c /= '#' && not (isSpace c)) val) -- Parsers fields and constants. fieldParsers :: [Parser (Either (ByteString, MsgType) (ByteString, MsgType, ByteString))] fieldParsers = map (comment *>) $ map (Right . sanitizeConstants <$>) constParsers ++ map (Left <$>) (builtIns ++ [userTypeParser]) where builtIns = concatMap (`map` simpleFieldAssoc) [simpleParser, fixedArrayParser, varArrayParser] mkParser :: MsgName -> String -> ByteString -> Parser Msg mkParser sname lname txt = aux . partitionEithers <$> many (choice fieldParsers) where aux (fs, cs) = Msg sname lname txt (map buildField fs) (map buildConst cs) buildField :: (ByteString, MsgType) -> MsgField buildField (name,typ) = MsgField fname typ name where fname = B.append "_" $ sanitize name buildConst :: (ByteString, MsgType, ByteString) -> MsgConst buildConst (name,typ,val) = MsgConst fname typ val name where fname = B.map toLower $ sanitize name {- testMsg :: ByteString testMsg = "# Foo bar\n\n# \nHeader header # a header\nuint32 aNum # a number \n # It's not important\ngeometry_msgs/PoseStamped[] poses\nbyte DEBUG=1 #debug level\n" test :: Result Msg test = feed (parse (comment *> (mkParser "" "" testMsg)) testMsg) "" -} -- Ensure that field and constant names are valid Haskell identifiers -- and do not coincide with Haskell reserved words. sanitize :: ByteString -> ByteString sanitize "data" = "_data" sanitize "type" = "_type" sanitize "class" = "_class" sanitize "module" = "_module" sanitize x = B.cons (toLower (B.head x)) (B.tail x) pkgName :: FilePath -> String pkgName f = let parts = splitDirectories f [pkg,_,_msgFile] = drop (length parts - 3) parts in pkg parseMsg :: FilePath -> IO (Either String Msg) parseMsg fname = do msgFile <- B.readFile fname let tName = msgName . dropExtension . takeFileName $ fname packageName = pkgName fname return $ parseMsgWithName tName packageName msgFile parseMsgWithName :: MsgName -> String -> ByteString -> Either String Msg parseMsgWithName name packageName msgFile = case feed (parse parser msgFile) "" of Done leftOver msg | B.null leftOver -> Right msg | otherwise -> Left $ "Couldn't parse " ++ unpack leftOver Fail _ _ctxt err -> Left err Partial _ -> Left "Incomplete msg definition" where parser = comment *> mkParser name packageName msgFile -- | Parse a service file by splitting the file into a request and a response -- | and parsing each part separately. parseSrv :: FilePath -> IO (Either String Srv) parseSrv fname = do srvFile <- B.readFile fname let (request, response) = splitService srvFile packageName = pkgName fname rawServiceName = dropExtension . takeFileName $ fname return $ do rqst <- parseMsgWithName (requestMsgName rawServiceName) packageName request resp <- parseMsgWithName (responseMsgName rawServiceName) packageName response return Srv{srvRequest = rqst , srvResponse = resp , srvName = msgName rawServiceName , srvPackage = packageName , srvSource = srvFile} splitService :: ByteString -> (ByteString, ByteString) splitService service = (request, response) where -- divider does not include newlines to allow it match even -- if there is no request or response message divider = "---" (request, dividerAndResponse) = B.breakSubstring divider service --Add 1 to the length of the divider to remove newline response = B.drop (1 + B.length divider) dividerAndResponse
bitemyapp/roshask
src/executable/Parse.hs
bsd-3-clause
7,585
0
13
1,728
2,148
1,166
982
-1
-1
module FunIn3 where --The application of a function is replaced by the right-hand side of the definition, --with actual parameters replacing formals. --In this example, unfold 'addthree'. --This example aims to test the elimination of extra parentheses when unfolding --a function defintion. main :: Int -> Int main = \x -> case x of 1 -> 1 + main 0 0 ->((1 + 2) + 3) addthree :: Int -> Int -> Int -> Int addthree a b c = a + b + c
mpickering/HaRe
old/testing/unfoldDef/FunIn3_TokOut.hs
bsd-3-clause
469
0
12
122
102
57
45
7
2
module StrategoAST2(module AST) where import StrategoPattern as AST import StrategoTerm as AST import StrategoType as AST import StrategoProp as AST import StrategoDecl as AST
forste/haReFork
tools/hs2stratego/AST/StrategoAST2.hs
bsd-3-clause
176
0
4
24
35
27
8
6
0
module ShowRepoEvents where import qualified Github.Issues.Events as Github import Data.List (intercalate) import Data.Maybe (fromJust) main = do possibleEvents <- Github.eventsForRepo "thoughtbot" "paperclip" case possibleEvents of (Left error) -> putStrLn $ "Error: " ++ show error (Right events) -> do putStrLn $ intercalate "\n" $ map formatEvent events formatEvent event = "Issue #" ++ issueNumber event ++ ": " ++ formatEvent' event (Github.eventType event) where formatEvent' event Github.Closed = "closed on " ++ createdAt event ++ " by " ++ loginName event ++ withCommitId event (\commitId -> " in the commit " ++ commitId) formatEvent' event Github.Reopened = "reopened on " ++ createdAt event ++ " by " ++ loginName event formatEvent' event Github.Subscribed = loginName event ++ " is subscribed to receive notifications" formatEvent' event Github.Unsubscribed = loginName event ++ " is unsubscribed from notifications" formatEvent' event Github.Merged = "merged by " ++ loginName event ++ " on " ++ createdAt event ++ (withCommitId event $ \commitId -> " in the commit " ++ commitId) formatEvent' event Github.Referenced = withCommitId event $ \commitId -> "referenced from " ++ commitId ++ " by " ++ loginName event formatEvent' event Github.Mentioned = loginName event ++ " was mentioned in the issue's body" formatEvent' event Github.Assigned = "assigned to " ++ loginName event ++ " on " ++ createdAt event loginName = Github.githubOwnerLogin . Github.eventActor createdAt = show . Github.fromGithubDate . Github.eventCreatedAt withCommitId event f = maybe "" f (Github.eventCommitId event) issueNumber = show . Github.issueNumber . fromJust . Github.eventIssue
bitemyapp/github
samples/Issues/Events/ShowRepoEvents.hs
bsd-3-clause
1,783
0
14
352
487
241
246
36
8
-- -- Copyright (c) 2011 Citrix Systems, Inc. -- -- 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 -- import Distribution.Simple import Distribution.Simple.PreProcess import Distribution.Simple.PreProcess.Unlit (unlit) import Distribution.Package ( Package(..), PackageName(..) ) import Distribution.ModuleName (ModuleName) import qualified Distribution.ModuleName as ModuleName import Distribution.PackageDescription as PD ( PackageDescription(..), BuildInfo(..), Executable(..), withExe , Library(..), withLib, libModules ) import qualified Distribution.InstalledPackageInfo as Installed ( InstalledPackageInfo_(..) ) import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Simple.Compiler ( CompilerFlavor(..), Compiler(..), compilerFlavor, compilerVersion ) import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..)) import Distribution.Simple.BuildPaths (autogenModulesDir,cppHeaderName) import Distribution.Simple.Utils ( createDirectoryIfMissingVerbose, withUTF8FileContents, writeUTF8File , die, setupMessage, intercalate, copyFileVerbose , findFileWithExtension, findFileWithExtension' ) import Distribution.Simple.Program ( Program(..), ConfiguredProgram(..), lookupProgram, programPath , rawSystemProgramConf, rawSystemProgram , greencardProgram, cpphsProgram, hsc2hsProgram, c2hsProgram , happyProgram, alexProgram, haddockProgram, ghcProgram, gccProgram, ldProgram ) import Distribution.System ( OS(OSX, Windows), buildOS ) import Distribution.Version (Version(..)) import Distribution.Verbosity import Distribution.Text ( display ) import Control.Monad (when, unless) import Data.Maybe (fromMaybe) import Data.List (nub) import System.Directory (getModificationTime, doesFileExist) import System.Info (os, arch) import System.FilePath (splitExtension, dropExtensions, (</>), (<.>), takeDirectory, normalise, replaceExtension) import Distribution.Simple.Program (simpleProgram) hsc2hsLdProgram = simpleProgram "hsc2hs-ld" my_ppHsc2hs :: BuildInfo -> LocalBuildInfo -> PreProcessor my_ppHsc2hs bi lbi = standardPP lbi hsc2hsProgram $ [ "--cc=" ++ programPath gccProg , "--ld=" ++ programPath ldProg ] -- [ "--cc=" ++ cc -- , "--ld=" ++ ld ] -- Additional gcc options ++ [ "--cflag=" ++ opt | opt <- programArgs gccProg ] ++ [ "--lflag=" ++ opt | opt <- programArgs gccProg ] -- OSX frameworks: ++ [ what ++ "=-F" ++ opt | isOSX , opt <- nub (concatMap Installed.frameworkDirs pkgs) , what <- ["--cflag", "--lflag"] ] ++ [ "--lflag=" ++ arg | isOSX , opt <- PD.frameworks bi ++ concatMap Installed.frameworks pkgs , arg <- ["-framework", opt] ] -- Note that on ELF systems, wherever we use -L, we must also use -R -- because presumably that -L dir is not on the normal path for the -- system's dynamic linker. This is needed because hsc2hs works by -- compiling a C program and then running it. -- Options from the current package: ++ [ "--cflag=" ++ opt | opt <- hcDefines (compiler lbi) ] ++ [ "--cflag=-I" ++ dir | dir <- PD.includeDirs bi ] ++ [ "--cflag=" ++ opt | opt <- PD.ccOptions bi ++ PD.cppOptions bi ] ++ [ "--lflag=-L" ++ opt | opt <- PD.extraLibDirs bi ] ++ [ "--lflag=-Wl,-R," ++ opt | isELF , opt <- PD.extraLibDirs bi ] ++ [ "--lflag=-l" ++ opt | opt <- PD.extraLibs bi ] ++ [ "--lflag=" ++ opt | opt <- PD.ldOptions bi ] -- Options from dependent packages ++ [ "--cflag=" ++ opt | pkg <- pkgs , opt <- [ "-I" ++ opt | opt <- Installed.includeDirs pkg ] ++ [ opt | opt <- Installed.ccOptions pkg ] ] ++ [ "--lflag=" ++ opt | pkg <- pkgs , opt <- [ "-L" ++ opt | opt <- Installed.libraryDirs pkg ] ++ [ "-Wl,-R," ++ opt | isELF , opt <- Installed.libraryDirs pkg ] ++ [ "-l" ++ opt | opt <- Installed.extraLibraries pkg ] ++ [ opt | opt <- Installed.ldOptions pkg ] ] where pkgs = PackageIndex.topologicalOrder (packageHacks (installedPkgs lbi)) Just gccProg = lookupProgram gccProgram (withPrograms lbi) Just ldProg = lookupProgram hsc2hsLdProgram (withPrograms lbi) isOSX = case buildOS of OSX -> True; _ -> False isELF = case buildOS of OSX -> False; Windows -> False; _ -> True; packageHacks = case compilerFlavor (compiler lbi) of GHC -> hackRtsPackage _ -> id -- We don't link in the actual Haskell libraries of our dependencies, so -- the -u flags in the ldOptions of the rts package mean linking fails on -- OS X (it's ld is a tad stricter than gnu ld). Thus we remove the -- ldOptions for GHC's rts package: hackRtsPackage index = case PackageIndex.lookupPackageName index (PackageName "rts") of [(_, [rts])] -> PackageIndex.insert rts { Installed.ldOptions = [] } index _ -> error "No (or multiple) ghc rts package is registered!!" -- TODO: move this into the compiler abstraction -- FIXME: this forces GHC's crazy 4.8.2 -> 408 convention on all the other -- compilers. Check if that's really what they want. versionInt :: Version -> String versionInt (Version { versionBranch = [] }) = "1" versionInt (Version { versionBranch = [n] }) = show n versionInt (Version { versionBranch = n1:n2:_ }) = -- 6.8.x -> 608 -- 6.10.x -> 610 let s1 = show n1 s2 = show n2 middle = case s2 of _ : _ : _ -> "" _ -> "0" in s1 ++ middle ++ s2 standardPP :: LocalBuildInfo -> Program -> [String] -> PreProcessor standardPP lbi prog args = PreProcessor { platformIndependent = False, runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> do rawSystemProgramConf verbosity prog (withPrograms lbi) (args ++ ["-o", outFile, inFile]) -- XXX This is a nasty hack. GHC requires that hs-boot files -- be in the same place as the hs files, so if we put the hs -- file in dist/... then we need to copy the hs-boot file -- there too. This should probably be done another way, e.g. -- by preprocessing all files, with and "id" preprocessor if -- nothing else, so the hs-boot files automatically get copied -- into the right place. -- Possibly we should also be looking for .lhs-boot files, but -- I think that preprocessors only produce .hs files. let inBoot = replaceExtension inFile "hs-boot" outBoot = replaceExtension outFile "hs-boot" exists <- doesFileExist inBoot when exists $ copyFileVerbose verbosity inBoot outBoot } hcDefines :: Compiler -> [String] hcDefines comp = case compilerFlavor comp of GHC -> ["-D__GLASGOW_HASKELL__=" ++ versionInt version] JHC -> ["-D__JHC__=" ++ versionInt version] NHC -> ["-D__NHC__=" ++ versionInt version] Hugs -> ["-D__HUGS__"] _ -> [] where version = compilerVersion comp main = defaultMainWithHooks $ simpleUserHooks { hookedPreProcessors = [ ("hsc", my_ppHsc2hs) ] , hookedPrograms = hsc2hsLdProgram : hookedPrograms simpleUserHooks }
jean-edouard/manager
xenmgr/Setup.hs
gpl-2.0
8,034
0
22
1,919
1,714
964
750
122
6
module Lib where import Data.Function (on) import Data.List (findIndices, minimumBy, transpose) import Data.Maybe (isJust, isNothing) data Shape = Nought | Cross deriving (Read, Show, Eq) type Cell = Maybe Shape type Board = [Cell] boardSize = 3 emptyBoard = replicate (boardSize * boardSize) Nothing makeBoard :: String -> Board makeBoard = map charToCell . take (boardSize * boardSize) where charToCell 'o' = Just Nought charToCell 'x' = Just Cross charToCell _ = Nothing nextMove :: Board -> Shape -> Board nextMove brd shp = minimumBy (compare `on` opponentScore) (nextBoards brd shp) where opponentScore brd' = scoreFor brd' (opponent shp) isWinFor :: Board -> Shape -> Bool isWinFor brd shp = any winningSlice allSlices where winningSlice = all (== Just shp) allSlices = rows brd ++ cols brd ++ diagonals brd isLossFor :: Board -> Shape -> Bool isLossFor brd shp = isWinFor brd (opponent shp) isDraw :: Board -> Bool isDraw brd = isFull brd && noWin Nought && noWin Cross where noWin = not . isWinFor brd isFull :: Board -> Bool isFull = all isJust nextBoards :: Board -> Shape -> [Board] nextBoards brd shp = map makeMove emptyIdxs where makeMove n = fillCell brd n (Just shp) emptyIdxs = findIndices isNothing brd fillCell :: Board -> Int -> Cell -> Board fillCell brd n cell | n >= (boardSize * boardSize) = brd | otherwise = before ++ [cell] ++ (drop 1 after) where (before, after) = splitAt n brd scoreFor :: Board -> Shape -> Int scoreFor brd shp | isWinFor brd shp = 1 | isLossFor brd shp = -1 | isDraw brd = 0 | otherwise = -(minimum $ map opponentScore (nextBoards brd shp)) where opponentScore brd' = scoreFor brd' (opponent shp) rows :: Board -> [[Cell]] rows brd = map row [0..boardSize-1] where row n = take boardSize . drop (n * boardSize) $ brd cols :: Board -> [[Cell]] cols = transpose . rows diagonals :: Board -> [[Cell]] diagonals brd = map extract [topLeft, topRight] where extract = map (brd !!) topLeft = map (\n -> n * (boardSize + 1)) [0..boardSize-1] topRight = map (\n -> (n + 1) * (boardSize - 1)) [0..boardSize-1] opponent :: Shape -> Shape opponent Nought = Cross opponent Cross = Nought
leocassarani/noughts-and-crosses
src/Lib.hs
mit
2,262
0
12
515
922
478
444
58
3
{-| Module : TestUtils.Validate Description : The Validate type class Copyright : (c) Andrew Burnett 2014-2015 Maintainer : [email protected] Stability : experimental Portability : Unknown 'Validate' provides a definition for validating a data structure. For example, we may cache information about the size of a list as it is created. Validate would check that this is correct -} module TestUtils.Validate ( Validate(..) ) where {-| The 'Validate' class provides a validate method for types, to make sure that they have been defined correctly. -} class Validate a where -- | validate should return a 'Bool' which defines whether a data structure -- | is valid validate :: a -> Bool
aburnett88/HSat
tests-src/TestUtils/Validate.hs
mit
712
0
7
133
37
23
14
4
0
module Language.Aspell ( -- * Constructors SpellChecker, spellChecker, spellCheckerWithOptions, spellCheckerWithDictionary, -- * Using the spell checker check, suggest ) where import Data.ByteString.Char8 import Foreign #if !MIN_VERSION_base(4,7,0) hiding (unsafePerformIO) #endif import Foreign.C.String import Foreign.C.Types import Language.Aspell.Options import System.IO.Unsafe type AspellConfig = ForeignPtr () type SpellChecker = ForeignPtr () type CAspellConfig = Ptr () type CSpellChecker = Ptr () type CAspellCanHaveError = Ptr () type CWordList = Ptr () type CStringEnumeration = Ptr () newConfig :: IO AspellConfig newConfig = do cf <- new_aspell_config newForeignPtr delete_aspell_config cf setOpts :: [ACOption] -> AspellConfig -> IO AspellConfig setOpts (Dictionary dict:opts) pt = setOpt "master" dict pt >>= setOpts opts setOpts (WordListDir dir:opts) pt = setOpt "dict-dir" dir pt >>= setOpts opts setOpts (Lang lang:opts) pt = setOpt "lang" lang pt >>= setOpts opts setOpts (Size size:opts) pt = setOpt "size" newSize pt >>= setOpts opts where newSize = case size of Tiny -> "+10" ReallySmall -> "+20" Small -> "+30" MediumSmall -> "+40" Medium -> "+50" MediumLarge -> "+60" Large -> "+70" Huge -> "+80" Insane -> "+90" setOpts (PersonalWordList wl:opts) pt = setOpt "personal" wl pt >>= setOpts opts setOpts (ReplacementsList rl:opts) pt = setOpt "repl" rl pt >>= setOpts opts setOpts (Encoding encoding:opts) pt = setOpt "encoding" enc pt >>= setOpts opts where enc = case encoding of UTF8 -> "utf-8" Latin1 -> "iso-8859-1" setOpts (Normalize n:opts) pt = setOptBool "normalize" n pt >>= setOpts opts setOpts (NormalizeStrict n:opts) pt = setOptBool "norm-strict" n pt >>= setOpts opts setOpts (NormalizeForm form:opts) pt = setOpt "norm-form" nform pt >>= setOpts opts where nform = case form of None -> "none" NFD -> "nfd" NFC -> "nfc" Composed -> "comp" setOpts (NormalizeRequired b:opts) pt = setOptBool "norm-required" b pt >>= setOpts opts setOpts (Ignore i:opts) pt = setOptInteger "ignore" i pt >>= setOpts opts setOpts (IgnoreReplace b:opts) pt = setOptBool "ignore-repl" b pt >>= setOpts opts setOpts (SaveReplace b:opts) pt = setOptBool "save-repl" b pt >>= setOpts opts setOpts (KeyboardDef s:opts) pt = setOpt "keyboard" s pt >>= setOpts opts setOpts (SuggestMode sm:opts) pt = setOpt "sug-mode" mode pt >>= setOpts opts where mode = case sm of Ultra -> "ultra" Fast -> "fast" Normal -> "normal" Slow -> "slow" BadSpellers -> "bad-spellers" setOpts (IgnoreCase b:opts) pt = setOptBool "ignore-case" b pt >>= setOpts opts setOpts (IgnoreAccents b:opts) pt = setOptBool "ignore-accents" b pt >>= setOpts opts setOpts (FilterMode s:opts) pt = setOpt "mode" s pt >>= setOpts opts setOpts (EmailMargin n:opts) pt = setOptInteger "email-margin" n pt >>= setOpts opts setOpts (TeXCheckComments b:opts) pt = setOptBool "tex-check-comments" b pt >>= setOpts opts setOpts (ContextVisibleFirst b:opts) pt = setOptBool "context-visible-first" b pt >>= setOpts opts setOpts (RunTogether b:opts) pt = setOptBool "run-together" b pt >>= setOpts opts setOpts (RunTogetherLimit n:opts) pt = setOptInteger "run-together-limit" n pt >>= setOpts opts setOpts (RunTogetherMin n:opts) pt = setOptInteger "run-together-min" n pt >>= setOpts opts setOpts (MainConfig s:opts) pt = setOpt "conf" s pt >>= setOpts opts setOpts (MainConfigDir s:opts) pt = setOpt "conf-dir" s pt >>= setOpts opts setOpts (DataDir s:opts) pt = setOpt "data-dir" s pt >>= setOpts opts setOpts (LocalDataDir s:opts) pt = setOpt "local-data-dir" s pt >>= setOpts opts setOpts (HomeDir s:opts) pt = setOpt "home-dir" s pt >>= setOpts opts setOpts (PersonalConfig s:opts) pt = setOpt "per-conf" s pt >>= setOpts opts setOpts (Layout s:opts) pt = setOpt "keyboard" s pt >>= setOpts opts setOpts (Prefix s:opts) pt = setOpt "prefix" s pt >>= setOpts opts setOpts (SetPrefix b:opts) pt = setOptBool "set-prefix" b pt >>= setOpts opts setOpts [] pt = return pt setOpt :: ByteString -> ByteString -> AspellConfig -> IO AspellConfig setOpt key value pt = do withForeignPtr pt $ \ac -> useAsCString key $ \k -> useAsCString value $ aspell_config_replace ac k return pt setOptBool :: ByteString -> Bool -> AspellConfig -> IO AspellConfig setOptBool k v = setOpt k (if v then "true" else "false") setOptInteger :: ByteString -> Integer -> AspellConfig -> IO AspellConfig setOptInteger k v = setOpt k (pack $ show v) -- | Creates a spell checker with default options. -- -- @ -- 'spellChecker' = 'spellCheckerWithOptions' [] -- @ -- spellChecker :: IO (Either ByteString SpellChecker) spellChecker = spellCheckerWithOptions [] -- | Creates a spell checker with a custom set of options. spellCheckerWithOptions :: [ACOption] -> IO (Either ByteString SpellChecker) spellCheckerWithOptions opts = do cf <- newConfig setOpts opts cf canError <- withForeignPtr cf new_aspell_speller (errNum :: Int) <- fromIntegral `fmap` aspell_error_number canError if errNum > 0 then do errMsg <- aspell_error_message canError >>= packCString return $ Left errMsg else do speller <- to_aspell_speller canError for <- newForeignPtr delete_aspell_speller speller return $ Right for -- | Convenience function for specifying a dictionary. -- -- You can determine which dictionaries are available to you with @aspell dump dicts@. -- -- @ -- 'spellCheckerWithDictionary' dict = 'spellCheckerWithOptions' ['Dictionary' dict] -- @ spellCheckerWithDictionary :: ByteString -> IO (Either ByteString SpellChecker) spellCheckerWithDictionary b = spellCheckerWithOptions [Dictionary b] -- | Checks if a word has been spelled correctly. check :: SpellChecker -> ByteString -> Bool check checker word = unsafePerformIO $ withForeignPtr checker $ \ck -> useAsCString word $ \w -> do res <- aspell_speller_check ck w $ negate 1 return $ res == 1 -- | Lists suggestions for misspelled words. -- -- If the input is not misspelled according to the dictionary, returns @[]@. suggest :: SpellChecker -> ByteString -> IO [ByteString] suggest checker word = withForeignPtr checker $ \ck -> useAsCString word $ \w -> do wlist <- aspell_speller_suggest ck w (negate 1) elems <- aspell_word_list_elements wlist suggestions <- strEnumToList elems delete_aspell_string_enumeration elems return suggestions strEnumToList :: CStringEnumeration -> IO [ByteString] strEnumToList enum = go enum where go e = do nw <- aspell_string_enumeration_next enum if nw == nullPtr then return [] else do curWord <- packCString nw next <- go e return $ curWord:next foreign import ccall unsafe "aspell.h &delete_aspell_config" delete_aspell_config :: FunPtr (CAspellConfig -> IO ()) foreign import ccall unsafe "aspell.h &delete_aspell_speller" delete_aspell_speller :: FunPtr (CSpellChecker -> IO ()) foreign import ccall unsafe "aspell.h delete_aspell_string_enumeration" delete_aspell_string_enumeration :: CStringEnumeration -> IO () foreign import ccall unsafe "aspell.h new_aspell_config" new_aspell_config :: IO CAspellConfig foreign import ccall unsafe "aspell.h aspell_config_replace" aspell_config_replace :: CAspellConfig -> CString -> CString -> IO CAspellConfig foreign import ccall unsafe "aspell.h new_aspell_speller" new_aspell_speller :: CAspellConfig -> IO CAspellCanHaveError foreign import ccall unsafe "aspell.h aspell_error_number" aspell_error_number :: CAspellCanHaveError -> IO CUInt foreign import ccall unsafe "aspell.h aspell_error_message" aspell_error_message :: CAspellCanHaveError -> IO CString foreign import ccall unsafe "aspell.h to_aspell_speller" to_aspell_speller :: CAspellCanHaveError -> IO CSpellChecker foreign import ccall unsafe "aspell.h aspell_speller_check" aspell_speller_check :: CSpellChecker -> CString -> CInt -> IO CInt foreign import ccall unsafe "aspell.h aspell_speller_suggest" aspell_speller_suggest :: CSpellChecker -> CString -> CInt -> IO CWordList foreign import ccall unsafe "aspell.h aspell_word_list_elements" aspell_word_list_elements :: CWordList -> IO CStringEnumeration foreign import ccall unsafe "aspell.h aspell_string_enumeration_next" aspell_string_enumeration_next :: CStringEnumeration -> IO CString
pikajude/haspell
Language/Aspell.hs
mit
9,412
0
14
2,466
2,523
1,242
1,281
-1
-1
{- | module: Main description: Testing the FEN to Unicode conversion license: MIT maintainer: Joe Leslie-Hurd <[email protected]> stability: provisional portability: portable -} module Main ( main ) where import qualified Unicode import qualified Chess tests :: [(String,String,Chess.Edge)] tests = [("Initial position", "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR", Chess.NoEdge), ("Mate in 3", "KR6/8/kN4r1/p7/8/8/8/8", Chess.SingleEdge), ("Mate in 4", "8/8/4K3/1BkN4/8/2NpP3/3P4/8", Chess.DoubleEdge)] outputFen :: (String,String,Chess.Edge) -> IO () outputFen (s,f,e) = do putStrLn (s ++ ":") Unicode.encode (Chess.fenToUnicode f e ++ Unicode.newline) main :: IO () main = mapM_ outputFen tests
gilith/opentheory
data/haskell/fen2s/src/Test.hs
mit
765
0
11
150
183
106
77
21
1
{-# LANGUAGE TupleSections #-} module Y2016.M09.D09.Solution where import Control.Arrow (first) import Control.Monad (guard, (>=>)) import Data.Function (on) import Data.List (sortBy) import Data.Map (Map) import qualified Data.Map as Map -- below import available from 1HaskellADay git repository import Control.List (takeout) {-- Now for something completely different ... So some related cryptoarithmetic: --} sums :: [(String, String, Int)] sums = [("FAT", "CAT", 904), ("STORE","CAKE",60836), ("EACH", "ROSE", 7839)] -- solve these sums -- Okay, first we need to assign a letter to a value assign :: Map Char Int -> Char -> [Int] -> [((Char, Int), [Int])] assign ctx ch domain = maybe (fmap (first (ch,)) (takeout domain)) (pure . (,domain) . (ch,)) (Map.lookup ch ctx) -- we do that for each of the letters. assigns :: Map Char Int -> String -> [Int] -> [([(Char, Int)], [Int])] assigns _ [] = pure . ([],) assigns ctx (ch:s) = assign ctx ch >=> \(a,b) -> assigns ctx s b >>= return . first (a:) {-- *Y2016.M09.D09.Solution> let ans = assigns Map.empty "FAT" [0..9] *Y2016.M09.D09.Solution> head ans ~> ([('F',0),('A',1),('T',2)],[3,4,5,6,7,8,9]) *Y2016.M09.D09.Solution> last ans ~> ([('F',9),('A',8),('T',7)],[0,1,2,3,4,5,6]) *Y2016.M09.D09.Solution> length ans ~> 720 --} -- Okay, we have that, so let's convert that to a map. With arrows, this is -- easy, right: map (first Map.fromList) -- Now we convert a word into a number: numfrom :: Map Char Int -> String -> Int numfrom ctx = foldl (\tots -> (10 * tots +) . (ctx Map.!)) 0 {-- *Y2016.M09.D09.Solution> let fats = map (first (flip numfrom "FAT" . Map.fromList)) ans *Y2016.M09.D09.Solution> head fats ~> (210,[3,4,5,6,7,8,9]) *Y2016.M09.D09.Solution> last fats ~> (789,[0,1,2,3,4,5,6]) --} solver :: (String, String, Int) -> Map Char Int -> [Int] -> [(Map Char Int, [Int])] solver (a,b,c) ctx domain = assigns ctx a domain >>= \(asol, rest) -> let amap = merge ctx asol na = numfrom amap a in guard (na < c) >> assigns amap b rest >>= \(bsol, subdom) -> let newmap = merge amap bsol in guard (na + numfrom newmap b == c) >> return (newmap, subdom) merge :: Ord a => Map a b -> [(a,b)] -> Map a b merge m = Map.union m . Map.fromList -- solving all three will map the letter to the digits [0..9] {-- *Y2016.M09.D09.Solution> let solves = solver Map.empty [0..9] (head sums) *Y2016.M09.D09.Solution> length solves ~> 10 *Y2016.M09.D09.Solution> head solves (fromList [('A',5),('C',8),('F',0),('T',2)],[1,3,4,6,7,9]) so: --} solveAll :: [(String, String, Int)] -> Map Char Int -> [Int] -> [Map Char Int] solveAll [] ctx = const (pure ctx) solveAll (e:qs) ctx = solver e ctx >=> uncurry (solveAll qs) . first (Map.union ctx) {-- *Y2016.M09.D09.Solution> solveAll sums Map.empty [0..9] ~> {[('A',0),('C',8),('E',3),('F',1),('H',6),('K',9),('O',7),('R',4),('S',5),('T',2)]} --} -- arrange the character in their digit-value order. What word do you get? arrange :: Map Char Int -> String arrange = map fst . sortBy (compare `on` snd) . Map.toList -- *Y2016.M09.D09.Solution> arrange (head it) ~> "AFTERSHOCK"
geophf/1HaskellADay
exercises/HAD/Y2016/M09/D09/Solution.hs
mit
3,206
0
18
614
876
489
387
-1
-1
{-# htermination (scanl :: (a -> b -> a) -> a -> (List b) -> (List a)) #-} import qualified Prelude data MyBool = MyTrue | MyFalse data List a = Cons a (List a) | Nil scanl0 f q Nil = Nil; scanl0 f q (Cons x xs) = scanl f (f q x) xs; scanl :: (b -> a -> b) -> b -> (List a) -> (List b); scanl f q xs = Cons q (scanl0 f q xs);
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Haskell/basic_haskell/scanl_1.hs
mit
352
0
9
108
155
83
72
7
1
{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-} -- | The GhostLang.Node.Flow module is implementing the Flows - -- business logic - for the Node. module GhostLang.Node.Flow ( getHttpConfig , setHttpConfig , listPrograms , listPatternsFromProgram , runNamedPattern , runRandomPattern , loadProgram , listPatterns , getGlobalCounter , getPatternCounter , patternStatus ) where import Control.Concurrent.Async (async, poll) import Control.Concurrent.STM (newTVarIO, readTVarIO) import Data.ByteString (ByteString) import Data.List (find) import Data.Text (Text) import Data.Text.Encoding (encodeUtf8) import GhostLang ( GhostPattern , PatternTuple , Counter (..) , compileAndLink , emptyCounter , runPattern , toPatternList ) import GhostLang.API ( PatternInfo (..) , ProgramPath (..) , Resource (..) , Service (..) , ExecParams (..) , NamedPattern (..) , PatternStatus (..) , PatternCounter (..) ) import GhostLang.Node.IdGen (genId) import GhostLang.Node.State ( State (..) , ResourceKey , ProgramRepr (..) , PatternRepr (..) , NetworkConfiguration (..) , insertProgram , lookupProgram , allPrograms , insertPattern , lookupPattern , allPatterns , modifyTVar'IO , mkRandomSelector ) import qualified Data.ByteString.Char8 as BS import qualified Data.Text as T -- | Get the current http configuration. getHttpConfig :: State -> IO Service getHttpConfig state = do nw <- readTVarIO $ networkConf state return $ Service { serviceAddress = httpServiceAddress nw , servicePort = httpServicePort nw } -- | Set the http configuration. setHttpConfig :: State -> Service -> IO () setHttpConfig State {..} Service {..} = modifyTVar'IO networkConf $ \nw -> nw { httpServiceAddress = serviceAddress , httpServicePort = servicePort } -- | List all registered programs. listPrograms :: State -> IO [Resource] listPrograms state = map (Resource . programUrl) <$> allPrograms state -- | List the patterns from the selected program. listPatternsFromProgram :: State -> ResourceKey -> IO (Maybe [PatternInfo]) listPatternsFromProgram state key = do maybe Nothing (Just . mapPatternInfo) <$> lookupProgram state key where mapPatternInfo = map (\(l, w, _) -> PatternInfo l w) . patternList -- | Compile the ghost program, if succesful store it in the state. loadProgram :: State -> ProgramPath -> IO (Either String Resource) loadProgram state ProgramPath {..} = do result <- compileAndLink (T.unpack programPath) case result of Right program -> do key <- genId randomPattern' <- mkRandomSelector $ toPatternList program let url = "/program/" `T.append` key repr = ProgramRepr { programPath_ = programPath , programUrl = url , ghostProgram = program , patternList = toPatternList program , randomPattern = randomPattern' } answer = Resource { resourceUrl = url } insertProgram state key repr return $ Right answer Left err -> return $ Left err -- | Run a named pattern from the program identified by the resource -- key. runNamedPattern :: State -> ResourceKey -> NamedPattern -> IO (Either ByteString Resource) runNamedPattern state key NamedPattern {..} = do -- A lot of looking things up ... maybeProgram <- lookupProgram state key case maybeProgram of Just program -> case fromPatternList execPattern $ patternList program of -- Yes, both program and pattern is found. Just pattern -> Right <$> runSelectedPattern state execParams pattern -- Not able to find the requested pattern. Nothing -> return $ Left ("Not found pattern: " `BS.append` encodeUtf8 execPattern) -- Not able to find the requested program. Nothing -> return $ Left ("Not found program key: " `BS.append` encodeUtf8 key) -- | Run a random pattern from the program identified by the resource -- key. runRandomPattern :: State -> ResourceKey -> ExecParams -> IO (Either ByteString Resource) runRandomPattern state key params = do maybeProgram <- lookupProgram state key case maybeProgram of Just program -> do pattern <- randomPattern program Right <$> runSelectedPattern state params pattern Nothing -> return $ Left ("Not found program key: " `BS.append` encodeUtf8 key) -- | Help function to run a selected pattern. Do the core stuff. runSelectedPattern :: State -> ExecParams -> GhostPattern -> IO Resource runSelectedPattern state ExecParams {..} pattern = do localCounter' <- newTVarIO emptyCounter networkConf' <- readTVarIO $ networkConf state key <- genId let networkConf'' = networkConf' { srcIpAddress = srcIp } url = "/pattern/" `T.append` key async_' <- async $ runPattern pattern [localCounter', globalCounter state] networkConf'' (dataChunk state) shallTrace (logger state) insertPattern state key $ PatternRepr { patternUrl = url , ghostPattern = pattern , localCounter = localCounter' , async_ = async_' } return Resource { resourceUrl = url } -- | List all patterns instances. listPatterns :: State -> IO [Resource] listPatterns state = map (Resource . patternUrl) <$> allPatterns state -- | List the global counter. getGlobalCounter :: State -> IO PatternCounter getGlobalCounter state = fromCounter <$> readTVarIO (globalCounter state) -- | List the counter from a selected pattern. getPatternCounter :: State -> ResourceKey -> IO (Maybe PatternCounter) getPatternCounter state key = maybe (return Nothing) fromCounter' =<< lookupPattern state key where fromCounter' :: PatternRepr -> IO (Maybe PatternCounter) fromCounter' p = Just . fromCounter <$> (readTVarIO $ localCounter p) -- | List pattern execution status. patternStatus :: State -> ResourceKey -> IO (Maybe PatternStatus) patternStatus state key = do maybe (return Nothing) patternStatus' =<< lookupPattern state key where patternStatus' :: PatternRepr -> IO (Maybe PatternStatus) patternStatus' PatternRepr {..} = do result <- poll async_ case result of Just status -> case status of Right () -> return $ Just PatternStatus { completed = True , failed = False , failMessage = "" } Left e -> return $ Just PatternStatus { completed = True , failed = True , failMessage = T.pack $ show e } Nothing -> return $ Just PatternStatus { completed = False , failed = False , failMessage = "" } -- | Try find a pattern with a specific name from a list of pattern -- tuples. fromPatternList :: Text -> [PatternTuple] -> Maybe GhostPattern fromPatternList label patterns = maybe Nothing lastInTuple $ find matchingLabel patterns where matchingLabel (label', _, _) = label' == label lastInTuple (_, _, pattern) = Just pattern -- | Convert from the internal counter format fromCounter :: Counter -> PatternCounter fromCounter Counter {..} = PatternCounter { totalTimeS = realToFrac patternExecTime , httpGetTimeS = realToFrac httpGETExecTime , httpGetBytes = httpGETBytes , httpPutTimeS = realToFrac httpPUTExecTime , httpPutBytes = httpPUTBytes }
kosmoskatten/ghost-lang
ghost-node/src/GhostLang/Node/Flow.hs
mit
8,813
0
20
3,122
1,816
977
839
165
3
{-# LANGUAGE CPP #-} module GHCJS.DOM.DataTransfer ( #if (defined(ghcjs_HOST_OS) && defined(USE_JAVASCRIPTFFI)) || !defined(USE_WEBKIT) module GHCJS.DOM.JSFFI.Generated.DataTransfer #else #endif ) where #if (defined(ghcjs_HOST_OS) && defined(USE_JAVASCRIPTFFI)) || !defined(USE_WEBKIT) import GHCJS.DOM.JSFFI.Generated.DataTransfer #else #endif
plow-technologies/ghcjs-dom
src/GHCJS/DOM/DataTransfer.hs
mit
349
0
5
33
33
26
7
4
0
{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, FlexibleInstances, MultiParamTypeClasses #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module Hadoop.Protos.YarnProtos.AMCommandProto (AMCommandProto(..)) where import Prelude ((+), (/), (.)) import qualified Prelude as Prelude' import qualified Data.Typeable as Prelude' import qualified Data.Data as Prelude' import qualified Text.ProtocolBuffers.Header as P' data AMCommandProto = AM_RESYNC | AM_SHUTDOWN deriving (Prelude'.Read, Prelude'.Show, Prelude'.Eq, Prelude'.Ord, Prelude'.Typeable, Prelude'.Data) instance P'.Mergeable AMCommandProto instance Prelude'.Bounded AMCommandProto where minBound = AM_RESYNC maxBound = AM_SHUTDOWN instance P'.Default AMCommandProto where defaultValue = AM_RESYNC toMaybe'Enum :: Prelude'.Int -> P'.Maybe AMCommandProto toMaybe'Enum 1 = Prelude'.Just AM_RESYNC toMaybe'Enum 2 = Prelude'.Just AM_SHUTDOWN toMaybe'Enum _ = Prelude'.Nothing instance Prelude'.Enum AMCommandProto where fromEnum AM_RESYNC = 1 fromEnum AM_SHUTDOWN = 2 toEnum = P'.fromMaybe (Prelude'.error "hprotoc generated code: toEnum failure for type Hadoop.Protos.YarnProtos.AMCommandProto") . toMaybe'Enum succ AM_RESYNC = AM_SHUTDOWN succ _ = Prelude'.error "hprotoc generated code: succ failure for type Hadoop.Protos.YarnProtos.AMCommandProto" pred AM_SHUTDOWN = AM_RESYNC pred _ = Prelude'.error "hprotoc generated code: pred failure for type Hadoop.Protos.YarnProtos.AMCommandProto" instance P'.Wire AMCommandProto where wireSize ft' enum = P'.wireSize ft' (Prelude'.fromEnum enum) wirePut ft' enum = P'.wirePut ft' (Prelude'.fromEnum enum) wireGet 14 = P'.wireGetEnum toMaybe'Enum wireGet ft' = P'.wireGetErr ft' wireGetPacked 14 = P'.wireGetPackedEnum toMaybe'Enum wireGetPacked ft' = P'.wireGetErr ft' instance P'.GPB AMCommandProto instance P'.MessageAPI msg' (msg' -> AMCommandProto) AMCommandProto where getVal m' f' = f' m' instance P'.ReflectEnum AMCommandProto where reflectEnum = [(1, "AM_RESYNC", AM_RESYNC), (2, "AM_SHUTDOWN", AM_SHUTDOWN)] reflectEnumInfo _ = P'.EnumInfo (P'.makePNF (P'.pack ".hadoop.yarn.AMCommandProto") ["Hadoop", "Protos"] ["YarnProtos"] "AMCommandProto") ["Hadoop", "Protos", "YarnProtos", "AMCommandProto.hs"] [(1, "AM_RESYNC"), (2, "AM_SHUTDOWN")] instance P'.TextType AMCommandProto where tellT = P'.tellShow getT = P'.getRead
alexbiehl/hoop
hadoop-protos/src/Hadoop/Protos/YarnProtos/AMCommandProto.hs
mit
2,466
0
11
377
601
327
274
50
1
-- module Day04 (solveDay04) where module Day04 where import Control.Monad (mapM_) import Data.Char (chr, isDigit, ord) import Data.Function (on) import Data.List (group, nub, sort, sortBy) import Data.List.Split (splitOn, wordsBy) isSquareBracket :: Char -> Bool isSquareBracket c = c == '[' || c == ']' break' :: String -> ([String], String) break' s = (takeWhile (not . isDigit . head) ss, last ss) where ss = splitOn "-" s breakDogtag :: String -> (Integer, String) breakDogtag s = (read (head ss) :: Integer, last ss) where ss = wordsBy isSquareBracket s mostFrequent :: String -> String mostFrequent = concat . sortBy (compare `on` (negate . length)) . group . sort processLine :: String -> (String, String, Integer) processLine s = (givenName, checksum, value) where parts = break' s (value, checksum) = breakDogtag . snd $ parts sorted = nub . mostFrequent . concat . fst $ parts givenName = take (length checksum) sorted processLine' :: String -> (String, Integer) processLine' s = (unwords . fst $ parts, value) where parts = break' s (value, _) = breakDogtag . snd $ parts decryptShiftRight :: Integer -> Char -> Char decryptShiftRight _ ' ' = ' ' decryptShiftRight n c = chr (k + ord 'a') where n' = fromIntegral n :: Int k = mod (ord c - ord 'a' + n') (ord 'z' - ord 'a' + 1) decryptName :: (String, Integer) -> (String, Integer) decryptName (s, v) = (map (decryptShiftRight v) s, v) solveDay04 :: FilePath -> IO () solveDay04 path = do putStrLn "Solution for day four: " ls <- readFile path let ls' = map processLine . lines $ ls print $ foldr (\(s, s', v) x -> if s == s' then x + v else x) 0 ls' let ls'' = map processLine' . lines $ ls let ss = map decryptName ls'' mapM_ print $ filter (\x -> head (fst x) == 'n') ss putStrLn ""
justanotherdot/advent-linguist
2016/Haskell/AdventOfCode/src/Day04.hs
mit
1,928
0
14
502
774
412
362
43
2
{-# htermination minFM :: (Ord a, Ord k) => FiniteMap (Either a k) b -> Maybe (Either a k) #-} import FiniteMap
ComputationWithBoundedResources/ara-inference
doc/tpdb_trs/Haskell/full_haskell/FiniteMap_minFM_10.hs
mit
112
0
3
22
5
3
2
1
0
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeSynonymInstances #-} module Stackage.BuildPlan ( readBuildPlan , writeBuildPlan ) where import qualified Data.Map as Map import qualified Data.Set as Set import Distribution.Text (display, simpleParse) import Stackage.Types import qualified System.IO.UTF8 import Data.Char (isSpace) import Stackage.Util readBuildPlan :: FilePath -> IO BuildPlan readBuildPlan fp = do str <- System.IO.UTF8.readFile fp case fromString str of Left s -> error $ "Could not read build plan: " ++ s Right (x, "") -> return x Right (_, _:_) -> error "Trailing content when reading build plan" writeBuildPlan :: FilePath -> BuildPlan -> IO () writeBuildPlan fp bp = System.IO.UTF8.writeFile fp $ toString bp class AsString a where toString :: a -> String fromString :: String -> Either String (a, String) instance AsString BuildPlan where toString BuildPlan {..} = concat [ makeSection "tools" bpTools , makeSection "packages" $ Map.toList bpPackages , makeSection "core" $ Map.toList bpCore , makeSection "optional-core" $ Map.toList bpOptionalCore , makeSection "skipped-tests" $ Set.toList bpSkippedTests ] fromString s1 = do (tools, s2) <- getSection "tools" s1 (packages, s3) <- getSection "packages" s2 (core, s4) <- getSection "core" s3 (optionalCore, s5) <- getSection "optional-core" s4 (skipped, s6) <- getSection "skipped-tests" s5 let bp = BuildPlan { bpTools = tools , bpPackages = Map.fromList packages , bpCore = Map.fromList core , bpOptionalCore = Map.fromList optionalCore , bpSkippedTests = Set.fromList skipped } return (bp, s6) makeSection :: AsString a => String -> [a] -> String makeSection title contents = unlines $ ("-- BEGIN " ++ title) : map toString contents ++ ["-- END " ++ title, ""] instance AsString String where toString = id fromString s = Right (s, "") instance AsString PackageName where toString (PackageName pn) = pn fromString s = Right (PackageName s, "") instance AsString (Maybe Version) where toString Nothing = "" toString (Just x) = toString x fromString s | all isSpace s = return (Nothing, s) | otherwise = do (v, s') <- fromString s return (Just v, s') instance AsString a => AsString (PackageName, a) where toString (PackageName pn, s) = concat [pn, " ", toString s] fromString s = do (pn, rest) <- takeWord s (rest', s') <- fromString rest return ((PackageName pn, rest'), s') takeWord :: AsString a => String -> Either String (a, String) takeWord s = case break (== ' ') s of (x, _:y) -> do (x', s') <- fromString x if null s' then Right (x', y) else Left $ "Unconsumed input in takeWord call" (_, []) -> Left "takeWord failed" instance AsString SelectedPackageInfo where toString SelectedPackageInfo {..} = unwords [ display spiVersion , toString spiHasTests , (\v -> if null v then "@" else v) $ githubMentions spiGithubUser , unMaintainer spiMaintainer ] fromString s1 = do (version, s2) <- takeWord s1 (hasTests, s3) <- takeWord s2 (gu, m) <- takeWord s3 Right (SelectedPackageInfo { spiVersion = version , spiHasTests = hasTests , spiGithubUser = [gu] , spiMaintainer = Maintainer m }, "") instance AsString (Maybe String) where toString Nothing = "@" toString (Just x) = "@" ++ x fromString "@" = Right (Nothing, "") fromString ('@':rest) = Right (Just rest, "") fromString x = Left $ "Invalid Github user: " ++ x instance AsString Bool where toString True = "test" toString False = "notest" fromString "test" = Right (True, "") fromString "notest" = Right (False, "") fromString x = Left $ "Invalid test value: " ++ x instance AsString Version where toString = display fromString s = case simpleParse s of Nothing -> Left $ "Invalid version: " ++ s Just v -> Right (v, "") getSection :: AsString a => String -> String -> Either String ([a], String) getSection title orig = case lines orig of [] -> Left "Unexpected EOF when looking for a section" l1:ls1 | l1 == begin -> case break (== end) ls1 of (here, _:"":rest) -> do here' <- mapM fromString' here Right (here', unlines rest) (_, _) -> Left $ "Could not find section end: " ++ title | otherwise -> Left $ "Could not find section start: " ++ title where begin = "-- BEGIN " ++ title end = "-- END " ++ title fromString' x = do (y, z) <- fromString x if null z then return y else Left $ "Unconsumed input on line: " ++ x
yogsototh/stackage
Stackage/BuildPlan.hs
mit
5,250
0
16
1,670
1,656
852
804
132
4
module Puppet.Master.Interpreter ( InterpreterWorker , newInterpreterWorker , ask , eval , typeOf ) where import Exception import Control.Monad import GHC import GHC.Paths ( libdir ) import GHCi import GhcMonad import Outputable import Puppet.Master.Worker type InterpreterWorker = Worker Ghc eval :: String -> Ghc String eval e = liftM (either (const "error") (showSDocUnsafe . ppr)) attempt where attempt :: Ghc (Either SomeException [Name]) attempt = gtry $ execStmt e (ExecOptions RunToCompletion "prompr" 0 EvalThis) >>= result result :: ExecResult -> Ghc [Name] result (ExecComplete (Right ns) _) = return ns result _ = return [] typeOf :: String -> Ghc String typeOf e = liftM (either (const "") (showSDocUnsafe . ppr)) attempt where attempt :: Ghc (Either SomeException Type) attempt = gtry $ exprType e initGhc :: Ghc () initGhc = do df <- getSessionDynFlags setSessionDynFlags $ df { hscTarget = HscInterpreted , ghcLink = LinkInMemory } setContext $ map (IIDecl . simpleImportDecl . mkModuleName) [ "Prelude" ] return () newInterpreterWorker :: IO InterpreterWorker newInterpreterWorker = newWorker $ runGhc (Just libdir) . (initGhc >>) >=> const (return ())
jd823592/puppeteer
src/Puppet/Master/Interpreter.hs
mit
1,473
0
11
480
421
221
200
-1
-1
{-# LANGUAGE Haskell2010 , MagicHash , FlexibleInstances , FlexibleContexts , MultiParamTypeClasses , FunctionalDependencies #-} {-# OPTIONS -Wall -fno-warn-missing-signatures -fno-warn-name-shadowing #-} -- | This module contains mostly boiler plate code that is needed -- for method discovery. module Foreign.Java.Types ( -- These are human readable short hands for -- Z, X, C, ... below boolean, char, byte, short, int, long, float, double, string, object, array, void, -- These types are used to describe methods with the -- same vocabulary as the JNI does. -- -- Notable additions: A, X, and Q are not defined in -- the JNI. A and X are used for convenience and -- resemble Arrays and Strings (S is already taken by -- Short, therefor X). Q is special and stands for -- objects in much the same way as L does, but Q will -- carry it's own low level signature (for example -- [Ljava.lang.String; ). Z (Z), C (C), B (B), S (S), I (I), J (J), D (D), F (F), L (L), V (V), A (A), X (X), -- P is used to apply the above descriptors. -- (-->) does the same thing, but is an infix operator. P (P), (-->), MethodDescriptor (..), -- The famous Q. See above. object', Q (Q), constructorSignature, methodSignature, Constructor, Method, Param (..), JArg (jarg) ) where import Data.Int import Data.Word import Foreign.Java.JNI.Types hiding (JArg) import qualified Foreign.Java.JNI.Types as Core import Foreign.Java.Util data Z = Z deriving Show data C = C deriving Show data B = B deriving Show data S = S deriving Show data I = I deriving Show data J = J deriving Show data F = F deriving Show data D = D deriving Show data L = L String deriving Show data V = V deriving Show data A x = A x deriving Show data X = X deriving Show data Q = Q String deriving Show boolean = Z char = C byte = B short = S int = I long = J float = F double = D object = L array = A string = X void = V object' = Q data P a x = P a x deriving Show class Param a where fieldSignature :: a -> String -- These are the translations of descriptors to -- JNI signatures. instance Param Z where fieldSignature _ = "Z" instance Param C where fieldSignature _ = "C" instance Param B where fieldSignature _ = "B" instance Param S where fieldSignature _ = "S" instance Param I where fieldSignature _ = "I" instance Param J where fieldSignature _ = "J" instance Param F where fieldSignature _ = "F" instance Param D where fieldSignature _ = "D" instance Param L where fieldSignature (L x) = 'L' : tr '.' '/' x ++ ";" instance Param X where fieldSignature _ = "Ljava/lang/String;" instance Param x => Param (A x) where fieldSignature (A x) = '[' : fieldSignature x instance Param Q where fieldSignature (Q s) = s class JArg a b | a -> b where jarg :: a -> b -> Core.JArg -- These are the known argument types. instance JArg Z Bool where jarg _ = BooleanA instance JArg C Word16 where jarg _ = CharA instance JArg B Int8 where jarg _ = ByteA instance JArg S Int16 where jarg _ = ShortA instance JArg I Int32 where jarg _ = IntA instance JArg J Int64 where jarg _ = LongA instance JArg F Float where jarg _ = FloatA instance JArg D Double where jarg _ = DoubleA instance JArg L (Maybe JObject) where jarg _ = ObjectA instance JArg (A e) (Maybe (JArray e)) where jarg _ = ArrayA instance JArg X String where jarg _ = StringA instance JArg Q (Maybe JObject) where jarg _ = ObjectA -- (-->), (::=) are infix operators for convenience. infixr 9 --> infixl 8 ::= (-->) :: a -> x -> P a x a --> x = P a x -- A MethodDescriptor is what is given to -- 'getMethod', 'getConstructor', and friends. data MethodDescriptor p = String ::= p deriving Show --------------- -- Constructors -- -- The signatures for looking up constructors are forged here. constructorSignature :: Constructor p => p constructorSignature = _constructorSignature "(" class Constructor p where _constructorSignature :: String -> p instance Constructor String where _constructorSignature _ = "()V" instance (Constructor (t -> r), Param a) => Constructor (P a t -> r) where _constructorSignature sig (P a t) = _constructorSignature (sig ++ fieldSignature a) t instance Constructor (Z -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (C -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (B -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (S -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (I -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (J -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (F -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (D -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (L -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Param a => Constructor (A a -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" instance Constructor (X -> String) where _constructorSignature sig X = sig ++ "Ljava/lang/String;" ++ ")V" instance Constructor (Q -> String) where _constructorSignature sig a = sig ++ fieldSignature a ++ ")V" ---------- -- Methods -- -- The signatures for looking up methods (both static and virtual, -- that distinction has no meaning on this level) are forged here. methodSignature :: Method p => p methodSignature = _methodSignature "(" class Method p where _methodSignature :: String -> p instance (Param a, Method r, Method (P b x -> r)) => Method (P a (P b x) -> r) where _methodSignature sig (P a x) = _methodSignature (sig ++ fieldSignature a) x instance Param a => Method (P a Z -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")Z") instance Param a => Method (P a C -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")C") instance Param a => Method (P a B -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")B") instance Param a => Method (P a S -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")S") instance Param a => Method (P a I -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")I") instance Param a => Method (P a J -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")J") instance Param a => Method (P a F -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")F") instance Param a => Method (P a D -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")D") instance Param a => Method (P a L -> String) where _methodSignature sig (P a t) = _methodSignature (sig ++ fieldSignature a ++ ")" ++ fieldSignature t) instance Param a => Method (P a V -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")V") instance Param a => Method (P a X -> String) where _methodSignature sig (P a _) = _methodSignature (sig ++ fieldSignature a ++ ")Ljava/lang/String;") instance (Param a, Param e) => Method (P a (A e) -> String) where _methodSignature sig (P a t) = _methodSignature (sig ++ fieldSignature a ++ ")" ++ fieldSignature t) instance Param a => Method (P a Q -> String) where _methodSignature sig (P a t) = _methodSignature (sig ++ fieldSignature a ++ ")" ++ fieldSignature t) instance Method (Z -> String) where _methodSignature sig _ = sig ++ ")Z" instance Method (C -> String) where _methodSignature sig _ = sig ++ ")C" instance Method (B -> String) where _methodSignature sig _ = sig ++ ")B" instance Method (S -> String) where _methodSignature sig _ = sig ++ ")S" instance Method (I -> String) where _methodSignature sig _ = sig ++ ")I" instance Method (J -> String) where _methodSignature sig _ = sig ++ ")J" instance Method (F -> String) where _methodSignature sig _ = sig ++ ")F" instance Method (D -> String) where _methodSignature sig _ = sig ++ ")D" instance Method (L -> String) where _methodSignature sig s = sig ++ ")" ++ fieldSignature s instance Method (V -> String) where _methodSignature sig _ = sig ++ ")V" instance Method (X -> String) where _methodSignature sig _ = sig ++ ")Ljava/lang/String;" instance (Param e, Method (e -> String)) => Method (A e -> String) where _methodSignature sig s = sig ++ ")" ++ fieldSignature s instance Method (Q -> String) where _methodSignature sig s = sig ++ ")" ++ fieldSignature s instance Method String where _methodSignature sig = sig
fehu/haskell-java-bridge-fork
src/Foreign/Java/Types.hs
mit
9,256
0
11
2,093
3,056
1,606
1,450
210
1
module Feature.DeleteSpec where import Test.Hspec import Test.Hspec.Wai import Text.Heredoc import SpecHelper import PostgREST.Types (DbStructure(..)) import qualified Hasql.Connection as H import Network.HTTP.Types spec :: DbStructure -> H.Connection -> Spec spec struct c = beforeAll resetDb . around (withApp cfgDefault struct c) $ describe "Deleting" $ do context "existing record" $ do it "succeeds with 204 and deletion count" $ request methodDelete "/items?id=eq.1" [] "" `shouldRespondWith` ResponseMatcher { matchBody = Nothing , matchStatus = 204 , matchHeaders = ["Content-Range" <:> "*/1"] } it "actually clears items ouf the db" $ do _ <- request methodDelete "/items?id=lt.15" [] "" get "/items" `shouldRespondWith` ResponseMatcher { matchBody = Just [str|[{"id":15}]|] , matchStatus = 200 , matchHeaders = ["Content-Range" <:> "0-0/1"] } context "known route, unknown record" $ it "fails with 404" $ request methodDelete "/items?id=eq.101" [] "" `shouldRespondWith` 404 context "totally unknown route" $ it "fails with 404" $ request methodDelete "/foozle?id=eq.101" [] "" `shouldRespondWith` 404
motiz88/postgrest
test/Feature/DeleteSpec.hs
mit
1,312
0
18
351
315
168
147
-1
-1
module Data.HashId ( -- * Core types HashId , HashEncoder , HashOptions , Salt -- * Core functions , defaultOptions , mkEncoder , encode , decode , parse , toText , salt ) where import Data.HashId.Internal
muhbaasu/hash-id
src/Data/HashId.hs
mit
325
0
4
155
49
33
16
14
0
#!runghc import Data.List main = interact (unlines.map unwords.groupBy f.words.filter (/='\0')) where f "0xff" _ = False f _ _ = True
ducis/multitouch-visualizer
linebreaker.hs
gpl-2.0
136
0
9
23
59
31
28
4
2
module Paths_Haskell_Project ( version, getBinDir, getLibDir, getDataDir, getLibexecDir, getDataFileName, getSysconfDir ) where import qualified Control.Exception as Exception import Data.Version (Version(..)) import System.Environment (getEnv) import Prelude catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a catchIO = Exception.catch version :: Version version = Version [0,1,0,0] [] bindir, libdir, datadir, libexecdir, sysconfdir :: FilePath bindir = "/Users/TinyForce/Haskell_Project/.cabal-sandbox/bin" libdir = "/Users/TinyForce/Haskell_Project/.cabal-sandbox/lib/x86_64-osx-ghc-7.10.3/Haskell-Project-0.1.0.0-FEdJfXKgzGWKUsawrUg7bw" datadir = "/Users/TinyForce/Haskell_Project/.cabal-sandbox/share/x86_64-osx-ghc-7.10.3/Haskell-Project-0.1.0.0" libexecdir = "/Users/TinyForce/Haskell_Project/.cabal-sandbox/libexec" sysconfdir = "/Users/TinyForce/Haskell_Project/.cabal-sandbox/etc" getBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath getBinDir = catchIO (getEnv "Haskell_Project_bindir") (\_ -> return bindir) getLibDir = catchIO (getEnv "Haskell_Project_libdir") (\_ -> return libdir) getDataDir = catchIO (getEnv "Haskell_Project_datadir") (\_ -> return datadir) getLibexecDir = catchIO (getEnv "Haskell_Project_libexecdir") (\_ -> return libexecdir) getSysconfDir = catchIO (getEnv "Haskell_Project_sysconfdir") (\_ -> return sysconfdir) getDataFileName :: FilePath -> IO FilePath getDataFileName name = do dir <- getDataDir return (dir ++ "/" ++ name)
MaximusDesign/Haskell_Project
dist/build/autogen/Paths_Haskell_Project.hs
gpl-2.0
1,535
0
10
177
362
206
156
28
1
module FizzBuzz where import Control.Monad (mapM_) fizzbuzz :: (Show a, Integral a) => a -> String fizzbuzz n = if null s then (show n) else s where s = (if (n `mod` 3) == 0 then "Fizz" else "") ++ (if (n `mod` 5) == 0 then "Buzz" else "") main :: IO () main = mapM_ putStrLn $ map fizzbuzz [1..100]
AaronRobson/FizzBuzzHaskell
FizzBuzz.hs
gpl-3.0
309
0
12
72
154
87
67
7
4
module Util where import Data.Acid (Update) import Data.Aeson.Encode.Pretty import Data.IxSet (empty) import Data.Text (pack, unpack, Text) import Data.Text.IO (hPutStr) import qualified Data.Text.IO as TIO import Happstack.Server (toResponse, Response) import System.Directory (removeFile) import System.IO (hClose) import System.IO.Temp (openTempFile) import System.Process import Types -- = API helpers -- | successful API response success :: a -> ApiResponse a success = ApiResponse . Right -- | failed API response failure :: ApiError -> ApiResponse a failure = ApiResponse . Left -- | process anything that can be encoded as JSON to a Response respond :: ToJSON r => r -> Response respond = toResponse . encodePretty' (defConfig { confCompare = compare }) -- | lift a storeage action \"onto\" the 'ApiResponse' monad liftStore :: (a -> Update Morgue b) -> ApiResponse a -> Update Morgue (ApiResponse b) liftStore f a = sequence $ f <$> a -- | initial state of our app initialMorgueState :: Morgue initialMorgueState = Morgue empty empty -- | patch a file using the common UNIX utility patchFile :: File -> Text -> IO File patchFile file patch = do (path, handle) <- openTempFile (unpack . getFName $ fileName file) "" hPutStr handle (fileContents file) hClose handle output <- readProcess "patch" [path] (unpack patch) newFile <- TIO.readFile path removeFile path return file { fileContents = newFile } -- | get all matching files from a list and return an error in case of -- missing files matchFiles :: [File] -> [FileName] -> ApiResponse [FileContent] matchFiles files = foldr go (success []) where files' = map ((,) <$> fileName <*> id) files go f fs = case lookup f files' of Just file -> (fileContents file:) <$> fs Nothing -> failure $ NoSuchFile f -- | get all matching groups from a list and return an error in case of -- missing groups matchGroups :: [InternalGroup] -> [GroupFileList] -> ApiResponse [([File], [FileName])] matchGroups groups = foldr go (success []) where groups' = map ((,) <$> iGroupName <*> id) groups go (GroupFileList g fs) gs = case lookup g groups' of Just gr -> ((iGroupFiles gr, fs):) <$> gs Nothing -> failure NoAccess -- | replace a file by name replaceFile :: [File] -> File -> [File] replaceFile files newFile = foldr go [] files where go f@(File fName _) fs | fName == fileName newFile = newFile : fs | otherwise = f : fs
ibabushkin/morgue-server
src/Util.hs
gpl-3.0
2,663
0
13
689
778
414
364
52
2
module StandOff.DomTypeDefs where import StandOff.LineOffsets import qualified StandOff.TextRange as TR import StandOff.MarkupTree type AttrName = String type AttrVal = String data Attribute = Attribute (AttrName, AttrVal) deriving (Show) data XML = Element { name :: String , attributes :: [Attribute] , startOpenTag :: Position , endOpenTag :: Position , startCloseTag :: Position , endCloseTag :: Position , content :: [XML] } | EmptyElement { name :: String , attributes :: [Attribute] , startTag :: Position , endTag :: Position } | XMLDeclaration { declaration :: [Attribute] , start :: Position , end :: Position } | ProcessingInstruction { name :: String , declaration :: [Attribute] , start :: Position , end :: Position } | TextNode { text :: String , start :: Position , end :: Position } | Comment { text :: String , start :: Position , end :: Position } deriving (Show) myMapTuple :: (a -> b) -> (a, a) -> (b, b) myMapTuple f (a1, a2) = (f a1, f a2) instance TR.TextRange XML where start x = posOffset $ fst $ xmlSpanning x end x = posOffset $ snd $ xmlSpanning x -- Split points have to be corrected. The first part of the split -- should always end right before the open tag and the second part -- of the split should always start right after a tag, but not at -- the position of the tags last char. FIXME: Is this correct for -- all markup types? splitPoints x = ((so-1, eo+1), (sc-1, ec+1)) where (so, eo) = myMapTuple posOffset $ elementOpenTagPosition x (sc, ec) = myMapTuple posOffset $ elementCloseTagPosition x split _ _ = error "Cannot split internal markup" instance MarkupTree XML where getMarkupChildren (Element _ _ _ _ _ _ c) = filter isElementP c getMarkupChildren _ = [] elementName :: XML -> String elementName (Element n _ _ _ _ _ _) = n elementName (EmptyElement n _ _ _) = n elementAttributes :: XML -> [Attribute] elementAttributes (Element _ attrs _ _ _ _ _) = attrs elementAttributes (EmptyElement _ attrs _ _) = attrs xmlSpanning :: XML -> (Position, Position) xmlSpanning (Element _ _ s _ _ e _) = (s, e) xmlSpanning (EmptyElement _ _ s e) = (s, e) xmlSpanning (TextNode _ s e) = (s, e) xmlSpanning (Comment _ s e) = (s, e) xmlSpanning (XMLDeclaration _ s e) = (s, e) xmlSpanning (ProcessingInstruction _ _ s e) = (s, e) elementOpenTagPosition :: XML -> (Position, Position) elementOpenTagPosition (Element _ _ s e _ _ _) = (s, e) elementOpenTagPosition (EmptyElement _ _ s e) = (s, e) elementCloseTagPosition :: XML -> (Position, Position) elementCloseTagPosition (Element _ _ _ _ s e _) = (s, e) elementCloseTagPosition (EmptyElement _ _ s e) = (s, e) elementContent :: XML -> [XML] elementContent (Element _ _ _ _ _ _ c) = c elementContent _ = [] elementWithoutContent :: XML -> XML elementWithoutContent (Element n a so eo sc ec _) = Element n a so eo sc ec [] elementWithoutContent x = x textContent :: XML -> String textContent (TextNode t _ _) = t -- Is the node an XML element? False for white space, text nodes, -- processing instructions, xml declarations, comments etc. isElementP :: XML -> Bool isElementP (Element _ _ _ _ _ _ _) = True isElementP (EmptyElement _ _ _ _) = True isElementP _ = False isXMLDeclarationP :: XML -> Bool isXMLDeclarationP (XMLDeclaration _ _ _) = True isXMLDeclarationP _ = False
lueck/standoff-tools
src/StandOff/DomTypeDefs.hs
gpl-3.0
3,790
0
9
1,115
1,186
658
528
78
1
{-# LANGUAGE Rank2Types, GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} module Helium.Syntax.UHA_Pretty where -- Below two imports are to avoid clashes of "list" as used by the AG system. -- Effectively, only list from the imported library needs to be qualified. import Prelude hiding ((<$>)) import Text.PrettyPrint.Leijen hiding (list) import qualified Text.PrettyPrint.Leijen as PPrint import Data.Char import Top.Types (isTupleConstructor) import Helium.Syntax.UHA_Syntax import Helium.Utils.Utils (internalError, hole) import Control.Monad.Identity (Identity) import qualified Control.Monad.Identity intErr :: String -> String -> a intErr = internalError "UHA_Pretty" opt :: Maybe Doc -> Doc opt = maybe empty id parensIf, backQuotesIf :: Bool -> Doc -> Doc parensIf p n = if p then parens n else n backQuotesIf p n = if p then text "`" <> n <> text "`" else n parensIfList :: [Bool] -> [Doc] -> [Doc] parensIfList ps ns = map (uncurry parensIf) (zip ps ns) tupled1 :: [Doc] -> Doc tupled1 [] = empty tupled1 xs = tupled xs tupled2 :: [Doc] -> Doc tupled2 [] = empty tupled2 xs = tupledUnit xs tupledUnit :: [Doc] -> Doc tupledUnit [x] = x tupledUnit xs = tupled xs commas :: [Doc] -> Doc commas docs = hcat (punctuate (comma <+> empty) docs) -- Shortcut for printing possibly empty contexts: contextPP :: [Doc] -> Doc contextPP [] = empty contextPP [c] = c <+> text "=>" <+> empty contextPP cs = tupled cs <+> text "=>" <+> empty utrechtList :: Doc -> Doc -> [Doc] -> Doc utrechtList _ _ [] = empty utrechtList start end (d:ds) = let utrechtList' [] = end utrechtList' (doc:docs) = comma <+> doc <$> utrechtList' docs in start <+> d <$> utrechtList' ds -- Alternative ------------------------------------------------- -- wrapper data Inh_Alternative = Inh_Alternative { } data Syn_Alternative = Syn_Alternative { text_Syn_Alternative :: (Doc) } {-# INLINABLE wrap_Alternative #-} wrap_Alternative :: T_Alternative -> Inh_Alternative -> (Syn_Alternative ) wrap_Alternative (T_Alternative act) (Inh_Alternative ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg1 = T_Alternative_vIn1 (T_Alternative_vOut1 _lhsOtext) <- return (inv_Alternative_s2 sem arg1) return (Syn_Alternative _lhsOtext) ) -- cata {-# NOINLINE sem_Alternative #-} sem_Alternative :: Alternative -> T_Alternative sem_Alternative ( Alternative_Hole range_ id_ ) = sem_Alternative_Hole ( sem_Range range_ ) id_ sem_Alternative ( Alternative_Feedback range_ feedback_ alternative_ ) = sem_Alternative_Feedback ( sem_Range range_ ) feedback_ ( sem_Alternative alternative_ ) sem_Alternative ( Alternative_Alternative range_ pattern_ righthandside_ ) = sem_Alternative_Alternative ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_RightHandSide righthandside_ ) sem_Alternative ( Alternative_Empty range_ ) = sem_Alternative_Empty ( sem_Range range_ ) -- semantic domain newtype T_Alternative = T_Alternative { attach_T_Alternative :: Identity (T_Alternative_s2 ) } newtype T_Alternative_s2 = C_Alternative_s2 { inv_Alternative_s2 :: (T_Alternative_v1 ) } data T_Alternative_s3 = C_Alternative_s3 type T_Alternative_v1 = (T_Alternative_vIn1 ) -> (T_Alternative_vOut1 ) data T_Alternative_vIn1 = T_Alternative_vIn1 data T_Alternative_vOut1 = T_Alternative_vOut1 (Doc) {-# NOINLINE sem_Alternative_Hole #-} sem_Alternative_Hole :: T_Range -> (Integer) -> T_Alternative sem_Alternative_Hole arg_range_ _ = T_Alternative (return st2) where {-# NOINLINE st2 #-} st2 = let v1 :: T_Alternative_v1 v1 = \ (T_Alternative_vIn1 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule0 () _lhsOtext :: Doc _lhsOtext = rule1 _text __result_ = T_Alternative_vOut1 _lhsOtext in __result_ ) in C_Alternative_s2 v1 {-# INLINE rule0 #-} rule0 = \ (_ :: ()) -> text hole {-# INLINE rule1 #-} rule1 = \ _text -> _text {-# NOINLINE sem_Alternative_Feedback #-} sem_Alternative_Feedback :: T_Range -> (String) -> T_Alternative -> T_Alternative sem_Alternative_Feedback arg_range_ _ arg_alternative_ = T_Alternative (return st2) where {-# NOINLINE st2 #-} st2 = let v1 :: T_Alternative_v1 v1 = \ (T_Alternative_vIn1 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _alternativeX2 = Control.Monad.Identity.runIdentity (attach_T_Alternative (arg_alternative_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Alternative_vOut1 _alternativeItext) = inv_Alternative_s2 _alternativeX2 (T_Alternative_vIn1 ) _lhsOtext :: Doc _lhsOtext = rule2 _alternativeItext __result_ = T_Alternative_vOut1 _lhsOtext in __result_ ) in C_Alternative_s2 v1 {-# INLINE rule2 #-} rule2 = \ ((_alternativeItext) :: Doc) -> _alternativeItext {-# NOINLINE sem_Alternative_Alternative #-} sem_Alternative_Alternative :: T_Range -> T_Pattern -> T_RightHandSide -> T_Alternative sem_Alternative_Alternative arg_range_ arg_pattern_ arg_righthandside_ = T_Alternative (return st2) where {-# NOINLINE st2 #-} st2 = let v1 :: T_Alternative_v1 v1 = \ (T_Alternative_vIn1 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) _righthandsideX149 = Control.Monad.Identity.runIdentity (attach_T_RightHandSide (arg_righthandside_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) (T_RightHandSide_vOut148 _righthandsideItext) = inv_RightHandSide_s149 _righthandsideX149 (T_RightHandSide_vIn148 ) _text = rule3 _patternItext _righthandsideItext _lhsOtext :: Doc _lhsOtext = rule4 _text __result_ = T_Alternative_vOut1 _lhsOtext in __result_ ) in C_Alternative_s2 v1 {-# INLINE rule3 #-} rule3 = \ ((_patternItext) :: Doc) ((_righthandsideItext) :: Doc -> Doc ) -> _patternItext <$> indent 2 (_righthandsideItext (text "->")) {-# INLINE rule4 #-} rule4 = \ _text -> _text {-# NOINLINE sem_Alternative_Empty #-} sem_Alternative_Empty :: T_Range -> T_Alternative sem_Alternative_Empty arg_range_ = T_Alternative (return st2) where {-# NOINLINE st2 #-} st2 = let v1 :: T_Alternative_v1 v1 = \ (T_Alternative_vIn1 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule5 () _lhsOtext :: Doc _lhsOtext = rule6 _text __result_ = T_Alternative_vOut1 _lhsOtext in __result_ ) in C_Alternative_s2 v1 {-# INLINE rule5 #-} rule5 = \ (_ :: ()) -> empty {-# INLINE rule6 #-} rule6 = \ _text -> _text -- Alternatives ------------------------------------------------ -- wrapper data Inh_Alternatives = Inh_Alternatives { } data Syn_Alternatives = Syn_Alternatives { text_Syn_Alternatives :: ( [ Doc ] ) } {-# INLINABLE wrap_Alternatives #-} wrap_Alternatives :: T_Alternatives -> Inh_Alternatives -> (Syn_Alternatives ) wrap_Alternatives (T_Alternatives act) (Inh_Alternatives ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg4 = T_Alternatives_vIn4 (T_Alternatives_vOut4 _lhsOtext) <- return (inv_Alternatives_s5 sem arg4) return (Syn_Alternatives _lhsOtext) ) -- cata {-# NOINLINE sem_Alternatives #-} sem_Alternatives :: Alternatives -> T_Alternatives sem_Alternatives list = Prelude.foldr sem_Alternatives_Cons sem_Alternatives_Nil (Prelude.map sem_Alternative list) -- semantic domain newtype T_Alternatives = T_Alternatives { attach_T_Alternatives :: Identity (T_Alternatives_s5 ) } newtype T_Alternatives_s5 = C_Alternatives_s5 { inv_Alternatives_s5 :: (T_Alternatives_v4 ) } data T_Alternatives_s6 = C_Alternatives_s6 type T_Alternatives_v4 = (T_Alternatives_vIn4 ) -> (T_Alternatives_vOut4 ) data T_Alternatives_vIn4 = T_Alternatives_vIn4 data T_Alternatives_vOut4 = T_Alternatives_vOut4 ( [ Doc ] ) {-# NOINLINE sem_Alternatives_Cons #-} sem_Alternatives_Cons :: T_Alternative -> T_Alternatives -> T_Alternatives sem_Alternatives_Cons arg_hd_ arg_tl_ = T_Alternatives (return st5) where {-# NOINLINE st5 #-} st5 = let v4 :: T_Alternatives_v4 v4 = \ (T_Alternatives_vIn4 ) -> ( let _hdX2 = Control.Monad.Identity.runIdentity (attach_T_Alternative (arg_hd_)) _tlX5 = Control.Monad.Identity.runIdentity (attach_T_Alternatives (arg_tl_)) (T_Alternative_vOut1 _hdItext) = inv_Alternative_s2 _hdX2 (T_Alternative_vIn1 ) (T_Alternatives_vOut4 _tlItext) = inv_Alternatives_s5 _tlX5 (T_Alternatives_vIn4 ) _lhsOtext :: [ Doc ] _lhsOtext = rule7 _hdItext _tlItext __result_ = T_Alternatives_vOut4 _lhsOtext in __result_ ) in C_Alternatives_s5 v4 {-# INLINE rule7 #-} rule7 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Alternatives_Nil #-} sem_Alternatives_Nil :: T_Alternatives sem_Alternatives_Nil = T_Alternatives (return st5) where {-# NOINLINE st5 #-} st5 = let v4 :: T_Alternatives_v4 v4 = \ (T_Alternatives_vIn4 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule8 () __result_ = T_Alternatives_vOut4 _lhsOtext in __result_ ) in C_Alternatives_s5 v4 {-# INLINE rule8 #-} rule8 = \ (_ :: ()) -> [] -- AnnotatedType ----------------------------------------------- -- wrapper data Inh_AnnotatedType = Inh_AnnotatedType { } data Syn_AnnotatedType = Syn_AnnotatedType { text_Syn_AnnotatedType :: (Doc) } {-# INLINABLE wrap_AnnotatedType #-} wrap_AnnotatedType :: T_AnnotatedType -> Inh_AnnotatedType -> (Syn_AnnotatedType ) wrap_AnnotatedType (T_AnnotatedType act) (Inh_AnnotatedType ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg7 = T_AnnotatedType_vIn7 (T_AnnotatedType_vOut7 _lhsOtext) <- return (inv_AnnotatedType_s8 sem arg7) return (Syn_AnnotatedType _lhsOtext) ) -- cata {-# INLINE sem_AnnotatedType #-} sem_AnnotatedType :: AnnotatedType -> T_AnnotatedType sem_AnnotatedType ( AnnotatedType_AnnotatedType range_ strict_ type_ ) = sem_AnnotatedType_AnnotatedType ( sem_Range range_ ) strict_ ( sem_Type type_ ) -- semantic domain newtype T_AnnotatedType = T_AnnotatedType { attach_T_AnnotatedType :: Identity (T_AnnotatedType_s8 ) } newtype T_AnnotatedType_s8 = C_AnnotatedType_s8 { inv_AnnotatedType_s8 :: (T_AnnotatedType_v7 ) } data T_AnnotatedType_s9 = C_AnnotatedType_s9 type T_AnnotatedType_v7 = (T_AnnotatedType_vIn7 ) -> (T_AnnotatedType_vOut7 ) data T_AnnotatedType_vIn7 = T_AnnotatedType_vIn7 data T_AnnotatedType_vOut7 = T_AnnotatedType_vOut7 (Doc) {-# NOINLINE sem_AnnotatedType_AnnotatedType #-} sem_AnnotatedType_AnnotatedType :: T_Range -> (Bool) -> T_Type -> T_AnnotatedType sem_AnnotatedType_AnnotatedType arg_range_ arg_strict_ arg_type_ = T_AnnotatedType (return st8) where {-# NOINLINE st8 #-} st8 = let v7 :: T_AnnotatedType_v7 v7 = \ (T_AnnotatedType_vIn7 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule9 _typeItext arg_strict_ _lhsOtext :: Doc _lhsOtext = rule10 _text __result_ = T_AnnotatedType_vOut7 _lhsOtext in __result_ ) in C_AnnotatedType_s8 v7 {-# INLINE rule9 #-} rule9 = \ ((_typeItext) :: Doc) strict_ -> (if strict_ then (text "!" <+>) else id) _typeItext {-# INLINE rule10 #-} rule10 = \ _text -> _text -- AnnotatedTypes ---------------------------------------------- -- wrapper data Inh_AnnotatedTypes = Inh_AnnotatedTypes { } data Syn_AnnotatedTypes = Syn_AnnotatedTypes { text_Syn_AnnotatedTypes :: ( [ Doc ] ) } {-# INLINABLE wrap_AnnotatedTypes #-} wrap_AnnotatedTypes :: T_AnnotatedTypes -> Inh_AnnotatedTypes -> (Syn_AnnotatedTypes ) wrap_AnnotatedTypes (T_AnnotatedTypes act) (Inh_AnnotatedTypes ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg10 = T_AnnotatedTypes_vIn10 (T_AnnotatedTypes_vOut10 _lhsOtext) <- return (inv_AnnotatedTypes_s11 sem arg10) return (Syn_AnnotatedTypes _lhsOtext) ) -- cata {-# NOINLINE sem_AnnotatedTypes #-} sem_AnnotatedTypes :: AnnotatedTypes -> T_AnnotatedTypes sem_AnnotatedTypes list = Prelude.foldr sem_AnnotatedTypes_Cons sem_AnnotatedTypes_Nil (Prelude.map sem_AnnotatedType list) -- semantic domain newtype T_AnnotatedTypes = T_AnnotatedTypes { attach_T_AnnotatedTypes :: Identity (T_AnnotatedTypes_s11 ) } newtype T_AnnotatedTypes_s11 = C_AnnotatedTypes_s11 { inv_AnnotatedTypes_s11 :: (T_AnnotatedTypes_v10 ) } data T_AnnotatedTypes_s12 = C_AnnotatedTypes_s12 type T_AnnotatedTypes_v10 = (T_AnnotatedTypes_vIn10 ) -> (T_AnnotatedTypes_vOut10 ) data T_AnnotatedTypes_vIn10 = T_AnnotatedTypes_vIn10 data T_AnnotatedTypes_vOut10 = T_AnnotatedTypes_vOut10 ( [ Doc ] ) {-# NOINLINE sem_AnnotatedTypes_Cons #-} sem_AnnotatedTypes_Cons :: T_AnnotatedType -> T_AnnotatedTypes -> T_AnnotatedTypes sem_AnnotatedTypes_Cons arg_hd_ arg_tl_ = T_AnnotatedTypes (return st11) where {-# NOINLINE st11 #-} st11 = let v10 :: T_AnnotatedTypes_v10 v10 = \ (T_AnnotatedTypes_vIn10 ) -> ( let _hdX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_hd_)) _tlX11 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedTypes (arg_tl_)) (T_AnnotatedType_vOut7 _hdItext) = inv_AnnotatedType_s8 _hdX8 (T_AnnotatedType_vIn7 ) (T_AnnotatedTypes_vOut10 _tlItext) = inv_AnnotatedTypes_s11 _tlX11 (T_AnnotatedTypes_vIn10 ) _lhsOtext :: [ Doc ] _lhsOtext = rule11 _hdItext _tlItext __result_ = T_AnnotatedTypes_vOut10 _lhsOtext in __result_ ) in C_AnnotatedTypes_s11 v10 {-# INLINE rule11 #-} rule11 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_AnnotatedTypes_Nil #-} sem_AnnotatedTypes_Nil :: T_AnnotatedTypes sem_AnnotatedTypes_Nil = T_AnnotatedTypes (return st11) where {-# NOINLINE st11 #-} st11 = let v10 :: T_AnnotatedTypes_v10 v10 = \ (T_AnnotatedTypes_vIn10 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule12 () __result_ = T_AnnotatedTypes_vOut10 _lhsOtext in __result_ ) in C_AnnotatedTypes_s11 v10 {-# INLINE rule12 #-} rule12 = \ (_ :: ()) -> [] -- Body -------------------------------------------------------- -- wrapper data Inh_Body = Inh_Body { } data Syn_Body = Syn_Body { text_Syn_Body :: (Doc) } {-# INLINABLE wrap_Body #-} wrap_Body :: T_Body -> Inh_Body -> (Syn_Body ) wrap_Body (T_Body act) (Inh_Body ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg13 = T_Body_vIn13 (T_Body_vOut13 _lhsOtext) <- return (inv_Body_s14 sem arg13) return (Syn_Body _lhsOtext) ) -- cata {-# NOINLINE sem_Body #-} sem_Body :: Body -> T_Body sem_Body ( Body_Hole range_ id_ ) = sem_Body_Hole ( sem_Range range_ ) id_ sem_Body ( Body_Body range_ importdeclarations_ declarations_ ) = sem_Body_Body ( sem_Range range_ ) ( sem_ImportDeclarations importdeclarations_ ) ( sem_Declarations declarations_ ) -- semantic domain newtype T_Body = T_Body { attach_T_Body :: Identity (T_Body_s14 ) } newtype T_Body_s14 = C_Body_s14 { inv_Body_s14 :: (T_Body_v13 ) } data T_Body_s15 = C_Body_s15 type T_Body_v13 = (T_Body_vIn13 ) -> (T_Body_vOut13 ) data T_Body_vIn13 = T_Body_vIn13 data T_Body_vOut13 = T_Body_vOut13 (Doc) {-# NOINLINE sem_Body_Hole #-} sem_Body_Hole :: T_Range -> (Integer) -> T_Body sem_Body_Hole arg_range_ _ = T_Body (return st14) where {-# NOINLINE st14 #-} st14 = let v13 :: T_Body_v13 v13 = \ (T_Body_vIn13 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule13 () _lhsOtext :: Doc _lhsOtext = rule14 _text __result_ = T_Body_vOut13 _lhsOtext in __result_ ) in C_Body_s14 v13 {-# INLINE rule13 #-} rule13 = \ (_ :: ()) -> text hole {-# INLINE rule14 #-} rule14 = \ _text -> _text {-# NOINLINE sem_Body_Body #-} sem_Body_Body :: T_Range -> T_ImportDeclarations -> T_Declarations -> T_Body sem_Body_Body arg_range_ arg_importdeclarations_ arg_declarations_ = T_Body (return st14) where {-# NOINLINE st14 #-} st14 = let v13 :: T_Body_v13 v13 = \ (T_Body_vIn13 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _importdeclarationsX74 = Control.Monad.Identity.runIdentity (attach_T_ImportDeclarations (arg_importdeclarations_)) _declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_ImportDeclarations_vOut73 _importdeclarationsItext) = inv_ImportDeclarations_s74 _importdeclarationsX74 (T_ImportDeclarations_vIn73 ) (T_Declarations_vOut31 _declarationsItext) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 ) _text = rule15 _declarationsItext _importdeclarationsItext _lhsOtext :: Doc _lhsOtext = rule16 _text __result_ = T_Body_vOut13 _lhsOtext in __result_ ) in C_Body_s14 v13 {-# INLINE rule15 #-} rule15 = \ ((_declarationsItext) :: [ Doc ] ) ((_importdeclarationsItext) :: [ Doc ] ) -> vcat ( _importdeclarationsItext ++ _declarationsItext ) {-# INLINE rule16 #-} rule16 = \ _text -> _text -- Constructor ------------------------------------------------- -- wrapper data Inh_Constructor = Inh_Constructor { } data Syn_Constructor = Syn_Constructor { text_Syn_Constructor :: (Doc) } {-# INLINABLE wrap_Constructor #-} wrap_Constructor :: T_Constructor -> Inh_Constructor -> (Syn_Constructor ) wrap_Constructor (T_Constructor act) (Inh_Constructor ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg16 = T_Constructor_vIn16 (T_Constructor_vOut16 _lhsOtext) <- return (inv_Constructor_s17 sem arg16) return (Syn_Constructor _lhsOtext) ) -- cata {-# NOINLINE sem_Constructor #-} sem_Constructor :: Constructor -> T_Constructor sem_Constructor ( Constructor_Constructor range_ constructor_ types_ ) = sem_Constructor_Constructor ( sem_Range range_ ) ( sem_Name constructor_ ) ( sem_AnnotatedTypes types_ ) sem_Constructor ( Constructor_Infix range_ leftType_ constructorOperator_ rightType_ ) = sem_Constructor_Infix ( sem_Range range_ ) ( sem_AnnotatedType leftType_ ) ( sem_Name constructorOperator_ ) ( sem_AnnotatedType rightType_ ) sem_Constructor ( Constructor_Record range_ constructor_ fieldDeclarations_ ) = sem_Constructor_Record ( sem_Range range_ ) ( sem_Name constructor_ ) ( sem_FieldDeclarations fieldDeclarations_ ) -- semantic domain newtype T_Constructor = T_Constructor { attach_T_Constructor :: Identity (T_Constructor_s17 ) } newtype T_Constructor_s17 = C_Constructor_s17 { inv_Constructor_s17 :: (T_Constructor_v16 ) } data T_Constructor_s18 = C_Constructor_s18 type T_Constructor_v16 = (T_Constructor_vIn16 ) -> (T_Constructor_vOut16 ) data T_Constructor_vIn16 = T_Constructor_vIn16 data T_Constructor_vOut16 = T_Constructor_vOut16 (Doc) {-# NOINLINE sem_Constructor_Constructor #-} sem_Constructor_Constructor :: T_Range -> T_Name -> T_AnnotatedTypes -> T_Constructor sem_Constructor_Constructor arg_range_ arg_constructor_ arg_types_ = T_Constructor (return st17) where {-# NOINLINE st17 #-} st17 = let v16 :: T_Constructor_v16 v16 = \ (T_Constructor_vIn16 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _constructorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructor_)) _typesX11 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedTypes (arg_types_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _constructorIisIdentifier _constructorIisOperator _constructorIisSpecial _constructorItext) = inv_Name_s113 _constructorX113 (T_Name_vIn112 ) (T_AnnotatedTypes_vOut10 _typesItext) = inv_AnnotatedTypes_s11 _typesX11 (T_AnnotatedTypes_vIn10 ) _text = rule17 _constructorIisOperator _constructorItext _typesItext _lhsOtext :: Doc _lhsOtext = rule18 _text __result_ = T_Constructor_vOut16 _lhsOtext in __result_ ) in C_Constructor_s17 v16 {-# INLINE rule17 #-} rule17 = \ ((_constructorIisOperator) :: Bool) ((_constructorItext) :: Doc) ((_typesItext) :: [ Doc ] ) -> foldl (<+>) (parensIf _constructorIisOperator _constructorItext) _typesItext {-# INLINE rule18 #-} rule18 = \ _text -> _text {-# NOINLINE sem_Constructor_Infix #-} sem_Constructor_Infix :: T_Range -> T_AnnotatedType -> T_Name -> T_AnnotatedType -> T_Constructor sem_Constructor_Infix arg_range_ arg_leftType_ arg_constructorOperator_ arg_rightType_ = T_Constructor (return st17) where {-# NOINLINE st17 #-} st17 = let v16 :: T_Constructor_v16 v16 = \ (T_Constructor_vIn16 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _leftTypeX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_leftType_)) _constructorOperatorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructorOperator_)) _rightTypeX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_rightType_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_AnnotatedType_vOut7 _leftTypeItext) = inv_AnnotatedType_s8 _leftTypeX8 (T_AnnotatedType_vIn7 ) (T_Name_vOut112 _constructorOperatorIisIdentifier _constructorOperatorIisOperator _constructorOperatorIisSpecial _constructorOperatorItext) = inv_Name_s113 _constructorOperatorX113 (T_Name_vIn112 ) (T_AnnotatedType_vOut7 _rightTypeItext) = inv_AnnotatedType_s8 _rightTypeX8 (T_AnnotatedType_vIn7 ) _text = rule19 _constructorOperatorItext _leftTypeItext _rightTypeItext _lhsOtext :: Doc _lhsOtext = rule20 _text __result_ = T_Constructor_vOut16 _lhsOtext in __result_ ) in C_Constructor_s17 v16 {-# INLINE rule19 #-} rule19 = \ ((_constructorOperatorItext) :: Doc) ((_leftTypeItext) :: Doc) ((_rightTypeItext) :: Doc) -> _leftTypeItext <+> _constructorOperatorItext <+> _rightTypeItext {-# INLINE rule20 #-} rule20 = \ _text -> _text {-# NOINLINE sem_Constructor_Record #-} sem_Constructor_Record :: T_Range -> T_Name -> T_FieldDeclarations -> T_Constructor sem_Constructor_Record arg_range_ arg_constructor_ arg_fieldDeclarations_ = T_Constructor (return st17) where {-# NOINLINE st17 #-} st17 = let v16 :: T_Constructor_v16 v16 = \ (T_Constructor_vIn16 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _constructorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructor_)) _fieldDeclarationsX50 = Control.Monad.Identity.runIdentity (attach_T_FieldDeclarations (arg_fieldDeclarations_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _constructorIisIdentifier _constructorIisOperator _constructorIisSpecial _constructorItext) = inv_Name_s113 _constructorX113 (T_Name_vIn112 ) (T_FieldDeclarations_vOut49 _fieldDeclarationsItext) = inv_FieldDeclarations_s50 _fieldDeclarationsX50 (T_FieldDeclarations_vIn49 ) _text = rule21 () _lhsOtext :: Doc _lhsOtext = rule22 _text __result_ = T_Constructor_vOut16 _lhsOtext in __result_ ) in C_Constructor_s17 v16 {-# INLINE rule21 #-} rule21 = \ (_ :: ()) -> text "{- !!! record constructor -}" {-# INLINE rule22 #-} rule22 = \ _text -> _text -- Constructors ------------------------------------------------ -- wrapper data Inh_Constructors = Inh_Constructors { } data Syn_Constructors = Syn_Constructors { text_Syn_Constructors :: ( [ Doc ] ) } {-# INLINABLE wrap_Constructors #-} wrap_Constructors :: T_Constructors -> Inh_Constructors -> (Syn_Constructors ) wrap_Constructors (T_Constructors act) (Inh_Constructors ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg19 = T_Constructors_vIn19 (T_Constructors_vOut19 _lhsOtext) <- return (inv_Constructors_s20 sem arg19) return (Syn_Constructors _lhsOtext) ) -- cata {-# NOINLINE sem_Constructors #-} sem_Constructors :: Constructors -> T_Constructors sem_Constructors list = Prelude.foldr sem_Constructors_Cons sem_Constructors_Nil (Prelude.map sem_Constructor list) -- semantic domain newtype T_Constructors = T_Constructors { attach_T_Constructors :: Identity (T_Constructors_s20 ) } newtype T_Constructors_s20 = C_Constructors_s20 { inv_Constructors_s20 :: (T_Constructors_v19 ) } data T_Constructors_s21 = C_Constructors_s21 type T_Constructors_v19 = (T_Constructors_vIn19 ) -> (T_Constructors_vOut19 ) data T_Constructors_vIn19 = T_Constructors_vIn19 data T_Constructors_vOut19 = T_Constructors_vOut19 ( [ Doc ] ) {-# NOINLINE sem_Constructors_Cons #-} sem_Constructors_Cons :: T_Constructor -> T_Constructors -> T_Constructors sem_Constructors_Cons arg_hd_ arg_tl_ = T_Constructors (return st20) where {-# NOINLINE st20 #-} st20 = let v19 :: T_Constructors_v19 v19 = \ (T_Constructors_vIn19 ) -> ( let _hdX17 = Control.Monad.Identity.runIdentity (attach_T_Constructor (arg_hd_)) _tlX20 = Control.Monad.Identity.runIdentity (attach_T_Constructors (arg_tl_)) (T_Constructor_vOut16 _hdItext) = inv_Constructor_s17 _hdX17 (T_Constructor_vIn16 ) (T_Constructors_vOut19 _tlItext) = inv_Constructors_s20 _tlX20 (T_Constructors_vIn19 ) _lhsOtext :: [ Doc ] _lhsOtext = rule23 _hdItext _tlItext __result_ = T_Constructors_vOut19 _lhsOtext in __result_ ) in C_Constructors_s20 v19 {-# INLINE rule23 #-} rule23 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Constructors_Nil #-} sem_Constructors_Nil :: T_Constructors sem_Constructors_Nil = T_Constructors (return st20) where {-# NOINLINE st20 #-} st20 = let v19 :: T_Constructors_v19 v19 = \ (T_Constructors_vIn19 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule24 () __result_ = T_Constructors_vOut19 _lhsOtext in __result_ ) in C_Constructors_s20 v19 {-# INLINE rule24 #-} rule24 = \ (_ :: ()) -> [] -- ContextItem ------------------------------------------------- -- wrapper data Inh_ContextItem = Inh_ContextItem { } data Syn_ContextItem = Syn_ContextItem { text_Syn_ContextItem :: (Doc) } {-# INLINABLE wrap_ContextItem #-} wrap_ContextItem :: T_ContextItem -> Inh_ContextItem -> (Syn_ContextItem ) wrap_ContextItem (T_ContextItem act) (Inh_ContextItem ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg22 = T_ContextItem_vIn22 (T_ContextItem_vOut22 _lhsOtext) <- return (inv_ContextItem_s23 sem arg22) return (Syn_ContextItem _lhsOtext) ) -- cata {-# NOINLINE sem_ContextItem #-} sem_ContextItem :: ContextItem -> T_ContextItem sem_ContextItem ( ContextItem_ContextItem range_ name_ types_ ) = sem_ContextItem_ContextItem ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Types types_ ) -- semantic domain newtype T_ContextItem = T_ContextItem { attach_T_ContextItem :: Identity (T_ContextItem_s23 ) } newtype T_ContextItem_s23 = C_ContextItem_s23 { inv_ContextItem_s23 :: (T_ContextItem_v22 ) } data T_ContextItem_s24 = C_ContextItem_s24 type T_ContextItem_v22 = (T_ContextItem_vIn22 ) -> (T_ContextItem_vOut22 ) data T_ContextItem_vIn22 = T_ContextItem_vIn22 data T_ContextItem_vOut22 = T_ContextItem_vOut22 (Doc) {-# NOINLINE sem_ContextItem_ContextItem #-} sem_ContextItem_ContextItem :: T_Range -> T_Name -> T_Types -> T_ContextItem sem_ContextItem_ContextItem arg_range_ arg_name_ arg_types_ = T_ContextItem (return st23) where {-# NOINLINE st23 #-} st23 = let v22 :: T_ContextItem_v22 v22 = \ (T_ContextItem_vIn22 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _typesX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_types_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Types_vOut166 _typesItext) = inv_Types_s167 _typesX167 (T_Types_vIn166 ) _text = rule25 _nameItext _typesItext _lhsOtext :: Doc _lhsOtext = rule26 _text __result_ = T_ContextItem_vOut22 _lhsOtext in __result_ ) in C_ContextItem_s23 v22 {-# INLINE rule25 #-} rule25 = \ ((_nameItext) :: Doc) ((_typesItext) :: [ Doc ] ) -> _nameItext <+> head _typesItext {-# INLINE rule26 #-} rule26 = \ _text -> _text -- ContextItems ------------------------------------------------ -- wrapper data Inh_ContextItems = Inh_ContextItems { } data Syn_ContextItems = Syn_ContextItems { text_Syn_ContextItems :: ( [ Doc ] ) } {-# INLINABLE wrap_ContextItems #-} wrap_ContextItems :: T_ContextItems -> Inh_ContextItems -> (Syn_ContextItems ) wrap_ContextItems (T_ContextItems act) (Inh_ContextItems ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg25 = T_ContextItems_vIn25 (T_ContextItems_vOut25 _lhsOtext) <- return (inv_ContextItems_s26 sem arg25) return (Syn_ContextItems _lhsOtext) ) -- cata {-# NOINLINE sem_ContextItems #-} sem_ContextItems :: ContextItems -> T_ContextItems sem_ContextItems list = Prelude.foldr sem_ContextItems_Cons sem_ContextItems_Nil (Prelude.map sem_ContextItem list) -- semantic domain newtype T_ContextItems = T_ContextItems { attach_T_ContextItems :: Identity (T_ContextItems_s26 ) } newtype T_ContextItems_s26 = C_ContextItems_s26 { inv_ContextItems_s26 :: (T_ContextItems_v25 ) } data T_ContextItems_s27 = C_ContextItems_s27 type T_ContextItems_v25 = (T_ContextItems_vIn25 ) -> (T_ContextItems_vOut25 ) data T_ContextItems_vIn25 = T_ContextItems_vIn25 data T_ContextItems_vOut25 = T_ContextItems_vOut25 ( [ Doc ] ) {-# NOINLINE sem_ContextItems_Cons #-} sem_ContextItems_Cons :: T_ContextItem -> T_ContextItems -> T_ContextItems sem_ContextItems_Cons arg_hd_ arg_tl_ = T_ContextItems (return st26) where {-# NOINLINE st26 #-} st26 = let v25 :: T_ContextItems_v25 v25 = \ (T_ContextItems_vIn25 ) -> ( let _hdX23 = Control.Monad.Identity.runIdentity (attach_T_ContextItem (arg_hd_)) _tlX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_tl_)) (T_ContextItem_vOut22 _hdItext) = inv_ContextItem_s23 _hdX23 (T_ContextItem_vIn22 ) (T_ContextItems_vOut25 _tlItext) = inv_ContextItems_s26 _tlX26 (T_ContextItems_vIn25 ) _lhsOtext :: [ Doc ] _lhsOtext = rule27 _hdItext _tlItext __result_ = T_ContextItems_vOut25 _lhsOtext in __result_ ) in C_ContextItems_s26 v25 {-# INLINE rule27 #-} rule27 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_ContextItems_Nil #-} sem_ContextItems_Nil :: T_ContextItems sem_ContextItems_Nil = T_ContextItems (return st26) where {-# NOINLINE st26 #-} st26 = let v25 :: T_ContextItems_v25 v25 = \ (T_ContextItems_vIn25 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule28 () __result_ = T_ContextItems_vOut25 _lhsOtext in __result_ ) in C_ContextItems_s26 v25 {-# INLINE rule28 #-} rule28 = \ (_ :: ()) -> [] -- Declaration ------------------------------------------------- -- wrapper data Inh_Declaration = Inh_Declaration { } data Syn_Declaration = Syn_Declaration { text_Syn_Declaration :: (Doc) } {-# INLINABLE wrap_Declaration #-} wrap_Declaration :: T_Declaration -> Inh_Declaration -> (Syn_Declaration ) wrap_Declaration (T_Declaration act) (Inh_Declaration ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg28 = T_Declaration_vIn28 (T_Declaration_vOut28 _lhsOtext) <- return (inv_Declaration_s29 sem arg28) return (Syn_Declaration _lhsOtext) ) -- cata {-# NOINLINE sem_Declaration #-} sem_Declaration :: Declaration -> T_Declaration sem_Declaration ( Declaration_Hole range_ id_ ) = sem_Declaration_Hole ( sem_Range range_ ) id_ sem_Declaration ( Declaration_Type range_ simpletype_ type_ ) = sem_Declaration_Type ( sem_Range range_ ) ( sem_SimpleType simpletype_ ) ( sem_Type type_ ) sem_Declaration ( Declaration_Data range_ context_ simpletype_ constructors_ derivings_ ) = sem_Declaration_Data ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_SimpleType simpletype_ ) ( sem_Constructors constructors_ ) ( sem_Names derivings_ ) sem_Declaration ( Declaration_Newtype range_ context_ simpletype_ constructor_ derivings_ ) = sem_Declaration_Newtype ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_SimpleType simpletype_ ) ( sem_Constructor constructor_ ) ( sem_Names derivings_ ) sem_Declaration ( Declaration_Class range_ context_ simpletype_ where_ ) = sem_Declaration_Class ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_SimpleType simpletype_ ) ( sem_MaybeDeclarations where_ ) sem_Declaration ( Declaration_Instance range_ context_ name_ types_ where_ ) = sem_Declaration_Instance ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_Name name_ ) ( sem_Types types_ ) ( sem_MaybeDeclarations where_ ) sem_Declaration ( Declaration_Default range_ types_ ) = sem_Declaration_Default ( sem_Range range_ ) ( sem_Types types_ ) sem_Declaration ( Declaration_FunctionBindings range_ bindings_ ) = sem_Declaration_FunctionBindings ( sem_Range range_ ) ( sem_FunctionBindings bindings_ ) sem_Declaration ( Declaration_PatternBinding range_ pattern_ righthandside_ ) = sem_Declaration_PatternBinding ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_RightHandSide righthandside_ ) sem_Declaration ( Declaration_TypeSignature range_ names_ type_ ) = sem_Declaration_TypeSignature ( sem_Range range_ ) ( sem_Names names_ ) ( sem_Type type_ ) sem_Declaration ( Declaration_Fixity range_ fixity_ priority_ operators_ ) = sem_Declaration_Fixity ( sem_Range range_ ) ( sem_Fixity fixity_ ) ( sem_MaybeInt priority_ ) ( sem_Names operators_ ) sem_Declaration ( Declaration_Empty range_ ) = sem_Declaration_Empty ( sem_Range range_ ) -- semantic domain newtype T_Declaration = T_Declaration { attach_T_Declaration :: Identity (T_Declaration_s29 ) } newtype T_Declaration_s29 = C_Declaration_s29 { inv_Declaration_s29 :: (T_Declaration_v28 ) } data T_Declaration_s30 = C_Declaration_s30 type T_Declaration_v28 = (T_Declaration_vIn28 ) -> (T_Declaration_vOut28 ) data T_Declaration_vIn28 = T_Declaration_vIn28 data T_Declaration_vOut28 = T_Declaration_vOut28 (Doc) {-# NOINLINE sem_Declaration_Hole #-} sem_Declaration_Hole :: T_Range -> (Integer) -> T_Declaration sem_Declaration_Hole arg_range_ _ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule29 () _lhsOtext :: Doc _lhsOtext = rule30 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule29 #-} rule29 = \ (_ :: ()) -> text hole {-# INLINE rule30 #-} rule30 = \ _text -> _text {-# NOINLINE sem_Declaration_Type #-} sem_Declaration_Type :: T_Range -> T_SimpleType -> T_Type -> T_Declaration sem_Declaration_Type arg_range_ arg_simpletype_ arg_type_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_SimpleType_vOut151 _simpletypeItext) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule31 _simpletypeItext _typeItext _lhsOtext :: Doc _lhsOtext = rule32 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule31 #-} rule31 = \ ((_simpletypeItext) :: Doc) ((_typeItext) :: Doc) -> text "type" <+> _simpletypeItext <+> text "=" <+> _typeItext {-# INLINE rule32 #-} rule32 = \ _text -> _text {-# NOINLINE sem_Declaration_Data #-} sem_Declaration_Data :: T_Range -> T_ContextItems -> T_SimpleType -> T_Constructors -> T_Names -> T_Declaration sem_Declaration_Data arg_range_ arg_context_ arg_simpletype_ arg_constructors_ arg_derivings_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_)) _simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_)) _constructorsX20 = Control.Monad.Identity.runIdentity (attach_T_Constructors (arg_constructors_)) _derivingsX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_derivings_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_ContextItems_vOut25 _contextItext) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 ) (T_SimpleType_vOut151 _simpletypeItext) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 ) (T_Constructors_vOut19 _constructorsItext) = inv_Constructors_s20 _constructorsX20 (T_Constructors_vIn19 ) (T_Names_vOut115 _derivingsIisIdentifier _derivingsIisOperator _derivingsIisSpecial _derivingsItext) = inv_Names_s116 _derivingsX116 (T_Names_vIn115 ) _text = rule33 _constructorsItext _contextDoc _derivingDoc _simpletypeItext _contextDoc = rule34 _contextItext _derivingDoc = rule35 _derivingsItext _lhsOtext :: Doc _lhsOtext = rule36 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule33 #-} rule33 = \ ((_constructorsItext) :: [ Doc ] ) _contextDoc _derivingDoc ((_simpletypeItext) :: Doc) -> text "data" <+> _contextDoc <> _simpletypeItext <$> (indent 4 $ vcat ( text "=" <+> head _constructorsItext : map (text "|" <+>) (tail _constructorsItext) ++ [_derivingDoc] ) ) {-# INLINE rule34 #-} rule34 = \ ((_contextItext) :: [ Doc ] ) -> contextPP _contextItext {-# INLINE rule35 #-} rule35 = \ ((_derivingsItext) :: [ Doc ] ) -> if null _derivingsItext then empty else ( empty <+> text "deriving" <+> tupledUnit _derivingsItext ) {-# INLINE rule36 #-} rule36 = \ _text -> _text {-# NOINLINE sem_Declaration_Newtype #-} sem_Declaration_Newtype :: T_Range -> T_ContextItems -> T_SimpleType -> T_Constructor -> T_Names -> T_Declaration sem_Declaration_Newtype arg_range_ arg_context_ arg_simpletype_ arg_constructor_ arg_derivings_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_)) _simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_)) _constructorX17 = Control.Monad.Identity.runIdentity (attach_T_Constructor (arg_constructor_)) _derivingsX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_derivings_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_ContextItems_vOut25 _contextItext) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 ) (T_SimpleType_vOut151 _simpletypeItext) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 ) (T_Constructor_vOut16 _constructorItext) = inv_Constructor_s17 _constructorX17 (T_Constructor_vIn16 ) (T_Names_vOut115 _derivingsIisIdentifier _derivingsIisOperator _derivingsIisSpecial _derivingsItext) = inv_Names_s116 _derivingsX116 (T_Names_vIn115 ) _text = rule37 _constructorItext _contextDoc _derivingDoc _simpletypeItext _contextDoc = rule38 _contextItext _derivingDoc = rule39 _derivingsItext _lhsOtext :: Doc _lhsOtext = rule40 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule37 #-} rule37 = \ ((_constructorItext) :: Doc) _contextDoc _derivingDoc ((_simpletypeItext) :: Doc) -> text "newtype" <+> _contextDoc <> _simpletypeItext <+> _constructorItext <> _derivingDoc {-# INLINE rule38 #-} rule38 = \ ((_contextItext) :: [ Doc ] ) -> contextPP _contextItext {-# INLINE rule39 #-} rule39 = \ ((_derivingsItext) :: [ Doc ] ) -> if null _derivingsItext then empty else ( empty <+> text "deriving" <+> tupledUnit _derivingsItext ) {-# INLINE rule40 #-} rule40 = \ _text -> _text {-# NOINLINE sem_Declaration_Class #-} sem_Declaration_Class :: T_Range -> T_ContextItems -> T_SimpleType -> T_MaybeDeclarations -> T_Declaration sem_Declaration_Class arg_range_ arg_context_ arg_simpletype_ arg_where_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_)) _simpletypeX152 = Control.Monad.Identity.runIdentity (attach_T_SimpleType (arg_simpletype_)) _whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_ContextItems_vOut25 _contextItext) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 ) (T_SimpleType_vOut151 _simpletypeItext) = inv_SimpleType_s152 _simpletypeX152 (T_SimpleType_vIn151 ) (T_MaybeDeclarations_vOut88 _whereItext) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 ) _text = rule41 _contextItext _simpletypeItext _whereItext _lhsOtext :: Doc _lhsOtext = rule42 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule41 #-} rule41 = \ ((_contextItext) :: [ Doc ] ) ((_simpletypeItext) :: Doc) ((_whereItext) :: Maybe [ Doc ] ) -> (PPrint.empty <$> text "class" <+> contextPP _contextItext <+> _simpletypeItext <> maybe empty (\ds -> PPrint.empty <$> indent 4 (text "where" <$> indent 4 (vcat ds))) _whereItext ) {-# INLINE rule42 #-} rule42 = \ _text -> _text {-# NOINLINE sem_Declaration_Instance #-} sem_Declaration_Instance :: T_Range -> T_ContextItems -> T_Name -> T_Types -> T_MaybeDeclarations -> T_Declaration sem_Declaration_Instance arg_range_ arg_context_ arg_name_ arg_types_ arg_where_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _typesX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_types_)) _whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_ContextItems_vOut25 _contextItext) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Types_vOut166 _typesItext) = inv_Types_s167 _typesX167 (T_Types_vIn166 ) (T_MaybeDeclarations_vOut88 _whereItext) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 ) _text = rule43 _contextItext _nameItext _typesItext _whereItext _lhsOtext :: Doc _lhsOtext = rule44 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule43 #-} rule43 = \ ((_contextItext) :: [ Doc ] ) ((_nameItext) :: Doc) ((_typesItext) :: [ Doc ] ) ((_whereItext) :: Maybe [ Doc ] ) -> (PPrint.empty <$> text "instance" <+> contextPP _contextItext <+> _nameItext <+> PPrint.list _typesItext <> maybe empty (\ds -> PPrint.empty <$> indent 4 (text "where" <$> indent 4 (vcat ds))) _whereItext ) {-# INLINE rule44 #-} rule44 = \ _text -> _text {-# NOINLINE sem_Declaration_Default #-} sem_Declaration_Default :: T_Range -> T_Types -> T_Declaration sem_Declaration_Default arg_range_ arg_types_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _typesX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_types_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Types_vOut166 _typesItext) = inv_Types_s167 _typesX167 (T_Types_vIn166 ) _text = rule45 _typesItext _lhsOtext :: Doc _lhsOtext = rule46 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule45 #-} rule45 = \ ((_typesItext) :: [ Doc ] ) -> text "default" <+> tupled _typesItext {-# INLINE rule46 #-} rule46 = \ _text -> _text {-# NOINLINE sem_Declaration_FunctionBindings #-} sem_Declaration_FunctionBindings :: T_Range -> T_FunctionBindings -> T_Declaration sem_Declaration_FunctionBindings arg_range_ arg_bindings_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _bindingsX59 = Control.Monad.Identity.runIdentity (attach_T_FunctionBindings (arg_bindings_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_FunctionBindings_vOut58 _bindingsItext) = inv_FunctionBindings_s59 _bindingsX59 (T_FunctionBindings_vIn58 ) _text = rule47 _bindingsItext _lhsOtext :: Doc _lhsOtext = rule48 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule47 #-} rule47 = \ ((_bindingsItext) :: [ Doc ] ) -> case filter ((/= "") . show) _bindingsItext of [] -> text hole xs -> foldl1 (<$>) xs {-# INLINE rule48 #-} rule48 = \ _text -> _text {-# NOINLINE sem_Declaration_PatternBinding #-} sem_Declaration_PatternBinding :: T_Range -> T_Pattern -> T_RightHandSide -> T_Declaration sem_Declaration_PatternBinding arg_range_ arg_pattern_ arg_righthandside_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) _righthandsideX149 = Control.Monad.Identity.runIdentity (attach_T_RightHandSide (arg_righthandside_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) (T_RightHandSide_vOut148 _righthandsideItext) = inv_RightHandSide_s149 _righthandsideX149 (T_RightHandSide_vIn148 ) _text = rule49 _patternItext _righthandsideItext _lhsOtext :: Doc _lhsOtext = rule50 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule49 #-} rule49 = \ ((_patternItext) :: Doc) ((_righthandsideItext) :: Doc -> Doc ) -> _patternItext <+> _righthandsideItext (text "=") {-# INLINE rule50 #-} rule50 = \ _text -> _text {-# NOINLINE sem_Declaration_TypeSignature #-} sem_Declaration_TypeSignature :: T_Range -> T_Names -> T_Type -> T_Declaration sem_Declaration_TypeSignature arg_range_ arg_names_ arg_type_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _namesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_names_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Names_vOut115 _namesIisIdentifier _namesIisOperator _namesIisSpecial _namesItext) = inv_Names_s116 _namesX116 (T_Names_vIn115 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule51 _namesDocs _typeItext _namesDocs = rule52 _namesIisOperator _namesItext _lhsOtext :: Doc _lhsOtext = rule53 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule51 #-} rule51 = \ _namesDocs ((_typeItext) :: Doc) -> commas _namesDocs <+> text "::" <+> _typeItext {-# INLINE rule52 #-} rule52 = \ ((_namesIisOperator) :: [Bool] ) ((_namesItext) :: [ Doc ] ) -> parensIfList _namesIisOperator _namesItext {-# INLINE rule53 #-} rule53 = \ _text -> _text {-# NOINLINE sem_Declaration_Fixity #-} sem_Declaration_Fixity :: T_Range -> T_Fixity -> T_MaybeInt -> T_Names -> T_Declaration sem_Declaration_Fixity arg_range_ arg_fixity_ arg_priority_ arg_operators_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _fixityX53 = Control.Monad.Identity.runIdentity (attach_T_Fixity (arg_fixity_)) _priorityX101 = Control.Monad.Identity.runIdentity (attach_T_MaybeInt (arg_priority_)) _operatorsX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_operators_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Fixity_vOut52 _fixityItext) = inv_Fixity_s53 _fixityX53 (T_Fixity_vIn52 ) (T_MaybeInt_vOut100 _priorityItext) = inv_MaybeInt_s101 _priorityX101 (T_MaybeInt_vIn100 ) (T_Names_vOut115 _operatorsIisIdentifier _operatorsIisOperator _operatorsIisSpecial _operatorsItext) = inv_Names_s116 _operatorsX116 (T_Names_vIn115 ) _text = rule54 _fixityItext _ops _ops = rule55 _operatorsIisIdentifier _operatorsItext _priorityItext _lhsOtext :: Doc _lhsOtext = rule56 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule54 #-} rule54 = \ ((_fixityItext) :: Doc) _ops -> _fixityItext <+> _ops {-# INLINE rule55 #-} rule55 = \ ((_operatorsIisIdentifier) :: [Bool] ) ((_operatorsItext) :: [ Doc ] ) ((_priorityItext) :: Maybe Doc ) -> opt _priorityItext <+> commas (map (\(n, p) -> if p then text "`" <> n <> text "`" else n ) (zip _operatorsItext _operatorsIisIdentifier) ) {-# INLINE rule56 #-} rule56 = \ _text -> _text {-# NOINLINE sem_Declaration_Empty #-} sem_Declaration_Empty :: T_Range -> T_Declaration sem_Declaration_Empty arg_range_ = T_Declaration (return st29) where {-# NOINLINE st29 #-} st29 = let v28 :: T_Declaration_v28 v28 = \ (T_Declaration_vIn28 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule57 () _lhsOtext :: Doc _lhsOtext = rule58 _text __result_ = T_Declaration_vOut28 _lhsOtext in __result_ ) in C_Declaration_s29 v28 {-# INLINE rule57 #-} rule57 = \ (_ :: ()) -> empty {-# INLINE rule58 #-} rule58 = \ _text -> _text -- Declarations ------------------------------------------------ -- wrapper data Inh_Declarations = Inh_Declarations { } data Syn_Declarations = Syn_Declarations { text_Syn_Declarations :: ( [ Doc ] ) } {-# INLINABLE wrap_Declarations #-} wrap_Declarations :: T_Declarations -> Inh_Declarations -> (Syn_Declarations ) wrap_Declarations (T_Declarations act) (Inh_Declarations ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg31 = T_Declarations_vIn31 (T_Declarations_vOut31 _lhsOtext) <- return (inv_Declarations_s32 sem arg31) return (Syn_Declarations _lhsOtext) ) -- cata {-# NOINLINE sem_Declarations #-} sem_Declarations :: Declarations -> T_Declarations sem_Declarations list = Prelude.foldr sem_Declarations_Cons sem_Declarations_Nil (Prelude.map sem_Declaration list) -- semantic domain newtype T_Declarations = T_Declarations { attach_T_Declarations :: Identity (T_Declarations_s32 ) } newtype T_Declarations_s32 = C_Declarations_s32 { inv_Declarations_s32 :: (T_Declarations_v31 ) } data T_Declarations_s33 = C_Declarations_s33 type T_Declarations_v31 = (T_Declarations_vIn31 ) -> (T_Declarations_vOut31 ) data T_Declarations_vIn31 = T_Declarations_vIn31 data T_Declarations_vOut31 = T_Declarations_vOut31 ( [ Doc ] ) {-# NOINLINE sem_Declarations_Cons #-} sem_Declarations_Cons :: T_Declaration -> T_Declarations -> T_Declarations sem_Declarations_Cons arg_hd_ arg_tl_ = T_Declarations (return st32) where {-# NOINLINE st32 #-} st32 = let v31 :: T_Declarations_v31 v31 = \ (T_Declarations_vIn31 ) -> ( let _hdX29 = Control.Monad.Identity.runIdentity (attach_T_Declaration (arg_hd_)) _tlX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_tl_)) (T_Declaration_vOut28 _hdItext) = inv_Declaration_s29 _hdX29 (T_Declaration_vIn28 ) (T_Declarations_vOut31 _tlItext) = inv_Declarations_s32 _tlX32 (T_Declarations_vIn31 ) _lhsOtext :: [ Doc ] _lhsOtext = rule59 _hdItext _tlItext __result_ = T_Declarations_vOut31 _lhsOtext in __result_ ) in C_Declarations_s32 v31 {-# INLINE rule59 #-} rule59 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Declarations_Nil #-} sem_Declarations_Nil :: T_Declarations sem_Declarations_Nil = T_Declarations (return st32) where {-# NOINLINE st32 #-} st32 = let v31 :: T_Declarations_v31 v31 = \ (T_Declarations_vIn31 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule60 () __result_ = T_Declarations_vOut31 _lhsOtext in __result_ ) in C_Declarations_s32 v31 {-# INLINE rule60 #-} rule60 = \ (_ :: ()) -> [] -- Export ------------------------------------------------------ -- wrapper data Inh_Export = Inh_Export { } data Syn_Export = Syn_Export { text_Syn_Export :: (Doc) } {-# INLINABLE wrap_Export #-} wrap_Export :: T_Export -> Inh_Export -> (Syn_Export ) wrap_Export (T_Export act) (Inh_Export ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg34 = T_Export_vIn34 (T_Export_vOut34 _lhsOtext) <- return (inv_Export_s35 sem arg34) return (Syn_Export _lhsOtext) ) -- cata {-# NOINLINE sem_Export #-} sem_Export :: Export -> T_Export sem_Export ( Export_Variable range_ name_ ) = sem_Export_Variable ( sem_Range range_ ) ( sem_Name name_ ) sem_Export ( Export_TypeOrClass range_ name_ names_ ) = sem_Export_TypeOrClass ( sem_Range range_ ) ( sem_Name name_ ) ( sem_MaybeNames names_ ) sem_Export ( Export_TypeOrClassComplete range_ name_ ) = sem_Export_TypeOrClassComplete ( sem_Range range_ ) ( sem_Name name_ ) sem_Export ( Export_Module range_ name_ ) = sem_Export_Module ( sem_Range range_ ) ( sem_Name name_ ) -- semantic domain newtype T_Export = T_Export { attach_T_Export :: Identity (T_Export_s35 ) } newtype T_Export_s35 = C_Export_s35 { inv_Export_s35 :: (T_Export_v34 ) } data T_Export_s36 = C_Export_s36 type T_Export_v34 = (T_Export_vIn34 ) -> (T_Export_vOut34 ) data T_Export_vIn34 = T_Export_vIn34 data T_Export_vOut34 = T_Export_vOut34 (Doc) {-# NOINLINE sem_Export_Variable #-} sem_Export_Variable :: T_Range -> T_Name -> T_Export sem_Export_Variable arg_range_ arg_name_ = T_Export (return st35) where {-# NOINLINE st35 #-} st35 = let v34 :: T_Export_v34 v34 = \ (T_Export_vIn34 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule61 _nameItext _lhsOtext :: Doc _lhsOtext = rule62 _text __result_ = T_Export_vOut34 _lhsOtext in __result_ ) in C_Export_s35 v34 {-# INLINE rule61 #-} rule61 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule62 #-} rule62 = \ _text -> _text {-# NOINLINE sem_Export_TypeOrClass #-} sem_Export_TypeOrClass :: T_Range -> T_Name -> T_MaybeNames -> T_Export sem_Export_TypeOrClass arg_range_ arg_name_ arg_names_ = T_Export (return st35) where {-# NOINLINE st35 #-} st35 = let v34 :: T_Export_v34 v34 = \ (T_Export_vIn34 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _namesX107 = Control.Monad.Identity.runIdentity (attach_T_MaybeNames (arg_names_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_MaybeNames_vOut106 _namesItext) = inv_MaybeNames_s107 _namesX107 (T_MaybeNames_vIn106 ) _text = rule63 _nameItext _namesItext _lhsOtext :: Doc _lhsOtext = rule64 _text __result_ = T_Export_vOut34 _lhsOtext in __result_ ) in C_Export_s35 v34 {-# INLINE rule63 #-} rule63 = \ ((_nameItext) :: Doc) ((_namesItext) :: Maybe [ Doc ] ) -> _nameItext <> maybe empty tupled (_namesItext) {-# INLINE rule64 #-} rule64 = \ _text -> _text {-# NOINLINE sem_Export_TypeOrClassComplete #-} sem_Export_TypeOrClassComplete :: T_Range -> T_Name -> T_Export sem_Export_TypeOrClassComplete arg_range_ arg_name_ = T_Export (return st35) where {-# NOINLINE st35 #-} st35 = let v34 :: T_Export_v34 v34 = \ (T_Export_vIn34 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule65 _nameItext _lhsOtext :: Doc _lhsOtext = rule66 _text __result_ = T_Export_vOut34 _lhsOtext in __result_ ) in C_Export_s35 v34 {-# INLINE rule65 #-} rule65 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule66 #-} rule66 = \ _text -> _text {-# NOINLINE sem_Export_Module #-} sem_Export_Module :: T_Range -> T_Name -> T_Export sem_Export_Module arg_range_ arg_name_ = T_Export (return st35) where {-# NOINLINE st35 #-} st35 = let v34 :: T_Export_v34 v34 = \ (T_Export_vIn34 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule67 _nameItext _lhsOtext :: Doc _lhsOtext = rule68 _text __result_ = T_Export_vOut34 _lhsOtext in __result_ ) in C_Export_s35 v34 {-# INLINE rule67 #-} rule67 = \ ((_nameItext) :: Doc) -> text "module" <+> _nameItext {-# INLINE rule68 #-} rule68 = \ _text -> _text -- Exports ----------------------------------------------------- -- wrapper data Inh_Exports = Inh_Exports { } data Syn_Exports = Syn_Exports { text_Syn_Exports :: ( [ Doc ] ) } {-# INLINABLE wrap_Exports #-} wrap_Exports :: T_Exports -> Inh_Exports -> (Syn_Exports ) wrap_Exports (T_Exports act) (Inh_Exports ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg37 = T_Exports_vIn37 (T_Exports_vOut37 _lhsOtext) <- return (inv_Exports_s38 sem arg37) return (Syn_Exports _lhsOtext) ) -- cata {-# NOINLINE sem_Exports #-} sem_Exports :: Exports -> T_Exports sem_Exports list = Prelude.foldr sem_Exports_Cons sem_Exports_Nil (Prelude.map sem_Export list) -- semantic domain newtype T_Exports = T_Exports { attach_T_Exports :: Identity (T_Exports_s38 ) } newtype T_Exports_s38 = C_Exports_s38 { inv_Exports_s38 :: (T_Exports_v37 ) } data T_Exports_s39 = C_Exports_s39 type T_Exports_v37 = (T_Exports_vIn37 ) -> (T_Exports_vOut37 ) data T_Exports_vIn37 = T_Exports_vIn37 data T_Exports_vOut37 = T_Exports_vOut37 ( [ Doc ] ) {-# NOINLINE sem_Exports_Cons #-} sem_Exports_Cons :: T_Export -> T_Exports -> T_Exports sem_Exports_Cons arg_hd_ arg_tl_ = T_Exports (return st38) where {-# NOINLINE st38 #-} st38 = let v37 :: T_Exports_v37 v37 = \ (T_Exports_vIn37 ) -> ( let _hdX35 = Control.Monad.Identity.runIdentity (attach_T_Export (arg_hd_)) _tlX38 = Control.Monad.Identity.runIdentity (attach_T_Exports (arg_tl_)) (T_Export_vOut34 _hdItext) = inv_Export_s35 _hdX35 (T_Export_vIn34 ) (T_Exports_vOut37 _tlItext) = inv_Exports_s38 _tlX38 (T_Exports_vIn37 ) _lhsOtext :: [ Doc ] _lhsOtext = rule69 _hdItext _tlItext __result_ = T_Exports_vOut37 _lhsOtext in __result_ ) in C_Exports_s38 v37 {-# INLINE rule69 #-} rule69 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Exports_Nil #-} sem_Exports_Nil :: T_Exports sem_Exports_Nil = T_Exports (return st38) where {-# NOINLINE st38 #-} st38 = let v37 :: T_Exports_v37 v37 = \ (T_Exports_vIn37 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule70 () __result_ = T_Exports_vOut37 _lhsOtext in __result_ ) in C_Exports_s38 v37 {-# INLINE rule70 #-} rule70 = \ (_ :: ()) -> [] -- Expression -------------------------------------------------- -- wrapper data Inh_Expression = Inh_Expression { } data Syn_Expression = Syn_Expression { text_Syn_Expression :: (Doc) } {-# INLINABLE wrap_Expression #-} wrap_Expression :: T_Expression -> Inh_Expression -> (Syn_Expression ) wrap_Expression (T_Expression act) (Inh_Expression ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg40 = T_Expression_vIn40 (T_Expression_vOut40 _lhsOtext) <- return (inv_Expression_s41 sem arg40) return (Syn_Expression _lhsOtext) ) -- cata {-# NOINLINE sem_Expression #-} sem_Expression :: Expression -> T_Expression sem_Expression ( Expression_Hole range_ id_ ) = sem_Expression_Hole ( sem_Range range_ ) id_ sem_Expression ( Expression_Feedback range_ feedback_ expression_ ) = sem_Expression_Feedback ( sem_Range range_ ) feedback_ ( sem_Expression expression_ ) sem_Expression ( Expression_MustUse range_ expression_ ) = sem_Expression_MustUse ( sem_Range range_ ) ( sem_Expression expression_ ) sem_Expression ( Expression_Literal range_ literal_ ) = sem_Expression_Literal ( sem_Range range_ ) ( sem_Literal literal_ ) sem_Expression ( Expression_Variable range_ name_ ) = sem_Expression_Variable ( sem_Range range_ ) ( sem_Name name_ ) sem_Expression ( Expression_Constructor range_ name_ ) = sem_Expression_Constructor ( sem_Range range_ ) ( sem_Name name_ ) sem_Expression ( Expression_Parenthesized range_ expression_ ) = sem_Expression_Parenthesized ( sem_Range range_ ) ( sem_Expression expression_ ) sem_Expression ( Expression_NormalApplication range_ function_ arguments_ ) = sem_Expression_NormalApplication ( sem_Range range_ ) ( sem_Expression function_ ) ( sem_Expressions arguments_ ) sem_Expression ( Expression_InfixApplication range_ leftExpression_ operator_ rightExpression_ ) = sem_Expression_InfixApplication ( sem_Range range_ ) ( sem_MaybeExpression leftExpression_ ) ( sem_Expression operator_ ) ( sem_MaybeExpression rightExpression_ ) sem_Expression ( Expression_If range_ guardExpression_ thenExpression_ elseExpression_ ) = sem_Expression_If ( sem_Range range_ ) ( sem_Expression guardExpression_ ) ( sem_Expression thenExpression_ ) ( sem_Expression elseExpression_ ) sem_Expression ( Expression_Lambda range_ patterns_ expression_ ) = sem_Expression_Lambda ( sem_Range range_ ) ( sem_Patterns patterns_ ) ( sem_Expression expression_ ) sem_Expression ( Expression_Case range_ expression_ alternatives_ ) = sem_Expression_Case ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_Alternatives alternatives_ ) sem_Expression ( Expression_Let range_ declarations_ expression_ ) = sem_Expression_Let ( sem_Range range_ ) ( sem_Declarations declarations_ ) ( sem_Expression expression_ ) sem_Expression ( Expression_Do range_ statements_ ) = sem_Expression_Do ( sem_Range range_ ) ( sem_Statements statements_ ) sem_Expression ( Expression_List range_ expressions_ ) = sem_Expression_List ( sem_Range range_ ) ( sem_Expressions expressions_ ) sem_Expression ( Expression_Tuple range_ expressions_ ) = sem_Expression_Tuple ( sem_Range range_ ) ( sem_Expressions expressions_ ) sem_Expression ( Expression_Comprehension range_ expression_ qualifiers_ ) = sem_Expression_Comprehension ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_Qualifiers qualifiers_ ) sem_Expression ( Expression_Typed range_ expression_ type_ ) = sem_Expression_Typed ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_Type type_ ) sem_Expression ( Expression_RecordConstruction range_ name_ recordExpressionBindings_ ) = sem_Expression_RecordConstruction ( sem_Range range_ ) ( sem_Name name_ ) ( sem_RecordExpressionBindings recordExpressionBindings_ ) sem_Expression ( Expression_RecordUpdate range_ expression_ recordExpressionBindings_ ) = sem_Expression_RecordUpdate ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_RecordExpressionBindings recordExpressionBindings_ ) sem_Expression ( Expression_Enum range_ from_ then_ to_ ) = sem_Expression_Enum ( sem_Range range_ ) ( sem_Expression from_ ) ( sem_MaybeExpression then_ ) ( sem_MaybeExpression to_ ) sem_Expression ( Expression_Negate range_ expression_ ) = sem_Expression_Negate ( sem_Range range_ ) ( sem_Expression expression_ ) sem_Expression ( Expression_NegateFloat range_ expression_ ) = sem_Expression_NegateFloat ( sem_Range range_ ) ( sem_Expression expression_ ) -- semantic domain newtype T_Expression = T_Expression { attach_T_Expression :: Identity (T_Expression_s41 ) } newtype T_Expression_s41 = C_Expression_s41 { inv_Expression_s41 :: (T_Expression_v40 ) } data T_Expression_s42 = C_Expression_s42 type T_Expression_v40 = (T_Expression_vIn40 ) -> (T_Expression_vOut40 ) data T_Expression_vIn40 = T_Expression_vIn40 data T_Expression_vOut40 = T_Expression_vOut40 (Doc) {-# NOINLINE sem_Expression_Hole #-} sem_Expression_Hole :: T_Range -> (Integer) -> T_Expression sem_Expression_Hole arg_range_ _ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule71 () _lhsOtext :: Doc _lhsOtext = rule72 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule71 #-} rule71 = \ (_ :: ()) -> text hole {-# INLINE rule72 #-} rule72 = \ _text -> _text {-# NOINLINE sem_Expression_Feedback #-} sem_Expression_Feedback :: T_Range -> (String) -> T_Expression -> T_Expression sem_Expression_Feedback arg_range_ _ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _lhsOtext :: Doc _lhsOtext = rule73 _expressionItext __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule73 #-} rule73 = \ ((_expressionItext) :: Doc) -> _expressionItext {-# NOINLINE sem_Expression_MustUse #-} sem_Expression_MustUse :: T_Range -> T_Expression -> T_Expression sem_Expression_MustUse arg_range_ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _lhsOtext :: Doc _lhsOtext = rule74 _expressionItext __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule74 #-} rule74 = \ ((_expressionItext) :: Doc) -> _expressionItext {-# NOINLINE sem_Expression_Literal #-} sem_Expression_Literal :: T_Range -> T_Literal -> T_Expression sem_Expression_Literal arg_range_ arg_literal_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Literal_vOut85 _literalItext) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 ) _text = rule75 _literalItext _lhsOtext :: Doc _lhsOtext = rule76 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule75 #-} rule75 = \ ((_literalItext) :: Doc) -> _literalItext {-# INLINE rule76 #-} rule76 = \ _text -> _text {-# NOINLINE sem_Expression_Variable #-} sem_Expression_Variable :: T_Range -> T_Name -> T_Expression sem_Expression_Variable arg_range_ arg_name_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule77 _nameItext _lhsOtext :: Doc _lhsOtext = rule78 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule77 #-} rule77 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule78 #-} rule78 = \ _text -> _text {-# NOINLINE sem_Expression_Constructor #-} sem_Expression_Constructor :: T_Range -> T_Name -> T_Expression sem_Expression_Constructor arg_range_ arg_name_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule79 _nameItext _lhsOtext :: Doc _lhsOtext = rule80 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule79 #-} rule79 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule80 #-} rule80 = \ _text -> _text {-# NOINLINE sem_Expression_Parenthesized #-} sem_Expression_Parenthesized :: T_Range -> T_Expression -> T_Expression sem_Expression_Parenthesized arg_range_ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule81 _expressionItext _lhsOtext :: Doc _lhsOtext = rule82 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule81 #-} rule81 = \ ((_expressionItext) :: Doc) -> parens _expressionItext {-# INLINE rule82 #-} rule82 = \ _text -> _text {-# NOINLINE sem_Expression_NormalApplication #-} sem_Expression_NormalApplication :: T_Range -> T_Expression -> T_Expressions -> T_Expression sem_Expression_NormalApplication arg_range_ arg_function_ arg_arguments_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _functionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_function_)) _argumentsX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_arguments_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _functionItext) = inv_Expression_s41 _functionX41 (T_Expression_vIn40 ) (T_Expressions_vOut43 _argumentsItext) = inv_Expressions_s44 _argumentsX44 (T_Expressions_vIn43 ) _text = rule83 _argumentsItext _functionItext _lhsOtext :: Doc _lhsOtext = rule84 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule83 #-} rule83 = \ ((_argumentsItext) :: [ Doc ] ) ((_functionItext) :: Doc) -> foldl (<+>) _functionItext _argumentsItext {-# INLINE rule84 #-} rule84 = \ _text -> _text {-# NOINLINE sem_Expression_InfixApplication #-} sem_Expression_InfixApplication :: T_Range -> T_MaybeExpression -> T_Expression -> T_MaybeExpression -> T_Expression sem_Expression_InfixApplication arg_range_ arg_leftExpression_ arg_operator_ arg_rightExpression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _leftExpressionX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_leftExpression_)) _operatorX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_operator_)) _rightExpressionX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_rightExpression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_MaybeExpression_vOut94 _leftExpressionItext) = inv_MaybeExpression_s95 _leftExpressionX95 (T_MaybeExpression_vIn94 ) (T_Expression_vOut40 _operatorItext) = inv_Expression_s41 _operatorX41 (T_Expression_vIn40 ) (T_MaybeExpression_vOut94 _rightExpressionItext) = inv_MaybeExpression_s95 _rightExpressionX95 (T_MaybeExpression_vIn94 ) _text = rule85 _leftExpressionItext _operatorItext _rightExpressionItext _lhsOtext :: Doc _lhsOtext = rule86 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule85 #-} rule85 = \ ((_leftExpressionItext) :: Maybe Doc ) ((_operatorItext) :: Doc) ((_rightExpressionItext) :: Maybe Doc ) -> let f [] m = m f (c:cs) m = if isAlpha c && all (\ch -> ch == '_' || ch == '\'' || isAlphaNum ch) cs then char '`' <> m <> char '`' else m in case (_leftExpressionItext, _rightExpressionItext) of (Nothing, Nothing) -> parens _operatorItext (Just l , Nothing) -> parens (l <+> _operatorItext) (Nothing, Just r ) -> parens (_operatorItext <+> r) (Just l , Just r ) -> l <+> f (show _operatorItext) _operatorItext <+> r {-# INLINE rule86 #-} rule86 = \ _text -> _text {-# NOINLINE sem_Expression_If #-} sem_Expression_If :: T_Range -> T_Expression -> T_Expression -> T_Expression -> T_Expression sem_Expression_If arg_range_ arg_guardExpression_ arg_thenExpression_ arg_elseExpression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _guardExpressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_guardExpression_)) _thenExpressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_thenExpression_)) _elseExpressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_elseExpression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _guardExpressionItext) = inv_Expression_s41 _guardExpressionX41 (T_Expression_vIn40 ) (T_Expression_vOut40 _thenExpressionItext) = inv_Expression_s41 _thenExpressionX41 (T_Expression_vIn40 ) (T_Expression_vOut40 _elseExpressionItext) = inv_Expression_s41 _elseExpressionX41 (T_Expression_vIn40 ) _text = rule87 _elseExpressionItext _guardExpressionItext _thenExpressionItext _lhsOtext :: Doc _lhsOtext = rule88 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule87 #-} rule87 = \ ((_elseExpressionItext) :: Doc) ((_guardExpressionItext) :: Doc) ((_thenExpressionItext) :: Doc) -> text "if" <+> _guardExpressionItext <$> indent 4 (text "then" <+> _thenExpressionItext <$> text "else" <+> _elseExpressionItext) {-# INLINE rule88 #-} rule88 = \ _text -> _text {-# NOINLINE sem_Expression_Lambda #-} sem_Expression_Lambda :: T_Range -> T_Patterns -> T_Expression -> T_Expression sem_Expression_Lambda arg_range_ arg_patterns_ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Patterns_vOut121 _patternsItext) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule89 _expressionItext _patternsItext _lhsOtext :: Doc _lhsOtext = rule90 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule89 #-} rule89 = \ ((_expressionItext) :: Doc) ((_patternsItext) :: [ Doc ] ) -> text "\\" <+> foldl1 (<+>) _patternsItext <+> text "->" <+> _expressionItext {-# INLINE rule90 #-} rule90 = \ _text -> _text {-# NOINLINE sem_Expression_Case #-} sem_Expression_Case :: T_Range -> T_Expression -> T_Alternatives -> T_Expression sem_Expression_Case arg_range_ arg_expression_ arg_alternatives_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) _alternativesX5 = Control.Monad.Identity.runIdentity (attach_T_Alternatives (arg_alternatives_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) (T_Alternatives_vOut4 _alternativesItext) = inv_Alternatives_s5 _alternativesX5 (T_Alternatives_vIn4 ) _text = rule91 _alternativesItext _expressionItext _lhsOtext :: Doc _lhsOtext = rule92 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule91 #-} rule91 = \ ((_alternativesItext) :: [ Doc ] ) ((_expressionItext) :: Doc) -> (text "case" <+> _expressionItext <+> text "of" <$> (indent 4 $ vcat _alternativesItext) <$> empty ) {-# INLINE rule92 #-} rule92 = \ _text -> _text {-# NOINLINE sem_Expression_Let #-} sem_Expression_Let :: T_Range -> T_Declarations -> T_Expression -> T_Expression sem_Expression_Let arg_range_ arg_declarations_ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Declarations_vOut31 _declarationsItext) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule93 _declarationsItext _expressionItext _lhsOtext :: Doc _lhsOtext = rule94 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule93 #-} rule93 = \ ((_declarationsItext) :: [ Doc ] ) ((_expressionItext) :: Doc) -> (text "let"<$> (indent 4 $ vcat _declarationsItext) <+> text "in" <$> (indent 4 $ _expressionItext) ) <$> empty {-# INLINE rule94 #-} rule94 = \ _text -> _text {-# NOINLINE sem_Expression_Do #-} sem_Expression_Do :: T_Range -> T_Statements -> T_Expression sem_Expression_Do arg_range_ arg_statements_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _statementsX158 = Control.Monad.Identity.runIdentity (attach_T_Statements (arg_statements_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Statements_vOut157 _statementsItext) = inv_Statements_s158 _statementsX158 (T_Statements_vIn157 ) _text = rule95 _statementsItext _lhsOtext :: Doc _lhsOtext = rule96 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule95 #-} rule95 = \ ((_statementsItext) :: [ Doc ] ) -> text "do" <$> (indent 4 $ vcat _statementsItext) <$> empty {-# INLINE rule96 #-} rule96 = \ _text -> _text {-# NOINLINE sem_Expression_List #-} sem_Expression_List :: T_Range -> T_Expressions -> T_Expression sem_Expression_List arg_range_ arg_expressions_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionsX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_expressions_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expressions_vOut43 _expressionsItext) = inv_Expressions_s44 _expressionsX44 (T_Expressions_vIn43 ) _text = rule97 _expressionsItext _lhsOtext :: Doc _lhsOtext = rule98 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule97 #-} rule97 = \ ((_expressionsItext) :: [ Doc ] ) -> PPrint.list _expressionsItext {-# INLINE rule98 #-} rule98 = \ _text -> _text {-# NOINLINE sem_Expression_Tuple #-} sem_Expression_Tuple :: T_Range -> T_Expressions -> T_Expression sem_Expression_Tuple arg_range_ arg_expressions_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionsX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_expressions_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expressions_vOut43 _expressionsItext) = inv_Expressions_s44 _expressionsX44 (T_Expressions_vIn43 ) _text = rule99 _expressionsItext _lhsOtext :: Doc _lhsOtext = rule100 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule99 #-} rule99 = \ ((_expressionsItext) :: [ Doc ] ) -> tupled _expressionsItext {-# INLINE rule100 #-} rule100 = \ _text -> _text {-# NOINLINE sem_Expression_Comprehension #-} sem_Expression_Comprehension :: T_Range -> T_Expression -> T_Qualifiers -> T_Expression sem_Expression_Comprehension arg_range_ arg_expression_ arg_qualifiers_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) _qualifiersX131 = Control.Monad.Identity.runIdentity (attach_T_Qualifiers (arg_qualifiers_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) (T_Qualifiers_vOut130 _qualifiersItext) = inv_Qualifiers_s131 _qualifiersX131 (T_Qualifiers_vIn130 ) _text = rule101 _expressionItext _qualifiersItext _lhsOtext :: Doc _lhsOtext = rule102 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule101 #-} rule101 = \ ((_expressionItext) :: Doc) ((_qualifiersItext) :: [ Doc ] ) -> text "[" <+> _expressionItext <+> text "|" <+> commas _qualifiersItext <+> text "]" {-# INLINE rule102 #-} rule102 = \ _text -> _text {-# NOINLINE sem_Expression_Typed #-} sem_Expression_Typed :: T_Range -> T_Expression -> T_Type -> T_Expression sem_Expression_Typed arg_range_ arg_expression_ arg_type_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule103 _expressionItext _typeItext _lhsOtext :: Doc _lhsOtext = rule104 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule103 #-} rule103 = \ ((_expressionItext) :: Doc) ((_typeItext) :: Doc) -> _expressionItext <+> text "::" <+> _typeItext {-# INLINE rule104 #-} rule104 = \ _text -> _text {-# NOINLINE sem_Expression_RecordConstruction #-} sem_Expression_RecordConstruction :: T_Range -> T_Name -> T_RecordExpressionBindings -> T_Expression sem_Expression_RecordConstruction arg_range_ arg_name_ arg_recordExpressionBindings_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _recordExpressionBindingsX140 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBindings (arg_recordExpressionBindings_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_RecordExpressionBindings_vOut139 _recordExpressionBindingsItext) = inv_RecordExpressionBindings_s140 _recordExpressionBindingsX140 (T_RecordExpressionBindings_vIn139 ) _text = rule105 () _lhsOtext :: Doc _lhsOtext = rule106 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule105 #-} rule105 = \ (_ :: ()) -> intErr "Expression" "record construction" {-# INLINE rule106 #-} rule106 = \ _text -> _text {-# NOINLINE sem_Expression_RecordUpdate #-} sem_Expression_RecordUpdate :: T_Range -> T_Expression -> T_RecordExpressionBindings -> T_Expression sem_Expression_RecordUpdate arg_range_ arg_expression_ arg_recordExpressionBindings_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) _recordExpressionBindingsX140 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBindings (arg_recordExpressionBindings_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) (T_RecordExpressionBindings_vOut139 _recordExpressionBindingsItext) = inv_RecordExpressionBindings_s140 _recordExpressionBindingsX140 (T_RecordExpressionBindings_vIn139 ) _text = rule107 () _lhsOtext :: Doc _lhsOtext = rule108 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule107 #-} rule107 = \ (_ :: ()) -> intErr "Expression" "record update" {-# INLINE rule108 #-} rule108 = \ _text -> _text {-# NOINLINE sem_Expression_Enum #-} sem_Expression_Enum :: T_Range -> T_Expression -> T_MaybeExpression -> T_MaybeExpression -> T_Expression sem_Expression_Enum arg_range_ arg_from_ arg_then_ arg_to_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _fromX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_from_)) _thenX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_then_)) _toX95 = Control.Monad.Identity.runIdentity (attach_T_MaybeExpression (arg_to_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _fromItext) = inv_Expression_s41 _fromX41 (T_Expression_vIn40 ) (T_MaybeExpression_vOut94 _thenItext) = inv_MaybeExpression_s95 _thenX95 (T_MaybeExpression_vIn94 ) (T_MaybeExpression_vOut94 _toItext) = inv_MaybeExpression_s95 _toX95 (T_MaybeExpression_vIn94 ) _text = rule109 _fromItext _thenItext _toItext _lhsOtext :: Doc _lhsOtext = rule110 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule109 #-} rule109 = \ ((_fromItext) :: Doc) ((_thenItext) :: Maybe Doc ) ((_toItext) :: Maybe Doc ) -> text "[" <> _fromItext <> maybe empty (text "," <+>) _thenItext <+> text ".." <+> opt _toItext <> text "]" {-# INLINE rule110 #-} rule110 = \ _text -> _text {-# NOINLINE sem_Expression_Negate #-} sem_Expression_Negate :: T_Range -> T_Expression -> T_Expression sem_Expression_Negate arg_range_ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule111 _expressionItext _lhsOtext :: Doc _lhsOtext = rule112 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule111 #-} rule111 = \ ((_expressionItext) :: Doc) -> text "-" <> _expressionItext {-# INLINE rule112 #-} rule112 = \ _text -> _text {-# NOINLINE sem_Expression_NegateFloat #-} sem_Expression_NegateFloat :: T_Range -> T_Expression -> T_Expression sem_Expression_NegateFloat arg_range_ arg_expression_ = T_Expression (return st41) where {-# NOINLINE st41 #-} st41 = let v40 :: T_Expression_v40 v40 = \ (T_Expression_vIn40 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule113 _expressionItext _lhsOtext :: Doc _lhsOtext = rule114 _text __result_ = T_Expression_vOut40 _lhsOtext in __result_ ) in C_Expression_s41 v40 {-# INLINE rule113 #-} rule113 = \ ((_expressionItext) :: Doc) -> text "-." <> _expressionItext {-# INLINE rule114 #-} rule114 = \ _text -> _text -- Expressions ------------------------------------------------- -- wrapper data Inh_Expressions = Inh_Expressions { } data Syn_Expressions = Syn_Expressions { text_Syn_Expressions :: ( [ Doc ] ) } {-# INLINABLE wrap_Expressions #-} wrap_Expressions :: T_Expressions -> Inh_Expressions -> (Syn_Expressions ) wrap_Expressions (T_Expressions act) (Inh_Expressions ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg43 = T_Expressions_vIn43 (T_Expressions_vOut43 _lhsOtext) <- return (inv_Expressions_s44 sem arg43) return (Syn_Expressions _lhsOtext) ) -- cata {-# NOINLINE sem_Expressions #-} sem_Expressions :: Expressions -> T_Expressions sem_Expressions list = Prelude.foldr sem_Expressions_Cons sem_Expressions_Nil (Prelude.map sem_Expression list) -- semantic domain newtype T_Expressions = T_Expressions { attach_T_Expressions :: Identity (T_Expressions_s44 ) } newtype T_Expressions_s44 = C_Expressions_s44 { inv_Expressions_s44 :: (T_Expressions_v43 ) } data T_Expressions_s45 = C_Expressions_s45 type T_Expressions_v43 = (T_Expressions_vIn43 ) -> (T_Expressions_vOut43 ) data T_Expressions_vIn43 = T_Expressions_vIn43 data T_Expressions_vOut43 = T_Expressions_vOut43 ( [ Doc ] ) {-# NOINLINE sem_Expressions_Cons #-} sem_Expressions_Cons :: T_Expression -> T_Expressions -> T_Expressions sem_Expressions_Cons arg_hd_ arg_tl_ = T_Expressions (return st44) where {-# NOINLINE st44 #-} st44 = let v43 :: T_Expressions_v43 v43 = \ (T_Expressions_vIn43 ) -> ( let _hdX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_hd_)) _tlX44 = Control.Monad.Identity.runIdentity (attach_T_Expressions (arg_tl_)) (T_Expression_vOut40 _hdItext) = inv_Expression_s41 _hdX41 (T_Expression_vIn40 ) (T_Expressions_vOut43 _tlItext) = inv_Expressions_s44 _tlX44 (T_Expressions_vIn43 ) _lhsOtext :: [ Doc ] _lhsOtext = rule115 _hdItext _tlItext __result_ = T_Expressions_vOut43 _lhsOtext in __result_ ) in C_Expressions_s44 v43 {-# INLINE rule115 #-} rule115 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Expressions_Nil #-} sem_Expressions_Nil :: T_Expressions sem_Expressions_Nil = T_Expressions (return st44) where {-# NOINLINE st44 #-} st44 = let v43 :: T_Expressions_v43 v43 = \ (T_Expressions_vIn43 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule116 () __result_ = T_Expressions_vOut43 _lhsOtext in __result_ ) in C_Expressions_s44 v43 {-# INLINE rule116 #-} rule116 = \ (_ :: ()) -> [] -- FieldDeclaration -------------------------------------------- -- wrapper data Inh_FieldDeclaration = Inh_FieldDeclaration { } data Syn_FieldDeclaration = Syn_FieldDeclaration { text_Syn_FieldDeclaration :: (Doc) } {-# INLINABLE wrap_FieldDeclaration #-} wrap_FieldDeclaration :: T_FieldDeclaration -> Inh_FieldDeclaration -> (Syn_FieldDeclaration ) wrap_FieldDeclaration (T_FieldDeclaration act) (Inh_FieldDeclaration ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg46 = T_FieldDeclaration_vIn46 (T_FieldDeclaration_vOut46 _lhsOtext) <- return (inv_FieldDeclaration_s47 sem arg46) return (Syn_FieldDeclaration _lhsOtext) ) -- cata {-# INLINE sem_FieldDeclaration #-} sem_FieldDeclaration :: FieldDeclaration -> T_FieldDeclaration sem_FieldDeclaration ( FieldDeclaration_FieldDeclaration range_ names_ type_ ) = sem_FieldDeclaration_FieldDeclaration ( sem_Range range_ ) ( sem_Names names_ ) ( sem_AnnotatedType type_ ) -- semantic domain newtype T_FieldDeclaration = T_FieldDeclaration { attach_T_FieldDeclaration :: Identity (T_FieldDeclaration_s47 ) } newtype T_FieldDeclaration_s47 = C_FieldDeclaration_s47 { inv_FieldDeclaration_s47 :: (T_FieldDeclaration_v46 ) } data T_FieldDeclaration_s48 = C_FieldDeclaration_s48 type T_FieldDeclaration_v46 = (T_FieldDeclaration_vIn46 ) -> (T_FieldDeclaration_vOut46 ) data T_FieldDeclaration_vIn46 = T_FieldDeclaration_vIn46 data T_FieldDeclaration_vOut46 = T_FieldDeclaration_vOut46 (Doc) {-# NOINLINE sem_FieldDeclaration_FieldDeclaration #-} sem_FieldDeclaration_FieldDeclaration :: T_Range -> T_Names -> T_AnnotatedType -> T_FieldDeclaration sem_FieldDeclaration_FieldDeclaration arg_range_ arg_names_ arg_type_ = T_FieldDeclaration (return st47) where {-# NOINLINE st47 #-} st47 = let v46 :: T_FieldDeclaration_v46 v46 = \ (T_FieldDeclaration_vIn46 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _namesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_names_)) _typeX8 = Control.Monad.Identity.runIdentity (attach_T_AnnotatedType (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Names_vOut115 _namesIisIdentifier _namesIisOperator _namesIisSpecial _namesItext) = inv_Names_s116 _namesX116 (T_Names_vIn115 ) (T_AnnotatedType_vOut7 _typeItext) = inv_AnnotatedType_s8 _typeX8 (T_AnnotatedType_vIn7 ) _text = rule117 () _lhsOtext :: Doc _lhsOtext = rule118 _text __result_ = T_FieldDeclaration_vOut46 _lhsOtext in __result_ ) in C_FieldDeclaration_s47 v46 {-# INLINE rule117 #-} rule117 = \ (_ :: ()) -> text "{- !!! field declaration -}" {-# INLINE rule118 #-} rule118 = \ _text -> _text -- FieldDeclarations ------------------------------------------- -- wrapper data Inh_FieldDeclarations = Inh_FieldDeclarations { } data Syn_FieldDeclarations = Syn_FieldDeclarations { text_Syn_FieldDeclarations :: ( [ Doc ] ) } {-# INLINABLE wrap_FieldDeclarations #-} wrap_FieldDeclarations :: T_FieldDeclarations -> Inh_FieldDeclarations -> (Syn_FieldDeclarations ) wrap_FieldDeclarations (T_FieldDeclarations act) (Inh_FieldDeclarations ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg49 = T_FieldDeclarations_vIn49 (T_FieldDeclarations_vOut49 _lhsOtext) <- return (inv_FieldDeclarations_s50 sem arg49) return (Syn_FieldDeclarations _lhsOtext) ) -- cata {-# NOINLINE sem_FieldDeclarations #-} sem_FieldDeclarations :: FieldDeclarations -> T_FieldDeclarations sem_FieldDeclarations list = Prelude.foldr sem_FieldDeclarations_Cons sem_FieldDeclarations_Nil (Prelude.map sem_FieldDeclaration list) -- semantic domain newtype T_FieldDeclarations = T_FieldDeclarations { attach_T_FieldDeclarations :: Identity (T_FieldDeclarations_s50 ) } newtype T_FieldDeclarations_s50 = C_FieldDeclarations_s50 { inv_FieldDeclarations_s50 :: (T_FieldDeclarations_v49 ) } data T_FieldDeclarations_s51 = C_FieldDeclarations_s51 type T_FieldDeclarations_v49 = (T_FieldDeclarations_vIn49 ) -> (T_FieldDeclarations_vOut49 ) data T_FieldDeclarations_vIn49 = T_FieldDeclarations_vIn49 data T_FieldDeclarations_vOut49 = T_FieldDeclarations_vOut49 ( [ Doc ] ) {-# NOINLINE sem_FieldDeclarations_Cons #-} sem_FieldDeclarations_Cons :: T_FieldDeclaration -> T_FieldDeclarations -> T_FieldDeclarations sem_FieldDeclarations_Cons arg_hd_ arg_tl_ = T_FieldDeclarations (return st50) where {-# NOINLINE st50 #-} st50 = let v49 :: T_FieldDeclarations_v49 v49 = \ (T_FieldDeclarations_vIn49 ) -> ( let _hdX47 = Control.Monad.Identity.runIdentity (attach_T_FieldDeclaration (arg_hd_)) _tlX50 = Control.Monad.Identity.runIdentity (attach_T_FieldDeclarations (arg_tl_)) (T_FieldDeclaration_vOut46 _hdItext) = inv_FieldDeclaration_s47 _hdX47 (T_FieldDeclaration_vIn46 ) (T_FieldDeclarations_vOut49 _tlItext) = inv_FieldDeclarations_s50 _tlX50 (T_FieldDeclarations_vIn49 ) _lhsOtext :: [ Doc ] _lhsOtext = rule119 _hdItext _tlItext __result_ = T_FieldDeclarations_vOut49 _lhsOtext in __result_ ) in C_FieldDeclarations_s50 v49 {-# INLINE rule119 #-} rule119 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_FieldDeclarations_Nil #-} sem_FieldDeclarations_Nil :: T_FieldDeclarations sem_FieldDeclarations_Nil = T_FieldDeclarations (return st50) where {-# NOINLINE st50 #-} st50 = let v49 :: T_FieldDeclarations_v49 v49 = \ (T_FieldDeclarations_vIn49 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule120 () __result_ = T_FieldDeclarations_vOut49 _lhsOtext in __result_ ) in C_FieldDeclarations_s50 v49 {-# INLINE rule120 #-} rule120 = \ (_ :: ()) -> [] -- Fixity ------------------------------------------------------ -- wrapper data Inh_Fixity = Inh_Fixity { } data Syn_Fixity = Syn_Fixity { text_Syn_Fixity :: (Doc) } {-# INLINABLE wrap_Fixity #-} wrap_Fixity :: T_Fixity -> Inh_Fixity -> (Syn_Fixity ) wrap_Fixity (T_Fixity act) (Inh_Fixity ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg52 = T_Fixity_vIn52 (T_Fixity_vOut52 _lhsOtext) <- return (inv_Fixity_s53 sem arg52) return (Syn_Fixity _lhsOtext) ) -- cata {-# NOINLINE sem_Fixity #-} sem_Fixity :: Fixity -> T_Fixity sem_Fixity ( Fixity_Infixl range_ ) = sem_Fixity_Infixl ( sem_Range range_ ) sem_Fixity ( Fixity_Infixr range_ ) = sem_Fixity_Infixr ( sem_Range range_ ) sem_Fixity ( Fixity_Infix range_ ) = sem_Fixity_Infix ( sem_Range range_ ) -- semantic domain newtype T_Fixity = T_Fixity { attach_T_Fixity :: Identity (T_Fixity_s53 ) } newtype T_Fixity_s53 = C_Fixity_s53 { inv_Fixity_s53 :: (T_Fixity_v52 ) } data T_Fixity_s54 = C_Fixity_s54 type T_Fixity_v52 = (T_Fixity_vIn52 ) -> (T_Fixity_vOut52 ) data T_Fixity_vIn52 = T_Fixity_vIn52 data T_Fixity_vOut52 = T_Fixity_vOut52 (Doc) {-# NOINLINE sem_Fixity_Infixl #-} sem_Fixity_Infixl :: T_Range -> T_Fixity sem_Fixity_Infixl arg_range_ = T_Fixity (return st53) where {-# NOINLINE st53 #-} st53 = let v52 :: T_Fixity_v52 v52 = \ (T_Fixity_vIn52 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule121 () _lhsOtext :: Doc _lhsOtext = rule122 _text __result_ = T_Fixity_vOut52 _lhsOtext in __result_ ) in C_Fixity_s53 v52 {-# INLINE rule121 #-} rule121 = \ (_ :: ()) -> text "infixl" {-# INLINE rule122 #-} rule122 = \ _text -> _text {-# NOINLINE sem_Fixity_Infixr #-} sem_Fixity_Infixr :: T_Range -> T_Fixity sem_Fixity_Infixr arg_range_ = T_Fixity (return st53) where {-# NOINLINE st53 #-} st53 = let v52 :: T_Fixity_v52 v52 = \ (T_Fixity_vIn52 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule123 () _lhsOtext :: Doc _lhsOtext = rule124 _text __result_ = T_Fixity_vOut52 _lhsOtext in __result_ ) in C_Fixity_s53 v52 {-# INLINE rule123 #-} rule123 = \ (_ :: ()) -> text "infixr" {-# INLINE rule124 #-} rule124 = \ _text -> _text {-# NOINLINE sem_Fixity_Infix #-} sem_Fixity_Infix :: T_Range -> T_Fixity sem_Fixity_Infix arg_range_ = T_Fixity (return st53) where {-# NOINLINE st53 #-} st53 = let v52 :: T_Fixity_v52 v52 = \ (T_Fixity_vIn52 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule125 () _lhsOtext :: Doc _lhsOtext = rule126 _text __result_ = T_Fixity_vOut52 _lhsOtext in __result_ ) in C_Fixity_s53 v52 {-# INLINE rule125 #-} rule125 = \ (_ :: ()) -> text "infix " {-# INLINE rule126 #-} rule126 = \ _text -> _text -- FunctionBinding --------------------------------------------- -- wrapper data Inh_FunctionBinding = Inh_FunctionBinding { } data Syn_FunctionBinding = Syn_FunctionBinding { text_Syn_FunctionBinding :: (Doc) } {-# INLINABLE wrap_FunctionBinding #-} wrap_FunctionBinding :: T_FunctionBinding -> Inh_FunctionBinding -> (Syn_FunctionBinding ) wrap_FunctionBinding (T_FunctionBinding act) (Inh_FunctionBinding ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg55 = T_FunctionBinding_vIn55 (T_FunctionBinding_vOut55 _lhsOtext) <- return (inv_FunctionBinding_s56 sem arg55) return (Syn_FunctionBinding _lhsOtext) ) -- cata {-# NOINLINE sem_FunctionBinding #-} sem_FunctionBinding :: FunctionBinding -> T_FunctionBinding sem_FunctionBinding ( FunctionBinding_Hole range_ id_ ) = sem_FunctionBinding_Hole ( sem_Range range_ ) id_ sem_FunctionBinding ( FunctionBinding_Feedback range_ feedback_ functionBinding_ ) = sem_FunctionBinding_Feedback ( sem_Range range_ ) feedback_ ( sem_FunctionBinding functionBinding_ ) sem_FunctionBinding ( FunctionBinding_FunctionBinding range_ lefthandside_ righthandside_ ) = sem_FunctionBinding_FunctionBinding ( sem_Range range_ ) ( sem_LeftHandSide lefthandside_ ) ( sem_RightHandSide righthandside_ ) -- semantic domain newtype T_FunctionBinding = T_FunctionBinding { attach_T_FunctionBinding :: Identity (T_FunctionBinding_s56 ) } newtype T_FunctionBinding_s56 = C_FunctionBinding_s56 { inv_FunctionBinding_s56 :: (T_FunctionBinding_v55 ) } data T_FunctionBinding_s57 = C_FunctionBinding_s57 type T_FunctionBinding_v55 = (T_FunctionBinding_vIn55 ) -> (T_FunctionBinding_vOut55 ) data T_FunctionBinding_vIn55 = T_FunctionBinding_vIn55 data T_FunctionBinding_vOut55 = T_FunctionBinding_vOut55 (Doc) {-# NOINLINE sem_FunctionBinding_Hole #-} sem_FunctionBinding_Hole :: T_Range -> (Integer) -> T_FunctionBinding sem_FunctionBinding_Hole arg_range_ _ = T_FunctionBinding (return st56) where {-# NOINLINE st56 #-} st56 = let v55 :: T_FunctionBinding_v55 v55 = \ (T_FunctionBinding_vIn55 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule127 () _lhsOtext :: Doc _lhsOtext = rule128 _text __result_ = T_FunctionBinding_vOut55 _lhsOtext in __result_ ) in C_FunctionBinding_s56 v55 {-# INLINE rule127 #-} rule127 = \ (_ :: ()) -> empty {-# INLINE rule128 #-} rule128 = \ _text -> _text {-# NOINLINE sem_FunctionBinding_Feedback #-} sem_FunctionBinding_Feedback :: T_Range -> (String) -> T_FunctionBinding -> T_FunctionBinding sem_FunctionBinding_Feedback arg_range_ _ arg_functionBinding_ = T_FunctionBinding (return st56) where {-# NOINLINE st56 #-} st56 = let v55 :: T_FunctionBinding_v55 v55 = \ (T_FunctionBinding_vIn55 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _functionBindingX56 = Control.Monad.Identity.runIdentity (attach_T_FunctionBinding (arg_functionBinding_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_FunctionBinding_vOut55 _functionBindingItext) = inv_FunctionBinding_s56 _functionBindingX56 (T_FunctionBinding_vIn55 ) _lhsOtext :: Doc _lhsOtext = rule129 _functionBindingItext __result_ = T_FunctionBinding_vOut55 _lhsOtext in __result_ ) in C_FunctionBinding_s56 v55 {-# INLINE rule129 #-} rule129 = \ ((_functionBindingItext) :: Doc) -> _functionBindingItext {-# NOINLINE sem_FunctionBinding_FunctionBinding #-} sem_FunctionBinding_FunctionBinding :: T_Range -> T_LeftHandSide -> T_RightHandSide -> T_FunctionBinding sem_FunctionBinding_FunctionBinding arg_range_ arg_lefthandside_ arg_righthandside_ = T_FunctionBinding (return st56) where {-# NOINLINE st56 #-} st56 = let v55 :: T_FunctionBinding_v55 v55 = \ (T_FunctionBinding_vIn55 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _lefthandsideX83 = Control.Monad.Identity.runIdentity (attach_T_LeftHandSide (arg_lefthandside_)) _righthandsideX149 = Control.Monad.Identity.runIdentity (attach_T_RightHandSide (arg_righthandside_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_LeftHandSide_vOut82 _lefthandsideItext) = inv_LeftHandSide_s83 _lefthandsideX83 (T_LeftHandSide_vIn82 ) (T_RightHandSide_vOut148 _righthandsideItext) = inv_RightHandSide_s149 _righthandsideX149 (T_RightHandSide_vIn148 ) _text = rule130 _lefthandsideItext _righthandsideItext _lhsOtext :: Doc _lhsOtext = rule131 _text __result_ = T_FunctionBinding_vOut55 _lhsOtext in __result_ ) in C_FunctionBinding_s56 v55 {-# INLINE rule130 #-} rule130 = \ ((_lefthandsideItext) :: Doc) ((_righthandsideItext) :: Doc -> Doc ) -> _lefthandsideItext <+> _righthandsideItext (text "=") {-# INLINE rule131 #-} rule131 = \ _text -> _text -- FunctionBindings -------------------------------------------- -- wrapper data Inh_FunctionBindings = Inh_FunctionBindings { } data Syn_FunctionBindings = Syn_FunctionBindings { text_Syn_FunctionBindings :: ( [ Doc ] ) } {-# INLINABLE wrap_FunctionBindings #-} wrap_FunctionBindings :: T_FunctionBindings -> Inh_FunctionBindings -> (Syn_FunctionBindings ) wrap_FunctionBindings (T_FunctionBindings act) (Inh_FunctionBindings ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg58 = T_FunctionBindings_vIn58 (T_FunctionBindings_vOut58 _lhsOtext) <- return (inv_FunctionBindings_s59 sem arg58) return (Syn_FunctionBindings _lhsOtext) ) -- cata {-# NOINLINE sem_FunctionBindings #-} sem_FunctionBindings :: FunctionBindings -> T_FunctionBindings sem_FunctionBindings list = Prelude.foldr sem_FunctionBindings_Cons sem_FunctionBindings_Nil (Prelude.map sem_FunctionBinding list) -- semantic domain newtype T_FunctionBindings = T_FunctionBindings { attach_T_FunctionBindings :: Identity (T_FunctionBindings_s59 ) } newtype T_FunctionBindings_s59 = C_FunctionBindings_s59 { inv_FunctionBindings_s59 :: (T_FunctionBindings_v58 ) } data T_FunctionBindings_s60 = C_FunctionBindings_s60 type T_FunctionBindings_v58 = (T_FunctionBindings_vIn58 ) -> (T_FunctionBindings_vOut58 ) data T_FunctionBindings_vIn58 = T_FunctionBindings_vIn58 data T_FunctionBindings_vOut58 = T_FunctionBindings_vOut58 ( [ Doc ] ) {-# NOINLINE sem_FunctionBindings_Cons #-} sem_FunctionBindings_Cons :: T_FunctionBinding -> T_FunctionBindings -> T_FunctionBindings sem_FunctionBindings_Cons arg_hd_ arg_tl_ = T_FunctionBindings (return st59) where {-# NOINLINE st59 #-} st59 = let v58 :: T_FunctionBindings_v58 v58 = \ (T_FunctionBindings_vIn58 ) -> ( let _hdX56 = Control.Monad.Identity.runIdentity (attach_T_FunctionBinding (arg_hd_)) _tlX59 = Control.Monad.Identity.runIdentity (attach_T_FunctionBindings (arg_tl_)) (T_FunctionBinding_vOut55 _hdItext) = inv_FunctionBinding_s56 _hdX56 (T_FunctionBinding_vIn55 ) (T_FunctionBindings_vOut58 _tlItext) = inv_FunctionBindings_s59 _tlX59 (T_FunctionBindings_vIn58 ) _lhsOtext :: [ Doc ] _lhsOtext = rule132 _hdItext _tlItext __result_ = T_FunctionBindings_vOut58 _lhsOtext in __result_ ) in C_FunctionBindings_s59 v58 {-# INLINE rule132 #-} rule132 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_FunctionBindings_Nil #-} sem_FunctionBindings_Nil :: T_FunctionBindings sem_FunctionBindings_Nil = T_FunctionBindings (return st59) where {-# NOINLINE st59 #-} st59 = let v58 :: T_FunctionBindings_v58 v58 = \ (T_FunctionBindings_vIn58 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule133 () __result_ = T_FunctionBindings_vOut58 _lhsOtext in __result_ ) in C_FunctionBindings_s59 v58 {-# INLINE rule133 #-} rule133 = \ (_ :: ()) -> [] -- GuardedExpression ------------------------------------------- -- wrapper data Inh_GuardedExpression = Inh_GuardedExpression { } data Syn_GuardedExpression = Syn_GuardedExpression { text_Syn_GuardedExpression :: ( Doc -> Doc ) } {-# INLINABLE wrap_GuardedExpression #-} wrap_GuardedExpression :: T_GuardedExpression -> Inh_GuardedExpression -> (Syn_GuardedExpression ) wrap_GuardedExpression (T_GuardedExpression act) (Inh_GuardedExpression ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg61 = T_GuardedExpression_vIn61 (T_GuardedExpression_vOut61 _lhsOtext) <- return (inv_GuardedExpression_s62 sem arg61) return (Syn_GuardedExpression _lhsOtext) ) -- cata {-# NOINLINE sem_GuardedExpression #-} sem_GuardedExpression :: GuardedExpression -> T_GuardedExpression sem_GuardedExpression ( GuardedExpression_GuardedExpression range_ guard_ expression_ ) = sem_GuardedExpression_GuardedExpression ( sem_Range range_ ) ( sem_Expression guard_ ) ( sem_Expression expression_ ) -- semantic domain newtype T_GuardedExpression = T_GuardedExpression { attach_T_GuardedExpression :: Identity (T_GuardedExpression_s62 ) } newtype T_GuardedExpression_s62 = C_GuardedExpression_s62 { inv_GuardedExpression_s62 :: (T_GuardedExpression_v61 ) } data T_GuardedExpression_s63 = C_GuardedExpression_s63 type T_GuardedExpression_v61 = (T_GuardedExpression_vIn61 ) -> (T_GuardedExpression_vOut61 ) data T_GuardedExpression_vIn61 = T_GuardedExpression_vIn61 data T_GuardedExpression_vOut61 = T_GuardedExpression_vOut61 ( Doc -> Doc ) {-# NOINLINE sem_GuardedExpression_GuardedExpression #-} sem_GuardedExpression_GuardedExpression :: T_Range -> T_Expression -> T_Expression -> T_GuardedExpression sem_GuardedExpression_GuardedExpression arg_range_ arg_guard_ arg_expression_ = T_GuardedExpression (return st62) where {-# NOINLINE st62 #-} st62 = let v61 :: T_GuardedExpression_v61 v61 = \ (T_GuardedExpression_vIn61 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _guardX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_guard_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _guardItext) = inv_Expression_s41 _guardX41 (T_Expression_vIn40 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule134 _expressionItext _guardItext _lhsOtext :: Doc -> Doc _lhsOtext = rule135 _text __result_ = T_GuardedExpression_vOut61 _lhsOtext in __result_ ) in C_GuardedExpression_s62 v61 {-# INLINE rule134 #-} rule134 = \ ((_expressionItext) :: Doc) ((_guardItext) :: Doc) -> \assign -> text "|" <+> _guardItext <+> assign <+> _expressionItext {-# INLINE rule135 #-} rule135 = \ _text -> _text -- GuardedExpressions ------------------------------------------ -- wrapper data Inh_GuardedExpressions = Inh_GuardedExpressions { } data Syn_GuardedExpressions = Syn_GuardedExpressions { text_Syn_GuardedExpressions :: ( [ Doc -> Doc ] ) } {-# INLINABLE wrap_GuardedExpressions #-} wrap_GuardedExpressions :: T_GuardedExpressions -> Inh_GuardedExpressions -> (Syn_GuardedExpressions ) wrap_GuardedExpressions (T_GuardedExpressions act) (Inh_GuardedExpressions ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg64 = T_GuardedExpressions_vIn64 (T_GuardedExpressions_vOut64 _lhsOtext) <- return (inv_GuardedExpressions_s65 sem arg64) return (Syn_GuardedExpressions _lhsOtext) ) -- cata {-# NOINLINE sem_GuardedExpressions #-} sem_GuardedExpressions :: GuardedExpressions -> T_GuardedExpressions sem_GuardedExpressions list = Prelude.foldr sem_GuardedExpressions_Cons sem_GuardedExpressions_Nil (Prelude.map sem_GuardedExpression list) -- semantic domain newtype T_GuardedExpressions = T_GuardedExpressions { attach_T_GuardedExpressions :: Identity (T_GuardedExpressions_s65 ) } newtype T_GuardedExpressions_s65 = C_GuardedExpressions_s65 { inv_GuardedExpressions_s65 :: (T_GuardedExpressions_v64 ) } data T_GuardedExpressions_s66 = C_GuardedExpressions_s66 type T_GuardedExpressions_v64 = (T_GuardedExpressions_vIn64 ) -> (T_GuardedExpressions_vOut64 ) data T_GuardedExpressions_vIn64 = T_GuardedExpressions_vIn64 data T_GuardedExpressions_vOut64 = T_GuardedExpressions_vOut64 ( [ Doc -> Doc ] ) {-# NOINLINE sem_GuardedExpressions_Cons #-} sem_GuardedExpressions_Cons :: T_GuardedExpression -> T_GuardedExpressions -> T_GuardedExpressions sem_GuardedExpressions_Cons arg_hd_ arg_tl_ = T_GuardedExpressions (return st65) where {-# NOINLINE st65 #-} st65 = let v64 :: T_GuardedExpressions_v64 v64 = \ (T_GuardedExpressions_vIn64 ) -> ( let _hdX62 = Control.Monad.Identity.runIdentity (attach_T_GuardedExpression (arg_hd_)) _tlX65 = Control.Monad.Identity.runIdentity (attach_T_GuardedExpressions (arg_tl_)) (T_GuardedExpression_vOut61 _hdItext) = inv_GuardedExpression_s62 _hdX62 (T_GuardedExpression_vIn61 ) (T_GuardedExpressions_vOut64 _tlItext) = inv_GuardedExpressions_s65 _tlX65 (T_GuardedExpressions_vIn64 ) _lhsOtext :: [ Doc -> Doc ] _lhsOtext = rule136 _hdItext _tlItext __result_ = T_GuardedExpressions_vOut64 _lhsOtext in __result_ ) in C_GuardedExpressions_s65 v64 {-# INLINE rule136 #-} rule136 = \ ((_hdItext) :: Doc -> Doc ) ((_tlItext) :: [ Doc -> Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_GuardedExpressions_Nil #-} sem_GuardedExpressions_Nil :: T_GuardedExpressions sem_GuardedExpressions_Nil = T_GuardedExpressions (return st65) where {-# NOINLINE st65 #-} st65 = let v64 :: T_GuardedExpressions_v64 v64 = \ (T_GuardedExpressions_vIn64 ) -> ( let _lhsOtext :: [ Doc -> Doc ] _lhsOtext = rule137 () __result_ = T_GuardedExpressions_vOut64 _lhsOtext in __result_ ) in C_GuardedExpressions_s65 v64 {-# INLINE rule137 #-} rule137 = \ (_ :: ()) -> [] -- Import ------------------------------------------------------ -- wrapper data Inh_Import = Inh_Import { } data Syn_Import = Syn_Import { text_Syn_Import :: (Doc) } {-# INLINABLE wrap_Import #-} wrap_Import :: T_Import -> Inh_Import -> (Syn_Import ) wrap_Import (T_Import act) (Inh_Import ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg67 = T_Import_vIn67 (T_Import_vOut67 _lhsOtext) <- return (inv_Import_s68 sem arg67) return (Syn_Import _lhsOtext) ) -- cata {-# NOINLINE sem_Import #-} sem_Import :: Import -> T_Import sem_Import ( Import_Variable range_ name_ ) = sem_Import_Variable ( sem_Range range_ ) ( sem_Name name_ ) sem_Import ( Import_TypeOrClass range_ name_ names_ ) = sem_Import_TypeOrClass ( sem_Range range_ ) ( sem_Name name_ ) ( sem_MaybeNames names_ ) sem_Import ( Import_TypeOrClassComplete range_ name_ ) = sem_Import_TypeOrClassComplete ( sem_Range range_ ) ( sem_Name name_ ) -- semantic domain newtype T_Import = T_Import { attach_T_Import :: Identity (T_Import_s68 ) } newtype T_Import_s68 = C_Import_s68 { inv_Import_s68 :: (T_Import_v67 ) } data T_Import_s69 = C_Import_s69 type T_Import_v67 = (T_Import_vIn67 ) -> (T_Import_vOut67 ) data T_Import_vIn67 = T_Import_vIn67 data T_Import_vOut67 = T_Import_vOut67 (Doc) {-# NOINLINE sem_Import_Variable #-} sem_Import_Variable :: T_Range -> T_Name -> T_Import sem_Import_Variable arg_range_ arg_name_ = T_Import (return st68) where {-# NOINLINE st68 #-} st68 = let v67 :: T_Import_v67 v67 = \ (T_Import_vIn67 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule138 _nameItext _lhsOtext :: Doc _lhsOtext = rule139 _text __result_ = T_Import_vOut67 _lhsOtext in __result_ ) in C_Import_s68 v67 {-# INLINE rule138 #-} rule138 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule139 #-} rule139 = \ _text -> _text {-# NOINLINE sem_Import_TypeOrClass #-} sem_Import_TypeOrClass :: T_Range -> T_Name -> T_MaybeNames -> T_Import sem_Import_TypeOrClass arg_range_ arg_name_ arg_names_ = T_Import (return st68) where {-# NOINLINE st68 #-} st68 = let v67 :: T_Import_v67 v67 = \ (T_Import_vIn67 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _namesX107 = Control.Monad.Identity.runIdentity (attach_T_MaybeNames (arg_names_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_MaybeNames_vOut106 _namesItext) = inv_MaybeNames_s107 _namesX107 (T_MaybeNames_vIn106 ) _text = rule140 _nameItext _namesItext _lhsOtext :: Doc _lhsOtext = rule141 _text __result_ = T_Import_vOut67 _lhsOtext in __result_ ) in C_Import_s68 v67 {-# INLINE rule140 #-} rule140 = \ ((_nameItext) :: Doc) ((_namesItext) :: Maybe [ Doc ] ) -> _nameItext <> maybe empty tupled1 _namesItext {-# INLINE rule141 #-} rule141 = \ _text -> _text {-# NOINLINE sem_Import_TypeOrClassComplete #-} sem_Import_TypeOrClassComplete :: T_Range -> T_Name -> T_Import sem_Import_TypeOrClassComplete arg_range_ arg_name_ = T_Import (return st68) where {-# NOINLINE st68 #-} st68 = let v67 :: T_Import_v67 v67 = \ (T_Import_vIn67 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule142 _nameItext _lhsOtext :: Doc _lhsOtext = rule143 _text __result_ = T_Import_vOut67 _lhsOtext in __result_ ) in C_Import_s68 v67 {-# INLINE rule142 #-} rule142 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule143 #-} rule143 = \ _text -> _text -- ImportDeclaration ------------------------------------------- -- wrapper data Inh_ImportDeclaration = Inh_ImportDeclaration { } data Syn_ImportDeclaration = Syn_ImportDeclaration { text_Syn_ImportDeclaration :: (Doc) } {-# INLINABLE wrap_ImportDeclaration #-} wrap_ImportDeclaration :: T_ImportDeclaration -> Inh_ImportDeclaration -> (Syn_ImportDeclaration ) wrap_ImportDeclaration (T_ImportDeclaration act) (Inh_ImportDeclaration ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg70 = T_ImportDeclaration_vIn70 (T_ImportDeclaration_vOut70 _lhsOtext) <- return (inv_ImportDeclaration_s71 sem arg70) return (Syn_ImportDeclaration _lhsOtext) ) -- cata {-# NOINLINE sem_ImportDeclaration #-} sem_ImportDeclaration :: ImportDeclaration -> T_ImportDeclaration sem_ImportDeclaration ( ImportDeclaration_Import range_ qualified_ name_ asname_ importspecification_ ) = sem_ImportDeclaration_Import ( sem_Range range_ ) qualified_ ( sem_Name name_ ) ( sem_MaybeName asname_ ) ( sem_MaybeImportSpecification importspecification_ ) sem_ImportDeclaration ( ImportDeclaration_Empty range_ ) = sem_ImportDeclaration_Empty ( sem_Range range_ ) -- semantic domain newtype T_ImportDeclaration = T_ImportDeclaration { attach_T_ImportDeclaration :: Identity (T_ImportDeclaration_s71 ) } newtype T_ImportDeclaration_s71 = C_ImportDeclaration_s71 { inv_ImportDeclaration_s71 :: (T_ImportDeclaration_v70 ) } data T_ImportDeclaration_s72 = C_ImportDeclaration_s72 type T_ImportDeclaration_v70 = (T_ImportDeclaration_vIn70 ) -> (T_ImportDeclaration_vOut70 ) data T_ImportDeclaration_vIn70 = T_ImportDeclaration_vIn70 data T_ImportDeclaration_vOut70 = T_ImportDeclaration_vOut70 (Doc) {-# NOINLINE sem_ImportDeclaration_Import #-} sem_ImportDeclaration_Import :: T_Range -> (Bool) -> T_Name -> T_MaybeName -> T_MaybeImportSpecification -> T_ImportDeclaration sem_ImportDeclaration_Import arg_range_ arg_qualified_ arg_name_ arg_asname_ arg_importspecification_ = T_ImportDeclaration (return st71) where {-# NOINLINE st71 #-} st71 = let v70 :: T_ImportDeclaration_v70 v70 = \ (T_ImportDeclaration_vIn70 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _asnameX104 = Control.Monad.Identity.runIdentity (attach_T_MaybeName (arg_asname_)) _importspecificationX98 = Control.Monad.Identity.runIdentity (attach_T_MaybeImportSpecification (arg_importspecification_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_MaybeName_vOut103 _asnameItext) = inv_MaybeName_s104 _asnameX104 (T_MaybeName_vIn103 ) (T_MaybeImportSpecification_vOut97 _importspecificationItext) = inv_MaybeImportSpecification_s98 _importspecificationX98 (T_MaybeImportSpecification_vIn97 ) _text = rule144 _importspecificationItext _nameItext arg_qualified_ _lhsOtext :: Doc _lhsOtext = rule145 _text __result_ = T_ImportDeclaration_vOut70 _lhsOtext in __result_ ) in C_ImportDeclaration_s71 v70 {-# INLINE rule144 #-} rule144 = \ ((_importspecificationItext) :: Maybe Doc ) ((_nameItext) :: Doc) qualified_ -> text "import" <+> (if qualified_ then (text "qualified" <+>) else id) _nameItext <+> maybe empty id _importspecificationItext {-# INLINE rule145 #-} rule145 = \ _text -> _text {-# NOINLINE sem_ImportDeclaration_Empty #-} sem_ImportDeclaration_Empty :: T_Range -> T_ImportDeclaration sem_ImportDeclaration_Empty arg_range_ = T_ImportDeclaration (return st71) where {-# NOINLINE st71 #-} st71 = let v70 :: T_ImportDeclaration_v70 v70 = \ (T_ImportDeclaration_vIn70 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule146 () _lhsOtext :: Doc _lhsOtext = rule147 _text __result_ = T_ImportDeclaration_vOut70 _lhsOtext in __result_ ) in C_ImportDeclaration_s71 v70 {-# INLINE rule146 #-} rule146 = \ (_ :: ()) -> empty {-# INLINE rule147 #-} rule147 = \ _text -> _text -- ImportDeclarations ------------------------------------------ -- wrapper data Inh_ImportDeclarations = Inh_ImportDeclarations { } data Syn_ImportDeclarations = Syn_ImportDeclarations { text_Syn_ImportDeclarations :: ( [ Doc ] ) } {-# INLINABLE wrap_ImportDeclarations #-} wrap_ImportDeclarations :: T_ImportDeclarations -> Inh_ImportDeclarations -> (Syn_ImportDeclarations ) wrap_ImportDeclarations (T_ImportDeclarations act) (Inh_ImportDeclarations ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg73 = T_ImportDeclarations_vIn73 (T_ImportDeclarations_vOut73 _lhsOtext) <- return (inv_ImportDeclarations_s74 sem arg73) return (Syn_ImportDeclarations _lhsOtext) ) -- cata {-# NOINLINE sem_ImportDeclarations #-} sem_ImportDeclarations :: ImportDeclarations -> T_ImportDeclarations sem_ImportDeclarations list = Prelude.foldr sem_ImportDeclarations_Cons sem_ImportDeclarations_Nil (Prelude.map sem_ImportDeclaration list) -- semantic domain newtype T_ImportDeclarations = T_ImportDeclarations { attach_T_ImportDeclarations :: Identity (T_ImportDeclarations_s74 ) } newtype T_ImportDeclarations_s74 = C_ImportDeclarations_s74 { inv_ImportDeclarations_s74 :: (T_ImportDeclarations_v73 ) } data T_ImportDeclarations_s75 = C_ImportDeclarations_s75 type T_ImportDeclarations_v73 = (T_ImportDeclarations_vIn73 ) -> (T_ImportDeclarations_vOut73 ) data T_ImportDeclarations_vIn73 = T_ImportDeclarations_vIn73 data T_ImportDeclarations_vOut73 = T_ImportDeclarations_vOut73 ( [ Doc ] ) {-# NOINLINE sem_ImportDeclarations_Cons #-} sem_ImportDeclarations_Cons :: T_ImportDeclaration -> T_ImportDeclarations -> T_ImportDeclarations sem_ImportDeclarations_Cons arg_hd_ arg_tl_ = T_ImportDeclarations (return st74) where {-# NOINLINE st74 #-} st74 = let v73 :: T_ImportDeclarations_v73 v73 = \ (T_ImportDeclarations_vIn73 ) -> ( let _hdX71 = Control.Monad.Identity.runIdentity (attach_T_ImportDeclaration (arg_hd_)) _tlX74 = Control.Monad.Identity.runIdentity (attach_T_ImportDeclarations (arg_tl_)) (T_ImportDeclaration_vOut70 _hdItext) = inv_ImportDeclaration_s71 _hdX71 (T_ImportDeclaration_vIn70 ) (T_ImportDeclarations_vOut73 _tlItext) = inv_ImportDeclarations_s74 _tlX74 (T_ImportDeclarations_vIn73 ) _lhsOtext :: [ Doc ] _lhsOtext = rule148 _hdItext _tlItext __result_ = T_ImportDeclarations_vOut73 _lhsOtext in __result_ ) in C_ImportDeclarations_s74 v73 {-# INLINE rule148 #-} rule148 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_ImportDeclarations_Nil #-} sem_ImportDeclarations_Nil :: T_ImportDeclarations sem_ImportDeclarations_Nil = T_ImportDeclarations (return st74) where {-# NOINLINE st74 #-} st74 = let v73 :: T_ImportDeclarations_v73 v73 = \ (T_ImportDeclarations_vIn73 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule149 () __result_ = T_ImportDeclarations_vOut73 _lhsOtext in __result_ ) in C_ImportDeclarations_s74 v73 {-# INLINE rule149 #-} rule149 = \ (_ :: ()) -> [] -- ImportSpecification ----------------------------------------- -- wrapper data Inh_ImportSpecification = Inh_ImportSpecification { } data Syn_ImportSpecification = Syn_ImportSpecification { text_Syn_ImportSpecification :: (Doc) } {-# INLINABLE wrap_ImportSpecification #-} wrap_ImportSpecification :: T_ImportSpecification -> Inh_ImportSpecification -> (Syn_ImportSpecification ) wrap_ImportSpecification (T_ImportSpecification act) (Inh_ImportSpecification ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg76 = T_ImportSpecification_vIn76 (T_ImportSpecification_vOut76 _lhsOtext) <- return (inv_ImportSpecification_s77 sem arg76) return (Syn_ImportSpecification _lhsOtext) ) -- cata {-# INLINE sem_ImportSpecification #-} sem_ImportSpecification :: ImportSpecification -> T_ImportSpecification sem_ImportSpecification ( ImportSpecification_Import range_ hiding_ imports_ ) = sem_ImportSpecification_Import ( sem_Range range_ ) hiding_ ( sem_Imports imports_ ) -- semantic domain newtype T_ImportSpecification = T_ImportSpecification { attach_T_ImportSpecification :: Identity (T_ImportSpecification_s77 ) } newtype T_ImportSpecification_s77 = C_ImportSpecification_s77 { inv_ImportSpecification_s77 :: (T_ImportSpecification_v76 ) } data T_ImportSpecification_s78 = C_ImportSpecification_s78 type T_ImportSpecification_v76 = (T_ImportSpecification_vIn76 ) -> (T_ImportSpecification_vOut76 ) data T_ImportSpecification_vIn76 = T_ImportSpecification_vIn76 data T_ImportSpecification_vOut76 = T_ImportSpecification_vOut76 (Doc) {-# NOINLINE sem_ImportSpecification_Import #-} sem_ImportSpecification_Import :: T_Range -> (Bool) -> T_Imports -> T_ImportSpecification sem_ImportSpecification_Import arg_range_ arg_hiding_ arg_imports_ = T_ImportSpecification (return st77) where {-# NOINLINE st77 #-} st77 = let v76 :: T_ImportSpecification_v76 v76 = \ (T_ImportSpecification_vIn76 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _importsX80 = Control.Monad.Identity.runIdentity (attach_T_Imports (arg_imports_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Imports_vOut79 _importsItext) = inv_Imports_s80 _importsX80 (T_Imports_vIn79 ) _text = rule150 _importsItext arg_hiding_ _lhsOtext :: Doc _lhsOtext = rule151 _text __result_ = T_ImportSpecification_vOut76 _lhsOtext in __result_ ) in C_ImportSpecification_s77 v76 {-# INLINE rule150 #-} rule150 = \ ((_importsItext) :: [ Doc ] ) hiding_ -> (if hiding_ then (text "hiding" <+>) else id) (tupled _importsItext) {-# INLINE rule151 #-} rule151 = \ _text -> _text -- Imports ----------------------------------------------------- -- wrapper data Inh_Imports = Inh_Imports { } data Syn_Imports = Syn_Imports { text_Syn_Imports :: ( [ Doc ] ) } {-# INLINABLE wrap_Imports #-} wrap_Imports :: T_Imports -> Inh_Imports -> (Syn_Imports ) wrap_Imports (T_Imports act) (Inh_Imports ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg79 = T_Imports_vIn79 (T_Imports_vOut79 _lhsOtext) <- return (inv_Imports_s80 sem arg79) return (Syn_Imports _lhsOtext) ) -- cata {-# NOINLINE sem_Imports #-} sem_Imports :: Imports -> T_Imports sem_Imports list = Prelude.foldr sem_Imports_Cons sem_Imports_Nil (Prelude.map sem_Import list) -- semantic domain newtype T_Imports = T_Imports { attach_T_Imports :: Identity (T_Imports_s80 ) } newtype T_Imports_s80 = C_Imports_s80 { inv_Imports_s80 :: (T_Imports_v79 ) } data T_Imports_s81 = C_Imports_s81 type T_Imports_v79 = (T_Imports_vIn79 ) -> (T_Imports_vOut79 ) data T_Imports_vIn79 = T_Imports_vIn79 data T_Imports_vOut79 = T_Imports_vOut79 ( [ Doc ] ) {-# NOINLINE sem_Imports_Cons #-} sem_Imports_Cons :: T_Import -> T_Imports -> T_Imports sem_Imports_Cons arg_hd_ arg_tl_ = T_Imports (return st80) where {-# NOINLINE st80 #-} st80 = let v79 :: T_Imports_v79 v79 = \ (T_Imports_vIn79 ) -> ( let _hdX68 = Control.Monad.Identity.runIdentity (attach_T_Import (arg_hd_)) _tlX80 = Control.Monad.Identity.runIdentity (attach_T_Imports (arg_tl_)) (T_Import_vOut67 _hdItext) = inv_Import_s68 _hdX68 (T_Import_vIn67 ) (T_Imports_vOut79 _tlItext) = inv_Imports_s80 _tlX80 (T_Imports_vIn79 ) _lhsOtext :: [ Doc ] _lhsOtext = rule152 _hdItext _tlItext __result_ = T_Imports_vOut79 _lhsOtext in __result_ ) in C_Imports_s80 v79 {-# INLINE rule152 #-} rule152 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Imports_Nil #-} sem_Imports_Nil :: T_Imports sem_Imports_Nil = T_Imports (return st80) where {-# NOINLINE st80 #-} st80 = let v79 :: T_Imports_v79 v79 = \ (T_Imports_vIn79 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule153 () __result_ = T_Imports_vOut79 _lhsOtext in __result_ ) in C_Imports_s80 v79 {-# INLINE rule153 #-} rule153 = \ (_ :: ()) -> [] -- LeftHandSide ------------------------------------------------ -- wrapper data Inh_LeftHandSide = Inh_LeftHandSide { } data Syn_LeftHandSide = Syn_LeftHandSide { text_Syn_LeftHandSide :: (Doc) } {-# INLINABLE wrap_LeftHandSide #-} wrap_LeftHandSide :: T_LeftHandSide -> Inh_LeftHandSide -> (Syn_LeftHandSide ) wrap_LeftHandSide (T_LeftHandSide act) (Inh_LeftHandSide ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg82 = T_LeftHandSide_vIn82 (T_LeftHandSide_vOut82 _lhsOtext) <- return (inv_LeftHandSide_s83 sem arg82) return (Syn_LeftHandSide _lhsOtext) ) -- cata {-# NOINLINE sem_LeftHandSide #-} sem_LeftHandSide :: LeftHandSide -> T_LeftHandSide sem_LeftHandSide ( LeftHandSide_Function range_ name_ patterns_ ) = sem_LeftHandSide_Function ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Patterns patterns_ ) sem_LeftHandSide ( LeftHandSide_Infix range_ leftPattern_ operator_ rightPattern_ ) = sem_LeftHandSide_Infix ( sem_Range range_ ) ( sem_Pattern leftPattern_ ) ( sem_Name operator_ ) ( sem_Pattern rightPattern_ ) sem_LeftHandSide ( LeftHandSide_Parenthesized range_ lefthandside_ patterns_ ) = sem_LeftHandSide_Parenthesized ( sem_Range range_ ) ( sem_LeftHandSide lefthandside_ ) ( sem_Patterns patterns_ ) -- semantic domain newtype T_LeftHandSide = T_LeftHandSide { attach_T_LeftHandSide :: Identity (T_LeftHandSide_s83 ) } newtype T_LeftHandSide_s83 = C_LeftHandSide_s83 { inv_LeftHandSide_s83 :: (T_LeftHandSide_v82 ) } data T_LeftHandSide_s84 = C_LeftHandSide_s84 type T_LeftHandSide_v82 = (T_LeftHandSide_vIn82 ) -> (T_LeftHandSide_vOut82 ) data T_LeftHandSide_vIn82 = T_LeftHandSide_vIn82 data T_LeftHandSide_vOut82 = T_LeftHandSide_vOut82 (Doc) {-# NOINLINE sem_LeftHandSide_Function #-} sem_LeftHandSide_Function :: T_Range -> T_Name -> T_Patterns -> T_LeftHandSide sem_LeftHandSide_Function arg_range_ arg_name_ arg_patterns_ = T_LeftHandSide (return st83) where {-# NOINLINE st83 #-} st83 = let v82 :: T_LeftHandSide_v82 v82 = \ (T_LeftHandSide_vIn82 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Patterns_vOut121 _patternsItext) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 ) _text = rule154 _nameIisOperator _nameItext _patternsItext _lhsOtext :: Doc _lhsOtext = rule155 _text __result_ = T_LeftHandSide_vOut82 _lhsOtext in __result_ ) in C_LeftHandSide_s83 v82 {-# INLINE rule154 #-} rule154 = \ ((_nameIisOperator) :: Bool) ((_nameItext) :: Doc) ((_patternsItext) :: [ Doc ] ) -> foldl (<+>) (parensIf _nameIisOperator _nameItext) _patternsItext {-# INLINE rule155 #-} rule155 = \ _text -> _text {-# NOINLINE sem_LeftHandSide_Infix #-} sem_LeftHandSide_Infix :: T_Range -> T_Pattern -> T_Name -> T_Pattern -> T_LeftHandSide sem_LeftHandSide_Infix arg_range_ arg_leftPattern_ arg_operator_ arg_rightPattern_ = T_LeftHandSide (return st83) where {-# NOINLINE st83 #-} st83 = let v82 :: T_LeftHandSide_v82 v82 = \ (T_LeftHandSide_vIn82 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _leftPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_leftPattern_)) _operatorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_operator_)) _rightPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_rightPattern_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _leftPatternItext) = inv_Pattern_s119 _leftPatternX119 (T_Pattern_vIn118 ) (T_Name_vOut112 _operatorIisIdentifier _operatorIisOperator _operatorIisSpecial _operatorItext) = inv_Name_s113 _operatorX113 (T_Name_vIn112 ) (T_Pattern_vOut118 _rightPatternItext) = inv_Pattern_s119 _rightPatternX119 (T_Pattern_vIn118 ) _text = rule156 _leftPatternItext _operatorIisOperator _operatorItext _rightPatternItext _lhsOtext :: Doc _lhsOtext = rule157 _text __result_ = T_LeftHandSide_vOut82 _lhsOtext in __result_ ) in C_LeftHandSide_s83 v82 {-# INLINE rule156 #-} rule156 = \ ((_leftPatternItext) :: Doc) ((_operatorIisOperator) :: Bool) ((_operatorItext) :: Doc) ((_rightPatternItext) :: Doc) -> _leftPatternItext <+> backQuotesIf (not _operatorIisOperator) _operatorItext <+> _rightPatternItext {-# INLINE rule157 #-} rule157 = \ _text -> _text {-# NOINLINE sem_LeftHandSide_Parenthesized #-} sem_LeftHandSide_Parenthesized :: T_Range -> T_LeftHandSide -> T_Patterns -> T_LeftHandSide sem_LeftHandSide_Parenthesized arg_range_ arg_lefthandside_ arg_patterns_ = T_LeftHandSide (return st83) where {-# NOINLINE st83 #-} st83 = let v82 :: T_LeftHandSide_v82 v82 = \ (T_LeftHandSide_vIn82 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _lefthandsideX83 = Control.Monad.Identity.runIdentity (attach_T_LeftHandSide (arg_lefthandside_)) _patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_LeftHandSide_vOut82 _lefthandsideItext) = inv_LeftHandSide_s83 _lefthandsideX83 (T_LeftHandSide_vIn82 ) (T_Patterns_vOut121 _patternsItext) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 ) _text = rule158 _lefthandsideItext _patternsItext _lhsOtext :: Doc _lhsOtext = rule159 _text __result_ = T_LeftHandSide_vOut82 _lhsOtext in __result_ ) in C_LeftHandSide_s83 v82 {-# INLINE rule158 #-} rule158 = \ ((_lefthandsideItext) :: Doc) ((_patternsItext) :: [ Doc ] ) -> foldl (<+>) (parens _lefthandsideItext) _patternsItext {-# INLINE rule159 #-} rule159 = \ _text -> _text -- Literal ----------------------------------------------------- -- wrapper data Inh_Literal = Inh_Literal { } data Syn_Literal = Syn_Literal { text_Syn_Literal :: (Doc) } {-# INLINABLE wrap_Literal #-} wrap_Literal :: T_Literal -> Inh_Literal -> (Syn_Literal ) wrap_Literal (T_Literal act) (Inh_Literal ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg85 = T_Literal_vIn85 (T_Literal_vOut85 _lhsOtext) <- return (inv_Literal_s86 sem arg85) return (Syn_Literal _lhsOtext) ) -- cata {-# NOINLINE sem_Literal #-} sem_Literal :: Literal -> T_Literal sem_Literal ( Literal_Int range_ value_ ) = sem_Literal_Int ( sem_Range range_ ) value_ sem_Literal ( Literal_Char range_ value_ ) = sem_Literal_Char ( sem_Range range_ ) value_ sem_Literal ( Literal_Float range_ value_ ) = sem_Literal_Float ( sem_Range range_ ) value_ sem_Literal ( Literal_String range_ value_ ) = sem_Literal_String ( sem_Range range_ ) value_ -- semantic domain newtype T_Literal = T_Literal { attach_T_Literal :: Identity (T_Literal_s86 ) } newtype T_Literal_s86 = C_Literal_s86 { inv_Literal_s86 :: (T_Literal_v85 ) } data T_Literal_s87 = C_Literal_s87 type T_Literal_v85 = (T_Literal_vIn85 ) -> (T_Literal_vOut85 ) data T_Literal_vIn85 = T_Literal_vIn85 data T_Literal_vOut85 = T_Literal_vOut85 (Doc) {-# NOINLINE sem_Literal_Int #-} sem_Literal_Int :: T_Range -> (String) -> T_Literal sem_Literal_Int arg_range_ arg_value_ = T_Literal (return st86) where {-# NOINLINE st86 #-} st86 = let v85 :: T_Literal_v85 v85 = \ (T_Literal_vIn85 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule160 arg_value_ _lhsOtext :: Doc _lhsOtext = rule161 _text __result_ = T_Literal_vOut85 _lhsOtext in __result_ ) in C_Literal_s86 v85 {-# INLINE rule160 #-} rule160 = \ value_ -> text value_ {-# INLINE rule161 #-} rule161 = \ _text -> _text {-# NOINLINE sem_Literal_Char #-} sem_Literal_Char :: T_Range -> (String) -> T_Literal sem_Literal_Char arg_range_ arg_value_ = T_Literal (return st86) where {-# NOINLINE st86 #-} st86 = let v85 :: T_Literal_v85 v85 = \ (T_Literal_vIn85 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule162 arg_value_ _lhsOtext :: Doc _lhsOtext = rule163 _text __result_ = T_Literal_vOut85 _lhsOtext in __result_ ) in C_Literal_s86 v85 {-# INLINE rule162 #-} rule162 = \ value_ -> text ("'" ++ value_ ++ "'") {-# INLINE rule163 #-} rule163 = \ _text -> _text {-# NOINLINE sem_Literal_Float #-} sem_Literal_Float :: T_Range -> (String) -> T_Literal sem_Literal_Float arg_range_ arg_value_ = T_Literal (return st86) where {-# NOINLINE st86 #-} st86 = let v85 :: T_Literal_v85 v85 = \ (T_Literal_vIn85 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule164 arg_value_ _lhsOtext :: Doc _lhsOtext = rule165 _text __result_ = T_Literal_vOut85 _lhsOtext in __result_ ) in C_Literal_s86 v85 {-# INLINE rule164 #-} rule164 = \ value_ -> text value_ {-# INLINE rule165 #-} rule165 = \ _text -> _text {-# NOINLINE sem_Literal_String #-} sem_Literal_String :: T_Range -> (String) -> T_Literal sem_Literal_String arg_range_ arg_value_ = T_Literal (return st86) where {-# NOINLINE st86 #-} st86 = let v85 :: T_Literal_v85 v85 = \ (T_Literal_vIn85 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule166 arg_value_ _lhsOtext :: Doc _lhsOtext = rule167 _text __result_ = T_Literal_vOut85 _lhsOtext in __result_ ) in C_Literal_s86 v85 {-# INLINE rule166 #-} rule166 = \ value_ -> text ("\"" ++ value_ ++ "\"") {-# INLINE rule167 #-} rule167 = \ _text -> _text -- MaybeDeclarations ------------------------------------------- -- wrapper data Inh_MaybeDeclarations = Inh_MaybeDeclarations { } data Syn_MaybeDeclarations = Syn_MaybeDeclarations { text_Syn_MaybeDeclarations :: ( Maybe [ Doc ] ) } {-# INLINABLE wrap_MaybeDeclarations #-} wrap_MaybeDeclarations :: T_MaybeDeclarations -> Inh_MaybeDeclarations -> (Syn_MaybeDeclarations ) wrap_MaybeDeclarations (T_MaybeDeclarations act) (Inh_MaybeDeclarations ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg88 = T_MaybeDeclarations_vIn88 (T_MaybeDeclarations_vOut88 _lhsOtext) <- return (inv_MaybeDeclarations_s89 sem arg88) return (Syn_MaybeDeclarations _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeDeclarations #-} sem_MaybeDeclarations :: MaybeDeclarations -> T_MaybeDeclarations sem_MaybeDeclarations ( MaybeDeclarations_Nothing ) = sem_MaybeDeclarations_Nothing sem_MaybeDeclarations ( MaybeDeclarations_Just declarations_ ) = sem_MaybeDeclarations_Just ( sem_Declarations declarations_ ) -- semantic domain newtype T_MaybeDeclarations = T_MaybeDeclarations { attach_T_MaybeDeclarations :: Identity (T_MaybeDeclarations_s89 ) } newtype T_MaybeDeclarations_s89 = C_MaybeDeclarations_s89 { inv_MaybeDeclarations_s89 :: (T_MaybeDeclarations_v88 ) } data T_MaybeDeclarations_s90 = C_MaybeDeclarations_s90 type T_MaybeDeclarations_v88 = (T_MaybeDeclarations_vIn88 ) -> (T_MaybeDeclarations_vOut88 ) data T_MaybeDeclarations_vIn88 = T_MaybeDeclarations_vIn88 data T_MaybeDeclarations_vOut88 = T_MaybeDeclarations_vOut88 ( Maybe [ Doc ] ) {-# NOINLINE sem_MaybeDeclarations_Nothing #-} sem_MaybeDeclarations_Nothing :: T_MaybeDeclarations sem_MaybeDeclarations_Nothing = T_MaybeDeclarations (return st89) where {-# NOINLINE st89 #-} st89 = let v88 :: T_MaybeDeclarations_v88 v88 = \ (T_MaybeDeclarations_vIn88 ) -> ( let _text = rule168 () _lhsOtext :: Maybe [ Doc ] _lhsOtext = rule169 _text __result_ = T_MaybeDeclarations_vOut88 _lhsOtext in __result_ ) in C_MaybeDeclarations_s89 v88 {-# INLINE rule168 #-} rule168 = \ (_ :: ()) -> Nothing {-# INLINE rule169 #-} rule169 = \ _text -> _text {-# NOINLINE sem_MaybeDeclarations_Just #-} sem_MaybeDeclarations_Just :: T_Declarations -> T_MaybeDeclarations sem_MaybeDeclarations_Just arg_declarations_ = T_MaybeDeclarations (return st89) where {-# NOINLINE st89 #-} st89 = let v88 :: T_MaybeDeclarations_v88 v88 = \ (T_MaybeDeclarations_vIn88 ) -> ( let _declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_)) (T_Declarations_vOut31 _declarationsItext) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 ) _text = rule170 _declarationsItext _lhsOtext :: Maybe [ Doc ] _lhsOtext = rule171 _text __result_ = T_MaybeDeclarations_vOut88 _lhsOtext in __result_ ) in C_MaybeDeclarations_s89 v88 {-# INLINE rule170 #-} rule170 = \ ((_declarationsItext) :: [ Doc ] ) -> case filter ((/= "") . show) _declarationsItext of [] -> Nothing xs -> Just xs {-# INLINE rule171 #-} rule171 = \ _text -> _text -- MaybeExports ------------------------------------------------ -- wrapper data Inh_MaybeExports = Inh_MaybeExports { } data Syn_MaybeExports = Syn_MaybeExports { text_Syn_MaybeExports :: ( Maybe [ Doc ] ) } {-# INLINABLE wrap_MaybeExports #-} wrap_MaybeExports :: T_MaybeExports -> Inh_MaybeExports -> (Syn_MaybeExports ) wrap_MaybeExports (T_MaybeExports act) (Inh_MaybeExports ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg91 = T_MaybeExports_vIn91 (T_MaybeExports_vOut91 _lhsOtext) <- return (inv_MaybeExports_s92 sem arg91) return (Syn_MaybeExports _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeExports #-} sem_MaybeExports :: MaybeExports -> T_MaybeExports sem_MaybeExports ( MaybeExports_Nothing ) = sem_MaybeExports_Nothing sem_MaybeExports ( MaybeExports_Just exports_ ) = sem_MaybeExports_Just ( sem_Exports exports_ ) -- semantic domain newtype T_MaybeExports = T_MaybeExports { attach_T_MaybeExports :: Identity (T_MaybeExports_s92 ) } newtype T_MaybeExports_s92 = C_MaybeExports_s92 { inv_MaybeExports_s92 :: (T_MaybeExports_v91 ) } data T_MaybeExports_s93 = C_MaybeExports_s93 type T_MaybeExports_v91 = (T_MaybeExports_vIn91 ) -> (T_MaybeExports_vOut91 ) data T_MaybeExports_vIn91 = T_MaybeExports_vIn91 data T_MaybeExports_vOut91 = T_MaybeExports_vOut91 ( Maybe [ Doc ] ) {-# NOINLINE sem_MaybeExports_Nothing #-} sem_MaybeExports_Nothing :: T_MaybeExports sem_MaybeExports_Nothing = T_MaybeExports (return st92) where {-# NOINLINE st92 #-} st92 = let v91 :: T_MaybeExports_v91 v91 = \ (T_MaybeExports_vIn91 ) -> ( let _text = rule172 () _lhsOtext :: Maybe [ Doc ] _lhsOtext = rule173 _text __result_ = T_MaybeExports_vOut91 _lhsOtext in __result_ ) in C_MaybeExports_s92 v91 {-# INLINE rule172 #-} rule172 = \ (_ :: ()) -> Nothing {-# INLINE rule173 #-} rule173 = \ _text -> _text {-# NOINLINE sem_MaybeExports_Just #-} sem_MaybeExports_Just :: T_Exports -> T_MaybeExports sem_MaybeExports_Just arg_exports_ = T_MaybeExports (return st92) where {-# NOINLINE st92 #-} st92 = let v91 :: T_MaybeExports_v91 v91 = \ (T_MaybeExports_vIn91 ) -> ( let _exportsX38 = Control.Monad.Identity.runIdentity (attach_T_Exports (arg_exports_)) (T_Exports_vOut37 _exportsItext) = inv_Exports_s38 _exportsX38 (T_Exports_vIn37 ) _text = rule174 _exportsItext _lhsOtext :: Maybe [ Doc ] _lhsOtext = rule175 _text __result_ = T_MaybeExports_vOut91 _lhsOtext in __result_ ) in C_MaybeExports_s92 v91 {-# INLINE rule174 #-} rule174 = \ ((_exportsItext) :: [ Doc ] ) -> Just _exportsItext {-# INLINE rule175 #-} rule175 = \ _text -> _text -- MaybeExpression --------------------------------------------- -- wrapper data Inh_MaybeExpression = Inh_MaybeExpression { } data Syn_MaybeExpression = Syn_MaybeExpression { text_Syn_MaybeExpression :: ( Maybe Doc ) } {-# INLINABLE wrap_MaybeExpression #-} wrap_MaybeExpression :: T_MaybeExpression -> Inh_MaybeExpression -> (Syn_MaybeExpression ) wrap_MaybeExpression (T_MaybeExpression act) (Inh_MaybeExpression ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg94 = T_MaybeExpression_vIn94 (T_MaybeExpression_vOut94 _lhsOtext) <- return (inv_MaybeExpression_s95 sem arg94) return (Syn_MaybeExpression _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeExpression #-} sem_MaybeExpression :: MaybeExpression -> T_MaybeExpression sem_MaybeExpression ( MaybeExpression_Nothing ) = sem_MaybeExpression_Nothing sem_MaybeExpression ( MaybeExpression_Just expression_ ) = sem_MaybeExpression_Just ( sem_Expression expression_ ) -- semantic domain newtype T_MaybeExpression = T_MaybeExpression { attach_T_MaybeExpression :: Identity (T_MaybeExpression_s95 ) } newtype T_MaybeExpression_s95 = C_MaybeExpression_s95 { inv_MaybeExpression_s95 :: (T_MaybeExpression_v94 ) } data T_MaybeExpression_s96 = C_MaybeExpression_s96 type T_MaybeExpression_v94 = (T_MaybeExpression_vIn94 ) -> (T_MaybeExpression_vOut94 ) data T_MaybeExpression_vIn94 = T_MaybeExpression_vIn94 data T_MaybeExpression_vOut94 = T_MaybeExpression_vOut94 ( Maybe Doc ) {-# NOINLINE sem_MaybeExpression_Nothing #-} sem_MaybeExpression_Nothing :: T_MaybeExpression sem_MaybeExpression_Nothing = T_MaybeExpression (return st95) where {-# NOINLINE st95 #-} st95 = let v94 :: T_MaybeExpression_v94 v94 = \ (T_MaybeExpression_vIn94 ) -> ( let _text = rule176 () _lhsOtext :: Maybe Doc _lhsOtext = rule177 _text __result_ = T_MaybeExpression_vOut94 _lhsOtext in __result_ ) in C_MaybeExpression_s95 v94 {-# INLINE rule176 #-} rule176 = \ (_ :: ()) -> Nothing {-# INLINE rule177 #-} rule177 = \ _text -> _text {-# NOINLINE sem_MaybeExpression_Just #-} sem_MaybeExpression_Just :: T_Expression -> T_MaybeExpression sem_MaybeExpression_Just arg_expression_ = T_MaybeExpression (return st95) where {-# NOINLINE st95 #-} st95 = let v94 :: T_MaybeExpression_v94 v94 = \ (T_MaybeExpression_vIn94 ) -> ( let _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule178 _expressionItext _lhsOtext :: Maybe Doc _lhsOtext = rule179 _text __result_ = T_MaybeExpression_vOut94 _lhsOtext in __result_ ) in C_MaybeExpression_s95 v94 {-# INLINE rule178 #-} rule178 = \ ((_expressionItext) :: Doc) -> Just _expressionItext {-# INLINE rule179 #-} rule179 = \ _text -> _text -- MaybeImportSpecification ------------------------------------ -- wrapper data Inh_MaybeImportSpecification = Inh_MaybeImportSpecification { } data Syn_MaybeImportSpecification = Syn_MaybeImportSpecification { text_Syn_MaybeImportSpecification :: ( Maybe Doc ) } {-# INLINABLE wrap_MaybeImportSpecification #-} wrap_MaybeImportSpecification :: T_MaybeImportSpecification -> Inh_MaybeImportSpecification -> (Syn_MaybeImportSpecification ) wrap_MaybeImportSpecification (T_MaybeImportSpecification act) (Inh_MaybeImportSpecification ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg97 = T_MaybeImportSpecification_vIn97 (T_MaybeImportSpecification_vOut97 _lhsOtext) <- return (inv_MaybeImportSpecification_s98 sem arg97) return (Syn_MaybeImportSpecification _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeImportSpecification #-} sem_MaybeImportSpecification :: MaybeImportSpecification -> T_MaybeImportSpecification sem_MaybeImportSpecification ( MaybeImportSpecification_Nothing ) = sem_MaybeImportSpecification_Nothing sem_MaybeImportSpecification ( MaybeImportSpecification_Just importspecification_ ) = sem_MaybeImportSpecification_Just ( sem_ImportSpecification importspecification_ ) -- semantic domain newtype T_MaybeImportSpecification = T_MaybeImportSpecification { attach_T_MaybeImportSpecification :: Identity (T_MaybeImportSpecification_s98 ) } newtype T_MaybeImportSpecification_s98 = C_MaybeImportSpecification_s98 { inv_MaybeImportSpecification_s98 :: (T_MaybeImportSpecification_v97 ) } data T_MaybeImportSpecification_s99 = C_MaybeImportSpecification_s99 type T_MaybeImportSpecification_v97 = (T_MaybeImportSpecification_vIn97 ) -> (T_MaybeImportSpecification_vOut97 ) data T_MaybeImportSpecification_vIn97 = T_MaybeImportSpecification_vIn97 data T_MaybeImportSpecification_vOut97 = T_MaybeImportSpecification_vOut97 ( Maybe Doc ) {-# NOINLINE sem_MaybeImportSpecification_Nothing #-} sem_MaybeImportSpecification_Nothing :: T_MaybeImportSpecification sem_MaybeImportSpecification_Nothing = T_MaybeImportSpecification (return st98) where {-# NOINLINE st98 #-} st98 = let v97 :: T_MaybeImportSpecification_v97 v97 = \ (T_MaybeImportSpecification_vIn97 ) -> ( let _text = rule180 () _lhsOtext :: Maybe Doc _lhsOtext = rule181 _text __result_ = T_MaybeImportSpecification_vOut97 _lhsOtext in __result_ ) in C_MaybeImportSpecification_s98 v97 {-# INLINE rule180 #-} rule180 = \ (_ :: ()) -> Nothing {-# INLINE rule181 #-} rule181 = \ _text -> _text {-# NOINLINE sem_MaybeImportSpecification_Just #-} sem_MaybeImportSpecification_Just :: T_ImportSpecification -> T_MaybeImportSpecification sem_MaybeImportSpecification_Just arg_importspecification_ = T_MaybeImportSpecification (return st98) where {-# NOINLINE st98 #-} st98 = let v97 :: T_MaybeImportSpecification_v97 v97 = \ (T_MaybeImportSpecification_vIn97 ) -> ( let _importspecificationX77 = Control.Monad.Identity.runIdentity (attach_T_ImportSpecification (arg_importspecification_)) (T_ImportSpecification_vOut76 _importspecificationItext) = inv_ImportSpecification_s77 _importspecificationX77 (T_ImportSpecification_vIn76 ) _text = rule182 _importspecificationItext _lhsOtext :: Maybe Doc _lhsOtext = rule183 _text __result_ = T_MaybeImportSpecification_vOut97 _lhsOtext in __result_ ) in C_MaybeImportSpecification_s98 v97 {-# INLINE rule182 #-} rule182 = \ ((_importspecificationItext) :: Doc) -> Just _importspecificationItext {-# INLINE rule183 #-} rule183 = \ _text -> _text -- MaybeInt ---------------------------------------------------- -- wrapper data Inh_MaybeInt = Inh_MaybeInt { } data Syn_MaybeInt = Syn_MaybeInt { text_Syn_MaybeInt :: ( Maybe Doc ) } {-# INLINABLE wrap_MaybeInt #-} wrap_MaybeInt :: T_MaybeInt -> Inh_MaybeInt -> (Syn_MaybeInt ) wrap_MaybeInt (T_MaybeInt act) (Inh_MaybeInt ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg100 = T_MaybeInt_vIn100 (T_MaybeInt_vOut100 _lhsOtext) <- return (inv_MaybeInt_s101 sem arg100) return (Syn_MaybeInt _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeInt #-} sem_MaybeInt :: MaybeInt -> T_MaybeInt sem_MaybeInt ( MaybeInt_Nothing ) = sem_MaybeInt_Nothing sem_MaybeInt ( MaybeInt_Just int_ ) = sem_MaybeInt_Just int_ -- semantic domain newtype T_MaybeInt = T_MaybeInt { attach_T_MaybeInt :: Identity (T_MaybeInt_s101 ) } newtype T_MaybeInt_s101 = C_MaybeInt_s101 { inv_MaybeInt_s101 :: (T_MaybeInt_v100 ) } data T_MaybeInt_s102 = C_MaybeInt_s102 type T_MaybeInt_v100 = (T_MaybeInt_vIn100 ) -> (T_MaybeInt_vOut100 ) data T_MaybeInt_vIn100 = T_MaybeInt_vIn100 data T_MaybeInt_vOut100 = T_MaybeInt_vOut100 ( Maybe Doc ) {-# NOINLINE sem_MaybeInt_Nothing #-} sem_MaybeInt_Nothing :: T_MaybeInt sem_MaybeInt_Nothing = T_MaybeInt (return st101) where {-# NOINLINE st101 #-} st101 = let v100 :: T_MaybeInt_v100 v100 = \ (T_MaybeInt_vIn100 ) -> ( let _text = rule184 () _lhsOtext :: Maybe Doc _lhsOtext = rule185 _text __result_ = T_MaybeInt_vOut100 _lhsOtext in __result_ ) in C_MaybeInt_s101 v100 {-# INLINE rule184 #-} rule184 = \ (_ :: ()) -> Nothing {-# INLINE rule185 #-} rule185 = \ _text -> _text {-# NOINLINE sem_MaybeInt_Just #-} sem_MaybeInt_Just :: (Int) -> T_MaybeInt sem_MaybeInt_Just arg_int_ = T_MaybeInt (return st101) where {-# NOINLINE st101 #-} st101 = let v100 :: T_MaybeInt_v100 v100 = \ (T_MaybeInt_vIn100 ) -> ( let _text = rule186 arg_int_ _lhsOtext :: Maybe Doc _lhsOtext = rule187 _text __result_ = T_MaybeInt_vOut100 _lhsOtext in __result_ ) in C_MaybeInt_s101 v100 {-# INLINE rule186 #-} rule186 = \ int_ -> Just (int int_) {-# INLINE rule187 #-} rule187 = \ _text -> _text -- MaybeName --------------------------------------------------- -- wrapper data Inh_MaybeName = Inh_MaybeName { } data Syn_MaybeName = Syn_MaybeName { text_Syn_MaybeName :: ( Maybe Doc ) } {-# INLINABLE wrap_MaybeName #-} wrap_MaybeName :: T_MaybeName -> Inh_MaybeName -> (Syn_MaybeName ) wrap_MaybeName (T_MaybeName act) (Inh_MaybeName ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg103 = T_MaybeName_vIn103 (T_MaybeName_vOut103 _lhsOtext) <- return (inv_MaybeName_s104 sem arg103) return (Syn_MaybeName _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeName #-} sem_MaybeName :: MaybeName -> T_MaybeName sem_MaybeName ( MaybeName_Nothing ) = sem_MaybeName_Nothing sem_MaybeName ( MaybeName_Just name_ ) = sem_MaybeName_Just ( sem_Name name_ ) -- semantic domain newtype T_MaybeName = T_MaybeName { attach_T_MaybeName :: Identity (T_MaybeName_s104 ) } newtype T_MaybeName_s104 = C_MaybeName_s104 { inv_MaybeName_s104 :: (T_MaybeName_v103 ) } data T_MaybeName_s105 = C_MaybeName_s105 type T_MaybeName_v103 = (T_MaybeName_vIn103 ) -> (T_MaybeName_vOut103 ) data T_MaybeName_vIn103 = T_MaybeName_vIn103 data T_MaybeName_vOut103 = T_MaybeName_vOut103 ( Maybe Doc ) {-# NOINLINE sem_MaybeName_Nothing #-} sem_MaybeName_Nothing :: T_MaybeName sem_MaybeName_Nothing = T_MaybeName (return st104) where {-# NOINLINE st104 #-} st104 = let v103 :: T_MaybeName_v103 v103 = \ (T_MaybeName_vIn103 ) -> ( let _text = rule188 () _lhsOtext :: Maybe Doc _lhsOtext = rule189 _text __result_ = T_MaybeName_vOut103 _lhsOtext in __result_ ) in C_MaybeName_s104 v103 {-# INLINE rule188 #-} rule188 = \ (_ :: ()) -> Nothing {-# INLINE rule189 #-} rule189 = \ _text -> _text {-# NOINLINE sem_MaybeName_Just #-} sem_MaybeName_Just :: T_Name -> T_MaybeName sem_MaybeName_Just arg_name_ = T_MaybeName (return st104) where {-# NOINLINE st104 #-} st104 = let v103 :: T_MaybeName_v103 v103 = \ (T_MaybeName_vIn103 ) -> ( let _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule190 _nameItext _lhsOtext :: Maybe Doc _lhsOtext = rule191 _text __result_ = T_MaybeName_vOut103 _lhsOtext in __result_ ) in C_MaybeName_s104 v103 {-# INLINE rule190 #-} rule190 = \ ((_nameItext) :: Doc) -> Just _nameItext {-# INLINE rule191 #-} rule191 = \ _text -> _text -- MaybeNames -------------------------------------------------- -- wrapper data Inh_MaybeNames = Inh_MaybeNames { } data Syn_MaybeNames = Syn_MaybeNames { text_Syn_MaybeNames :: ( Maybe [ Doc ] ) } {-# INLINABLE wrap_MaybeNames #-} wrap_MaybeNames :: T_MaybeNames -> Inh_MaybeNames -> (Syn_MaybeNames ) wrap_MaybeNames (T_MaybeNames act) (Inh_MaybeNames ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg106 = T_MaybeNames_vIn106 (T_MaybeNames_vOut106 _lhsOtext) <- return (inv_MaybeNames_s107 sem arg106) return (Syn_MaybeNames _lhsOtext) ) -- cata {-# NOINLINE sem_MaybeNames #-} sem_MaybeNames :: MaybeNames -> T_MaybeNames sem_MaybeNames ( MaybeNames_Nothing ) = sem_MaybeNames_Nothing sem_MaybeNames ( MaybeNames_Just names_ ) = sem_MaybeNames_Just ( sem_Names names_ ) -- semantic domain newtype T_MaybeNames = T_MaybeNames { attach_T_MaybeNames :: Identity (T_MaybeNames_s107 ) } newtype T_MaybeNames_s107 = C_MaybeNames_s107 { inv_MaybeNames_s107 :: (T_MaybeNames_v106 ) } data T_MaybeNames_s108 = C_MaybeNames_s108 type T_MaybeNames_v106 = (T_MaybeNames_vIn106 ) -> (T_MaybeNames_vOut106 ) data T_MaybeNames_vIn106 = T_MaybeNames_vIn106 data T_MaybeNames_vOut106 = T_MaybeNames_vOut106 ( Maybe [ Doc ] ) {-# NOINLINE sem_MaybeNames_Nothing #-} sem_MaybeNames_Nothing :: T_MaybeNames sem_MaybeNames_Nothing = T_MaybeNames (return st107) where {-# NOINLINE st107 #-} st107 = let v106 :: T_MaybeNames_v106 v106 = \ (T_MaybeNames_vIn106 ) -> ( let _text = rule192 () _lhsOtext :: Maybe [ Doc ] _lhsOtext = rule193 _text __result_ = T_MaybeNames_vOut106 _lhsOtext in __result_ ) in C_MaybeNames_s107 v106 {-# INLINE rule192 #-} rule192 = \ (_ :: ()) -> Nothing {-# INLINE rule193 #-} rule193 = \ _text -> _text {-# NOINLINE sem_MaybeNames_Just #-} sem_MaybeNames_Just :: T_Names -> T_MaybeNames sem_MaybeNames_Just arg_names_ = T_MaybeNames (return st107) where {-# NOINLINE st107 #-} st107 = let v106 :: T_MaybeNames_v106 v106 = \ (T_MaybeNames_vIn106 ) -> ( let _namesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_names_)) (T_Names_vOut115 _namesIisIdentifier _namesIisOperator _namesIisSpecial _namesItext) = inv_Names_s116 _namesX116 (T_Names_vIn115 ) _text = rule194 _namesItext _lhsOtext :: Maybe [ Doc ] _lhsOtext = rule195 _text __result_ = T_MaybeNames_vOut106 _lhsOtext in __result_ ) in C_MaybeNames_s107 v106 {-# INLINE rule194 #-} rule194 = \ ((_namesItext) :: [ Doc ] ) -> Just _namesItext {-# INLINE rule195 #-} rule195 = \ _text -> _text -- Module ------------------------------------------------------ -- wrapper data Inh_Module = Inh_Module { } data Syn_Module = Syn_Module { text_Syn_Module :: (Doc) } {-# INLINABLE wrap_Module #-} wrap_Module :: T_Module -> Inh_Module -> (Syn_Module ) wrap_Module (T_Module act) (Inh_Module ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg109 = T_Module_vIn109 (T_Module_vOut109 _lhsOtext) <- return (inv_Module_s110 sem arg109) return (Syn_Module _lhsOtext) ) -- cata {-# INLINE sem_Module #-} sem_Module :: Module -> T_Module sem_Module ( Module_Module range_ name_ exports_ body_ ) = sem_Module_Module ( sem_Range range_ ) ( sem_MaybeName name_ ) ( sem_MaybeExports exports_ ) ( sem_Body body_ ) -- semantic domain newtype T_Module = T_Module { attach_T_Module :: Identity (T_Module_s110 ) } newtype T_Module_s110 = C_Module_s110 { inv_Module_s110 :: (T_Module_v109 ) } data T_Module_s111 = C_Module_s111 type T_Module_v109 = (T_Module_vIn109 ) -> (T_Module_vOut109 ) data T_Module_vIn109 = T_Module_vIn109 data T_Module_vOut109 = T_Module_vOut109 (Doc) {-# NOINLINE sem_Module_Module #-} sem_Module_Module :: T_Range -> T_MaybeName -> T_MaybeExports -> T_Body -> T_Module sem_Module_Module arg_range_ arg_name_ arg_exports_ arg_body_ = T_Module (return st110) where {-# NOINLINE st110 #-} st110 = let v109 :: T_Module_v109 v109 = \ (T_Module_vIn109 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX104 = Control.Monad.Identity.runIdentity (attach_T_MaybeName (arg_name_)) _exportsX92 = Control.Monad.Identity.runIdentity (attach_T_MaybeExports (arg_exports_)) _bodyX14 = Control.Monad.Identity.runIdentity (attach_T_Body (arg_body_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_MaybeName_vOut103 _nameItext) = inv_MaybeName_s104 _nameX104 (T_MaybeName_vIn103 ) (T_MaybeExports_vOut91 _exportsItext) = inv_MaybeExports_s92 _exportsX92 (T_MaybeExports_vIn91 ) (T_Body_vOut13 _bodyItext) = inv_Body_s14 _bodyX14 (T_Body_vIn13 ) _text = rule196 _bodyItext _exportsItext _nameItext _lhsOtext :: Doc _lhsOtext = rule197 _text __result_ = T_Module_vOut109 _lhsOtext in __result_ ) in C_Module_s110 v109 {-# INLINE rule196 #-} rule196 = \ ((_bodyItext) :: Doc) ((_exportsItext) :: Maybe [ Doc ] ) ((_nameItext) :: Maybe Doc ) -> maybe id ( \name body -> text "module" <+> name <+> (maybe (text "where") (\x -> indent 4 (utrechtList (text "(") (text ")") x <+> text "where")) _exportsItext ) <$> empty <$> body ) _nameItext _bodyItext {-# INLINE rule197 #-} rule197 = \ _text -> _text -- Name -------------------------------------------------------- -- wrapper data Inh_Name = Inh_Name { } data Syn_Name = Syn_Name { isIdentifier_Syn_Name :: (Bool), isOperator_Syn_Name :: (Bool), isSpecial_Syn_Name :: (Bool), text_Syn_Name :: (Doc) } {-# INLINABLE wrap_Name #-} wrap_Name :: T_Name -> Inh_Name -> (Syn_Name ) wrap_Name (T_Name act) (Inh_Name ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg112 = T_Name_vIn112 (T_Name_vOut112 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext) <- return (inv_Name_s113 sem arg112) return (Syn_Name _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext) ) -- cata {-# NOINLINE sem_Name #-} sem_Name :: Name -> T_Name sem_Name ( Name_Identifier range_ module_ name_ ) = sem_Name_Identifier ( sem_Range range_ ) ( sem_Strings module_ ) name_ sem_Name ( Name_Operator range_ module_ name_ ) = sem_Name_Operator ( sem_Range range_ ) ( sem_Strings module_ ) name_ sem_Name ( Name_Special range_ module_ name_ ) = sem_Name_Special ( sem_Range range_ ) ( sem_Strings module_ ) name_ -- semantic domain newtype T_Name = T_Name { attach_T_Name :: Identity (T_Name_s113 ) } newtype T_Name_s113 = C_Name_s113 { inv_Name_s113 :: (T_Name_v112 ) } data T_Name_s114 = C_Name_s114 type T_Name_v112 = (T_Name_vIn112 ) -> (T_Name_vOut112 ) data T_Name_vIn112 = T_Name_vIn112 data T_Name_vOut112 = T_Name_vOut112 (Bool) (Bool) (Bool) (Doc) {-# NOINLINE sem_Name_Identifier #-} sem_Name_Identifier :: T_Range -> T_Strings -> (String) -> T_Name sem_Name_Identifier arg_range_ arg_module_ arg_name_ = T_Name (return st113) where {-# NOINLINE st113 #-} st113 = let v112 :: T_Name_v112 v112 = \ (T_Name_vIn112 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _moduleX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_module_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Strings_vOut160 _moduleItext) = inv_Strings_s161 _moduleX161 (T_Strings_vIn160 ) _text = rule198 arg_name_ _lhsOisIdentifier :: Bool _lhsOisIdentifier = rule199 () _lhsOisOperator :: Bool _lhsOisOperator = rule200 () _lhsOisSpecial :: Bool _lhsOisSpecial = rule201 () _lhsOtext :: Doc _lhsOtext = rule202 _text __result_ = T_Name_vOut112 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext in __result_ ) in C_Name_s113 v112 {-# INLINE rule198 #-} rule198 = \ name_ -> text name_ {-# INLINE rule199 #-} rule199 = \ (_ :: ()) -> True {-# INLINE rule200 #-} rule200 = \ (_ :: ()) -> False {-# INLINE rule201 #-} rule201 = \ (_ :: ()) -> False {-# INLINE rule202 #-} rule202 = \ _text -> _text {-# NOINLINE sem_Name_Operator #-} sem_Name_Operator :: T_Range -> T_Strings -> (String) -> T_Name sem_Name_Operator arg_range_ arg_module_ arg_name_ = T_Name (return st113) where {-# NOINLINE st113 #-} st113 = let v112 :: T_Name_v112 v112 = \ (T_Name_vIn112 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _moduleX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_module_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Strings_vOut160 _moduleItext) = inv_Strings_s161 _moduleX161 (T_Strings_vIn160 ) _text = rule203 arg_name_ _lhsOisOperator :: Bool _lhsOisOperator = rule204 () _lhsOisIdentifier :: Bool _lhsOisIdentifier = rule205 () _lhsOisSpecial :: Bool _lhsOisSpecial = rule206 () _lhsOtext :: Doc _lhsOtext = rule207 _text __result_ = T_Name_vOut112 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext in __result_ ) in C_Name_s113 v112 {-# INLINE rule203 #-} rule203 = \ name_ -> text name_ {-# INLINE rule204 #-} rule204 = \ (_ :: ()) -> True {-# INLINE rule205 #-} rule205 = \ (_ :: ()) -> False {-# INLINE rule206 #-} rule206 = \ (_ :: ()) -> False {-# INLINE rule207 #-} rule207 = \ _text -> _text {-# NOINLINE sem_Name_Special #-} sem_Name_Special :: T_Range -> T_Strings -> (String) -> T_Name sem_Name_Special arg_range_ arg_module_ arg_name_ = T_Name (return st113) where {-# NOINLINE st113 #-} st113 = let v112 :: T_Name_v112 v112 = \ (T_Name_vIn112 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _moduleX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_module_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Strings_vOut160 _moduleItext) = inv_Strings_s161 _moduleX161 (T_Strings_vIn160 ) _text = rule208 arg_name_ _lhsOisSpecial :: Bool _lhsOisSpecial = rule209 () _lhsOisIdentifier :: Bool _lhsOisIdentifier = rule210 () _lhsOisOperator :: Bool _lhsOisOperator = rule211 () _lhsOtext :: Doc _lhsOtext = rule212 _text __result_ = T_Name_vOut112 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext in __result_ ) in C_Name_s113 v112 {-# INLINE rule208 #-} rule208 = \ name_ -> text name_ {-# INLINE rule209 #-} rule209 = \ (_ :: ()) -> True {-# INLINE rule210 #-} rule210 = \ (_ :: ()) -> False {-# INLINE rule211 #-} rule211 = \ (_ :: ()) -> False {-# INLINE rule212 #-} rule212 = \ _text -> _text -- Names ------------------------------------------------------- -- wrapper data Inh_Names = Inh_Names { } data Syn_Names = Syn_Names { isIdentifier_Syn_Names :: ( [Bool] ), isOperator_Syn_Names :: ( [Bool] ), isSpecial_Syn_Names :: ( [Bool] ), text_Syn_Names :: ( [ Doc ] ) } {-# INLINABLE wrap_Names #-} wrap_Names :: T_Names -> Inh_Names -> (Syn_Names ) wrap_Names (T_Names act) (Inh_Names ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg115 = T_Names_vIn115 (T_Names_vOut115 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext) <- return (inv_Names_s116 sem arg115) return (Syn_Names _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext) ) -- cata {-# NOINLINE sem_Names #-} sem_Names :: Names -> T_Names sem_Names list = Prelude.foldr sem_Names_Cons sem_Names_Nil (Prelude.map sem_Name list) -- semantic domain newtype T_Names = T_Names { attach_T_Names :: Identity (T_Names_s116 ) } newtype T_Names_s116 = C_Names_s116 { inv_Names_s116 :: (T_Names_v115 ) } data T_Names_s117 = C_Names_s117 type T_Names_v115 = (T_Names_vIn115 ) -> (T_Names_vOut115 ) data T_Names_vIn115 = T_Names_vIn115 data T_Names_vOut115 = T_Names_vOut115 ( [Bool] ) ( [Bool] ) ( [Bool] ) ( [ Doc ] ) {-# NOINLINE sem_Names_Cons #-} sem_Names_Cons :: T_Name -> T_Names -> T_Names sem_Names_Cons arg_hd_ arg_tl_ = T_Names (return st116) where {-# NOINLINE st116 #-} st116 = let v115 :: T_Names_v115 v115 = \ (T_Names_vIn115 ) -> ( let _hdX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_hd_)) _tlX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_tl_)) (T_Name_vOut112 _hdIisIdentifier _hdIisOperator _hdIisSpecial _hdItext) = inv_Name_s113 _hdX113 (T_Name_vIn112 ) (T_Names_vOut115 _tlIisIdentifier _tlIisOperator _tlIisSpecial _tlItext) = inv_Names_s116 _tlX116 (T_Names_vIn115 ) _lhsOisIdentifier :: [Bool] _lhsOisIdentifier = rule213 _hdIisIdentifier _tlIisIdentifier _lhsOisOperator :: [Bool] _lhsOisOperator = rule214 _hdIisOperator _tlIisOperator _lhsOisSpecial :: [Bool] _lhsOisSpecial = rule215 _hdIisSpecial _tlIisSpecial _lhsOtext :: [ Doc ] _lhsOtext = rule216 _hdItext _tlItext __result_ = T_Names_vOut115 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext in __result_ ) in C_Names_s116 v115 {-# INLINE rule213 #-} rule213 = \ ((_hdIisIdentifier) :: Bool) ((_tlIisIdentifier) :: [Bool] ) -> _hdIisIdentifier : _tlIisIdentifier {-# INLINE rule214 #-} rule214 = \ ((_hdIisOperator) :: Bool) ((_tlIisOperator) :: [Bool] ) -> _hdIisOperator : _tlIisOperator {-# INLINE rule215 #-} rule215 = \ ((_hdIisSpecial) :: Bool) ((_tlIisSpecial) :: [Bool] ) -> _hdIisSpecial : _tlIisSpecial {-# INLINE rule216 #-} rule216 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Names_Nil #-} sem_Names_Nil :: T_Names sem_Names_Nil = T_Names (return st116) where {-# NOINLINE st116 #-} st116 = let v115 :: T_Names_v115 v115 = \ (T_Names_vIn115 ) -> ( let _lhsOisIdentifier :: [Bool] _lhsOisIdentifier = rule217 () _lhsOisOperator :: [Bool] _lhsOisOperator = rule218 () _lhsOisSpecial :: [Bool] _lhsOisSpecial = rule219 () _lhsOtext :: [ Doc ] _lhsOtext = rule220 () __result_ = T_Names_vOut115 _lhsOisIdentifier _lhsOisOperator _lhsOisSpecial _lhsOtext in __result_ ) in C_Names_s116 v115 {-# INLINE rule217 #-} rule217 = \ (_ :: ()) -> [] {-# INLINE rule218 #-} rule218 = \ (_ :: ()) -> [] {-# INLINE rule219 #-} rule219 = \ (_ :: ()) -> [] {-# INLINE rule220 #-} rule220 = \ (_ :: ()) -> [] -- Pattern ----------------------------------------------------- -- wrapper data Inh_Pattern = Inh_Pattern { } data Syn_Pattern = Syn_Pattern { text_Syn_Pattern :: (Doc) } {-# INLINABLE wrap_Pattern #-} wrap_Pattern :: T_Pattern -> Inh_Pattern -> (Syn_Pattern ) wrap_Pattern (T_Pattern act) (Inh_Pattern ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg118 = T_Pattern_vIn118 (T_Pattern_vOut118 _lhsOtext) <- return (inv_Pattern_s119 sem arg118) return (Syn_Pattern _lhsOtext) ) -- cata {-# NOINLINE sem_Pattern #-} sem_Pattern :: Pattern -> T_Pattern sem_Pattern ( Pattern_Hole range_ id_ ) = sem_Pattern_Hole ( sem_Range range_ ) id_ sem_Pattern ( Pattern_Literal range_ literal_ ) = sem_Pattern_Literal ( sem_Range range_ ) ( sem_Literal literal_ ) sem_Pattern ( Pattern_Variable range_ name_ ) = sem_Pattern_Variable ( sem_Range range_ ) ( sem_Name name_ ) sem_Pattern ( Pattern_Constructor range_ name_ patterns_ ) = sem_Pattern_Constructor ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Patterns patterns_ ) sem_Pattern ( Pattern_Parenthesized range_ pattern_ ) = sem_Pattern_Parenthesized ( sem_Range range_ ) ( sem_Pattern pattern_ ) sem_Pattern ( Pattern_InfixConstructor range_ leftPattern_ constructorOperator_ rightPattern_ ) = sem_Pattern_InfixConstructor ( sem_Range range_ ) ( sem_Pattern leftPattern_ ) ( sem_Name constructorOperator_ ) ( sem_Pattern rightPattern_ ) sem_Pattern ( Pattern_List range_ patterns_ ) = sem_Pattern_List ( sem_Range range_ ) ( sem_Patterns patterns_ ) sem_Pattern ( Pattern_Tuple range_ patterns_ ) = sem_Pattern_Tuple ( sem_Range range_ ) ( sem_Patterns patterns_ ) sem_Pattern ( Pattern_Record range_ name_ recordPatternBindings_ ) = sem_Pattern_Record ( sem_Range range_ ) ( sem_Name name_ ) ( sem_RecordPatternBindings recordPatternBindings_ ) sem_Pattern ( Pattern_Negate range_ literal_ ) = sem_Pattern_Negate ( sem_Range range_ ) ( sem_Literal literal_ ) sem_Pattern ( Pattern_As range_ name_ pattern_ ) = sem_Pattern_As ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Pattern pattern_ ) sem_Pattern ( Pattern_Wildcard range_ ) = sem_Pattern_Wildcard ( sem_Range range_ ) sem_Pattern ( Pattern_Irrefutable range_ pattern_ ) = sem_Pattern_Irrefutable ( sem_Range range_ ) ( sem_Pattern pattern_ ) sem_Pattern ( Pattern_Successor range_ name_ literal_ ) = sem_Pattern_Successor ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Literal literal_ ) sem_Pattern ( Pattern_NegateFloat range_ literal_ ) = sem_Pattern_NegateFloat ( sem_Range range_ ) ( sem_Literal literal_ ) -- semantic domain newtype T_Pattern = T_Pattern { attach_T_Pattern :: Identity (T_Pattern_s119 ) } newtype T_Pattern_s119 = C_Pattern_s119 { inv_Pattern_s119 :: (T_Pattern_v118 ) } data T_Pattern_s120 = C_Pattern_s120 type T_Pattern_v118 = (T_Pattern_vIn118 ) -> (T_Pattern_vOut118 ) data T_Pattern_vIn118 = T_Pattern_vIn118 data T_Pattern_vOut118 = T_Pattern_vOut118 (Doc) {-# NOINLINE sem_Pattern_Hole #-} sem_Pattern_Hole :: T_Range -> (Integer) -> T_Pattern sem_Pattern_Hole arg_range_ _ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule221 () _lhsOtext :: Doc _lhsOtext = rule222 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule221 #-} rule221 = \ (_ :: ()) -> text hole {-# INLINE rule222 #-} rule222 = \ _text -> _text {-# NOINLINE sem_Pattern_Literal #-} sem_Pattern_Literal :: T_Range -> T_Literal -> T_Pattern sem_Pattern_Literal arg_range_ arg_literal_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Literal_vOut85 _literalItext) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 ) _text = rule223 _literalItext _lhsOtext :: Doc _lhsOtext = rule224 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule223 #-} rule223 = \ ((_literalItext) :: Doc) -> _literalItext {-# INLINE rule224 #-} rule224 = \ _text -> _text {-# NOINLINE sem_Pattern_Variable #-} sem_Pattern_Variable :: T_Range -> T_Name -> T_Pattern sem_Pattern_Variable arg_range_ arg_name_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule225 _nameIisOperator _nameItext _lhsOtext :: Doc _lhsOtext = rule226 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule225 #-} rule225 = \ ((_nameIisOperator) :: Bool) ((_nameItext) :: Doc) -> parensIf _nameIisOperator _nameItext {-# INLINE rule226 #-} rule226 = \ _text -> _text {-# NOINLINE sem_Pattern_Constructor #-} sem_Pattern_Constructor :: T_Range -> T_Name -> T_Patterns -> T_Pattern sem_Pattern_Constructor arg_range_ arg_name_ arg_patterns_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Patterns_vOut121 _patternsItext) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 ) _text = rule227 _nameIisOperator _nameItext _patternsItext _lhsOtext :: Doc _lhsOtext = rule228 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule227 #-} rule227 = \ ((_nameIisOperator) :: Bool) ((_nameItext) :: Doc) ((_patternsItext) :: [ Doc ] ) -> foldl (<+>) (parensIf _nameIisOperator _nameItext) _patternsItext {-# INLINE rule228 #-} rule228 = \ _text -> _text {-# NOINLINE sem_Pattern_Parenthesized #-} sem_Pattern_Parenthesized :: T_Range -> T_Pattern -> T_Pattern sem_Pattern_Parenthesized arg_range_ arg_pattern_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) _text = rule229 _patternItext _lhsOtext :: Doc _lhsOtext = rule230 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule229 #-} rule229 = \ ((_patternItext) :: Doc) -> parens _patternItext {-# INLINE rule230 #-} rule230 = \ _text -> _text {-# NOINLINE sem_Pattern_InfixConstructor #-} sem_Pattern_InfixConstructor :: T_Range -> T_Pattern -> T_Name -> T_Pattern -> T_Pattern sem_Pattern_InfixConstructor arg_range_ arg_leftPattern_ arg_constructorOperator_ arg_rightPattern_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _leftPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_leftPattern_)) _constructorOperatorX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_constructorOperator_)) _rightPatternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_rightPattern_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _leftPatternItext) = inv_Pattern_s119 _leftPatternX119 (T_Pattern_vIn118 ) (T_Name_vOut112 _constructorOperatorIisIdentifier _constructorOperatorIisOperator _constructorOperatorIisSpecial _constructorOperatorItext) = inv_Name_s113 _constructorOperatorX113 (T_Name_vIn112 ) (T_Pattern_vOut118 _rightPatternItext) = inv_Pattern_s119 _rightPatternX119 (T_Pattern_vIn118 ) _text = rule231 _constructorOperatorItext _leftPatternItext _rightPatternItext _lhsOtext :: Doc _lhsOtext = rule232 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule231 #-} rule231 = \ ((_constructorOperatorItext) :: Doc) ((_leftPatternItext) :: Doc) ((_rightPatternItext) :: Doc) -> _leftPatternItext <+> _constructorOperatorItext <+> _rightPatternItext {-# INLINE rule232 #-} rule232 = \ _text -> _text {-# NOINLINE sem_Pattern_List #-} sem_Pattern_List :: T_Range -> T_Patterns -> T_Pattern sem_Pattern_List arg_range_ arg_patterns_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Patterns_vOut121 _patternsItext) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 ) _text = rule233 _patternsItext _lhsOtext :: Doc _lhsOtext = rule234 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule233 #-} rule233 = \ ((_patternsItext) :: [ Doc ] ) -> PPrint.list _patternsItext {-# INLINE rule234 #-} rule234 = \ _text -> _text {-# NOINLINE sem_Pattern_Tuple #-} sem_Pattern_Tuple :: T_Range -> T_Patterns -> T_Pattern sem_Pattern_Tuple arg_range_ arg_patterns_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternsX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_patterns_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Patterns_vOut121 _patternsItext) = inv_Patterns_s122 _patternsX122 (T_Patterns_vIn121 ) _text = rule235 _patternsItext _lhsOtext :: Doc _lhsOtext = rule236 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule235 #-} rule235 = \ ((_patternsItext) :: [ Doc ] ) -> tupled _patternsItext {-# INLINE rule236 #-} rule236 = \ _text -> _text {-# NOINLINE sem_Pattern_Record #-} sem_Pattern_Record :: T_Range -> T_Name -> T_RecordPatternBindings -> T_Pattern sem_Pattern_Record arg_range_ arg_name_ arg_recordPatternBindings_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _recordPatternBindingsX146 = Control.Monad.Identity.runIdentity (attach_T_RecordPatternBindings (arg_recordPatternBindings_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_RecordPatternBindings_vOut145 _recordPatternBindingsItext) = inv_RecordPatternBindings_s146 _recordPatternBindingsX146 (T_RecordPatternBindings_vIn145 ) _text = rule237 () _lhsOtext :: Doc _lhsOtext = rule238 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule237 #-} rule237 = \ (_ :: ()) -> text "{- !!! record pattern -}" {-# INLINE rule238 #-} rule238 = \ _text -> _text {-# NOINLINE sem_Pattern_Negate #-} sem_Pattern_Negate :: T_Range -> T_Literal -> T_Pattern sem_Pattern_Negate arg_range_ arg_literal_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Literal_vOut85 _literalItext) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 ) _text = rule239 _literalItext _lhsOtext :: Doc _lhsOtext = rule240 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule239 #-} rule239 = \ ((_literalItext) :: Doc) -> text "-" <> _literalItext {-# INLINE rule240 #-} rule240 = \ _text -> _text {-# NOINLINE sem_Pattern_As #-} sem_Pattern_As :: T_Range -> T_Name -> T_Pattern -> T_Pattern sem_Pattern_As arg_range_ arg_name_ arg_pattern_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) _text = rule241 _nameItext _patternItext _lhsOtext :: Doc _lhsOtext = rule242 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule241 #-} rule241 = \ ((_nameItext) :: Doc) ((_patternItext) :: Doc) -> _nameItext <> text "@" <> _patternItext {-# INLINE rule242 #-} rule242 = \ _text -> _text {-# NOINLINE sem_Pattern_Wildcard #-} sem_Pattern_Wildcard :: T_Range -> T_Pattern sem_Pattern_Wildcard arg_range_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule243 () _lhsOtext :: Doc _lhsOtext = rule244 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule243 #-} rule243 = \ (_ :: ()) -> text "_" {-# INLINE rule244 #-} rule244 = \ _text -> _text {-# NOINLINE sem_Pattern_Irrefutable #-} sem_Pattern_Irrefutable :: T_Range -> T_Pattern -> T_Pattern sem_Pattern_Irrefutable arg_range_ arg_pattern_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) _text = rule245 _patternItext _lhsOtext :: Doc _lhsOtext = rule246 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule245 #-} rule245 = \ ((_patternItext) :: Doc) -> text "~" <> _patternItext {-# INLINE rule246 #-} rule246 = \ _text -> _text {-# NOINLINE sem_Pattern_Successor #-} sem_Pattern_Successor :: T_Range -> T_Name -> T_Literal -> T_Pattern sem_Pattern_Successor arg_range_ arg_name_ arg_literal_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Literal_vOut85 _literalItext) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 ) _text = rule247 _literalItext _nameItext _lhsOtext :: Doc _lhsOtext = rule248 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule247 #-} rule247 = \ ((_literalItext) :: Doc) ((_nameItext) :: Doc) -> _nameItext <+> text "+" <+> _literalItext {-# INLINE rule248 #-} rule248 = \ _text -> _text {-# NOINLINE sem_Pattern_NegateFloat #-} sem_Pattern_NegateFloat :: T_Range -> T_Literal -> T_Pattern sem_Pattern_NegateFloat arg_range_ arg_literal_ = T_Pattern (return st119) where {-# NOINLINE st119 #-} st119 = let v118 :: T_Pattern_v118 v118 = \ (T_Pattern_vIn118 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _literalX86 = Control.Monad.Identity.runIdentity (attach_T_Literal (arg_literal_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Literal_vOut85 _literalItext) = inv_Literal_s86 _literalX86 (T_Literal_vIn85 ) _text = rule249 _literalItext _lhsOtext :: Doc _lhsOtext = rule250 _text __result_ = T_Pattern_vOut118 _lhsOtext in __result_ ) in C_Pattern_s119 v118 {-# INLINE rule249 #-} rule249 = \ ((_literalItext) :: Doc) -> text "-." <> _literalItext {-# INLINE rule250 #-} rule250 = \ _text -> _text -- Patterns ---------------------------------------------------- -- wrapper data Inh_Patterns = Inh_Patterns { } data Syn_Patterns = Syn_Patterns { text_Syn_Patterns :: ( [ Doc ] ) } {-# INLINABLE wrap_Patterns #-} wrap_Patterns :: T_Patterns -> Inh_Patterns -> (Syn_Patterns ) wrap_Patterns (T_Patterns act) (Inh_Patterns ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg121 = T_Patterns_vIn121 (T_Patterns_vOut121 _lhsOtext) <- return (inv_Patterns_s122 sem arg121) return (Syn_Patterns _lhsOtext) ) -- cata {-# NOINLINE sem_Patterns #-} sem_Patterns :: Patterns -> T_Patterns sem_Patterns list = Prelude.foldr sem_Patterns_Cons sem_Patterns_Nil (Prelude.map sem_Pattern list) -- semantic domain newtype T_Patterns = T_Patterns { attach_T_Patterns :: Identity (T_Patterns_s122 ) } newtype T_Patterns_s122 = C_Patterns_s122 { inv_Patterns_s122 :: (T_Patterns_v121 ) } data T_Patterns_s123 = C_Patterns_s123 type T_Patterns_v121 = (T_Patterns_vIn121 ) -> (T_Patterns_vOut121 ) data T_Patterns_vIn121 = T_Patterns_vIn121 data T_Patterns_vOut121 = T_Patterns_vOut121 ( [ Doc ] ) {-# NOINLINE sem_Patterns_Cons #-} sem_Patterns_Cons :: T_Pattern -> T_Patterns -> T_Patterns sem_Patterns_Cons arg_hd_ arg_tl_ = T_Patterns (return st122) where {-# NOINLINE st122 #-} st122 = let v121 :: T_Patterns_v121 v121 = \ (T_Patterns_vIn121 ) -> ( let _hdX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_hd_)) _tlX122 = Control.Monad.Identity.runIdentity (attach_T_Patterns (arg_tl_)) (T_Pattern_vOut118 _hdItext) = inv_Pattern_s119 _hdX119 (T_Pattern_vIn118 ) (T_Patterns_vOut121 _tlItext) = inv_Patterns_s122 _tlX122 (T_Patterns_vIn121 ) _lhsOtext :: [ Doc ] _lhsOtext = rule251 _hdItext _tlItext __result_ = T_Patterns_vOut121 _lhsOtext in __result_ ) in C_Patterns_s122 v121 {-# INLINE rule251 #-} rule251 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Patterns_Nil #-} sem_Patterns_Nil :: T_Patterns sem_Patterns_Nil = T_Patterns (return st122) where {-# NOINLINE st122 #-} st122 = let v121 :: T_Patterns_v121 v121 = \ (T_Patterns_vIn121 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule252 () __result_ = T_Patterns_vOut121 _lhsOtext in __result_ ) in C_Patterns_s122 v121 {-# INLINE rule252 #-} rule252 = \ (_ :: ()) -> [] -- Position ---------------------------------------------------- -- wrapper data Inh_Position = Inh_Position { } data Syn_Position = Syn_Position { text_Syn_Position :: (Doc) } {-# INLINABLE wrap_Position #-} wrap_Position :: T_Position -> Inh_Position -> (Syn_Position ) wrap_Position (T_Position act) (Inh_Position ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg124 = T_Position_vIn124 (T_Position_vOut124 _lhsOtext) <- return (inv_Position_s125 sem arg124) return (Syn_Position _lhsOtext) ) -- cata {-# NOINLINE sem_Position #-} sem_Position :: Position -> T_Position sem_Position ( Position_Position filename_ line_ column_ ) = sem_Position_Position filename_ line_ column_ sem_Position ( Position_Unknown ) = sem_Position_Unknown -- semantic domain newtype T_Position = T_Position { attach_T_Position :: Identity (T_Position_s125 ) } newtype T_Position_s125 = C_Position_s125 { inv_Position_s125 :: (T_Position_v124 ) } data T_Position_s126 = C_Position_s126 type T_Position_v124 = (T_Position_vIn124 ) -> (T_Position_vOut124 ) data T_Position_vIn124 = T_Position_vIn124 data T_Position_vOut124 = T_Position_vOut124 (Doc) {-# NOINLINE sem_Position_Position #-} sem_Position_Position :: (String) -> (Int) -> (Int) -> T_Position sem_Position_Position arg_filename_ arg_line_ arg_column_ = T_Position (return st125) where {-# NOINLINE st125 #-} st125 = let v124 :: T_Position_v124 v124 = \ (T_Position_vIn124 ) -> ( let _text = rule253 arg_column_ arg_filename_ arg_line_ _lhsOtext :: Doc _lhsOtext = rule254 _text __result_ = T_Position_vOut124 _lhsOtext in __result_ ) in C_Position_s125 v124 {-# INLINE rule253 #-} rule253 = \ column_ filename_ line_ -> text filename_ <> tupled [int line_, int column_] {-# INLINE rule254 #-} rule254 = \ _text -> _text {-# NOINLINE sem_Position_Unknown #-} sem_Position_Unknown :: T_Position sem_Position_Unknown = T_Position (return st125) where {-# NOINLINE st125 #-} st125 = let v124 :: T_Position_v124 v124 = \ (T_Position_vIn124 ) -> ( let _text = rule255 () _lhsOtext :: Doc _lhsOtext = rule256 _text __result_ = T_Position_vOut124 _lhsOtext in __result_ ) in C_Position_s125 v124 {-# INLINE rule255 #-} rule255 = \ (_ :: ()) -> text "Unknown" {-# INLINE rule256 #-} rule256 = \ _text -> _text -- Qualifier --------------------------------------------------- -- wrapper data Inh_Qualifier = Inh_Qualifier { } data Syn_Qualifier = Syn_Qualifier { text_Syn_Qualifier :: (Doc) } {-# INLINABLE wrap_Qualifier #-} wrap_Qualifier :: T_Qualifier -> Inh_Qualifier -> (Syn_Qualifier ) wrap_Qualifier (T_Qualifier act) (Inh_Qualifier ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg127 = T_Qualifier_vIn127 (T_Qualifier_vOut127 _lhsOtext) <- return (inv_Qualifier_s128 sem arg127) return (Syn_Qualifier _lhsOtext) ) -- cata {-# NOINLINE sem_Qualifier #-} sem_Qualifier :: Qualifier -> T_Qualifier sem_Qualifier ( Qualifier_Guard range_ guard_ ) = sem_Qualifier_Guard ( sem_Range range_ ) ( sem_Expression guard_ ) sem_Qualifier ( Qualifier_Let range_ declarations_ ) = sem_Qualifier_Let ( sem_Range range_ ) ( sem_Declarations declarations_ ) sem_Qualifier ( Qualifier_Generator range_ pattern_ expression_ ) = sem_Qualifier_Generator ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_Expression expression_ ) sem_Qualifier ( Qualifier_Empty range_ ) = sem_Qualifier_Empty ( sem_Range range_ ) -- semantic domain newtype T_Qualifier = T_Qualifier { attach_T_Qualifier :: Identity (T_Qualifier_s128 ) } newtype T_Qualifier_s128 = C_Qualifier_s128 { inv_Qualifier_s128 :: (T_Qualifier_v127 ) } data T_Qualifier_s129 = C_Qualifier_s129 type T_Qualifier_v127 = (T_Qualifier_vIn127 ) -> (T_Qualifier_vOut127 ) data T_Qualifier_vIn127 = T_Qualifier_vIn127 data T_Qualifier_vOut127 = T_Qualifier_vOut127 (Doc) {-# NOINLINE sem_Qualifier_Guard #-} sem_Qualifier_Guard :: T_Range -> T_Expression -> T_Qualifier sem_Qualifier_Guard arg_range_ arg_guard_ = T_Qualifier (return st128) where {-# NOINLINE st128 #-} st128 = let v127 :: T_Qualifier_v127 v127 = \ (T_Qualifier_vIn127 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _guardX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_guard_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _guardItext) = inv_Expression_s41 _guardX41 (T_Expression_vIn40 ) _text = rule257 _guardItext _lhsOtext :: Doc _lhsOtext = rule258 _text __result_ = T_Qualifier_vOut127 _lhsOtext in __result_ ) in C_Qualifier_s128 v127 {-# INLINE rule257 #-} rule257 = \ ((_guardItext) :: Doc) -> _guardItext {-# INLINE rule258 #-} rule258 = \ _text -> _text {-# NOINLINE sem_Qualifier_Let #-} sem_Qualifier_Let :: T_Range -> T_Declarations -> T_Qualifier sem_Qualifier_Let arg_range_ arg_declarations_ = T_Qualifier (return st128) where {-# NOINLINE st128 #-} st128 = let v127 :: T_Qualifier_v127 v127 = \ (T_Qualifier_vIn127 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Declarations_vOut31 _declarationsItext) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 ) _text = rule259 _declarationsItext _lhsOtext :: Doc _lhsOtext = rule260 _text __result_ = T_Qualifier_vOut127 _lhsOtext in __result_ ) in C_Qualifier_s128 v127 {-# INLINE rule259 #-} rule259 = \ ((_declarationsItext) :: [ Doc ] ) -> text "let" <$> (indent 4 $ vcat _declarationsItext) {-# INLINE rule260 #-} rule260 = \ _text -> _text {-# NOINLINE sem_Qualifier_Generator #-} sem_Qualifier_Generator :: T_Range -> T_Pattern -> T_Expression -> T_Qualifier sem_Qualifier_Generator arg_range_ arg_pattern_ arg_expression_ = T_Qualifier (return st128) where {-# NOINLINE st128 #-} st128 = let v127 :: T_Qualifier_v127 v127 = \ (T_Qualifier_vIn127 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule261 _expressionItext _patternItext _lhsOtext :: Doc _lhsOtext = rule262 _text __result_ = T_Qualifier_vOut127 _lhsOtext in __result_ ) in C_Qualifier_s128 v127 {-# INLINE rule261 #-} rule261 = \ ((_expressionItext) :: Doc) ((_patternItext) :: Doc) -> _patternItext <+> text "<-" <+> _expressionItext {-# INLINE rule262 #-} rule262 = \ _text -> _text {-# NOINLINE sem_Qualifier_Empty #-} sem_Qualifier_Empty :: T_Range -> T_Qualifier sem_Qualifier_Empty arg_range_ = T_Qualifier (return st128) where {-# NOINLINE st128 #-} st128 = let v127 :: T_Qualifier_v127 v127 = \ (T_Qualifier_vIn127 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule263 () _lhsOtext :: Doc _lhsOtext = rule264 _text __result_ = T_Qualifier_vOut127 _lhsOtext in __result_ ) in C_Qualifier_s128 v127 {-# INLINE rule263 #-} rule263 = \ (_ :: ()) -> empty {-# INLINE rule264 #-} rule264 = \ _text -> _text -- Qualifiers -------------------------------------------------- -- wrapper data Inh_Qualifiers = Inh_Qualifiers { } data Syn_Qualifiers = Syn_Qualifiers { text_Syn_Qualifiers :: ( [ Doc ] ) } {-# INLINABLE wrap_Qualifiers #-} wrap_Qualifiers :: T_Qualifiers -> Inh_Qualifiers -> (Syn_Qualifiers ) wrap_Qualifiers (T_Qualifiers act) (Inh_Qualifiers ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg130 = T_Qualifiers_vIn130 (T_Qualifiers_vOut130 _lhsOtext) <- return (inv_Qualifiers_s131 sem arg130) return (Syn_Qualifiers _lhsOtext) ) -- cata {-# NOINLINE sem_Qualifiers #-} sem_Qualifiers :: Qualifiers -> T_Qualifiers sem_Qualifiers list = Prelude.foldr sem_Qualifiers_Cons sem_Qualifiers_Nil (Prelude.map sem_Qualifier list) -- semantic domain newtype T_Qualifiers = T_Qualifiers { attach_T_Qualifiers :: Identity (T_Qualifiers_s131 ) } newtype T_Qualifiers_s131 = C_Qualifiers_s131 { inv_Qualifiers_s131 :: (T_Qualifiers_v130 ) } data T_Qualifiers_s132 = C_Qualifiers_s132 type T_Qualifiers_v130 = (T_Qualifiers_vIn130 ) -> (T_Qualifiers_vOut130 ) data T_Qualifiers_vIn130 = T_Qualifiers_vIn130 data T_Qualifiers_vOut130 = T_Qualifiers_vOut130 ( [ Doc ] ) {-# NOINLINE sem_Qualifiers_Cons #-} sem_Qualifiers_Cons :: T_Qualifier -> T_Qualifiers -> T_Qualifiers sem_Qualifiers_Cons arg_hd_ arg_tl_ = T_Qualifiers (return st131) where {-# NOINLINE st131 #-} st131 = let v130 :: T_Qualifiers_v130 v130 = \ (T_Qualifiers_vIn130 ) -> ( let _hdX128 = Control.Monad.Identity.runIdentity (attach_T_Qualifier (arg_hd_)) _tlX131 = Control.Monad.Identity.runIdentity (attach_T_Qualifiers (arg_tl_)) (T_Qualifier_vOut127 _hdItext) = inv_Qualifier_s128 _hdX128 (T_Qualifier_vIn127 ) (T_Qualifiers_vOut130 _tlItext) = inv_Qualifiers_s131 _tlX131 (T_Qualifiers_vIn130 ) _lhsOtext :: [ Doc ] _lhsOtext = rule265 _hdItext _tlItext __result_ = T_Qualifiers_vOut130 _lhsOtext in __result_ ) in C_Qualifiers_s131 v130 {-# INLINE rule265 #-} rule265 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Qualifiers_Nil #-} sem_Qualifiers_Nil :: T_Qualifiers sem_Qualifiers_Nil = T_Qualifiers (return st131) where {-# NOINLINE st131 #-} st131 = let v130 :: T_Qualifiers_v130 v130 = \ (T_Qualifiers_vIn130 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule266 () __result_ = T_Qualifiers_vOut130 _lhsOtext in __result_ ) in C_Qualifiers_s131 v130 {-# INLINE rule266 #-} rule266 = \ (_ :: ()) -> [] -- Range ------------------------------------------------------- -- wrapper data Inh_Range = Inh_Range { } data Syn_Range = Syn_Range { text_Syn_Range :: (Doc) } {-# INLINABLE wrap_Range #-} wrap_Range :: T_Range -> Inh_Range -> (Syn_Range ) wrap_Range (T_Range act) (Inh_Range ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg133 = T_Range_vIn133 (T_Range_vOut133 _lhsOtext) <- return (inv_Range_s134 sem arg133) return (Syn_Range _lhsOtext) ) -- cata {-# INLINE sem_Range #-} sem_Range :: Range -> T_Range sem_Range ( Range_Range start_ stop_ ) = sem_Range_Range ( sem_Position start_ ) ( sem_Position stop_ ) -- semantic domain newtype T_Range = T_Range { attach_T_Range :: Identity (T_Range_s134 ) } newtype T_Range_s134 = C_Range_s134 { inv_Range_s134 :: (T_Range_v133 ) } data T_Range_s135 = C_Range_s135 type T_Range_v133 = (T_Range_vIn133 ) -> (T_Range_vOut133 ) data T_Range_vIn133 = T_Range_vIn133 data T_Range_vOut133 = T_Range_vOut133 (Doc) {-# NOINLINE sem_Range_Range #-} sem_Range_Range :: T_Position -> T_Position -> T_Range sem_Range_Range arg_start_ arg_stop_ = T_Range (return st134) where {-# NOINLINE st134 #-} st134 = let v133 :: T_Range_v133 v133 = \ (T_Range_vIn133 ) -> ( let _startX125 = Control.Monad.Identity.runIdentity (attach_T_Position (arg_start_)) _stopX125 = Control.Monad.Identity.runIdentity (attach_T_Position (arg_stop_)) (T_Position_vOut124 _startItext) = inv_Position_s125 _startX125 (T_Position_vIn124 ) (T_Position_vOut124 _stopItext) = inv_Position_s125 _stopX125 (T_Position_vIn124 ) _text = rule267 _startItext _stopItext _lhsOtext :: Doc _lhsOtext = rule268 _text __result_ = T_Range_vOut133 _lhsOtext in __result_ ) in C_Range_s134 v133 {-# INLINE rule267 #-} rule267 = \ ((_startItext) :: Doc) ((_stopItext) :: Doc) -> text "{-" <+> _startItext <+> text ", " <+> _stopItext <+> text "-}" {-# INLINE rule268 #-} rule268 = \ _text -> _text -- RecordExpressionBinding ------------------------------------- -- wrapper data Inh_RecordExpressionBinding = Inh_RecordExpressionBinding { } data Syn_RecordExpressionBinding = Syn_RecordExpressionBinding { text_Syn_RecordExpressionBinding :: (Doc) } {-# INLINABLE wrap_RecordExpressionBinding #-} wrap_RecordExpressionBinding :: T_RecordExpressionBinding -> Inh_RecordExpressionBinding -> (Syn_RecordExpressionBinding ) wrap_RecordExpressionBinding (T_RecordExpressionBinding act) (Inh_RecordExpressionBinding ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg136 = T_RecordExpressionBinding_vIn136 (T_RecordExpressionBinding_vOut136 _lhsOtext) <- return (inv_RecordExpressionBinding_s137 sem arg136) return (Syn_RecordExpressionBinding _lhsOtext) ) -- cata {-# NOINLINE sem_RecordExpressionBinding #-} sem_RecordExpressionBinding :: RecordExpressionBinding -> T_RecordExpressionBinding sem_RecordExpressionBinding ( RecordExpressionBinding_RecordExpressionBinding range_ name_ expression_ ) = sem_RecordExpressionBinding_RecordExpressionBinding ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Expression expression_ ) -- semantic domain newtype T_RecordExpressionBinding = T_RecordExpressionBinding { attach_T_RecordExpressionBinding :: Identity (T_RecordExpressionBinding_s137 ) } newtype T_RecordExpressionBinding_s137 = C_RecordExpressionBinding_s137 { inv_RecordExpressionBinding_s137 :: (T_RecordExpressionBinding_v136 ) } data T_RecordExpressionBinding_s138 = C_RecordExpressionBinding_s138 type T_RecordExpressionBinding_v136 = (T_RecordExpressionBinding_vIn136 ) -> (T_RecordExpressionBinding_vOut136 ) data T_RecordExpressionBinding_vIn136 = T_RecordExpressionBinding_vIn136 data T_RecordExpressionBinding_vOut136 = T_RecordExpressionBinding_vOut136 (Doc) {-# NOINLINE sem_RecordExpressionBinding_RecordExpressionBinding #-} sem_RecordExpressionBinding_RecordExpressionBinding :: T_Range -> T_Name -> T_Expression -> T_RecordExpressionBinding sem_RecordExpressionBinding_RecordExpressionBinding arg_range_ arg_name_ arg_expression_ = T_RecordExpressionBinding (return st137) where {-# NOINLINE st137 #-} st137 = let v136 :: T_RecordExpressionBinding_v136 v136 = \ (T_RecordExpressionBinding_vIn136 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule269 () _lhsOtext :: Doc _lhsOtext = rule270 _text __result_ = T_RecordExpressionBinding_vOut136 _lhsOtext in __result_ ) in C_RecordExpressionBinding_s137 v136 {-# INLINE rule269 #-} rule269 = \ (_ :: ()) -> text "{- !!! record expression binding -}" {-# INLINE rule270 #-} rule270 = \ _text -> _text -- RecordExpressionBindings ------------------------------------ -- wrapper data Inh_RecordExpressionBindings = Inh_RecordExpressionBindings { } data Syn_RecordExpressionBindings = Syn_RecordExpressionBindings { text_Syn_RecordExpressionBindings :: ( [ Doc ] ) } {-# INLINABLE wrap_RecordExpressionBindings #-} wrap_RecordExpressionBindings :: T_RecordExpressionBindings -> Inh_RecordExpressionBindings -> (Syn_RecordExpressionBindings ) wrap_RecordExpressionBindings (T_RecordExpressionBindings act) (Inh_RecordExpressionBindings ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg139 = T_RecordExpressionBindings_vIn139 (T_RecordExpressionBindings_vOut139 _lhsOtext) <- return (inv_RecordExpressionBindings_s140 sem arg139) return (Syn_RecordExpressionBindings _lhsOtext) ) -- cata {-# NOINLINE sem_RecordExpressionBindings #-} sem_RecordExpressionBindings :: RecordExpressionBindings -> T_RecordExpressionBindings sem_RecordExpressionBindings list = Prelude.foldr sem_RecordExpressionBindings_Cons sem_RecordExpressionBindings_Nil (Prelude.map sem_RecordExpressionBinding list) -- semantic domain newtype T_RecordExpressionBindings = T_RecordExpressionBindings { attach_T_RecordExpressionBindings :: Identity (T_RecordExpressionBindings_s140 ) } newtype T_RecordExpressionBindings_s140 = C_RecordExpressionBindings_s140 { inv_RecordExpressionBindings_s140 :: (T_RecordExpressionBindings_v139 ) } data T_RecordExpressionBindings_s141 = C_RecordExpressionBindings_s141 type T_RecordExpressionBindings_v139 = (T_RecordExpressionBindings_vIn139 ) -> (T_RecordExpressionBindings_vOut139 ) data T_RecordExpressionBindings_vIn139 = T_RecordExpressionBindings_vIn139 data T_RecordExpressionBindings_vOut139 = T_RecordExpressionBindings_vOut139 ( [ Doc ] ) {-# NOINLINE sem_RecordExpressionBindings_Cons #-} sem_RecordExpressionBindings_Cons :: T_RecordExpressionBinding -> T_RecordExpressionBindings -> T_RecordExpressionBindings sem_RecordExpressionBindings_Cons arg_hd_ arg_tl_ = T_RecordExpressionBindings (return st140) where {-# NOINLINE st140 #-} st140 = let v139 :: T_RecordExpressionBindings_v139 v139 = \ (T_RecordExpressionBindings_vIn139 ) -> ( let _hdX137 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBinding (arg_hd_)) _tlX140 = Control.Monad.Identity.runIdentity (attach_T_RecordExpressionBindings (arg_tl_)) (T_RecordExpressionBinding_vOut136 _hdItext) = inv_RecordExpressionBinding_s137 _hdX137 (T_RecordExpressionBinding_vIn136 ) (T_RecordExpressionBindings_vOut139 _tlItext) = inv_RecordExpressionBindings_s140 _tlX140 (T_RecordExpressionBindings_vIn139 ) _lhsOtext :: [ Doc ] _lhsOtext = rule271 _hdItext _tlItext __result_ = T_RecordExpressionBindings_vOut139 _lhsOtext in __result_ ) in C_RecordExpressionBindings_s140 v139 {-# INLINE rule271 #-} rule271 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_RecordExpressionBindings_Nil #-} sem_RecordExpressionBindings_Nil :: T_RecordExpressionBindings sem_RecordExpressionBindings_Nil = T_RecordExpressionBindings (return st140) where {-# NOINLINE st140 #-} st140 = let v139 :: T_RecordExpressionBindings_v139 v139 = \ (T_RecordExpressionBindings_vIn139 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule272 () __result_ = T_RecordExpressionBindings_vOut139 _lhsOtext in __result_ ) in C_RecordExpressionBindings_s140 v139 {-# INLINE rule272 #-} rule272 = \ (_ :: ()) -> [] -- RecordPatternBinding ---------------------------------------- -- wrapper data Inh_RecordPatternBinding = Inh_RecordPatternBinding { } data Syn_RecordPatternBinding = Syn_RecordPatternBinding { text_Syn_RecordPatternBinding :: (Doc) } {-# INLINABLE wrap_RecordPatternBinding #-} wrap_RecordPatternBinding :: T_RecordPatternBinding -> Inh_RecordPatternBinding -> (Syn_RecordPatternBinding ) wrap_RecordPatternBinding (T_RecordPatternBinding act) (Inh_RecordPatternBinding ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg142 = T_RecordPatternBinding_vIn142 (T_RecordPatternBinding_vOut142 _lhsOtext) <- return (inv_RecordPatternBinding_s143 sem arg142) return (Syn_RecordPatternBinding _lhsOtext) ) -- cata {-# NOINLINE sem_RecordPatternBinding #-} sem_RecordPatternBinding :: RecordPatternBinding -> T_RecordPatternBinding sem_RecordPatternBinding ( RecordPatternBinding_RecordPatternBinding range_ name_ pattern_ ) = sem_RecordPatternBinding_RecordPatternBinding ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Pattern pattern_ ) -- semantic domain newtype T_RecordPatternBinding = T_RecordPatternBinding { attach_T_RecordPatternBinding :: Identity (T_RecordPatternBinding_s143 ) } newtype T_RecordPatternBinding_s143 = C_RecordPatternBinding_s143 { inv_RecordPatternBinding_s143 :: (T_RecordPatternBinding_v142 ) } data T_RecordPatternBinding_s144 = C_RecordPatternBinding_s144 type T_RecordPatternBinding_v142 = (T_RecordPatternBinding_vIn142 ) -> (T_RecordPatternBinding_vOut142 ) data T_RecordPatternBinding_vIn142 = T_RecordPatternBinding_vIn142 data T_RecordPatternBinding_vOut142 = T_RecordPatternBinding_vOut142 (Doc) {-# NOINLINE sem_RecordPatternBinding_RecordPatternBinding #-} sem_RecordPatternBinding_RecordPatternBinding :: T_Range -> T_Name -> T_Pattern -> T_RecordPatternBinding sem_RecordPatternBinding_RecordPatternBinding arg_range_ arg_name_ arg_pattern_ = T_RecordPatternBinding (return st143) where {-# NOINLINE st143 #-} st143 = let v142 :: T_RecordPatternBinding_v142 v142 = \ (T_RecordPatternBinding_vIn142 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) _text = rule273 () _lhsOtext :: Doc _lhsOtext = rule274 _text __result_ = T_RecordPatternBinding_vOut142 _lhsOtext in __result_ ) in C_RecordPatternBinding_s143 v142 {-# INLINE rule273 #-} rule273 = \ (_ :: ()) -> text "{- !!! record pattern binding -}" {-# INLINE rule274 #-} rule274 = \ _text -> _text -- RecordPatternBindings --------------------------------------- -- wrapper data Inh_RecordPatternBindings = Inh_RecordPatternBindings { } data Syn_RecordPatternBindings = Syn_RecordPatternBindings { text_Syn_RecordPatternBindings :: ( [ Doc ] ) } {-# INLINABLE wrap_RecordPatternBindings #-} wrap_RecordPatternBindings :: T_RecordPatternBindings -> Inh_RecordPatternBindings -> (Syn_RecordPatternBindings ) wrap_RecordPatternBindings (T_RecordPatternBindings act) (Inh_RecordPatternBindings ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg145 = T_RecordPatternBindings_vIn145 (T_RecordPatternBindings_vOut145 _lhsOtext) <- return (inv_RecordPatternBindings_s146 sem arg145) return (Syn_RecordPatternBindings _lhsOtext) ) -- cata {-# NOINLINE sem_RecordPatternBindings #-} sem_RecordPatternBindings :: RecordPatternBindings -> T_RecordPatternBindings sem_RecordPatternBindings list = Prelude.foldr sem_RecordPatternBindings_Cons sem_RecordPatternBindings_Nil (Prelude.map sem_RecordPatternBinding list) -- semantic domain newtype T_RecordPatternBindings = T_RecordPatternBindings { attach_T_RecordPatternBindings :: Identity (T_RecordPatternBindings_s146 ) } newtype T_RecordPatternBindings_s146 = C_RecordPatternBindings_s146 { inv_RecordPatternBindings_s146 :: (T_RecordPatternBindings_v145 ) } data T_RecordPatternBindings_s147 = C_RecordPatternBindings_s147 type T_RecordPatternBindings_v145 = (T_RecordPatternBindings_vIn145 ) -> (T_RecordPatternBindings_vOut145 ) data T_RecordPatternBindings_vIn145 = T_RecordPatternBindings_vIn145 data T_RecordPatternBindings_vOut145 = T_RecordPatternBindings_vOut145 ( [ Doc ] ) {-# NOINLINE sem_RecordPatternBindings_Cons #-} sem_RecordPatternBindings_Cons :: T_RecordPatternBinding -> T_RecordPatternBindings -> T_RecordPatternBindings sem_RecordPatternBindings_Cons arg_hd_ arg_tl_ = T_RecordPatternBindings (return st146) where {-# NOINLINE st146 #-} st146 = let v145 :: T_RecordPatternBindings_v145 v145 = \ (T_RecordPatternBindings_vIn145 ) -> ( let _hdX143 = Control.Monad.Identity.runIdentity (attach_T_RecordPatternBinding (arg_hd_)) _tlX146 = Control.Monad.Identity.runIdentity (attach_T_RecordPatternBindings (arg_tl_)) (T_RecordPatternBinding_vOut142 _hdItext) = inv_RecordPatternBinding_s143 _hdX143 (T_RecordPatternBinding_vIn142 ) (T_RecordPatternBindings_vOut145 _tlItext) = inv_RecordPatternBindings_s146 _tlX146 (T_RecordPatternBindings_vIn145 ) _lhsOtext :: [ Doc ] _lhsOtext = rule275 _hdItext _tlItext __result_ = T_RecordPatternBindings_vOut145 _lhsOtext in __result_ ) in C_RecordPatternBindings_s146 v145 {-# INLINE rule275 #-} rule275 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_RecordPatternBindings_Nil #-} sem_RecordPatternBindings_Nil :: T_RecordPatternBindings sem_RecordPatternBindings_Nil = T_RecordPatternBindings (return st146) where {-# NOINLINE st146 #-} st146 = let v145 :: T_RecordPatternBindings_v145 v145 = \ (T_RecordPatternBindings_vIn145 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule276 () __result_ = T_RecordPatternBindings_vOut145 _lhsOtext in __result_ ) in C_RecordPatternBindings_s146 v145 {-# INLINE rule276 #-} rule276 = \ (_ :: ()) -> [] -- RightHandSide ----------------------------------------------- -- wrapper data Inh_RightHandSide = Inh_RightHandSide { } data Syn_RightHandSide = Syn_RightHandSide { text_Syn_RightHandSide :: ( Doc -> Doc ) } {-# INLINABLE wrap_RightHandSide #-} wrap_RightHandSide :: T_RightHandSide -> Inh_RightHandSide -> (Syn_RightHandSide ) wrap_RightHandSide (T_RightHandSide act) (Inh_RightHandSide ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg148 = T_RightHandSide_vIn148 (T_RightHandSide_vOut148 _lhsOtext) <- return (inv_RightHandSide_s149 sem arg148) return (Syn_RightHandSide _lhsOtext) ) -- cata {-# NOINLINE sem_RightHandSide #-} sem_RightHandSide :: RightHandSide -> T_RightHandSide sem_RightHandSide ( RightHandSide_Expression range_ expression_ where_ ) = sem_RightHandSide_Expression ( sem_Range range_ ) ( sem_Expression expression_ ) ( sem_MaybeDeclarations where_ ) sem_RightHandSide ( RightHandSide_Guarded range_ guardedexpressions_ where_ ) = sem_RightHandSide_Guarded ( sem_Range range_ ) ( sem_GuardedExpressions guardedexpressions_ ) ( sem_MaybeDeclarations where_ ) -- semantic domain newtype T_RightHandSide = T_RightHandSide { attach_T_RightHandSide :: Identity (T_RightHandSide_s149 ) } newtype T_RightHandSide_s149 = C_RightHandSide_s149 { inv_RightHandSide_s149 :: (T_RightHandSide_v148 ) } data T_RightHandSide_s150 = C_RightHandSide_s150 type T_RightHandSide_v148 = (T_RightHandSide_vIn148 ) -> (T_RightHandSide_vOut148 ) data T_RightHandSide_vIn148 = T_RightHandSide_vIn148 data T_RightHandSide_vOut148 = T_RightHandSide_vOut148 ( Doc -> Doc ) {-# NOINLINE sem_RightHandSide_Expression #-} sem_RightHandSide_Expression :: T_Range -> T_Expression -> T_MaybeDeclarations -> T_RightHandSide sem_RightHandSide_Expression arg_range_ arg_expression_ arg_where_ = T_RightHandSide (return st149) where {-# NOINLINE st149 #-} st149 = let v148 :: T_RightHandSide_v148 v148 = \ (T_RightHandSide_vIn148 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) _whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) (T_MaybeDeclarations_vOut88 _whereItext) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 ) _text = rule277 _justText _justText = rule278 _expressionItext _whereItext _lhsOtext :: Doc -> Doc _lhsOtext = rule279 _text __result_ = T_RightHandSide_vOut148 _lhsOtext in __result_ ) in C_RightHandSide_s149 v148 {-# INLINE rule277 #-} rule277 = \ _justText -> \assign -> assign <$> _justText {-# INLINE rule278 #-} rule278 = \ ((_expressionItext) :: Doc) ((_whereItext) :: Maybe [ Doc ] ) -> indent 4 ( _expressionItext <> maybe empty (\ds -> PPrint.empty <$> text "where" <$> indent 4 (vcat ds)) _whereItext ) {-# INLINE rule279 #-} rule279 = \ _text -> _text {-# NOINLINE sem_RightHandSide_Guarded #-} sem_RightHandSide_Guarded :: T_Range -> T_GuardedExpressions -> T_MaybeDeclarations -> T_RightHandSide sem_RightHandSide_Guarded arg_range_ arg_guardedexpressions_ arg_where_ = T_RightHandSide (return st149) where {-# NOINLINE st149 #-} st149 = let v148 :: T_RightHandSide_v148 v148 = \ (T_RightHandSide_vIn148 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _guardedexpressionsX65 = Control.Monad.Identity.runIdentity (attach_T_GuardedExpressions (arg_guardedexpressions_)) _whereX89 = Control.Monad.Identity.runIdentity (attach_T_MaybeDeclarations (arg_where_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_GuardedExpressions_vOut64 _guardedexpressionsItext) = inv_GuardedExpressions_s65 _guardedexpressionsX65 (T_GuardedExpressions_vIn64 ) (T_MaybeDeclarations_vOut88 _whereItext) = inv_MaybeDeclarations_s89 _whereX89 (T_MaybeDeclarations_vIn88 ) _text = rule280 _guardedexpressionsItext _whereItext _lhsOtext :: Doc -> Doc _lhsOtext = rule281 _text __result_ = T_RightHandSide_vOut148 _lhsOtext in __result_ ) in C_RightHandSide_s149 v148 {-# INLINE rule280 #-} rule280 = \ ((_guardedexpressionsItext) :: [ Doc -> Doc ] ) ((_whereItext) :: Maybe [ Doc ] ) -> \assign -> ( PPrint.empty <$> vsep (zipWith (\f x -> indent 4 (f x)) _guardedexpressionsItext (repeat assign)) <> maybe empty (\ds -> PPrint.empty <$> indent 4 (text "where" <$> indent 4 (vcat ds))) _whereItext ) {-# INLINE rule281 #-} rule281 = \ _text -> _text -- SimpleType -------------------------------------------------- -- wrapper data Inh_SimpleType = Inh_SimpleType { } data Syn_SimpleType = Syn_SimpleType { text_Syn_SimpleType :: (Doc) } {-# INLINABLE wrap_SimpleType #-} wrap_SimpleType :: T_SimpleType -> Inh_SimpleType -> (Syn_SimpleType ) wrap_SimpleType (T_SimpleType act) (Inh_SimpleType ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg151 = T_SimpleType_vIn151 (T_SimpleType_vOut151 _lhsOtext) <- return (inv_SimpleType_s152 sem arg151) return (Syn_SimpleType _lhsOtext) ) -- cata {-# INLINE sem_SimpleType #-} sem_SimpleType :: SimpleType -> T_SimpleType sem_SimpleType ( SimpleType_SimpleType range_ name_ typevariables_ ) = sem_SimpleType_SimpleType ( sem_Range range_ ) ( sem_Name name_ ) ( sem_Names typevariables_ ) -- semantic domain newtype T_SimpleType = T_SimpleType { attach_T_SimpleType :: Identity (T_SimpleType_s152 ) } newtype T_SimpleType_s152 = C_SimpleType_s152 { inv_SimpleType_s152 :: (T_SimpleType_v151 ) } data T_SimpleType_s153 = C_SimpleType_s153 type T_SimpleType_v151 = (T_SimpleType_vIn151 ) -> (T_SimpleType_vOut151 ) data T_SimpleType_vIn151 = T_SimpleType_vIn151 data T_SimpleType_vOut151 = T_SimpleType_vOut151 (Doc) {-# NOINLINE sem_SimpleType_SimpleType #-} sem_SimpleType_SimpleType :: T_Range -> T_Name -> T_Names -> T_SimpleType sem_SimpleType_SimpleType arg_range_ arg_name_ arg_typevariables_ = T_SimpleType (return st152) where {-# NOINLINE st152 #-} st152 = let v151 :: T_SimpleType_v151 v151 = \ (T_SimpleType_vIn151 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) _typevariablesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_typevariables_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) (T_Names_vOut115 _typevariablesIisIdentifier _typevariablesIisOperator _typevariablesIisSpecial _typevariablesItext) = inv_Names_s116 _typevariablesX116 (T_Names_vIn115 ) _text = rule282 _nameItext _typevariablesItext _lhsOtext :: Doc _lhsOtext = rule283 _text __result_ = T_SimpleType_vOut151 _lhsOtext in __result_ ) in C_SimpleType_s152 v151 {-# INLINE rule282 #-} rule282 = \ ((_nameItext) :: Doc) ((_typevariablesItext) :: [ Doc ] ) -> foldl (<+>) _nameItext _typevariablesItext {-# INLINE rule283 #-} rule283 = \ _text -> _text -- Statement --------------------------------------------------- -- wrapper data Inh_Statement = Inh_Statement { } data Syn_Statement = Syn_Statement { text_Syn_Statement :: (Doc) } {-# INLINABLE wrap_Statement #-} wrap_Statement :: T_Statement -> Inh_Statement -> (Syn_Statement ) wrap_Statement (T_Statement act) (Inh_Statement ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg154 = T_Statement_vIn154 (T_Statement_vOut154 _lhsOtext) <- return (inv_Statement_s155 sem arg154) return (Syn_Statement _lhsOtext) ) -- cata {-# NOINLINE sem_Statement #-} sem_Statement :: Statement -> T_Statement sem_Statement ( Statement_Expression range_ expression_ ) = sem_Statement_Expression ( sem_Range range_ ) ( sem_Expression expression_ ) sem_Statement ( Statement_Let range_ declarations_ ) = sem_Statement_Let ( sem_Range range_ ) ( sem_Declarations declarations_ ) sem_Statement ( Statement_Generator range_ pattern_ expression_ ) = sem_Statement_Generator ( sem_Range range_ ) ( sem_Pattern pattern_ ) ( sem_Expression expression_ ) sem_Statement ( Statement_Empty range_ ) = sem_Statement_Empty ( sem_Range range_ ) -- semantic domain newtype T_Statement = T_Statement { attach_T_Statement :: Identity (T_Statement_s155 ) } newtype T_Statement_s155 = C_Statement_s155 { inv_Statement_s155 :: (T_Statement_v154 ) } data T_Statement_s156 = C_Statement_s156 type T_Statement_v154 = (T_Statement_vIn154 ) -> (T_Statement_vOut154 ) data T_Statement_vIn154 = T_Statement_vIn154 data T_Statement_vOut154 = T_Statement_vOut154 (Doc) {-# NOINLINE sem_Statement_Expression #-} sem_Statement_Expression :: T_Range -> T_Expression -> T_Statement sem_Statement_Expression arg_range_ arg_expression_ = T_Statement (return st155) where {-# NOINLINE st155 #-} st155 = let v154 :: T_Statement_v154 v154 = \ (T_Statement_vIn154 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule284 _expressionItext _lhsOtext :: Doc _lhsOtext = rule285 _text __result_ = T_Statement_vOut154 _lhsOtext in __result_ ) in C_Statement_s155 v154 {-# INLINE rule284 #-} rule284 = \ ((_expressionItext) :: Doc) -> _expressionItext {-# INLINE rule285 #-} rule285 = \ _text -> _text {-# NOINLINE sem_Statement_Let #-} sem_Statement_Let :: T_Range -> T_Declarations -> T_Statement sem_Statement_Let arg_range_ arg_declarations_ = T_Statement (return st155) where {-# NOINLINE st155 #-} st155 = let v154 :: T_Statement_v154 v154 = \ (T_Statement_vIn154 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _declarationsX32 = Control.Monad.Identity.runIdentity (attach_T_Declarations (arg_declarations_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Declarations_vOut31 _declarationsItext) = inv_Declarations_s32 _declarationsX32 (T_Declarations_vIn31 ) _text = rule286 _declarationsItext _lhsOtext :: Doc _lhsOtext = rule287 _text __result_ = T_Statement_vOut154 _lhsOtext in __result_ ) in C_Statement_s155 v154 {-# INLINE rule286 #-} rule286 = \ ((_declarationsItext) :: [ Doc ] ) -> text "let" <$> (indent 4 $ vcat _declarationsItext) {-# INLINE rule287 #-} rule287 = \ _text -> _text {-# NOINLINE sem_Statement_Generator #-} sem_Statement_Generator :: T_Range -> T_Pattern -> T_Expression -> T_Statement sem_Statement_Generator arg_range_ arg_pattern_ arg_expression_ = T_Statement (return st155) where {-# NOINLINE st155 #-} st155 = let v154 :: T_Statement_v154 v154 = \ (T_Statement_vIn154 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _patternX119 = Control.Monad.Identity.runIdentity (attach_T_Pattern (arg_pattern_)) _expressionX41 = Control.Monad.Identity.runIdentity (attach_T_Expression (arg_expression_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Pattern_vOut118 _patternItext) = inv_Pattern_s119 _patternX119 (T_Pattern_vIn118 ) (T_Expression_vOut40 _expressionItext) = inv_Expression_s41 _expressionX41 (T_Expression_vIn40 ) _text = rule288 _expressionItext _patternItext _lhsOtext :: Doc _lhsOtext = rule289 _text __result_ = T_Statement_vOut154 _lhsOtext in __result_ ) in C_Statement_s155 v154 {-# INLINE rule288 #-} rule288 = \ ((_expressionItext) :: Doc) ((_patternItext) :: Doc) -> _patternItext <+> text "<-" <+> _expressionItext {-# INLINE rule289 #-} rule289 = \ _text -> _text {-# NOINLINE sem_Statement_Empty #-} sem_Statement_Empty :: T_Range -> T_Statement sem_Statement_Empty arg_range_ = T_Statement (return st155) where {-# NOINLINE st155 #-} st155 = let v154 :: T_Statement_v154 v154 = \ (T_Statement_vIn154 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) _text = rule290 () _lhsOtext :: Doc _lhsOtext = rule291 _text __result_ = T_Statement_vOut154 _lhsOtext in __result_ ) in C_Statement_s155 v154 {-# INLINE rule290 #-} rule290 = \ (_ :: ()) -> empty {-# INLINE rule291 #-} rule291 = \ _text -> _text -- Statements -------------------------------------------------- -- wrapper data Inh_Statements = Inh_Statements { } data Syn_Statements = Syn_Statements { text_Syn_Statements :: ( [ Doc ] ) } {-# INLINABLE wrap_Statements #-} wrap_Statements :: T_Statements -> Inh_Statements -> (Syn_Statements ) wrap_Statements (T_Statements act) (Inh_Statements ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg157 = T_Statements_vIn157 (T_Statements_vOut157 _lhsOtext) <- return (inv_Statements_s158 sem arg157) return (Syn_Statements _lhsOtext) ) -- cata {-# NOINLINE sem_Statements #-} sem_Statements :: Statements -> T_Statements sem_Statements list = Prelude.foldr sem_Statements_Cons sem_Statements_Nil (Prelude.map sem_Statement list) -- semantic domain newtype T_Statements = T_Statements { attach_T_Statements :: Identity (T_Statements_s158 ) } newtype T_Statements_s158 = C_Statements_s158 { inv_Statements_s158 :: (T_Statements_v157 ) } data T_Statements_s159 = C_Statements_s159 type T_Statements_v157 = (T_Statements_vIn157 ) -> (T_Statements_vOut157 ) data T_Statements_vIn157 = T_Statements_vIn157 data T_Statements_vOut157 = T_Statements_vOut157 ( [ Doc ] ) {-# NOINLINE sem_Statements_Cons #-} sem_Statements_Cons :: T_Statement -> T_Statements -> T_Statements sem_Statements_Cons arg_hd_ arg_tl_ = T_Statements (return st158) where {-# NOINLINE st158 #-} st158 = let v157 :: T_Statements_v157 v157 = \ (T_Statements_vIn157 ) -> ( let _hdX155 = Control.Monad.Identity.runIdentity (attach_T_Statement (arg_hd_)) _tlX158 = Control.Monad.Identity.runIdentity (attach_T_Statements (arg_tl_)) (T_Statement_vOut154 _hdItext) = inv_Statement_s155 _hdX155 (T_Statement_vIn154 ) (T_Statements_vOut157 _tlItext) = inv_Statements_s158 _tlX158 (T_Statements_vIn157 ) _lhsOtext :: [ Doc ] _lhsOtext = rule292 _hdItext _tlItext __result_ = T_Statements_vOut157 _lhsOtext in __result_ ) in C_Statements_s158 v157 {-# INLINE rule292 #-} rule292 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Statements_Nil #-} sem_Statements_Nil :: T_Statements sem_Statements_Nil = T_Statements (return st158) where {-# NOINLINE st158 #-} st158 = let v157 :: T_Statements_v157 v157 = \ (T_Statements_vIn157 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule293 () __result_ = T_Statements_vOut157 _lhsOtext in __result_ ) in C_Statements_s158 v157 {-# INLINE rule293 #-} rule293 = \ (_ :: ()) -> [] -- Strings ----------------------------------------------------- -- wrapper data Inh_Strings = Inh_Strings { } data Syn_Strings = Syn_Strings { text_Syn_Strings :: ( [ Doc ] ) } {-# INLINABLE wrap_Strings #-} wrap_Strings :: T_Strings -> Inh_Strings -> (Syn_Strings ) wrap_Strings (T_Strings act) (Inh_Strings ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg160 = T_Strings_vIn160 (T_Strings_vOut160 _lhsOtext) <- return (inv_Strings_s161 sem arg160) return (Syn_Strings _lhsOtext) ) -- cata {-# NOINLINE sem_Strings #-} sem_Strings :: Strings -> T_Strings sem_Strings list = Prelude.foldr sem_Strings_Cons sem_Strings_Nil list -- semantic domain newtype T_Strings = T_Strings { attach_T_Strings :: Identity (T_Strings_s161 ) } newtype T_Strings_s161 = C_Strings_s161 { inv_Strings_s161 :: (T_Strings_v160 ) } data T_Strings_s162 = C_Strings_s162 type T_Strings_v160 = (T_Strings_vIn160 ) -> (T_Strings_vOut160 ) data T_Strings_vIn160 = T_Strings_vIn160 data T_Strings_vOut160 = T_Strings_vOut160 ( [ Doc ] ) {-# NOINLINE sem_Strings_Cons #-} sem_Strings_Cons :: (String) -> T_Strings -> T_Strings sem_Strings_Cons _ arg_tl_ = T_Strings (return st161) where {-# NOINLINE st161 #-} st161 = let v160 :: T_Strings_v160 v160 = \ (T_Strings_vIn160 ) -> ( let _tlX161 = Control.Monad.Identity.runIdentity (attach_T_Strings (arg_tl_)) (T_Strings_vOut160 _tlItext) = inv_Strings_s161 _tlX161 (T_Strings_vIn160 ) _lhsOtext :: [ Doc ] _lhsOtext = rule294 _tlItext __result_ = T_Strings_vOut160 _lhsOtext in __result_ ) in C_Strings_s161 v160 {-# INLINE rule294 #-} rule294 = \ ((_tlItext) :: [ Doc ] ) -> _tlItext {-# NOINLINE sem_Strings_Nil #-} sem_Strings_Nil :: T_Strings sem_Strings_Nil = T_Strings (return st161) where {-# NOINLINE st161 #-} st161 = let v160 :: T_Strings_v160 v160 = \ (T_Strings_vIn160 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule295 () __result_ = T_Strings_vOut160 _lhsOtext in __result_ ) in C_Strings_s161 v160 {-# INLINE rule295 #-} rule295 = \ (_ :: ()) -> [] -- Type -------------------------------------------------------- -- wrapper data Inh_Type = Inh_Type { } data Syn_Type = Syn_Type { text_Syn_Type :: (Doc) } {-# INLINABLE wrap_Type #-} wrap_Type :: T_Type -> Inh_Type -> (Syn_Type ) wrap_Type (T_Type act) (Inh_Type ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg163 = T_Type_vIn163 (T_Type_vOut163 _lhsOtext) <- return (inv_Type_s164 sem arg163) return (Syn_Type _lhsOtext) ) -- cata {-# NOINLINE sem_Type #-} sem_Type :: Type -> T_Type sem_Type ( Type_Application range_ prefix_ function_ arguments_ ) = sem_Type_Application ( sem_Range range_ ) prefix_ ( sem_Type function_ ) ( sem_Types arguments_ ) sem_Type ( Type_Variable range_ name_ ) = sem_Type_Variable ( sem_Range range_ ) ( sem_Name name_ ) sem_Type ( Type_Constructor range_ name_ ) = sem_Type_Constructor ( sem_Range range_ ) ( sem_Name name_ ) sem_Type ( Type_Qualified range_ context_ type_ ) = sem_Type_Qualified ( sem_Range range_ ) ( sem_ContextItems context_ ) ( sem_Type type_ ) sem_Type ( Type_Forall range_ typevariables_ type_ ) = sem_Type_Forall ( sem_Range range_ ) ( sem_Names typevariables_ ) ( sem_Type type_ ) sem_Type ( Type_Exists range_ typevariables_ type_ ) = sem_Type_Exists ( sem_Range range_ ) ( sem_Names typevariables_ ) ( sem_Type type_ ) sem_Type ( Type_Parenthesized range_ type_ ) = sem_Type_Parenthesized ( sem_Range range_ ) ( sem_Type type_ ) -- semantic domain newtype T_Type = T_Type { attach_T_Type :: Identity (T_Type_s164 ) } newtype T_Type_s164 = C_Type_s164 { inv_Type_s164 :: (T_Type_v163 ) } data T_Type_s165 = C_Type_s165 type T_Type_v163 = (T_Type_vIn163 ) -> (T_Type_vOut163 ) data T_Type_vIn163 = T_Type_vIn163 data T_Type_vOut163 = T_Type_vOut163 (Doc) {-# NOINLINE sem_Type_Application #-} sem_Type_Application :: T_Range -> (Bool) -> T_Type -> T_Types -> T_Type sem_Type_Application arg_range_ arg_prefix_ arg_function_ arg_arguments_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _functionX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_function_)) _argumentsX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_arguments_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Type_vOut163 _functionItext) = inv_Type_s164 _functionX164 (T_Type_vIn163 ) (T_Types_vOut166 _argumentsItext) = inv_Types_s167 _argumentsX167 (T_Types_vIn166 ) _text = rule296 _argumentsItext _functionItext arg_prefix_ _lhsOtext :: Doc _lhsOtext = rule297 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule296 #-} rule296 = \ ((_argumentsItext) :: [ Doc ] ) ((_functionItext) :: Doc) prefix_ -> if prefix_ then foldl (<+>) _functionItext _argumentsItext else if show _functionItext == "[]" then PPrint.list _argumentsItext else if isTupleConstructor (show _functionItext) then tupled _argumentsItext else case _argumentsItext of [a, b] -> a <+> _functionItext <+> b _ -> text "{- error: Unknown special application notation -}" {-# INLINE rule297 #-} rule297 = \ _text -> _text {-# NOINLINE sem_Type_Variable #-} sem_Type_Variable :: T_Range -> T_Name -> T_Type sem_Type_Variable arg_range_ arg_name_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule298 _nameItext _lhsOtext :: Doc _lhsOtext = rule299 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule298 #-} rule298 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule299 #-} rule299 = \ _text -> _text {-# NOINLINE sem_Type_Constructor #-} sem_Type_Constructor :: T_Range -> T_Name -> T_Type sem_Type_Constructor arg_range_ arg_name_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _nameX113 = Control.Monad.Identity.runIdentity (attach_T_Name (arg_name_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Name_vOut112 _nameIisIdentifier _nameIisOperator _nameIisSpecial _nameItext) = inv_Name_s113 _nameX113 (T_Name_vIn112 ) _text = rule300 _nameItext _lhsOtext :: Doc _lhsOtext = rule301 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule300 #-} rule300 = \ ((_nameItext) :: Doc) -> _nameItext {-# INLINE rule301 #-} rule301 = \ _text -> _text {-# NOINLINE sem_Type_Qualified #-} sem_Type_Qualified :: T_Range -> T_ContextItems -> T_Type -> T_Type sem_Type_Qualified arg_range_ arg_context_ arg_type_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _contextX26 = Control.Monad.Identity.runIdentity (attach_T_ContextItems (arg_context_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_ContextItems_vOut25 _contextItext) = inv_ContextItems_s26 _contextX26 (T_ContextItems_vIn25 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule302 _contextItext _typeItext _lhsOtext :: Doc _lhsOtext = rule303 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule302 #-} rule302 = \ ((_contextItext) :: [ Doc ] ) ((_typeItext) :: Doc) -> contextPP _contextItext <+> _typeItext {-# INLINE rule303 #-} rule303 = \ _text -> _text {-# NOINLINE sem_Type_Forall #-} sem_Type_Forall :: T_Range -> T_Names -> T_Type -> T_Type sem_Type_Forall arg_range_ arg_typevariables_ arg_type_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _typevariablesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_typevariables_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Names_vOut115 _typevariablesIisIdentifier _typevariablesIisOperator _typevariablesIisSpecial _typevariablesItext) = inv_Names_s116 _typevariablesX116 (T_Names_vIn115 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule304 _typeItext _typevariablesItext _lhsOtext :: Doc _lhsOtext = rule305 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule304 #-} rule304 = \ ((_typeItext) :: Doc) ((_typevariablesItext) :: [ Doc ] ) -> foldl (<+>) (text "forall") _typevariablesItext <> text "." <> _typeItext {-# INLINE rule305 #-} rule305 = \ _text -> _text {-# NOINLINE sem_Type_Exists #-} sem_Type_Exists :: T_Range -> T_Names -> T_Type -> T_Type sem_Type_Exists arg_range_ arg_typevariables_ arg_type_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _typevariablesX116 = Control.Monad.Identity.runIdentity (attach_T_Names (arg_typevariables_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Names_vOut115 _typevariablesIisIdentifier _typevariablesIisOperator _typevariablesIisSpecial _typevariablesItext) = inv_Names_s116 _typevariablesX116 (T_Names_vIn115 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule306 _typeItext _typevariablesItext _lhsOtext :: Doc _lhsOtext = rule307 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule306 #-} rule306 = \ ((_typeItext) :: Doc) ((_typevariablesItext) :: [ Doc ] ) -> foldl (<+>) (text "exists") _typevariablesItext <> text "." <> _typeItext {-# INLINE rule307 #-} rule307 = \ _text -> _text {-# NOINLINE sem_Type_Parenthesized #-} sem_Type_Parenthesized :: T_Range -> T_Type -> T_Type sem_Type_Parenthesized arg_range_ arg_type_ = T_Type (return st164) where {-# NOINLINE st164 #-} st164 = let v163 :: T_Type_v163 v163 = \ (T_Type_vIn163 ) -> ( let _rangeX134 = Control.Monad.Identity.runIdentity (attach_T_Range (arg_range_)) _typeX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_type_)) (T_Range_vOut133 _rangeItext) = inv_Range_s134 _rangeX134 (T_Range_vIn133 ) (T_Type_vOut163 _typeItext) = inv_Type_s164 _typeX164 (T_Type_vIn163 ) _text = rule308 _typeItext _lhsOtext :: Doc _lhsOtext = rule309 _text __result_ = T_Type_vOut163 _lhsOtext in __result_ ) in C_Type_s164 v163 {-# INLINE rule308 #-} rule308 = \ ((_typeItext) :: Doc) -> parens _typeItext {-# INLINE rule309 #-} rule309 = \ _text -> _text -- Types ------------------------------------------------------- -- wrapper data Inh_Types = Inh_Types { } data Syn_Types = Syn_Types { text_Syn_Types :: ( [ Doc ] ) } {-# INLINABLE wrap_Types #-} wrap_Types :: T_Types -> Inh_Types -> (Syn_Types ) wrap_Types (T_Types act) (Inh_Types ) = Control.Monad.Identity.runIdentity ( do sem <- act let arg166 = T_Types_vIn166 (T_Types_vOut166 _lhsOtext) <- return (inv_Types_s167 sem arg166) return (Syn_Types _lhsOtext) ) -- cata {-# NOINLINE sem_Types #-} sem_Types :: Types -> T_Types sem_Types list = Prelude.foldr sem_Types_Cons sem_Types_Nil (Prelude.map sem_Type list) -- semantic domain newtype T_Types = T_Types { attach_T_Types :: Identity (T_Types_s167 ) } newtype T_Types_s167 = C_Types_s167 { inv_Types_s167 :: (T_Types_v166 ) } data T_Types_s168 = C_Types_s168 type T_Types_v166 = (T_Types_vIn166 ) -> (T_Types_vOut166 ) data T_Types_vIn166 = T_Types_vIn166 data T_Types_vOut166 = T_Types_vOut166 ( [ Doc ] ) {-# NOINLINE sem_Types_Cons #-} sem_Types_Cons :: T_Type -> T_Types -> T_Types sem_Types_Cons arg_hd_ arg_tl_ = T_Types (return st167) where {-# NOINLINE st167 #-} st167 = let v166 :: T_Types_v166 v166 = \ (T_Types_vIn166 ) -> ( let _hdX164 = Control.Monad.Identity.runIdentity (attach_T_Type (arg_hd_)) _tlX167 = Control.Monad.Identity.runIdentity (attach_T_Types (arg_tl_)) (T_Type_vOut163 _hdItext) = inv_Type_s164 _hdX164 (T_Type_vIn163 ) (T_Types_vOut166 _tlItext) = inv_Types_s167 _tlX167 (T_Types_vIn166 ) _lhsOtext :: [ Doc ] _lhsOtext = rule310 _hdItext _tlItext __result_ = T_Types_vOut166 _lhsOtext in __result_ ) in C_Types_s167 v166 {-# INLINE rule310 #-} rule310 = \ ((_hdItext) :: Doc) ((_tlItext) :: [ Doc ] ) -> _hdItext : _tlItext {-# NOINLINE sem_Types_Nil #-} sem_Types_Nil :: T_Types sem_Types_Nil = T_Types (return st167) where {-# NOINLINE st167 #-} st167 = let v166 :: T_Types_v166 v166 = \ (T_Types_vIn166 ) -> ( let _lhsOtext :: [ Doc ] _lhsOtext = rule311 () __result_ = T_Types_vOut166 _lhsOtext in __result_ ) in C_Types_s167 v166 {-# INLINE rule311 #-} rule311 = \ (_ :: ()) -> []
roberth/uu-helium
src/Helium/Syntax/UHA_Pretty.hs
gpl-3.0
287,970
56
23
73,081
57,815
31,346
26,469
5,094
6
{-# OPTIONS -O0 #-} {-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, TypeFamilies #-} -- | The themes/ config format module Lamdu.Config.Theme ( Help(..) , helpTextSize, helpTextColor, helpInputDocColor, helpBGColor, helpTint , helpShownIconTint, helpSrcLocColor , Eval(..), neighborsScaleFactor, neighborsPadding, staleResultTint , ToolTip(..), tooltipFgColor, tooltipBgColor , StatusBar(..), statusBarBGColor, statusBarHSpaces , Deleted(..), deletedDefTint, deletedDefDiagonalWidth, deletedUseDiagonalWidth , FontSel(..), fontSelWidth, fontSelStyle, fontSelSlant, fontSelWeight , fontSel , Theme(..) , title, fonts, sprites, baseTextSize, animationTimePeriodSec , animationRemainInPeriod, help, menu, searchTerm, name, eval, hover, tooltip , textColors, textEditCursorColor, textEditCursorWidth , topPadding, statusBar, deleted, maxEvalViewSize, versionControl , valAnnotation, indent, backgroundColor, invalidCursorOverlayColor , errorColor, successColor , letItemPadding, narrowUnderlineWidth , wideUnderlineWidth, valFrameBGColor, valFramePadding , typeFrameBGColor, stdSpacing, cursorColor, cursorDecayExponent , disabledColor, presentationChoiceScaleFactor, evaluatedPathBGColor ) where import qualified Control.Lens as Lens import Data.Aeson.TH (deriveJSON) import qualified Data.Aeson.TH.Extended as JsonTH import qualified Data.Aeson.Types as Aeson import Data.Char (toLower) import Data.List.Lens (prefixed) import Data.Vector.Vector2 (Vector2) import qualified GUI.Momentu.Hover as Hover import qualified GUI.Momentu.Responsive.Expression as Expression import qualified GUI.Momentu.Widgets.Menu as Menu import qualified GUI.Momentu.Widgets.Menu.Search as SearchMenu import qualified Graphics.DrawingCombinators as Draw import Lamdu.Config.Folder (HasConfigFolder(..)) import qualified Lamdu.Config.Folder as Folder import Lamdu.Config.Theme.Fonts (FontSize, Fonts) import Lamdu.Config.Theme.Name (Name(..)) import Lamdu.Config.Theme.Sprites (Sprites) import Lamdu.Config.Theme.TextColors (TextColors(..)) import Lamdu.Config.Theme.ValAnnotation (ValAnnotation(..)) import qualified Lamdu.GUI.VersionControl.Config as VersionControl import qualified Lamdu.I18N.Fonts as I18N.Fonts import Lamdu.Prelude data Help = Help { _helpTextSize :: FontSize , _helpTextColor :: Draw.Color , _helpInputDocColor :: Draw.Color , _helpBGColor :: Draw.Color , _helpTint :: Draw.Color , _helpShownIconTint :: Draw.Color , _helpSrcLocColor :: Maybe Draw.Color } deriving (Eq, Generic) JsonTH.derivePrefixed "_help" ''Help Lens.makeLenses ''Help data Eval = Eval { _neighborsScaleFactor :: Vector2 Double , _neighborsPadding :: Vector2 Double , _staleResultTint :: Draw.Color } deriving (Eq, Generic) JsonTH.derivePrefixed "_" ''Eval Lens.makeLenses ''Eval data ToolTip = ToolTip { _tooltipFgColor :: Draw.Color , _tooltipBgColor :: Draw.Color } deriving (Eq, Generic) JsonTH.derivePrefixed "_tooltip" ''ToolTip Lens.makeLenses ''ToolTip data StatusBar = StatusBar { _statusBarBGColor :: Draw.Color , _statusBarHSpaces :: Double } deriving (Eq, Generic) deriveJSON Aeson.defaultOptions { Aeson.fieldLabelModifier = (Lens.taking 2 traverse %~ toLower) . (^?! prefixed "_statusBar") } ''StatusBar Lens.makeLenses ''StatusBar data Deleted = Deleted { _deletedDefTint :: Draw.Color , _deletedDefDiagonalWidth :: Double , _deletedUseDiagonalWidth :: Double } deriving (Eq, Generic) JsonTH.derivePrefixed "_deleted" ''Deleted Lens.makeLenses ''Deleted data FontSel = FontSel { _fontSelWidth :: I18N.Fonts.ProportionalOrMonospace , _fontSelStyle :: I18N.Fonts.SansOrSerif , _fontSelSlant :: I18N.Fonts.RomanOrItalic , _fontSelWeight :: I18N.Fonts.LightOrBold } deriving (Eq, Generic) JsonTH.derivePrefixed "_fontSel" ''FontSel Lens.makeLenses ''FontSel fontSel :: FontSel -> Lens.ALens' (I18N.Fonts.ProportionalAndMonospace (I18N.Fonts.SansAndSerif (I18N.Fonts.RomanAndItalic (I18N.Fonts.LightAndBold a)))) a fontSel sel = I18N.Fonts.choice (sel ^. fontSelWidth) . I18N.Fonts.choice (sel ^. fontSelStyle) . I18N.Fonts.choice (sel ^. fontSelSlant) . I18N.Fonts.choice (sel ^. fontSelWeight) data Theme = Theme { _title :: Map Text Text , _fonts :: Fonts FontSel , _sprites :: Sprites FilePath , _baseTextSize :: FontSize , _animationTimePeriodSec :: Double , _animationRemainInPeriod :: Double , _help :: Help , _menu :: Menu.Style , _searchTerm :: SearchMenu.TermStyle , _name :: Name , _eval :: Eval , _hover :: Hover.Style , _tooltip :: ToolTip , _textColors :: TextColors , _textEditCursorColor :: Draw.Color , _textEditCursorWidth :: Draw.R , _topPadding :: Draw.R , _statusBar :: StatusBar , _deleted :: Deleted , _maxEvalViewSize :: Int , _versionControl :: VersionControl.Theme , _valAnnotation :: ValAnnotation , _indent :: Expression.Style , _backgroundColor :: Draw.Color , _invalidCursorOverlayColor :: Draw.Color , _errorColor :: Draw.Color , _successColor :: Draw.Color , _letItemPadding :: Vector2 Double , _narrowUnderlineWidth :: Double , _wideUnderlineWidth :: Double , _valFrameBGColor :: Draw.Color , _valFramePadding :: Vector2 Double , _typeFrameBGColor :: Draw.Color , _stdSpacing :: Vector2 Double -- as ratio of space character size , _cursorColor :: Draw.Color , _cursorDecayExponent :: Draw.R , _disabledColor :: Draw.Color , _presentationChoiceScaleFactor :: Vector2 Double , _evaluatedPathBGColor :: Draw.Color } deriving (Eq, Generic) JsonTH.derivePrefixed "_" ''Theme Lens.makeLenses ''Theme instance Has Expression.Style Theme where has = indent instance Has Hover.Style Theme where has = hover instance HasConfigFolder Theme where type Folder Theme = Folder.Theme configFolderName _ = "themes"
lamdu/lamdu
src/Lamdu/Config/Theme.hs
gpl-3.0
6,252
0
15
1,257
1,464
885
579
154
1
module Robotics.Thingomatic.Config where data PrinterConfig = Config { extSpeed::Double, extTemp::Int, platTemp::Int, layer::Double } deriving(Show,Read,Eq) defaultConfig = Config {extSpeed = 1.98, extTemp = 220, platTemp = 125, layer = 0.35}
matthewSorensen/weft
Robotics/Thingomatic/Config.hs
gpl-3.0
434
0
8
220
86
54
32
7
1
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DeriveDataTypeable #-} {- | Module : Tct.Method.Bounds Copyright : (c) Martin Avanzini <[email protected]>, Georg Moser <[email protected]>, Andreas Schnabl <[email protected]> License : LGPL (see COPYING) Maintainer : Martin Avanzini <[email protected]>, Andreas Schnabl <[email protected]> Stability : unstable Portability : unportable This module implements the bounds processor. -} module Tct.Method.Bounds ( bounds , InitialAutomaton (..) , Enrichment (..) -- * Processor , Bounds , boundsProcessor -- * Proof Object , BoundsProof (..) , BoundsCertificate (..) ) where import Data.Typeable import qualified Data.Set as Set import Text.PrettyPrint.HughesPJ hiding (empty) import Termlib.Problem (StartTerms(..), strictComponents, weakComponents) import qualified Termlib.Problem as Prob import Termlib.Utils import Termlib.Trs (Trs) import qualified Termlib.Trs as Trs import Termlib.FunctionSymbol (Signature) import qualified Termlib.FunctionSymbol as FS import Tct.Certificate (certified, unknown, poly) import Tct.Processor (ComplexityProof(..), Answer(..)) import qualified Tct.Processor.Standard as S import qualified Tct.Processor.Args as A import Tct.Processor.Args.Instances import Tct.Processor.Args import Tct.Method.Bounds.Automata import Tct.Method.Bounds.Violations -- | This datatype represents the initial automaton -- employed. data InitialAutomaton = Minimal -- ^ Employ a minimal set of states, -- separating constructors from defined symbols -- in the case of runtime complexity analysis. | PerSymbol -- ^ Employ a state per function symbol. -- Slower, but more precise compared to 'Minimal'. deriving (Typeable, Enum, Bounded, Eq) instance Show InitialAutomaton where show Minimal = "minimal" show PerSymbol = "perSymbol" data Bounds = Bounds deriving (Typeable) -- proof object data BoundsCertificate = BoundsCertificate { boundHeight :: Int , automaton :: Automaton , sig :: Signature } data BoundsProof = BP Enrichment (Maybe BoundsCertificate) instance ComplexityProof BoundsProof where pprintProof (BP e Nothing) _ = paragraph (show e ++ "-boundness of the problem could not be verified.") pprintProof (BP e (Just p)) _ = paragraph ("The problem is " ++ show e ++ "-bounded by " ++ show (boundHeight p) ++ "." ++ " The enriched problem is compatible with the following automaton.") $+$ pprint (toRules (automaton p), (sig p)) answer (BP _ Nothing) = MaybeAnswer answer (BP _ _) = CertAnswer $ certified (unknown, poly (Just 1)) -- processor instance S.Processor Bounds where name Bounds = "bounds" description Bounds = [ unwords [ "This processor implements the (match|roof|top)-bounds technique" , "that induces linear derivational- and runtime-complexity for right-linear problems." , "For non-right-linear problems this processor fails immediately."] ] type ArgumentsOf Bounds = Arg (EnumOf InitialAutomaton) :+: Arg (EnumOf Enrichment) instanceName inst = "Bounds with " ++ show e ++ "-enrichment and initial automaton '" ++ show i ++ "'" where e :+: i = S.processorArgs inst arguments Bounds = opt { A.name = "initial" , A.description = unwords ["The employed initial automaton." , "If 'perSymbol' is set then the initial automaton admits one dedicated" , "state per function symbols." , "If 'minimal' is set then the initial automaton admits exactly" , "one state for derivational-complexity analysis. For runtime-complexity analysis, " , "two states are used in order to distinguish defined symbols from constructors."] , A.defaultValue = Minimal} :+: opt { A.name = "enrichment" , A.description = "The employed enrichment." , A.defaultValue = Match} type ProofOf Bounds = BoundsProof solve inst prob | isApplicable = do a <- compatibleAutomaton strict weak e i return $ BP e (Just $ BoundsCertificate (maximum $ 0 : [l | (_, l) <- Set.toList $ symbols a]) a sign) | otherwise = return $ BP e Nothing where strict = strictComponents prob weak = weakComponents prob sign = Prob.signature prob st = Prob.startTerms prob isApplicable = Trs.isRightLinear $ strict `Trs.union` weak i' :+: e = S.processorArgs inst -- e | e' == Default = if Trs.isRightLinear (strict `Trs.union` weak) then Match else Roof -- | otherwise = e' i = case i' of PerSymbol -> perSymInitialAutomaton strict weak st sign Minimal -> minimalInitialAutomaton strict weak st sign -- | This processor implements the bounds technique. bounds :: InitialAutomaton -> Enrichment -> S.ProcessorInstance Bounds bounds initialAutomaton enrichment = S.StdProcessor Bounds `S.withArgs` (initialAutomaton :+: enrichment) boundsProcessor :: S.StdProcessor Bounds boundsProcessor = S.StdProcessor Bounds mkMinRules :: Set.Set FS.Symbol -> Signature -> [State] -> State -> [Rule] mkMinRules fs sign qs q = [ Collapse (f,0) (take (FS.arity sign f) qs) q | f <- Set.toList $ fs] minimalInitialAutomaton :: Trs -> Trs -> StartTerms -> Signature -> Automaton minimalInitialAutomaton strict weak (TermAlgebra fs) sign = fromRules $ mkMinRules fs' sign (repeat 1) 1 where fs' = fs `Set.intersection` Trs.functionSymbols trs trs = strict `Trs.union` weak minimalInitialAutomaton strict weak (BasicTerms ds cs) sign = fromRules $ mkMinRules ds' sign (repeat 2) 1 ++ mkMinRules cs' sign (repeat 2) 2 where fs = Trs.functionSymbols trs ds' = fs `Set.intersection` ds cs' = fs `Set.intersection` cs trs = strict `Trs.union` weak mkPerSymRules :: Signature -> [FS.Symbol] -> FS.Symbol -> [Rule] mkPerSymRules sign fs f = [ Collapse (f,0) args (enum f) | args <- listProduct $ take (FS.arity sign f) ffs ] where ffs = repeat [enum g | g <- fs] mkPerSymEmptyRules :: Signature -> State -> FS.Symbol -> [Rule] mkPerSymEmptyRules sign q f = [Collapse (f,0) (replicate (FS.arity sign f) q) (enum f)] perSymInitialAutomaton :: Trs -> Trs -> StartTerms -> Signature -> Automaton perSymInitialAutomaton strict weak (TermAlgebra fs) sign = fromRules $ concatMap (mkPerSymRules sign fs') fs' where fs' = Set.toList $ fs `Set.intersection` Trs.functionSymbols trs trs = strict `Trs.union` weak perSymInitialAutomaton strict weak (BasicTerms ds cs) sign = fromRules $ mk ds' ++ mk cs' where fs = Trs.functionSymbols trs ds' = Set.toList $ fs `Set.intersection` ds cs' = Set.toList $ fs `Set.intersection` cs trs = strict `Trs.union` weak mk roots = concatMap mkBase roots mkBase = if null cs' then mkPerSymEmptyRules sign (maximum [ enum f | f <- Set.toList fs ] + 1) else mkPerSymRules sign cs'
mzini/TcT
source/Tct/Method/Bounds.hs
gpl-3.0
8,030
0
20
2,363
1,793
978
815
115
2
{-# LANGUAGE GADTs #-} -- | Simple embedded DSL using GADT's. -- -- Example adapted from: -- -- https://en.wikibooks.org/wiki/Haskell/GADT module ExprDSLGADTs where data Expr a where I :: Int -> Expr Int B :: Bool -> Expr Bool Add :: Expr Int -> Expr Int -> Expr Int Eq :: (Eq a) => Expr a -> Expr a -> Expr Bool eRight = (I 5 `Add` I 1) `Eq` I 7 -- | And here we see that the use of GADT's prevent us from writting these -- expressions. -- -- > eWrong = (B True) `Add` I 5 -- Won't type check since 'B True' does not -- > -- have type 'Expr Int'! -- -- | How to define an evaluator? Let see... eval :: Expr a -> a eval (I i) = i eval (B b) = b eval (Add e0 e1) = eval e0 + eval e1 eval (Eq e0 e1) = eval e0 == eval e1 -- | Note that @Expr@ is quite unusual: it is parametrized but it is not a container! -- -- - @Expr Int@ is an expresion that evaluates to an @Int@, not a container -- for an integer. -- -- - @Expr b@ could be inhabited for some @b@: for instance @Expr String@. -- -- - It makes no sense (and we cannot) define a function with type @(a ->b) -- -> Expr a -> Expr b@ (How would you transform a @Expr Int@ into a @Expr -- Bool@?). -- mapExpr :: (a -> b) -> Expr a -> Expr b mapExpr f e = undefined -- How would you define this? -- | Do we need to define the type of a function operating on Phantom Types -- explicitly? -- -- Note that there are two possible types to this function. --f :: Expr a -> String whatIs :: Expr Int -> String whatIs (I _) = "an integer expression" whatIs (Add _ _) = "an adition operation"
capitanbatata/apath-slfp
competent/gadts/src/ExprDSLGADTs.hs
gpl-3.0
1,592
0
8
389
315
173
142
18
1
{-| Module : Main Copyright : (c) Chris Tetreault, 2014 License : GPL-3 Stability : experimental The Main module implements the main function; the entry point to the program. -} module Main where import DMP.Photobooth import DMP.Photobooth.Monads import DMP.Photobooth.Core import System.Exit {-| The main function is the entry point to the program. The main function initializes the program state, then runs the photoboothMain monadic action. calls exitFailure if photoboothMain returns Nothing -} main :: IO () main = do coreState <- initCoreState result <- runCoreMonad coreState photoboothMain case result of Nothing -> exitFailure Just _ -> exitSuccess
christetreault/dmp-photo-booth-prime
Main.hs
gpl-3.0
746
0
10
185
84
45
39
17
2
{-# LANGUAGE Arrows, NoMonomorphismRestriction #-} -- -- Same transformation as the Yesod XML example: http://www.yesodweb.com/book/xml -- Using XHT to see how it compares to xml-coduit. -- module YesodExample (process) where import Text.XML.HXT.Core process :: ArrowXml a => a XmlTree XmlTree process = deep doc doc = isElm "document" >>> selem "html" [dead, body] dead = selem "head" [ selem "title" [ title ]] title = (hasTitle `guards` getTitle) `orElse` (txt "Untitled Document") where getTitle = getAttrValue "title" >>> mkText hasTitle = getAttrl >>> hasName "title" >>> (neg isWhiteSpace) -- could use hasAttr body = selem "body" [ tags ] tags = getChildren >>> choiceA [ isElm "para" :-> tag "p" , isElm "em" :-> tag "i" , isElm "strong" :-> tag "b" , isElm "image" :-> tagWithAttrFilter "img" imgAttrl [] -- images can't have children , this :-> this -- copy over as is if not one of the above ] imgAttrl = renameHref `when` (hasName "href") where renameHref = changeAttrName $ mkName . const "src" -- make a tag with the given name and copy over the element's attributes. tag name = tagWithAttrFilter name this [ tags ] -- make a tag with the given name and process the element's attributes using the given filter. tagWithAttrFilter name f = mkelem name [ getAttrl >>> f ] isElm name = isElem >>> hasName name
c0c0n3/hAppYard
hxml/hxt-vs-xml-conduit/hxt/YesodExample.hs
gpl-3.0
1,527
0
10
430
337
180
157
24
1
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} -- | -- Module : Main -- Copyright : (c) 2013 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 Main (main) where import Control.Concurrent hiding (yield) import Control.Concurrent.Race import Control.Concurrent.STM import Control.Monad (forever) import Control.Monad.CatchIO hiding (Handler) import Control.Monad.IO.Class import Czar.EKG import qualified Czar.Internal.Protocol.Event as E import qualified Czar.Internal.Protocol.Metric as M import Czar.Internal.Protocol.Subscription import Czar.Log import Czar.Options import Czar.Protocol import Czar.Socket import Czar.Types import qualified Data.ByteString.Char8 as BS import Data.Foldable import Data.Monoid import qualified Data.Sequence as Seq import Prelude hiding (mapM_) import Text.Printf commonOptions "Handler" $ do addressOption "hdServer" "server" defaultHandler "Czar Server address to connect to" addressOption "hdGraphite" "graphite" "unix://graphite.sock" "Graphite address to write metrics to" stringsOption "hdTags" "tags" ["*"] "Tags to subscribe to" secondsOption "optEmission" "metric-frequency" 30 "Frequency of internal metric emissions" main :: IO () main = runProgram $ \Handler{..} -> do logInfo "starting graphite handler ..." queue <- atomically newTQueue stats <- newStats "localhost" "czar.graphite" Nothing ["czar-graphite"] raceAll [ healthCheck optEmission stats (atomically . writeTQueue queue) , connectServer hdServer hdTags queue , connectGraphite hdGraphite queue ] connectServer :: (Functor m, MonadCatchIO m) => Address -> [String] -> TQueue Event -> m () connectServer addr tags queue = connect addr $ do logPeerTX $ "sending subscription for " ++ show tags send . Subscription "graphite" (Just "Graphite Handler") . Seq.fromList $ map fromString tags child <- forkContextFinally (forever $ liftIO (atomically $ readTQueue queue) >>= send) finish continue `finally` liftIO (killThread child) where continue = receive yield yield (E evt) = do logPeerRX (show $ E.tags evt) liftIO . atomically $ writeTQueue queue evt continue yield Syn = logPeerRX "SYN" >> send Ack >> logPeerTX "ACK" >> continue yield _ = logPeerRX "FIN" connectGraphite :: MonadCatchIO m => Address -> TQueue Event -> m () connectGraphite _addr queue = liftIO . forever $ do E.Event{..} <- atomically (readTQueue queue) mapM_ (print . line host key) metrics where line host pre M.Metric{..} = k <> " " <> v <> " " <> t where k = BS.intercalate "." $ map utf8ToBS [host, pre, key] v = BS.pack $ printf "%.8f" value t = BS.pack $ show time -- FIXME: Take type into account -- FIXME: Safely escape full keys
brendanhay/czar
czar-graphite/Main.hs
mpl-2.0
3,811
0
16
1,201
797
417
380
80
3
import Data.List import System.Random import System.IO import Neural main = do g <- getStdGen csv <- openFile "learning.dat" WriteMode let un = randomNNet g [2,16,1] let uloop n = do let r = concatMap (feedforward n) [[0,0],[1,1],[1,0],[0,1]] hPutStrLn csv $ intercalate " " $ map show r case map (\n -> (n < 0.1, n > 0.9)) r of [(True,_),(True,_),(_,True),(_,True)] -> do hClose csv putStrLn "Done" print n _ -> uloop $ (backprop 0.15 [0,0] [0] . backprop 0.15 [0,1] [1] . backprop 0.15 [1,1] [0] . backprop 0.15 [1,0] [1]) n uloop un
quickdudley/varroa
test.hs
agpl-3.0
609
0
22
167
348
184
164
19
2
{- - This file is part of Bilder. - - Bilder is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Bilder 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 Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with Bilder. If not, see <http://www.gnu.org/licenses/>. - - Copyright Β© 2012-2013 Filip Lundborg - Copyright Β© 2012-2013 Ingemar Γ…dahl - -} {-# LANGUAGE UnicodeSyntax #-} module TypeChecker.Inferring where -- Imports {{{ import Control.Monad import Builtins import TypeChecker.TCM import TypeChecker.TCM.Errors import TypeChecker.TCM.Utils import TypeChecker.Renamer.Utils import TypeChecker.Utils import TypeChecker.Types (varType) import FrontEnd.AbsGrammar import FrontEnd.Instances import Compiler.Utils (mapExpM) import Text.Printf (printf) -- }}} setExpAssigned ∷ Exp β†’ TCM () setExpAssigned (EVar cid) = setAssigned (cIdentToString cid) setExpAssigned e = void $ mapExpM (\x β†’ setExpAssigned x >> return x) e inferExp ∷ Exp β†’ TCM Type inferExp (EFloat _) = return TFloat inferExp (EInt _) = return TInt inferExp ETrue = return TBool inferExp EFalse = return TBool inferExp (EVar cid) = do types ← lookupVarTypes cid isAssigned cid >>= (\b β†’ unless b $ notAssigned cid) when (length types > 1) $ warning (cIdentToPos cid) $ printf "more than one function/variable by the name \"%s\" - using the one declared last." (cIdentToString cid) return (head types) inferExp (ECond ec tkq etrue tkc efalse) = do t ← inferExp ec unless (t `elem` [TInt,TFloat,TBool]) $ badConditional t (tkpos tkq) tetrue ← inferExp etrue tefalse ← inferExp efalse unless (tetrue == tefalse) $ typeMismatch (tkpos tkc) tetrue tefalse return tetrue inferExp (EAss m@(EMember {}) tk e) = inferNonVarAssignment tk m e inferExp (EAssAdd m@(EMember {}) tk e) = inferNonVarAssignment tk m e inferExp (EAssSub m@(EMember {}) tk e) = inferNonVarAssignment tk m e inferExp (EAssMul m@(EMember {}) tk e) = inferNonVarAssignment tk m e inferExp (EAssDiv m@(EMember {}) tk e) = inferNonVarAssignment tk m e inferExp (EAssMod m@(EMember {}) tk e) = inferNonVarAssignment tk m e inferExp (EAss (EVar cid) tk e) = inferAssignment tk cid e inferExp (EAssAdd (EVar cid) tk e) = inferAssignment tk cid e inferExp (EAssSub (EVar cid) tk e) = inferAssignment tk cid e inferExp (EAssMul (EVar cid) tk e) = inferAssignment tk cid e inferExp (EAssDiv (EVar cid) tk e) = inferAssignment tk cid e inferExp (EAssMod (EVar cid) tk e) = inferAssignment tk cid e inferExp (EAss _ tk _) = lhsMustBeVar tk inferExp (EAssAdd _ tk _) = lhsMustBeVar tk inferExp (EAssSub _ tk _) = lhsMustBeVar tk inferExp (EAssMul _ tk _) = lhsMustBeVar tk inferExp (EAssDiv _ tk _) = lhsMustBeVar tk inferExp (EAssMod _ tk _) = lhsMustBeVar tk inferExp (EAssBWAnd _ tk _) = notSupportedError tk inferExp (EAssBWXOR _ tk _) = notSupportedError tk inferExp (EAssBWOR _ tk _) = notSupportedError tk inferExp (EOR el tk er) = inferBoolexp tk el er inferExp (EXOR el tk er) = inferBoolexp tk el er inferExp (EAnd el tk er) = inferBoolexp tk el er inferExp (EBWOR _ tk _) = notSupportedError tk inferExp (EBWXOR _ tk _) = notSupportedError tk inferExp (EBWAnd _ tk _) = notSupportedError tk inferExp (EEqual el tk er) = inferConditional tk el er inferExp (ENEqual el tk er) = inferConditional tk el er inferExp (EBWShiftLeft _ tk _) = notSupportedError tk inferExp (EBWShiftRight _ tk _) = notSupportedError tk inferExp (ECall cid es) = do args ← mapM inferExp es funs ← lookupFunction (cIdentToString cid) funsAlias ← lookupAliasMaybe (cIdentToString cid) >>= (\x β†’ case x of Just y β†’ lookupFunction y; Nothing β†’ return [] ) case tryApplyType funs args `mplus` tryUncurryType funs args `mplus` tryApplyType funsAlias args `mplus` tryUncurryType funsAlias args of Just fun β†’ return fun Nothing β†’ noFunctionFound cid args inferExp (ETypeCall t es) = do expts ← mapM inferExp es t' ← filterTDef t if expts `elem` typeConstuctors t' then return t' else noTypeConstructorError t' expts inferExp (EAdd el tk er) = inferBinaryExp tk el er inferExp (EMul el tk er) = inferBinaryExp tk el er inferExp (ESub el tk er) = inferBinaryExp tk el er inferExp (EDiv el tk er) = inferBinaryExp tk el er inferExp (EMod _ tk _) = notSupportedError tk -- TODO: implement? :S inferExp (ENeg tk e) = inferBinaryNumExp tk e inferExp (EPos tk e) = inferBinaryNumExp tk e inferExp (ENegSign tk e) = do t ← inferExp e unless (isBoolish t) $ numOrBoolExpected tk return TBool inferExp (EPreInc tk e) = inferUnaryNumExp tk e inferExp (EPreDec tk e) = inferUnaryNumExp tk e inferExp (EPostInc e tk) = inferUnaryNumExp tk e inferExp (EPostDec e tk) = inferUnaryNumExp tk e inferExp (EComplement tk _) = notSupportedError tk inferExp (ELt el tk er) = inferConditional tk el er inferExp (EGt el tk er) = inferConditional tk el er inferExp (ELEt el tk er) = inferConditional tk el er inferExp (EGEt el tk er) = inferConditional tk el er inferExp (EMember el cid) = do t ← inferExp el let pos = memberComponents t if any (\p -> all (== True) $ map (`elem` p) n) pos then if length n <= length types then return $ types !! (length n - 1) else vectorTooBig cid (length n) else wrongVectorComponents cid t where types = [TFloat, TVec2, TVec3, TVec4] n = cIdentToString cid inferExp (EMemberCall el cid ers) = do tel ← inferExp el case componentFunc (cIdentToString cid) tel ers of Nothing β†’ mapM inferExp ers >>= noFunctionFound cid Just (rt, argt, ecf) β†’ do tecf ← mapM inferExp ecf if tecf == argt then return rt else noFunctionFound cid tecf inferExp (EIndex cid es) = do t ← inferExp es unless (t == TInt) $ debugError "NOPE" v ← lookupVar cid case varType v of TArray arrType β†’ return arrType typ β†’ if isMat typ then return $ mkVecType $ matSize typ else debugError "MOAR NOPE" inferExp (EIndexDouble cid e1 e2) = do t1 ← inferExp e1 t2 ← inferExp e2 v ← lookupVar cid unless (t1 == t2 && t1 == TInt) $ debugError "NOPE" unless (isMat (varType v)) $ debugError "ANNAT NOPE" return TFloat inferExp e = debugError $ show e ++ " not inferrablelollolo" inferConditional ∷ Token a => a β†’ Exp β†’ Exp β†’ TCM Type inferConditional tk el er = do tl ← inferExp el tr ← inferExp er if all isNum [tl,tr] then return TBool else badCondTypes tk tl tr inferBinaryExp ∷ Token a => a β†’ Exp β†’ Exp β†’ TCM Type inferBinaryExp tk el er = do tl ← inferExp el tr ← inferExp er case compNumType tl tr of Just t β†’ return t Nothing β†’ badBinaryTypes tk tl tr inferBinaryNumExp ∷ Token a => a β†’ Exp β†’ TCM Type inferBinaryNumExp tk e = do t ← inferExp e unless (isNum t) $ numExpected tk return t inferUnaryNumExp ∷ Token a => a β†’ Exp β†’ TCM Type inferUnaryNumExp tk (EVar n) = do t ← liftM varType $ lookupVar n unless (isNum t) $ numExpected tk return t inferUnaryNumExp tk _ = numExpected tk inferAssignment ∷ Token a => a β†’ CIdent β†’ Exp β†’ TCM Type inferAssignment tk cid e = do setCIdentAssigned cid targetType ← liftM varType $ lookupVar cid valueType ← inferExp e case compAssType targetType valueType of Just _ β†’ return targetType Nothing β†’ expTypeMismatch tk targetType valueType inferNonVarAssignment ∷ Token a => a β†’ Exp β†’ Exp β†’ TCM Type inferNonVarAssignment tk m@(EMember ie _) e = do setExpAssigned ie memType ← inferExp m valueType ← inferExp e case compAssType memType valueType of Just _ β†’ return valueType Nothing β†’ expTypeMismatch tk memType valueType inferBoolexp ∷ Token a => a β†’ Exp β†’ Exp β†’ TCM Type inferBoolexp tk el er = do tl ← inferExp el tr ← inferExp er if all isBoolish [tl,tr] then return TBool else badBinaryTypes tk tl tr -- vi:fdm=marker
ingemaradahl/bilder
src/TypeChecker/Inferring.hs
lgpl-3.0
8,353
0
15
1,715
3,108
1,484
1,624
185
10
{-# LANGUAGE QuasiQuotes, TemplateHaskell #-} {-# OPTIONS_GHC -Wall #-} -- http://www.well-typed.com/blog/2014/10/quasi-quoting-dsls/ import QQAst import Language.Haskell.TH.Syntax prog1 :: Prog prog1 = [prog| var x ; x := read ; write (x + x + 1) |] prog2 :: VarName -> Integer -> Prog prog2 y n = [prog| var x ; x := read ; write (x + y + n) |] optimize :: Expr -> Expr optimize [expr| a + n - m |] | n == m = optimize a optimize other = other test1 :: IO () test1 = intIO $ intProg prog1 test2 :: IO () test2 = intIO $ intProg (prog2 "x" 2) test3 :: IO () test3 = print . optimize =<< parseIO parseExpr =<< getLine test4 :: Lift a => a -> Q Exp test4 x = [| id x |]
egaburov/funstuff
Haskell/thsk/qqast.hs
apache-2.0
707
0
8
175
209
115
94
19
1
-- Copyright 2015 Peter Harpending -- -- 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. -- | -- Module : Main -- Description : Test of editor-open -- Copyright : Copyright 2015 Peter Harpending -- License : Apache-2.0 -- Maintainer : Peter Harpending <[email protected]> -- Stability : experimental -- Portability : POSIX -- module Main where import qualified Data.ByteString as B import Paths_editor_open import System.IO import Text.Editor main :: IO () main = getDataFileName "res/bug-schema.yaml" >>= runUserEditorDWIMFile yamlTemplate >>= B.hPut stdout
pharpend/editor-open
tests/test_yaml_file.hs
apache-2.0
1,128
0
7
227
81
55
26
10
1