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
-- | Part of this code is from "Report on the Programming Language Haskell", -- version 1.2, appendix C. module Language.Preprocessor.Unlit (unlit) where import Char data Classified = Program String | Blank | Comment | Include Int String | Pre String classify :: [String] -> [Classified] classify [] = [] classify (('\\':x):xs) | x == "begin{code}" = Blank : allProg xs where allProg [] = [] -- Should give an error message, -- but I have no good position information. allProg (('\\':x):xs) | x == "end{code}" = Blank : classify xs allProg (x:xs) = Program x:allProg xs classify (('>':x):xs) = Program (' ':x) : classify xs classify (('#':x):xs) = (case words x of (line:file:_) | all isDigit line -> Include (read line) file _ -> Pre x ) : classify xs classify (x:xs) | all isSpace x = Blank:classify xs classify (x:xs) = Comment:classify xs unclassify :: Classified -> String unclassify (Program s) = s unclassify (Pre s) = '#':s unclassify (Include i f) = '#':' ':show i ++ ' ':f unclassify Blank = "" unclassify Comment = "" -- | 'unlit' takes a filename (for error reports), and transforms the -- given string, to eliminate the literate comments from the program text. unlit :: FilePath -> String -> String unlit file lhs = (unlines . map unclassify . adjacent file (0::Int) Blank . classify) (inlines lhs) adjacent :: FilePath -> Int -> Classified -> [Classified] -> [Classified] adjacent file 0 _ (x :xs) = x : adjacent file 1 x xs -- force evaluation of line number adjacent file n y@(Program _) (x@Comment :xs) = error (message file n "program" "comment") adjacent file n y@(Program _) (x@(Include i f):xs) = x: adjacent f i y xs adjacent file n y@(Program _) (x@(Pre _) :xs) = x: adjacent file (n+1) y xs adjacent file n y@Comment (x@(Program _) :xs) = error (message file n "comment" "program") adjacent file n y@Comment (x@(Include i f):xs) = x: adjacent f i y xs adjacent file n y@Comment (x@(Pre _) :xs) = x: adjacent file (n+1) y xs adjacent file n y@Blank (x@(Include i f):xs) = x: adjacent f i y xs adjacent file n y@Blank (x@(Pre _) :xs) = x: adjacent file (n+1) y xs adjacent file n _ (x@next :xs) = x: adjacent file (n+1) x xs adjacent file n _ [] = [] message "\"\"" n p c = "Line "++show n++": "++p++ " line before "++c++" line.\n" message [] n p c = "Line "++show n++": "++p++ " line before "++c++" line.\n" message file n p c = "In file " ++ file ++ " at line "++show n++": "++p++ " line before "++c++" line.\n" -- Re-implementation of 'lines', for better efficiency (but decreased laziness). -- Also, importantly, accepts non-standard DOS and Mac line ending characters. inlines s = lines' s id where lines' [] acc = [acc []] lines' ('\^M':'\n':s) acc = acc [] : lines' s id -- DOS lines' ('\^M':s) acc = acc [] : lines' s id -- MacOS lines' ('\n':s) acc = acc [] : lines' s id -- Unix lines' (c:s) acc = lines' s (acc . (c:))
alekar/hugs
cpphs/Language/Preprocessor/Unlit.hs
bsd-3-clause
3,350
1
13
1,022
1,363
700
663
50
5
{-# LANGUAGE GADTs #-} -- ToDo: remove -fno-warn-incomplete-patterns {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} module CmmCvt ( cmmOfZgraph ) where import BlockId import Cmm import CmmUtils import qualified OldCmm as Old import OldPprCmm () import Compiler.Hoopl hiding ((<*>), mkLabel, mkBranch) import Data.Maybe import Maybes import Outputable cmmOfZgraph :: CmmGroup -> Old.CmmGroup cmmOfZgraph tops = map mapTop tops where mapTop (CmmProc h l g) = CmmProc (Old.CmmInfo Nothing Nothing (info_tbl h)) l (ofZgraph g) mapTop (CmmData s ds) = CmmData s ds data ValueDirection = Arguments | Results add_hints :: Convention -> ValueDirection -> [a] -> [Old.CmmHinted a] add_hints conv vd args = zipWith Old.CmmHinted args (get_hints conv vd) get_hints :: Convention -> ValueDirection -> [ForeignHint] get_hints (Foreign (ForeignConvention _ hints _)) Arguments = hints get_hints (Foreign (ForeignConvention _ _ hints)) Results = hints get_hints _other_conv _vd = repeat NoHint get_conv :: ForeignTarget -> Convention get_conv (PrimTarget _) = NativeNodeCall -- JD: SUSPICIOUS get_conv (ForeignTarget _ fc) = Foreign fc cmm_target :: ForeignTarget -> Old.CmmCallTarget cmm_target (PrimTarget op) = Old.CmmPrim op cmm_target (ForeignTarget e (ForeignConvention cc _ _)) = Old.CmmCallee e cc ofZgraph :: CmmGraph -> Old.ListGraph Old.CmmStmt ofZgraph g = Old.ListGraph $ mapMaybe convert_block $ postorderDfs g -- We catenated some blocks in the conversion process, -- because of the CmmCondBranch -- the machine code does not have -- 'jump here or there' instruction, but has 'jump if true' instruction. -- As OldCmm has the same instruction, so we use it. -- When we are doing this, we also catenate normal goto-s (it is for free). -- Exactly, we catenate blocks with nonentry labes, that are -- a) mentioned exactly once as a successor -- b) any of 1) are a target of a goto -- 2) are false branch target of a conditional jump -- 3) are true branch target of a conditional jump, and -- the false branch target is a successor of at least 2 blocks -- and the condition can be inverted -- The complicated rule 3) is here because we need to assign at most one -- catenable block to a CmmCondBranch. where preds :: BlockEnv [CmmNode O C] preds = mapFold add mapEmpty $ toBlockMap g where add block env = foldr (add' $ lastNode block) env (successors block) add' :: CmmNode O C -> BlockId -> BlockEnv [CmmNode O C] -> BlockEnv [CmmNode O C] add' node succ env = mapInsert succ (node : (mapLookup succ env `orElse` [])) env to_be_catenated :: BlockId -> Bool to_be_catenated id | id == g_entry g = False | Just [CmmBranch _] <- mapLookup id preds = True | Just [CmmCondBranch _ _ f] <- mapLookup id preds , f == id = True | Just [CmmCondBranch e t f] <- mapLookup id preds , t == id , Just (_:_:_) <- mapLookup f preds , Just _ <- maybeInvertCmmExpr e = True to_be_catenated _ = False convert_block block | to_be_catenated (entryLabel block) = Nothing convert_block block = Just $ foldBlockNodesB3 (first, middle, last) block () where first :: CmmNode C O -> [Old.CmmStmt] -> Old.CmmBasicBlock first (CmmEntry bid) stmts = Old.BasicBlock bid stmts middle :: CmmNode O O -> [Old.CmmStmt] -> [Old.CmmStmt] middle node stmts = stmt : stmts where stmt :: Old.CmmStmt stmt = case node of CmmComment s -> Old.CmmComment s CmmAssign l r -> Old.CmmAssign l r CmmStore l r -> Old.CmmStore l r CmmUnsafeForeignCall (PrimTarget MO_Touch) _ _ -> Old.CmmNop CmmUnsafeForeignCall target ress args -> Old.CmmCall (cmm_target target) (add_hints (get_conv target) Results ress) (add_hints (get_conv target) Arguments args) Old.CmmMayReturn last :: CmmNode O C -> () -> [Old.CmmStmt] last node _ = stmts where stmts :: [Old.CmmStmt] stmts = case node of CmmBranch tgt | to_be_catenated tgt -> tail_of tgt | otherwise -> [Old.CmmBranch tgt] CmmCondBranch expr tid fid | to_be_catenated fid -> Old.CmmCondBranch expr tid : tail_of fid | to_be_catenated tid , Just expr' <- maybeInvertCmmExpr expr -> Old.CmmCondBranch expr' fid : tail_of tid | otherwise -> [Old.CmmCondBranch expr tid, Old.CmmBranch fid] CmmSwitch arg ids -> [Old.CmmSwitch arg ids] CmmCall e _ _ _ _ -> [Old.CmmJump e []] CmmForeignCall {} -> panic "ofZgraph: CmmForeignCall" tail_of bid = case foldBlockNodesB3 (first, middle, last) block () of Old.BasicBlock _ stmts -> stmts where Just block = mapLookup bid $ toBlockMap g
mcmaniac/ghc
compiler/cmm/CmmCvt.hs
bsd-3-clause
5,848
0
18
2,183
1,429
713
716
81
11
import Distribution.Simple import System.Process import System.Exit main = defaultMainWithHooks $ simpleUserHooks { postBuild = makeManPage } makeManPage _ _ _ _ = runCommand "make hops.1" >>= waitForProcess >>= exitWith
akc/gfscript
Setup.hs
bsd-3-clause
227
0
7
35
58
31
27
6
1
{-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Setter -- Copyright : (C) 2012-15 Edward Kmett -- License : BSD-style (see the file LICENSE) -- Maintainer : Edward Kmett <[email protected]> -- Stability : provisional -- Portability : Rank2Types -- -- A @'Setter' s t a b@ is a generalization of 'fmap' from 'Functor'. It allows you to map into a -- structure and change out the contents, but it isn't strong enough to allow you to -- enumerate those contents. Starting with @'fmap' :: 'Functor' f => (a -> b) -> f a -> f b@ -- we monomorphize the type to obtain @(a -> b) -> s -> t@ and then decorate it with 'Data.Functor.Identity.Identity' to obtain: -- -- @ -- type 'Setter' s t a b = (a -> 'Data.Functor.Identity.Identity' b) -> s -> 'Data.Functor.Identity.Identity' t -- @ -- -- Every 'Traversal' is a valid 'Setter', since 'Data.Functor.Identity.Identity' is 'Applicative'. -- -- Everything you can do with a 'Functor', you can do with a 'Setter'. There -- are combinators that generalize 'fmap' and ('<$'). ---------------------------------------------------------------------------- module Control.Lens.Setter ( -- * Setters Setter, Setter' , IndexedSetter, IndexedSetter' , ASetter, ASetter' , AnIndexedSetter, AnIndexedSetter' , Setting, Setting' -- * Building Setters , sets, setting , cloneSetter , cloneIndexPreservingSetter , cloneIndexedSetter -- * Common Setters , mapped, lifted , contramapped , argument -- * Functional Combinators , over , set , (.~), (%~) , (+~), (-~), (*~), (//~), (^~), (^^~), (**~), (||~), (<>~), (&&~), (<.~), (?~), (<?~) -- * State Combinators , assign , (.=), (%=) , (+=), (-=), (*=), (//=), (^=), (^^=), (**=), (||=), (<>=), (&&=), (<.=), (?=), (<?=) , (<~) -- * Writer Combinators , scribe , passing, ipassing , censoring, icensoring -- * Simplified State Setting , set' -- * Indexed Setters , imapOf, iover, iset , isets , (%@~), (.@~), (%@=), (.@=) -- * Arrow operators , assignA -- * Exported for legible error messages , Settable , Identity(..) -- * Deprecated , mapOf ) where import Control.Applicative import Control.Arrow import Control.Comonad import Control.Lens.Internal.Indexed import Control.Lens.Internal.Setter import Control.Lens.Type import Control.Monad (liftM) import Control.Monad.State.Class as State import Control.Monad.Writer.Class as Writer import Data.Functor.Contravariant import Data.Functor.Identity import Data.Monoid import Data.Profunctor import Data.Profunctor.Rep import Data.Profunctor.Sieve import Data.Profunctor.Unsafe import Prelude #ifdef HLINT {-# ANN module "HLint: ignore Avoid lambda" #-} #endif -- $setup -- >>> import Control.Lens -- >>> import Control.Monad.State -- >>> import Data.Char -- >>> import Data.Map as Map -- >>> import Debug.SimpleReflect.Expr as Expr -- >>> import Debug.SimpleReflect.Vars as Vars -- >>> let f :: Expr -> Expr; f = Vars.f -- >>> let g :: Expr -> Expr; g = Vars.g -- >>> let h :: Expr -> Expr -> Expr; h = Vars.h -- >>> let getter :: Expr -> Expr; getter = fun "getter" -- >>> let setter :: Expr -> Expr -> Expr; setter = fun "setter" -- >>> :set -XNoOverloadedStrings infixr 4 %@~, .@~, .~, +~, *~, -~, //~, ^~, ^^~, **~, &&~, <>~, ||~, %~, <.~, ?~, <?~ infix 4 %@=, .@=, .=, +=, *=, -=, //=, ^=, ^^=, **=, &&=, <>=, ||=, %=, <.=, ?=, <?= infixr 2 <~ ------------------------------------------------------------------------------ -- Setters ------------------------------------------------------------------------------ -- | Running a 'Setter' instantiates it to a concrete type. -- -- When consuming a setter directly to perform a mapping, you can use this type, but most -- user code will not need to use this type. type ASetter s t a b = (a -> Identity b) -> s -> Identity t -- | This is a useful alias for use when consuming a 'Setter''. -- -- Most user code will never have to use this type. -- -- @ -- type 'ASetter'' = 'Simple' 'ASetter' -- @ type ASetter' s a = ASetter s s a a -- | Running an 'IndexedSetter' instantiates it to a concrete type. -- -- When consuming a setter directly to perform a mapping, you can use this type, but most -- user code will not need to use this type. type AnIndexedSetter i s t a b = Indexed i a (Identity b) -> s -> Identity t -- | @ -- type 'AnIndexedSetter'' i = 'Simple' ('AnIndexedSetter' i) -- @ type AnIndexedSetter' i s a = AnIndexedSetter i s s a a -- | This is a convenient alias when defining highly polymorphic code that takes both -- 'ASetter' and 'AnIndexedSetter' as appropriate. If a function takes this it is -- expecting one of those two things based on context. type Setting p s t a b = p a (Identity b) -> s -> Identity t -- | This is a convenient alias when defining highly polymorphic code that takes both -- 'ASetter'' and 'AnIndexedSetter'' as appropriate. If a function takes this it is -- expecting one of those two things based on context. type Setting' p s a = Setting p s s a a ----------------------------------------------------------------------------- -- Setters ----------------------------------------------------------------------------- -- | This 'Setter' can be used to map over all of the values in a 'Functor'. -- -- @ -- 'fmap' ≡ 'over' 'mapped' -- 'Data.Traversable.fmapDefault' ≡ 'over' 'Data.Traversable.traverse' -- ('<$') ≡ 'set' 'mapped' -- @ -- -- >>> over mapped f [a,b,c] -- [f a,f b,f c] -- -- >>> over mapped (+1) [1,2,3] -- [2,3,4] -- -- >>> set mapped x [a,b,c] -- [x,x,x] -- -- >>> [[a,b],[c]] & mapped.mapped +~ x -- [[a + x,b + x],[c + x]] -- -- >>> over (mapped._2) length [("hello","world"),("leaders","!!!")] -- [("hello",5),("leaders",3)] -- -- @ -- 'mapped' :: 'Functor' f => 'Setter' (f a) (f b) a b -- @ -- -- If you want an 'IndexPreservingSetter' use @'setting' 'fmap'@. mapped :: Functor f => Setter (f a) (f b) a b mapped = sets fmap {-# INLINE mapped #-} -- | This 'setter' can be used to modify all of the values in a 'Monad'. -- -- You sometimes have to use this rather than 'mapped' -- due to -- temporary insanity 'Functor' is not a superclass of 'Monad'. -- -- @ -- 'liftM' ≡ 'over' 'lifted' -- @ -- -- >>> over lifted f [a,b,c] -- [f a,f b,f c] -- -- >>> set lifted b (Just a) -- Just b -- -- If you want an 'IndexPreservingSetter' use @'setting' 'liftM'@. lifted :: Monad m => Setter (m a) (m b) a b lifted = sets liftM {-# INLINE lifted #-} -- | This 'Setter' can be used to map over all of the inputs to a 'Contravariant'. -- -- @ -- 'contramap' ≡ 'over' 'contramapped' -- @ -- -- >>> getPredicate (over contramapped (*2) (Predicate even)) 5 -- True -- -- >>> getOp (over contramapped (*5) (Op show)) 100 -- "500" -- -- >>> Prelude.map ($ 1) $ over (mapped . _Unwrapping' Op . contramapped) (*12) [(*2),(+1),(^3)] -- [24,13,1728] -- contramapped :: Contravariant f => Setter (f b) (f a) a b contramapped = sets contramap {-# INLINE contramapped #-} -- | This 'Setter' can be used to map over the input of a 'Profunctor'. -- -- The most common 'Profunctor' to use this with is @(->)@. -- -- >>> (argument %~ f) g x -- g (f x) -- -- >>> (argument %~ show) length [1,2,3] -- 7 -- -- >>> (argument %~ f) h x y -- h (f x) y -- -- Map over the argument of the result of a function -- i.e., its second -- argument: -- -- >>> (mapped.argument %~ f) h x y -- h x (f y) -- -- @ -- 'argument' :: 'Setter' (b -> r) (a -> r) a b -- @ argument :: Profunctor p => Setter (p b r) (p a r) a b argument = sets lmap {-# INLINE argument #-} -- | Build an index-preserving 'Setter' from a map-like function. -- -- Your supplied function @f@ is required to satisfy: -- -- @ -- f 'id' ≡ 'id' -- f g '.' f h ≡ f (g '.' h) -- @ -- -- Equational reasoning: -- -- @ -- 'setting' '.' 'over' ≡ 'id' -- 'over' '.' 'setting' ≡ 'id' -- @ -- -- Another way to view 'sets' is that it takes a \"semantic editor combinator\" -- and transforms it into a 'Setter'. -- -- @ -- 'setting' :: ((a -> b) -> s -> t) -> 'Setter' s t a b -- @ setting :: ((a -> b) -> s -> t) -> IndexPreservingSetter s t a b setting l pafb = cotabulate $ \ws -> pure $ l (\a -> untainted (cosieve pafb (a <$ ws))) (extract ws) {-# INLINE setting #-} -- | Build a 'Setter', 'IndexedSetter' or 'IndexPreservingSetter' depending on your choice of 'Profunctor'. -- -- @ -- 'sets' :: ((a -> b) -> s -> t) -> 'Setter' s t a b -- @ sets :: (Profunctor p, Profunctor q, Settable f) => (p a b -> q s t) -> Optical p q f s t a b sets f g = taintedDot (f (untaintedDot g)) {-# INLINE sets #-} -- | Restore 'ASetter' to a full 'Setter'. cloneSetter :: ASetter s t a b -> Setter s t a b cloneSetter l afb = taintedDot $ runIdentity #. l (Identity #. untaintedDot afb) {-# INLINE cloneSetter #-} -- | Build an 'IndexPreservingSetter' from any 'Setter'. cloneIndexPreservingSetter :: ASetter s t a b -> IndexPreservingSetter s t a b cloneIndexPreservingSetter l pafb = cotabulate $ \ws -> taintedDot runIdentity $ l (\a -> Identity (untainted (cosieve pafb (a <$ ws)))) (extract ws) {-# INLINE cloneIndexPreservingSetter #-} -- | Clone an 'IndexedSetter'. cloneIndexedSetter :: AnIndexedSetter i s t a b -> IndexedSetter i s t a b cloneIndexedSetter l pafb = taintedDot (runIdentity #. l (Indexed $ \i -> Identity #. untaintedDot (indexed pafb i))) {-# INLINE cloneIndexedSetter #-} ----------------------------------------------------------------------------- -- Using Setters ----------------------------------------------------------------------------- -- | Modify the target of a 'Lens' or all the targets of a 'Setter' or 'Traversal' -- with a function. -- -- @ -- 'fmap' ≡ 'over' 'mapped' -- 'Data.Traversable.fmapDefault' ≡ 'over' 'Data.Traversable.traverse' -- 'sets' '.' 'over' ≡ 'id' -- 'over' '.' 'sets' ≡ 'id' -- @ -- -- Given any valid 'Setter' @l@, you can also rely on the law: -- -- @ -- 'over' l f '.' 'over' l g = 'over' l (f '.' g) -- @ -- -- /e.g./ -- -- >>> over mapped f (over mapped g [a,b,c]) == over mapped (f . g) [a,b,c] -- True -- -- Another way to view 'over' is to say that it transforms a 'Setter' into a -- \"semantic editor combinator\". -- -- >>> over mapped f (Just a) -- Just (f a) -- -- >>> over mapped (*10) [1,2,3] -- [10,20,30] -- -- >>> over _1 f (a,b) -- (f a,b) -- -- >>> over _1 show (10,20) -- ("10",20) -- -- @ -- 'over' :: 'Setter' s t a b -> (a -> b) -> s -> t -- 'over' :: 'ASetter' s t a b -> (a -> b) -> s -> t -- @ over :: Profunctor p => Setting p s t a b -> p a b -> s -> t over l f = runIdentity #. l (Identity #. f) {-# INLINE over #-} -- | Replace the target of a 'Lens' or all of the targets of a 'Setter' -- or 'Traversal' with a constant value. -- -- @ -- ('<$') ≡ 'set' 'mapped' -- @ -- -- >>> set _2 "hello" (1,()) -- (1,"hello") -- -- >>> set mapped () [1,2,3,4] -- [(),(),(),()] -- -- Note: Attempting to 'set' a 'Fold' or 'Getter' will fail at compile time with an -- relatively nice error message. -- -- @ -- 'set' :: 'Setter' s t a b -> b -> s -> t -- 'set' :: 'Iso' s t a b -> b -> s -> t -- 'set' :: 'Lens' s t a b -> b -> s -> t -- 'set' :: 'Traversal' s t a b -> b -> s -> t -- @ set :: ASetter s t a b -> b -> s -> t set l b = runIdentity #. l (\_ -> Identity b) {-# INLINE set #-} -- | Replace the target of a 'Lens' or all of the targets of a 'Setter'' -- or 'Traversal' with a constant value, without changing its type. -- -- This is a type restricted version of 'set', which retains the type of the original. -- -- >>> set' mapped x [a,b,c,d] -- [x,x,x,x] -- -- >>> set' _2 "hello" (1,"world") -- (1,"hello") -- -- >>> set' mapped 0 [1,2,3,4] -- [0,0,0,0] -- -- Note: Attempting to adjust 'set'' a 'Fold' or 'Getter' will fail at compile time with an -- relatively nice error message. -- -- @ -- 'set'' :: 'Setter'' s a -> a -> s -> s -- 'set'' :: 'Iso'' s a -> a -> s -> s -- 'set'' :: 'Lens'' s a -> a -> s -> s -- 'set'' :: 'Traversal'' s a -> a -> s -> s -- @ set' :: ASetter' s a -> a -> s -> s set' l b = runIdentity #. l (\_ -> Identity b) {-# INLINE set' #-} -- | Modifies the target of a 'Lens' or all of the targets of a 'Setter' or -- 'Traversal' with a user supplied function. -- -- This is an infix version of 'over'. -- -- @ -- 'fmap' f ≡ 'mapped' '%~' f -- 'Data.Traversable.fmapDefault' f ≡ 'Data.Traversable.traverse' '%~' f -- @ -- -- >>> (a,b,c) & _3 %~ f -- (a,b,f c) -- -- >>> (a,b) & both %~ f -- (f a,f b) -- -- >>> _2 %~ length $ (1,"hello") -- (1,5) -- -- >>> traverse %~ f $ [a,b,c] -- [f a,f b,f c] -- -- >>> traverse %~ even $ [1,2,3] -- [False,True,False] -- -- >>> traverse.traverse %~ length $ [["hello","world"],["!!!"]] -- [[5,5],[3]] -- -- @ -- ('%~') :: 'Setter' s t a b -> (a -> b) -> s -> t -- ('%~') :: 'Iso' s t a b -> (a -> b) -> s -> t -- ('%~') :: 'Lens' s t a b -> (a -> b) -> s -> t -- ('%~') :: 'Traversal' s t a b -> (a -> b) -> s -> t -- @ (%~) :: Profunctor p => Setting p s t a b -> p a b -> s -> t (%~) = over {-# INLINE (%~) #-} -- | Replace the target of a 'Lens' or all of the targets of a 'Setter' -- or 'Traversal' with a constant value. -- -- This is an infix version of 'set', provided for consistency with ('.='). -- -- @ -- f '<$' a ≡ 'mapped' '.~' f '$' a -- @ -- -- >>> (a,b,c,d) & _4 .~ e -- (a,b,c,e) -- -- >>> (42,"world") & _1 .~ "hello" -- ("hello","world") -- -- >>> (a,b) & both .~ c -- (c,c) -- -- @ -- ('.~') :: 'Setter' s t a b -> b -> s -> t -- ('.~') :: 'Iso' s t a b -> b -> s -> t -- ('.~') :: 'Lens' s t a b -> b -> s -> t -- ('.~') :: 'Traversal' s t a b -> b -> s -> t -- @ (.~) :: ASetter s t a b -> b -> s -> t (.~) = set {-# INLINE (.~) #-} -- | Set the target of a 'Lens', 'Traversal' or 'Setter' to 'Just' a value. -- -- @ -- l '?~' t ≡ 'set' l ('Just' t) -- @ -- -- >>> Nothing & id ?~ a -- Just a -- -- >>> Map.empty & at 3 ?~ x -- fromList [(3,x)] -- -- @ -- ('?~') :: 'Setter' s t a ('Maybe' b) -> b -> s -> t -- ('?~') :: 'Iso' s t a ('Maybe' b) -> b -> s -> t -- ('?~') :: 'Lens' s t a ('Maybe' b) -> b -> s -> t -- ('?~') :: 'Traversal' s t a ('Maybe' b) -> b -> s -> t -- @ (?~) :: ASetter s t a (Maybe b) -> b -> s -> t l ?~ b = set l (Just b) {-# INLINE (?~) #-} -- | Set with pass-through. -- -- This is mostly present for consistency, but may be useful for for chaining assignments. -- -- If you do not need a copy of the intermediate result, then using @l '.~' t@ directly is a good idea. -- -- >>> (a,b) & _1 <.~ c -- (c,(c,b)) -- -- >>> ("good","morning","vietnam") & _3 <.~ "world" -- ("world",("good","morning","world")) -- -- >>> (42,Map.fromList [("goodnight","gracie")]) & _2.at "hello" <.~ Just "world" -- (Just "world",(42,fromList [("goodnight","gracie"),("hello","world")])) -- -- @ -- ('<.~') :: 'Setter' s t a b -> b -> s -> (b, t) -- ('<.~') :: 'Iso' s t a b -> b -> s -> (b, t) -- ('<.~') :: 'Lens' s t a b -> b -> s -> (b, t) -- ('<.~') :: 'Traversal' s t a b -> b -> s -> (b, t) -- @ (<.~) :: ASetter s t a b -> b -> s -> (b, t) l <.~ b = \s -> (b, set l b s) {-# INLINE (<.~) #-} -- | Set to 'Just' a value with pass-through. -- -- This is mostly present for consistency, but may be useful for for chaining assignments. -- -- If you do not need a copy of the intermediate result, then using @l '?~' d@ directly is a good idea. -- -- >>> import Data.Map as Map -- >>> _2.at "hello" <?~ "world" $ (42,Map.fromList [("goodnight","gracie")]) -- ("world",(42,fromList [("goodnight","gracie"),("hello","world")])) -- -- @ -- ('<?~') :: 'Setter' s t a ('Maybe' b) -> b -> s -> (b, t) -- ('<?~') :: 'Iso' s t a ('Maybe' b) -> b -> s -> (b, t) -- ('<?~') :: 'Lens' s t a ('Maybe' b) -> b -> s -> (b, t) -- ('<?~') :: 'Traversal' s t a ('Maybe' b) -> b -> s -> (b, t) -- @ (<?~) :: ASetter s t a (Maybe b) -> b -> s -> (b, t) l <?~ b = \s -> (b, set l (Just b) s) {-# INLINE (<?~) #-} -- | Increment the target(s) of a numerically valued 'Lens', 'Setter' or 'Traversal'. -- -- >>> (a,b) & _1 +~ c -- (a + c,b) -- -- >>> (a,b) & both +~ c -- (a + c,b + c) -- -- >>> (1,2) & _2 +~ 1 -- (1,3) -- -- >>> [(a,b),(c,d)] & traverse.both +~ e -- [(a + e,b + e),(c + e,d + e)] -- -- @ -- ('+~') :: 'Num' a => 'Setter'' s a -> a -> s -> s -- ('+~') :: 'Num' a => 'Iso'' s a -> a -> s -> s -- ('+~') :: 'Num' a => 'Lens'' s a -> a -> s -> s -- ('+~') :: 'Num' a => 'Traversal'' s a -> a -> s -> s -- @ (+~) :: Num a => ASetter s t a a -> a -> s -> t l +~ n = over l (+ n) {-# INLINE (+~) #-} -- | Multiply the target(s) of a numerically valued 'Lens', 'Iso', 'Setter' or 'Traversal'. -- -- >>> (a,b) & _1 *~ c -- (a * c,b) -- -- >>> (a,b) & both *~ c -- (a * c,b * c) -- -- >>> (1,2) & _2 *~ 4 -- (1,8) -- -- >>> Just 24 & mapped *~ 2 -- Just 48 -- -- @ -- ('*~') :: 'Num' a => 'Setter'' s a -> a -> s -> s -- ('*~') :: 'Num' a => 'Iso'' s a -> a -> s -> s -- ('*~') :: 'Num' a => 'Lens'' s a -> a -> s -> s -- ('*~') :: 'Num' a => 'Traversal'' s a -> a -> s -> s -- @ (*~) :: Num a => ASetter s t a a -> a -> s -> t l *~ n = over l (* n) {-# INLINE (*~) #-} -- | Decrement the target(s) of a numerically valued 'Lens', 'Iso', 'Setter' or 'Traversal'. -- -- >>> (a,b) & _1 -~ c -- (a - c,b) -- -- >>> (a,b) & both -~ c -- (a - c,b - c) -- -- >>> _1 -~ 2 $ (1,2) -- (-1,2) -- -- >>> mapped.mapped -~ 1 $ [[4,5],[6,7]] -- [[3,4],[5,6]] -- -- @ -- ('-~') :: 'Num' a => 'Setter'' s a -> a -> s -> s -- ('-~') :: 'Num' a => 'Iso'' s a -> a -> s -> s -- ('-~') :: 'Num' a => 'Lens'' s a -> a -> s -> s -- ('-~') :: 'Num' a => 'Traversal'' s a -> a -> s -> s -- @ (-~) :: Num a => ASetter s t a a -> a -> s -> t l -~ n = over l (subtract n) {-# INLINE (-~) #-} -- | Divide the target(s) of a numerically valued 'Lens', 'Iso', 'Setter' or 'Traversal'. -- -- >>> (a,b) & _1 //~ c -- (a / c,b) -- -- >>> (a,b) & both //~ c -- (a / c,b / c) -- -- >>> ("Hawaii",10) & _2 //~ 2 -- ("Hawaii",5.0) -- -- @ -- ('//~') :: 'Fractional' a => 'Setter'' s a -> a -> s -> s -- ('//~') :: 'Fractional' a => 'Iso'' s a -> a -> s -> s -- ('//~') :: 'Fractional' a => 'Lens'' s a -> a -> s -> s -- ('//~') :: 'Fractional' a => 'Traversal'' s a -> a -> s -> s -- @ (//~) :: Fractional a => ASetter s t a a -> a -> s -> t l //~ n = over l (/ n) {-# INLINE (//~) #-} -- | Raise the target(s) of a numerically valued 'Lens', 'Setter' or 'Traversal' to a non-negative integral power. -- -- >>> (1,3) & _2 ^~ 2 -- (1,9) -- -- @ -- ('^~') :: ('Num' a, 'Integral' e) => 'Setter'' s a -> e -> s -> s -- ('^~') :: ('Num' a, 'Integral' e) => 'Iso'' s a -> e -> s -> s -- ('^~') :: ('Num' a, 'Integral' e) => 'Lens'' s a -> e -> s -> s -- ('^~') :: ('Num' a, 'Integral' e) => 'Traversal'' s a -> e -> s -> s -- @ (^~) :: (Num a, Integral e) => ASetter s t a a -> e -> s -> t l ^~ n = over l (^ n) {-# INLINE (^~) #-} -- | Raise the target(s) of a fractionally valued 'Lens', 'Setter' or 'Traversal' to an integral power. -- -- >>> (1,2) & _2 ^^~ (-1) -- (1,0.5) -- -- @ -- ('^^~') :: ('Fractional' a, 'Integral' e) => 'Setter'' s a -> e -> s -> s -- ('^^~') :: ('Fractional' a, 'Integral' e) => 'Iso'' s a -> e -> s -> s -- ('^^~') :: ('Fractional' a, 'Integral' e) => 'Lens'' s a -> e -> s -> s -- ('^^~') :: ('Fractional' a, 'Integral' e) => 'Traversal'' s a -> e -> s -> s -- @ -- (^^~) :: (Fractional a, Integral e) => ASetter s t a a -> e -> s -> t l ^^~ n = over l (^^ n) {-# INLINE (^^~) #-} -- | Raise the target(s) of a floating-point valued 'Lens', 'Setter' or 'Traversal' to an arbitrary power. -- -- >>> (a,b) & _1 **~ c -- (a**c,b) -- -- >>> (a,b) & both **~ c -- (a**c,b**c) -- -- >>> _2 **~ 10 $ (3,2) -- (3,1024.0) -- -- @ -- ('**~') :: 'Floating' a => 'Setter'' s a -> a -> s -> s -- ('**~') :: 'Floating' a => 'Iso'' s a -> a -> s -> s -- ('**~') :: 'Floating' a => 'Lens'' s a -> a -> s -> s -- ('**~') :: 'Floating' a => 'Traversal'' s a -> a -> s -> s -- @ (**~) :: Floating a => ASetter s t a a -> a -> s -> t l **~ n = over l (** n) {-# INLINE (**~) #-} -- | Logically '||' the target(s) of a 'Bool'-valued 'Lens' or 'Setter'. -- -- >>> both ||~ True $ (False,True) -- (True,True) -- -- >>> both ||~ False $ (False,True) -- (False,True) -- -- @ -- ('||~') :: 'Setter'' s 'Bool' -> 'Bool' -> s -> s -- ('||~') :: 'Iso'' s 'Bool' -> 'Bool' -> s -> s -- ('||~') :: 'Lens'' s 'Bool' -> 'Bool' -> s -> s -- ('||~') :: 'Traversal'' s 'Bool' -> 'Bool' -> s -> s -- @ (||~):: ASetter s t Bool Bool -> Bool -> s -> t l ||~ n = over l (|| n) {-# INLINE (||~) #-} -- | Logically '&&' the target(s) of a 'Bool'-valued 'Lens' or 'Setter'. -- -- >>> both &&~ True $ (False, True) -- (False,True) -- -- >>> both &&~ False $ (False, True) -- (False,False) -- -- @ -- ('&&~') :: 'Setter'' s 'Bool' -> 'Bool' -> s -> s -- ('&&~') :: 'Iso'' s 'Bool' -> 'Bool' -> s -> s -- ('&&~') :: 'Lens'' s 'Bool' -> 'Bool' -> s -> s -- ('&&~') :: 'Traversal'' s 'Bool' -> 'Bool' -> s -> s -- @ (&&~) :: ASetter s t Bool Bool -> Bool -> s -> t l &&~ n = over l (&& n) {-# INLINE (&&~) #-} ------------------------------------------------------------------------------ -- Using Setters with State ------------------------------------------------------------------------------ -- | Replace the target of a 'Lens' or all of the targets of a 'Setter' or 'Traversal' in our monadic -- state with a new value, irrespective of the old. -- -- This is an alias for ('.='). -- -- >>> execState (do assign _1 c; assign _2 d) (a,b) -- (c,d) -- -- >>> execState (both .= c) (a,b) -- (c,c) -- -- @ -- 'assign' :: 'MonadState' s m => 'Iso'' s a -> a -> m () -- 'assign' :: 'MonadState' s m => 'Lens'' s a -> a -> m () -- 'assign' :: 'MonadState' s m => 'Traversal'' s a -> a -> m () -- 'assign' :: 'MonadState' s m => 'Setter'' s a -> a -> m () -- @ assign :: MonadState s m => ASetter s s a b -> b -> m () assign l b = State.modify (set l b) {-# INLINE assign #-} -- | Replace the target of a 'Lens' or all of the targets of a 'Setter' -- or 'Traversal' in our monadic state with a new value, irrespective of the -- old. -- -- This is an infix version of 'assign'. -- -- >>> execState (do _1 .= c; _2 .= d) (a,b) -- (c,d) -- -- >>> execState (both .= c) (a,b) -- (c,c) -- -- @ -- ('.=') :: 'MonadState' s m => 'Iso'' s a -> a -> m () -- ('.=') :: 'MonadState' s m => 'Lens'' s a -> a -> m () -- ('.=') :: 'MonadState' s m => 'Traversal'' s a -> a -> m () -- ('.=') :: 'MonadState' s m => 'Setter'' s a -> a -> m () -- @ -- -- /It puts the state in the monad or it gets the hose again./ (.=) :: MonadState s m => ASetter s s a b -> b -> m () l .= b = State.modify (l .~ b) {-# INLINE (.=) #-} -- | Map over the target of a 'Lens' or all of the targets of a 'Setter' or 'Traversal' in our monadic state. -- -- >>> execState (do _1 %= f;_2 %= g) (a,b) -- (f a,g b) -- -- >>> execState (do both %= f) (a,b) -- (f a,f b) -- -- @ -- ('%=') :: 'MonadState' s m => 'Iso'' s a -> (a -> a) -> m () -- ('%=') :: 'MonadState' s m => 'Lens'' s a -> (a -> a) -> m () -- ('%=') :: 'MonadState' s m => 'Traversal'' s a -> (a -> a) -> m () -- ('%=') :: 'MonadState' s m => 'Setter'' s a -> (a -> a) -> m () -- @ -- -- @ -- ('%=') :: 'MonadState' s m => 'ASetter' s s a b -> (a -> b) -> m () -- @ (%=) :: (Profunctor p, MonadState s m) => Setting p s s a b -> p a b -> m () l %= f = State.modify (l %~ f) {-# INLINE (%=) #-} -- | Replace the target of a 'Lens' or all of the targets of a 'Setter' or 'Traversal' in our monadic -- state with 'Just' a new value, irrespective of the old. -- -- >>> execState (do at 1 ?= a; at 2 ?= b) Map.empty -- fromList [(1,a),(2,b)] -- -- >>> execState (do _1 ?= b; _2 ?= c) (Just a, Nothing) -- (Just b,Just c) -- -- @ -- ('?=') :: 'MonadState' s m => 'Iso'' s ('Maybe' a) -> a -> m () -- ('?=') :: 'MonadState' s m => 'Lens'' s ('Maybe' a) -> a -> m () -- ('?=') :: 'MonadState' s m => 'Traversal'' s ('Maybe' a) -> a -> m () -- ('?=') :: 'MonadState' s m => 'Setter'' s ('Maybe' a) -> a -> m () -- @ (?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m () l ?= b = State.modify (l ?~ b) {-# INLINE (?=) #-} -- | Modify the target(s) of a 'Lens'', 'Iso', 'Setter' or 'Traversal' by adding a value. -- -- Example: -- -- @ -- 'fresh' :: 'MonadState' 'Int' m => m 'Int' -- 'fresh' = do -- 'id' '+=' 1 -- 'Control.Lens.Getter.use' 'id' -- @ -- -- >>> execState (do _1 += c; _2 += d) (a,b) -- (a + c,b + d) -- -- >>> execState (do _1.at 1.non 0 += 10) (Map.fromList [(2,100)],"hello") -- (fromList [(1,10),(2,100)],"hello") -- -- @ -- ('+=') :: ('MonadState' s m, 'Num' a) => 'Setter'' s a -> a -> m () -- ('+=') :: ('MonadState' s m, 'Num' a) => 'Iso'' s a -> a -> m () -- ('+=') :: ('MonadState' s m, 'Num' a) => 'Lens'' s a -> a -> m () -- ('+=') :: ('MonadState' s m, 'Num' a) => 'Traversal'' s a -> a -> m () -- @ (+=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m () l += b = State.modify (l +~ b) {-# INLINE (+=) #-} -- | Modify the target(s) of a 'Lens'', 'Iso', 'Setter' or 'Traversal' by subtracting a value. -- -- >>> execState (do _1 -= c; _2 -= d) (a,b) -- (a - c,b - d) -- -- @ -- ('-=') :: ('MonadState' s m, 'Num' a) => 'Setter'' s a -> a -> m () -- ('-=') :: ('MonadState' s m, 'Num' a) => 'Iso'' s a -> a -> m () -- ('-=') :: ('MonadState' s m, 'Num' a) => 'Lens'' s a -> a -> m () -- ('-=') :: ('MonadState' s m, 'Num' a) => 'Traversal'' s a -> a -> m () -- @ (-=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m () l -= b = State.modify (l -~ b) {-# INLINE (-=) #-} -- | Modify the target(s) of a 'Lens'', 'Iso', 'Setter' or 'Traversal' by multiplying by value. -- -- >>> execState (do _1 *= c; _2 *= d) (a,b) -- (a * c,b * d) -- -- @ -- ('*=') :: ('MonadState' s m, 'Num' a) => 'Setter'' s a -> a -> m () -- ('*=') :: ('MonadState' s m, 'Num' a) => 'Iso'' s a -> a -> m () -- ('*=') :: ('MonadState' s m, 'Num' a) => 'Lens'' s a -> a -> m () -- ('*=') :: ('MonadState' s m, 'Num' a) => 'Traversal'' s a -> a -> m () -- @ (*=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m () l *= b = State.modify (l *~ b) {-# INLINE (*=) #-} -- | Modify the target(s) of a 'Lens'', 'Iso', 'Setter' or 'Traversal' by dividing by a value. -- -- >>> execState (do _1 //= c; _2 //= d) (a,b) -- (a / c,b / d) -- -- @ -- ('//=') :: ('MonadState' s m, 'Fractional' a) => 'Setter'' s a -> a -> m () -- ('//=') :: ('MonadState' s m, 'Fractional' a) => 'Iso'' s a -> a -> m () -- ('//=') :: ('MonadState' s m, 'Fractional' a) => 'Lens'' s a -> a -> m () -- ('//=') :: ('MonadState' s m, 'Fractional' a) => 'Traversal'' s a -> a -> m () -- @ (//=) :: (MonadState s m, Fractional a) => ASetter' s a -> a -> m () l //= a = State.modify (l //~ a) {-# INLINE (//=) #-} -- | Raise the target(s) of a numerically valued 'Lens', 'Setter' or 'Traversal' to a non-negative integral power. -- -- @ -- ('^=') :: ('MonadState' s m, 'Num' a, 'Integral' e) => 'Setter'' s a -> e -> m () -- ('^=') :: ('MonadState' s m, 'Num' a, 'Integral' e) => 'Iso'' s a -> e -> m () -- ('^=') :: ('MonadState' s m, 'Num' a, 'Integral' e) => 'Lens'' s a -> e -> m () -- ('^=') :: ('MonadState' s m, 'Num' a, 'Integral' e) => 'Traversal'' s a -> e -> m () -- @ (^=) :: (MonadState s m, Num a, Integral e) => ASetter' s a -> e -> m () l ^= e = State.modify (l ^~ e) {-# INLINE (^=) #-} -- | Raise the target(s) of a numerically valued 'Lens', 'Setter' or 'Traversal' to an integral power. -- -- @ -- ('^^=') :: ('MonadState' s m, 'Fractional' a, 'Integral' e) => 'Setter'' s a -> e -> m () -- ('^^=') :: ('MonadState' s m, 'Fractional' a, 'Integral' e) => 'Iso'' s a -> e -> m () -- ('^^=') :: ('MonadState' s m, 'Fractional' a, 'Integral' e) => 'Lens'' s a -> e -> m () -- ('^^=') :: ('MonadState' s m, 'Fractional' a, 'Integral' e) => 'Traversal'' s a -> e -> m () -- @ (^^=) :: (MonadState s m, Fractional a, Integral e) => ASetter' s a -> e -> m () l ^^= e = State.modify (l ^^~ e) {-# INLINE (^^=) #-} -- | Raise the target(s) of a numerically valued 'Lens', 'Setter' or 'Traversal' to an arbitrary power -- -- >>> execState (do _1 **= c; _2 **= d) (a,b) -- (a**c,b**d) -- -- @ -- ('**=') :: ('MonadState' s m, 'Floating' a) => 'Setter'' s a -> a -> m () -- ('**=') :: ('MonadState' s m, 'Floating' a) => 'Iso'' s a -> a -> m () -- ('**=') :: ('MonadState' s m, 'Floating' a) => 'Lens'' s a -> a -> m () -- ('**=') :: ('MonadState' s m, 'Floating' a) => 'Traversal'' s a -> a -> m () -- @ (**=) :: (MonadState s m, Floating a) => ASetter' s a -> a -> m () l **= a = State.modify (l **~ a) {-# INLINE (**=) #-} -- | Modify the target(s) of a 'Lens'', 'Iso', 'Setter' or 'Traversal' by taking their logical '&&' with a value. -- -- >>> execState (do _1 &&= True; _2 &&= False; _3 &&= True; _4 &&= False) (True,True,False,False) -- (True,False,False,False) -- -- @ -- ('&&=') :: 'MonadState' s m => 'Setter'' s 'Bool' -> 'Bool' -> m () -- ('&&=') :: 'MonadState' s m => 'Iso'' s 'Bool' -> 'Bool' -> m () -- ('&&=') :: 'MonadState' s m => 'Lens'' s 'Bool' -> 'Bool' -> m () -- ('&&=') :: 'MonadState' s m => 'Traversal'' s 'Bool' -> 'Bool' -> m () -- @ (&&=):: MonadState s m => ASetter' s Bool -> Bool -> m () l &&= b = State.modify (l &&~ b) {-# INLINE (&&=) #-} -- | Modify the target(s) of a 'Lens'', 'Iso, 'Setter' or 'Traversal' by taking their logical '||' with a value. -- -- >>> execState (do _1 ||= True; _2 ||= False; _3 ||= True; _4 ||= False) (True,True,False,False) -- (True,True,True,False) -- -- @ -- ('||=') :: 'MonadState' s m => 'Setter'' s 'Bool' -> 'Bool' -> m () -- ('||=') :: 'MonadState' s m => 'Iso'' s 'Bool' -> 'Bool' -> m () -- ('||=') :: 'MonadState' s m => 'Lens'' s 'Bool' -> 'Bool' -> m () -- ('||=') :: 'MonadState' s m => 'Traversal'' s 'Bool' -> 'Bool' -> m () -- @ (||=) :: MonadState s m => ASetter' s Bool -> Bool -> m () l ||= b = State.modify (l ||~ b) {-# INLINE (||=) #-} -- | Run a monadic action, and set all of the targets of a 'Lens', 'Setter' or 'Traversal' to its result. -- -- @ -- ('<~') :: 'MonadState' s m => 'Iso' s s a b -> m b -> m () -- ('<~') :: 'MonadState' s m => 'Lens' s s a b -> m b -> m () -- ('<~') :: 'MonadState' s m => 'Traversal' s s a b -> m b -> m () -- ('<~') :: 'MonadState' s m => 'Setter' s s a b -> m b -> m () -- @ -- -- As a reasonable mnemonic, this lets you store the result of a monadic action in a 'Lens' rather than -- in a local variable. -- -- @ -- do foo <- bar -- ... -- @ -- -- will store the result in a variable, while -- -- @ -- do foo '<~' bar -- ... -- @ -- -- will store the result in a 'Lens', 'Setter', or 'Traversal'. (<~) :: MonadState s m => ASetter s s a b -> m b -> m () l <~ mb = mb >>= (l .=) {-# INLINE (<~) #-} -- | Set with pass-through -- -- This is useful for chaining assignment without round-tripping through your 'Monad' stack. -- -- @ -- do x <- 'Control.Lens.Tuple._2' '<.=' ninety_nine_bottles_of_beer_on_the_wall -- @ -- -- If you do not need a copy of the intermediate result, then using @l '.=' d@ will avoid unused binding warnings. -- -- @ -- ('<.=') :: 'MonadState' s m => 'Setter' s s a b -> b -> m b -- ('<.=') :: 'MonadState' s m => 'Iso' s s a b -> b -> m b -- ('<.=') :: 'MonadState' s m => 'Lens' s s a b -> b -> m b -- ('<.=') :: 'MonadState' s m => 'Traversal' s s a b -> b -> m b -- @ (<.=) :: MonadState s m => ASetter s s a b -> b -> m b l <.= b = do l .= b return b {-# INLINE (<.=) #-} -- | Set 'Just' a value with pass-through -- -- This is useful for chaining assignment without round-tripping through your 'Monad' stack. -- -- @ -- do x <- 'Control.Lens.At.at' "foo" '<?=' ninety_nine_bottles_of_beer_on_the_wall -- @ -- -- If you do not need a copy of the intermediate result, then using @l '?=' d@ will avoid unused binding warnings. -- -- @ -- ('<?=') :: 'MonadState' s m => 'Setter' s s a ('Maybe' b) -> b -> m b -- ('<?=') :: 'MonadState' s m => 'Iso' s s a ('Maybe' b) -> b -> m b -- ('<?=') :: 'MonadState' s m => 'Lens' s s a ('Maybe' b) -> b -> m b -- ('<?=') :: 'MonadState' s m => 'Traversal' s s a ('Maybe' b) -> b -> m b -- @ (<?=) :: MonadState s m => ASetter s s a (Maybe b) -> b -> m b l <?= b = do l ?= b return b {-# INLINE (<?=) #-} -- | Modify the target of a monoidally valued by 'mappend'ing another value. -- -- >>> (Sum a,b) & _1 <>~ Sum c -- (Sum {getSum = a + c},b) -- -- >>> (Sum a,Sum b) & both <>~ Sum c -- (Sum {getSum = a + c},Sum {getSum = b + c}) -- -- >>> both <>~ "!!!" $ ("hello","world") -- ("hello!!!","world!!!") -- -- @ -- ('<>~') :: 'Monoid' a => 'Setter' s t a a -> a -> s -> t -- ('<>~') :: 'Monoid' a => 'Iso' s t a a -> a -> s -> t -- ('<>~') :: 'Monoid' a => 'Lens' s t a a -> a -> s -> t -- ('<>~') :: 'Monoid' a => 'Traversal' s t a a -> a -> s -> t -- @ (<>~) :: Monoid a => ASetter s t a a -> a -> s -> t l <>~ n = over l (`mappend` n) {-# INLINE (<>~) #-} -- | Modify the target(s) of a 'Lens'', 'Iso', 'Setter' or 'Traversal' by 'mappend'ing a value. -- -- >>> execState (do _1 <>= Sum c; _2 <>= Product d) (Sum a,Product b) -- (Sum {getSum = a + c},Product {getProduct = b * d}) -- -- >>> execState (both <>= "!!!") ("hello","world") -- ("hello!!!","world!!!") -- -- @ -- ('<>=') :: ('MonadState' s m, 'Monoid' a) => 'Setter'' s a -> a -> m () -- ('<>=') :: ('MonadState' s m, 'Monoid' a) => 'Iso'' s a -> a -> m () -- ('<>=') :: ('MonadState' s m, 'Monoid' a) => 'Lens'' s a -> a -> m () -- ('<>=') :: ('MonadState' s m, 'Monoid' a) => 'Traversal'' s a -> a -> m () -- @ (<>=) :: (MonadState s m, Monoid a) => ASetter' s a -> a -> m () l <>= a = State.modify (l <>~ a) {-# INLINE (<>=) #-} ----------------------------------------------------------------------------- -- Writer Operations ---------------------------------------------------------------------------- -- | Write to a fragment of a larger 'Writer' format. scribe :: (MonadWriter t m, Monoid s) => ASetter s t a b -> b -> m () scribe l b = tell (set l b mempty) {-# INLINE scribe #-} -- | This is a generalization of 'pass' that alows you to modify just a -- portion of the resulting 'MonadWriter'. passing :: MonadWriter w m => Setter w w u v -> m (a, u -> v) -> m a passing l m = pass $ do (a, uv) <- m return (a, over l uv) {-# INLINE passing #-} -- | This is a generalization of 'pass' that alows you to modify just a -- portion of the resulting 'MonadWriter' with access to the index of an -- 'IndexedSetter'. ipassing :: MonadWriter w m => IndexedSetter i w w u v -> m (a, i -> u -> v) -> m a ipassing l m = pass $ do (a, uv) <- m return (a, iover l uv) {-# INLINE ipassing #-} -- | This is a generalization of 'censor' that alows you to 'censor' just a -- portion of the resulting 'MonadWriter'. censoring :: MonadWriter w m => Setter w w u v -> (u -> v) -> m a -> m a censoring l uv = censor (over l uv) {-# INLINE censoring #-} -- | This is a generalization of 'censor' that alows you to 'censor' just a -- portion of the resulting 'MonadWriter', with access to the index of an -- 'IndexedSetter'. icensoring :: MonadWriter w m => IndexedSetter i w w u v -> (i -> u -> v) -> m a -> m a icensoring l uv = censor (iover l uv) {-# INLINE icensoring #-} ----------------------------------------------------------------------------- -- Indexed Setters ---------------------------------------------------------------------------- -- | Map with index. This is an alias for 'imapOf'. -- -- When you do not need access to the index, then 'over' is more liberal in what it can accept. -- -- @ -- 'over' l ≡ 'iover' l '.' 'const' -- 'iover' l ≡ 'over' l '.' 'Indexed' -- @ -- -- @ -- 'iover' :: 'IndexedSetter' i s t a b -> (i -> a -> b) -> s -> t -- 'iover' :: 'IndexedLens' i s t a b -> (i -> a -> b) -> s -> t -- 'iover' :: 'IndexedTraversal' i s t a b -> (i -> a -> b) -> s -> t -- @ iover :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t iover l = over l .# Indexed {-# INLINE iover #-} -- | Set with index. Equivalent to 'iover' with the current value ignored. -- -- When you do not need access to the index, then 'set' is more liberal in what it can accept. -- -- @ -- 'set' l ≡ 'iset' l '.' 'const' -- @ -- -- @ -- 'iset' :: 'IndexedSetter' i s t a b -> (i -> b) -> s -> t -- 'iset' :: 'IndexedLens' i s t a b -> (i -> b) -> s -> t -- 'iset' :: 'IndexedTraversal' i s t a b -> (i -> b) -> s -> t -- @ iset :: AnIndexedSetter i s t a b -> (i -> b) -> s -> t iset l = iover l . (const .) {-# INLINE iset #-} -- | Build an 'IndexedSetter' from an 'Control.Lens.Indexed.imap'-like function. -- -- Your supplied function @f@ is required to satisfy: -- -- @ -- f 'id' ≡ 'id' -- f g '.' f h ≡ f (g '.' h) -- @ -- -- Equational reasoning: -- -- @ -- 'isets' '.' 'iover' ≡ 'id' -- 'iover' '.' 'isets' ≡ 'id' -- @ -- -- Another way to view 'sets' is that it takes a \"semantic editor combinator\" -- and transforms it into a 'Setter'. isets :: ((i -> a -> b) -> s -> t) -> IndexedSetter i s t a b isets f = sets (f . indexed) {-# INLINE isets #-} -- | Adjust every target of an 'IndexedSetter', 'IndexedLens' or 'IndexedTraversal' -- with access to the index. -- -- @ -- ('%@~') ≡ 'iover' -- @ -- -- When you do not need access to the index then ('%~') is more liberal in what it can accept. -- -- @ -- l '%~' f ≡ l '%@~' 'const' f -- @ -- -- @ -- ('%@~') :: 'IndexedSetter' i s t a b -> (i -> a -> b) -> s -> t -- ('%@~') :: 'IndexedLens' i s t a b -> (i -> a -> b) -> s -> t -- ('%@~') :: 'IndexedTraversal' i s t a b -> (i -> a -> b) -> s -> t -- @ (%@~) :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t l %@~ f = l %~ Indexed f {-# INLINE (%@~) #-} -- | Replace every target of an 'IndexedSetter', 'IndexedLens' or 'IndexedTraversal' -- with access to the index. -- -- @ -- ('.@~') ≡ 'iset' -- @ -- -- When you do not need access to the index then ('.~') is more liberal in what it can accept. -- -- @ -- l '.~' b ≡ l '.@~' 'const' b -- @ -- -- @ -- ('.@~') :: 'IndexedSetter' i s t a b -> (i -> b) -> s -> t -- ('.@~') :: 'IndexedLens' i s t a b -> (i -> b) -> s -> t -- ('.@~') :: 'IndexedTraversal' i s t a b -> (i -> b) -> s -> t -- @ (.@~) :: AnIndexedSetter i s t a b -> (i -> b) -> s -> t l .@~ f = l %~ Indexed (const . f) {-# INLINE (.@~) #-} -- | Adjust every target in the current state of an 'IndexedSetter', 'IndexedLens' or 'IndexedTraversal' -- with access to the index. -- -- When you do not need access to the index then ('%=') is more liberal in what it can accept. -- -- @ -- l '%=' f ≡ l '%@=' 'const' f -- @ -- -- @ -- ('%@=') :: 'MonadState' s m => 'IndexedSetter' i s s a b -> (i -> a -> b) -> m () -- ('%@=') :: 'MonadState' s m => 'IndexedLens' i s s a b -> (i -> a -> b) -> m () -- ('%@=') :: 'MonadState' s m => 'IndexedTraversal' i s t a b -> (i -> a -> b) -> m () -- @ (%@=) :: MonadState s m => AnIndexedSetter i s s a b -> (i -> a -> b) -> m () l %@= f = State.modify (l %@~ f) {-# INLINE (%@=) #-} -- | Replace every target in the current state of an 'IndexedSetter', 'IndexedLens' or 'IndexedTraversal' -- with access to the index. -- -- When you do not need access to the index then ('.=') is more liberal in what it can accept. -- -- @ -- l '.=' b ≡ l '.@=' 'const' b -- @ -- -- @ -- ('.@=') :: 'MonadState' s m => 'IndexedSetter' i s s a b -> (i -> b) -> m () -- ('.@=') :: 'MonadState' s m => 'IndexedLens' i s s a b -> (i -> b) -> m () -- ('.@=') :: 'MonadState' s m => 'IndexedTraversal' i s t a b -> (i -> b) -> m () -- @ (.@=) :: MonadState s m => AnIndexedSetter i s s a b -> (i -> b) -> m () l .@= f = State.modify (l .@~ f) {-# INLINE (.@=) #-} ------------------------------------------------------------------------------ -- Arrows ------------------------------------------------------------------------------ -- | Run an arrow command and use the output to set all the targets of -- a 'Lens', 'Setter' or 'Traversal' to the result. -- -- 'assignA' can be used very similarly to ('<~'), except that the type of -- the object being modified can change; for example: -- -- @ -- runKleisli action ((), (), ()) where -- action = assignA _1 (Kleisli (const getVal1)) -- \>>> assignA _2 (Kleisli (const getVal2)) -- \>>> assignA _3 (Kleisli (const getVal3)) -- getVal1 :: Either String Int -- getVal1 = ... -- getVal2 :: Either String Bool -- getVal2 = ... -- getVal3 :: Either String Char -- getVal3 = ... -- @ -- -- has the type @'Either' 'String' ('Int', 'Bool', 'Char')@ -- -- @ -- 'assignA' :: 'Arrow' p => 'Iso' s t a b -> p s b -> p s t -- 'assignA' :: 'Arrow' p => 'Lens' s t a b -> p s b -> p s t -- 'assignA' :: 'Arrow' p => 'Traversal' s t a b -> p s b -> p s t -- 'assignA' :: 'Arrow' p => 'Setter' s t a b -> p s b -> p s t -- @ assignA :: Arrow p => ASetter s t a b -> p s b -> p s t assignA l p = arr (flip $ set l) &&& p >>> arr (uncurry id) {-# INLINE assignA #-} ------------------------------------------------------------------------------ -- Deprecated ------------------------------------------------------------------------------ -- | 'mapOf' is a deprecated alias for 'over'. mapOf :: Profunctor p => Setting p s t a b -> p a b -> s -> t mapOf = over {-# INLINE mapOf #-} {-# DEPRECATED mapOf "Use `over`" #-} -- | Map with index. (Deprecated alias for 'iover'). -- -- When you do not need access to the index, then 'mapOf' is more liberal in what it can accept. -- -- @ -- 'mapOf' l ≡ 'imapOf' l '.' 'const' -- @ -- -- @ -- 'imapOf' :: 'IndexedSetter' i s t a b -> (i -> a -> b) -> s -> t -- 'imapOf' :: 'IndexedLens' i s t a b -> (i -> a -> b) -> s -> t -- 'imapOf' :: 'IndexedTraversal' i s t a b -> (i -> a -> b) -> s -> t -- @ imapOf :: AnIndexedSetter i s t a b -> (i -> a -> b) -> s -> t imapOf = iover {-# INLINE imapOf #-} {-# DEPRECATED imapOf "Use `iover`" #-}
Icelandjack/lens
src/Control/Lens/Setter.hs
bsd-3-clause
42,062
0
17
9,602
5,394
3,347
2,047
-1
-1
{- Teak synthesiser for the Balsa language Copyright (C) 2007-2010 The University of Manchester 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 3 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, see <http://www.gnu.org/licenses/>. Andrew Bardsley <[email protected]> (and others, see AUTHORS) School of Computer Science, The University of Manchester Oxford Road, MANCHESTER, M13 9PL, UK -} module GuiSupport ( Corner (..), colours, black, brown, red, orange, yellow, green, blue, paleBlue, violet, grey, white, pink, cyan, line, vLine, box, strokeFill, arrowhead, curveLine, curveBoxProp, curveBox, trapezium, invTrapezium, nickedTrapezium, centredText, blockTexts, vboxText, presentWindow, tableAddNameValueExtra, tableAddNameValue, TableOption (..), TableOptionType (..), TableOptionValue (..), tableOptionMakeTableEntry, Colour, makeAlignedScrolledWindow, makeDialogue, makeFrame, makeHPaned, makeVPaned, makeFileChooser, makeToolButton, fileChooserAddFilters, toolbarSetup, SimpleShapeRender, makeSourceErrorViewWindow, GuiOption (..), GuiDisplayMode (..), guiOptionUsage, defaultGuiOptions ) where import Options import Show import Data.Maybe import Control.Monad import Data.List import qualified Data.Text as Text import Misc import Dot import Report -- import Graphics.UI.Gtk hiding ({- fill, lineWidth, -} layoutHeight, layoutWidth) import qualified Graphics.UI.Gtk as Gtk import qualified System.Glib as Glib import Graphics.Rendering.Cairo import Graphics.UI.Gtk.Gdk.EventM (eventCoordinates) import Control.Monad.Trans type Colour = (Double, Double, Double) data Corner = TL | TR | BL | BR deriving (Show, Eq) black :: Colour black = (0.00, 0.00, 0.00) brown :: Colour brown = (0.65, 0.16, 0.16) red :: Colour red = (1.00, 0.00, 0.00) orange :: Colour orange = (1.00, 0.65, 0.00) yellow :: Colour yellow = (0.85, 0.65, 0.12) green :: Colour green = (0.00, 1.00, 0.00) blue :: Colour blue = (0.00, 0.00, 1.00) violet :: Colour violet = (0.85, 0.51, 0.93) grey :: Colour grey = (0.75, 0.75, 0.75) white :: Colour white = (1.00, 1.00, 1.00) offWhite :: Colour offWhite = (0.90, 0.90, 0.90) pink :: Colour pink = (1.00, 0.75, 0.75) paleBlue :: Colour paleBlue = (0.75, 0.75, 1.00) cyan :: Colour cyan = (0.00, 1.00, 1.00) colours :: [Colour] colours = [black, brown, red, orange, yellow, green, blue, violet, grey, offWhite, pink] strokeFill :: (Double, Double, Double) -> Render () strokeFill (r,g,b) = do save setSourceRGB r g b fillPreserve restore stroke type SimpleShapeRender = DPoint -> Double -> Double -> Render () box :: SimpleShapeRender box (x, y) width height = rectangle (x - width / 2) (y - height / 2) width height vLine :: DPoint -> Double -> Render () vLine (x, y) height = line [(x, y - halfHeight), (x, y + halfHeight)] where halfHeight = height / 2 {- -- titleCurve : box with curved top and inversely curve bottom titleCurve c (x, y) width height = do moveTo (left + c) top arc (right - c) (top + c) c (3 * halfPi) 0 arcNegative (right - c) (bottom + c) c 0 (3 * halfPi) arcNegative (left + c) (bottom + c) c (3 * halfPi) (2 * halfPi) arc (left + c) (top + c) c (2 * halfPi) halfPi closePath where BoundingBox top bottom left right = pointWHToBoundingBox (x, y) width height halfPi = pi / 2 -} -- curveBox : show a filled box with curved corners in the places specified (...Prop -- curved corners -- have size in proportion to the box's shortest dimension curveBoxProp :: [Corner] -> Double -> SimpleShapeRender curveBoxProp corners curveProportion (x, y) width height = curveBox corners c (x, y) width height where c = (min width height) * curveProportion curveBox :: [Corner] -> Double -> SimpleShapeRender curveBox corners c (x, y) width height = do moveTo (left + c) top if TR `elem` corners then arc (right - c) (top + c) c north east else lineTo right top if BR `elem` corners then arc (right - c) (bottom - c) c east south else lineTo right bottom if BL `elem` corners then arc (left + c) (bottom - c) c south west else lineTo left bottom if TL `elem` corners then arc (left + c) (top + c) c west north else lineTo left top closePath where BoundingBox top left bottom right = pointWHToBoundingBox (x, y) width height halfPi = pi / 2 (east, south, west, north) = (0, halfPi, 2 * halfPi, 3 * halfPi) trapezium :: SimpleShapeRender trapezium (x, y) width height = do moveTo (x - width / 2) (y - height / 2) relLineTo width 0 relLineTo (- skew) height lineTo (x - width / 2 + skew) (y + height / 2) closePath where skew | height < width = height / 2 | otherwise = width / 4 nickedTrapezium :: SimpleShapeRender nickedTrapezium (x, y) width height = do moveTo (x - width / 2) (y - height / 2) lineTo (x - skew / nickDivider) (y - height / 2) relLineTo (skew / nickDivider) (height / nickDivider) relLineTo (skew / nickDivider) (- (height / nickDivider)) lineTo (x + width / 2) (y - height / 2) relLineTo (- skew) height lineTo (x - width / 2 + skew) (y + height / 2) closePath where skew | height < width = height / 2 | otherwise = width / 4 nickDivider = 4 invTrapezium :: SimpleShapeRender invTrapezium (x, y) width height = do moveTo (x - width / 2) (y + height / 2) relLineTo width 0 relLineTo (- skew) (- height) lineTo (x - width / 2 + skew) (y - height / 2) closePath where skew | height < width = height / 2 | otherwise = width / 4 line :: [DPoint] -> Render () line [] = return () line ((x, y):rest) = do moveTo x y mapM_ (uncurry lineTo) rest stroke arrowhead :: Double -> Double -> DPoint -> DPoint -> Render () arrowhead size widthFraction (xPrev, yPrev) (x, y) = do save translate x y rotate (- angle) moveTo (- halfWidth) (- size) lineTo halfWidth (- size) lineTo 0 0 closePath fillPreserve stroke restore where halfWidth = (size * widthFraction) / 2 angle = atan2 (x - xPrev) (y - yPrev) curveLine :: [DPoint] -> Render () curveLine ((x, y):rest) = do moveTo x y sequence $ mapN 3 curveToL rest stroke where curveToL [(x1, y1), (x2, y2), (x3, y3)] = curveTo x1 y1 x2 y2 x3 y3 curveToL _ = return () curveLine _ = return () centredText :: DPoint -> String -> Render () centredText (x, y) string = do ext <- textExtents string let x' = x - textExtentsWidth ext / 2 y' = y + textExtentsHeight ext / 2 moveTo x' y' showText string blockTexts :: DPoint -> [String] -> Render () blockTexts (x, y) strings = do exts <- mapM textExtents strings let maxX = maximum (map textExtentsWidth exts) maxY = maximum (map textExtentsHeight exts) x' = x - maxX / 2 firstY = y + (maxY * fromIntegral (length strings)) / 2 foldM (\lineY string -> do moveTo x' lineY showText string return $ lineY - maxY) firstY strings return () vboxText :: Double -> (Double -> Double) -> Double -> [String] -> Render () vboxText y calcX vDelta strs = do mapM_ showTextStep $ zip [0..] strs where showTextStep (i, string) = do ext <- textExtents string moveTo (calcX (textExtentsWidth ext)) (y + i * vDelta + textExtentsHeight ext / 2) showText string toolbarGetItems :: Gtk.ToolbarClass toolbar => toolbar -> IO [Gtk.ToolItem] toolbarGetItems toolbar = do itemCount <- Gtk.toolbarGetNItems toolbar liftM catMaybes $ mapM (Gtk.toolbarGetNthItem toolbar) [0..itemCount-1] -- toolbarSetup : set a toolbar style and also do some cleaning up to make elements homogeneous -- and actually make icons and text appear correctly toolbarSetup :: Gtk.ToolbarClass toolbar => toolbar -> Gtk.Orientation -> Gtk.ToolbarStyle -> IO () toolbarSetup toolbar orient style = do Gtk.toolbarSetOrientation toolbar orient Gtk.toolbarSetStyle toolbar style Gtk.toolbarSetIconSize toolbar Gtk.IconSizeSmallToolbar Gtk.toolbarSetShowArrow toolbar True items <- toolbarGetItems toolbar forM_ items $ \item -> do Gtk.set item [ Gtk.toolItemIsImportant Gtk.:= True ] Gtk.set toolbar [ Gtk.toolbarChildHomogeneous item Gtk.:= False ] makeDialogue :: Gtk.WidgetClass widget => Gtk.Window -> String -> [Gtk.Button] -> widget -> IO Gtk.Window makeDialogue parent title buttons child = do ret <- Gtk.windowNew Gtk.windowSetTransientFor ret parent Gtk.set ret [ Gtk.windowTitle Gtk.:= title, Gtk.windowAllowShrink Gtk.:= True ] buttonBox <- Gtk.hButtonBoxNew Gtk.boxSetSpacing buttonBox 6 Gtk.set buttonBox [ Gtk.buttonBoxLayoutStyle Gtk.:= Gtk.ButtonboxEnd ] alignment <- Gtk.alignmentNew 0.5 0.5 1.0 1.0 Gtk.set alignment [ Gtk.alignmentTopPadding Gtk.:= 5, Gtk.alignmentBottomPadding Gtk.:= 5, Gtk.alignmentLeftPadding Gtk.:= 5, Gtk.alignmentRightPadding Gtk.:= 5 ] vBox <- Gtk.vBoxNew False 2 Gtk.boxPackStart vBox child Gtk.PackGrow 2 mapM_ (Gtk.containerAdd buttonBox) buttons Gtk.boxPackStart vBox buttonBox Gtk.PackNatural 2 Gtk.containerAdd alignment vBox Gtk.containerAdd ret alignment return ret makeFrame :: Gtk.WidgetClass widget => String -> widget -> IO Gtk.Frame makeFrame title child = do frame <- Gtk.frameNew label <- Gtk.labelNew (Just ("<b>" ++ title ++ "</b>")) Gtk.set label [ Gtk.labelUseMarkup Gtk.:= True ] Gtk.frameSetLabelWidget frame label alignment <- Gtk.alignmentNew 0.5 0.5 1.0 1.0 Gtk.set alignment [ Gtk.alignmentTopPadding Gtk.:= 4, Gtk.alignmentBottomPadding Gtk.:= 4, Gtk.alignmentLeftPadding Gtk.:= 4, Gtk.alignmentRightPadding Gtk.:= 4 ] Gtk.containerAdd alignment child Gtk.containerAdd frame alignment return frame makeHPaned :: (Gtk.WidgetClass left, Gtk.WidgetClass right) => left -> right -> IO Gtk.HPaned makeHPaned left right = do paned <- Gtk.hPanedNew Gtk.panedAdd1 paned left Gtk.panedAdd2 paned right return paned makeVPaned :: (Gtk.WidgetClass left, Gtk.WidgetClass right) => left -> right -> IO Gtk.VPaned makeVPaned left right = do paned <- Gtk.vPanedNew Gtk.panedAdd1 paned left Gtk.panedAdd2 paned right return paned presentWindow :: (Gtk.WindowClass window) => window -> IO () presentWindow window = do Gtk.widgetShowAll window Gtk.windowPresent window makeFileChooser :: Maybe Gtk.Window -> String -> Maybe FilePath -> Gtk.FileChooserAction -> String -> (FilePath -> IO Bool) -> IO Gtk.FileChooserDialog makeFileChooser parent title prevFile chooserAction yesLabel yesAction = do chooser <- Gtk.fileChooserDialogNew (Just title) parent chooserAction [(yesLabel, Gtk.ResponseAccept), ("gtk-cancel", Gtk.ResponseCancel)] when (isJust prevFile) $ do Gtk.fileChooserSetFilename chooser (fromJust prevFile) return () Gtk.onResponse chooser $ \response -> case response of Gtk.ResponseAccept -> do maybeFilename <- Gtk.fileChooserGetFilename chooser let Just filename = maybeFilename close <- if isJust maybeFilename then yesAction filename else return False when close $ Gtk.widgetDestroy chooser _ -> Gtk.widgetDestroy chooser Gtk.widgetShowAll chooser return chooser makeToolButton :: Gtk.Toolbar -> Bool -> Int -> Maybe Gtk.StockId -> Maybe String -> IO Gtk.ToolButton makeToolButton toolbar important pos icon label = do button <- if isJust icon then do button <- Gtk.toolButtonNewFromStock (fromJust icon) Gtk.toolButtonSetLabel button label return button else Gtk.toolButtonNew (Nothing :: Maybe Gtk.Button) label Gtk.toolbarInsert toolbar button pos Gtk.set toolbar [ Gtk.toolbarChildHomogeneous button Gtk.:= False ] when important $ Gtk.set button [ Gtk.toolItemIsImportant Gtk.:= True ] return button fileChooserAddFilters :: Gtk.FileChooserClass chooser => chooser -> [(String, String)] -> IO () fileChooserAddFilters chooser patternXdescs = do filters <- mapM (\(pattern, desc) -> do filter <- Gtk.fileFilterNew Gtk.fileFilterAddPattern filter pattern Gtk.fileFilterSetName filter desc Gtk.fileChooserAddFilter chooser filter return filter) patternXdescs when (not (null filters)) $ do Gtk.fileChooserSetFilter chooser $ last filters return () makeRelativeFilename :: FilePath -> FilePath -> FilePath makeRelativeFilename relativeFile ('/':name) = concat (replicate (pathCount - sharedDirCount) "../") ++ joinWith "/" (drop sharedDirCount split) where pathCount = length relativePath sharedDirCount = sharedLength relativePath split split = splitFilename name splitFilename = filter (/= "") . splitWith "/" relativePath = init $ splitFilename relativeFile sharedLength (a:as) (b:bs) | a == b = 1 + sharedLength as bs sharedLength _ _ = 0 makeRelativeFilename _ name = name data TableOptionValue = TableOptionValueString String | TableOptionValueEnum Int | TableOptionValueBool Bool | TableOptionValueColour Colour | TableOptionValueInt Int data TableOptionType = TableOptionTypeString | TableOptionTypeEnum [String] | TableOptionTypeBool | TableOptionTypeColour | TableOptionTypeIntSpin Int Int -- low, high data TableOption = TableOption { tableOptionName :: String, tableOptionType :: TableOptionType, tableOptionExtra :: Maybe Gtk.Widget, tableOptionGet :: IO TableOptionValue, tableOptionSet :: TableOptionValue -> IO () } | TableOptionSpacer { tableSpacerName :: String, tableSpacerWidth :: Int } colourToGtkColor :: Colour -> Gtk.Color colourToGtkColor (r,g,b) = Gtk.Color (scaleComp r) (scaleComp g) (scaleComp b) where scaleComp comp = floor $ comp * 65535 gtkColorToColour :: Gtk.Color -> Colour gtkColorToColour (Gtk.Color r g b) = (scaleComp r, scaleComp g, scaleComp b) where scaleComp comp = (fromIntegral comp) / 65535.0 tableOptionMakeTableEntry :: Gtk.Table -> Int -> Int -> TableOption -> IO () tableOptionMakeTableEntry table col row (TableOptionSpacer name width) = do label <- Gtk.labelNew $ Just name Gtk.labelSetJustify label Gtk.JustifyLeft Gtk.miscSetAlignment label 0.0 0.5 attach label col row [] where attach widget col row xOpts = Gtk.tableAttach table widget col (col + width) row (row + 1) (Gtk.Fill:xOpts) [Gtk.Fill] 2 2 tableOptionMakeTableEntry table col row opt@(TableOption {}) = do valueWidget <- case tableOptionType opt of TableOptionTypeString -> do entry <- Gtk.entryNew TableOptionValueString value <- tableOptionGet opt Gtk.entrySetText entry value Gtk.onEditableChanged entry $ do value <- Gtk.entryGetText entry tableOptionSet opt $ TableOptionValueString value return $ Gtk.toWidget entry TableOptionTypeEnum elems -> do combo <- Gtk.comboBoxNewText model <- Gtk.comboBoxGetModelText combo Gtk.listStoreClear model mapM_ (Gtk.listStoreAppend model) $ map Text.pack elems TableOptionValueEnum value <- tableOptionGet opt -- FIXME, make immediate/`apply' update an option rather than always doing it? Gtk.comboBoxSetActive combo value Gtk.on combo Gtk.changed $ do value <- Gtk.comboBoxGetActive combo tableOptionSet opt $ TableOptionValueEnum value return $ Gtk.toWidget combo TableOptionTypeBool -> do button <- Gtk.checkButtonNew TableOptionValueBool value <- tableOptionGet opt Gtk.toggleButtonSetActive button value Gtk.onToggled button $ do value <- Gtk.toggleButtonGetActive button tableOptionSet opt $ TableOptionValueBool value return $ Gtk.toWidget button TableOptionTypeColour -> do colourButton <- Gtk.colorButtonNew TableOptionValueColour value <- tableOptionGet opt Gtk.colorButtonSetColor colourButton $ colourToGtkColor value Gtk.onColorSet colourButton $ do colour <- Gtk.colorButtonGetColor colourButton tableOptionSet opt $ TableOptionValueColour $ gtkColorToColour colour return $ Gtk.toWidget colourButton TableOptionTypeIntSpin low high -> do spin <- Gtk.spinButtonNewWithRange (fromIntegral low) (fromIntegral high) 1 TableOptionValueInt value <- tableOptionGet opt Gtk.spinButtonSetValue spin $ fromIntegral value Gtk.onValueSpinned spin $ do value <- Gtk.spinButtonGetValue spin tableOptionSet opt $ TableOptionValueInt $ floor value return $ Gtk.toWidget spin tableAddNameValueExtra table col row (tableOptionName opt) valueWidget $ tableOptionExtra opt return () tableAddNameValueExtra :: (Gtk.WidgetClass valueWidget, Gtk.WidgetClass extraWidget) => Gtk.Table -> Int -> Int -> String -> valueWidget -> Maybe extraWidget -> IO Gtk.Label tableAddNameValueExtra table col row labelString valueWidget extraWidget = do label <- Gtk.labelNew $ Just $ labelString ++ ":" Gtk.labelSetJustify label Gtk.JustifyRight Gtk.miscSetAlignment label 1.0 0.5 attach label col row [] attach valueWidget (col + 1) row [Gtk.Expand] when (isJust extraWidget) $ attach (fromJust extraWidget) (col + 2) row [] return label where attach widget col row xOpts = Gtk.tableAttach table widget col (col + 1) row (row + 1) (Gtk.Fill:xOpts) [Gtk.Fill] 2 2 tableAddNameValue :: Gtk.WidgetClass valueWidget => Gtk.Table -> Int -> Int -> String -> valueWidget -> IO Gtk.Label tableAddNameValue table col row labelString valueWidget = tableAddNameValueExtra table col row labelString valueWidget (Nothing :: Maybe Gtk.Widget) -- makeSourceErrorViewWindow : make a window displaying the source files for the given error messages. -- `filename' is the full path of the top level file and is used to make relative paths for reported error -- filenames makeSourceErrorViewWindow :: PosContext posContext => Gtk.Window -> String -> Maybe posContext -> String -> [Report] -> IO Gtk.Window makeSourceErrorViewWindow parent title posContext filename errors = do let reportPos (Report pos _) = pos toFile (PosFile name _) = Just name toFile _ = Nothing findPosFiles pos = nub $ mapMaybe toFile $ posGetRoots posContext pos posFiles = mapMaybe toFile $ nub $ concatMap (posGetRoots posContext . reportPos) errors shortenFilename = makeRelativeFilename filename errorTree <- Gtk.treeViewNew errorSelection <- Gtk.treeViewGetSelection errorTree fileNotebook <- Gtk.notebookNew files <- filterM canReadFile posFiles let makeNotebookPage (i, file) = do buffer <- Gtk.textBufferNew Nothing iter <- Gtk.textBufferGetIterAtLine buffer 0 contents <- readFile file Gtk.textBufferInsert buffer iter contents text <- Gtk.textViewNewWithBuffer buffer Gtk.textViewSetEditable text False let shortName = shortenFilename file errorTag <- Gtk.textTagNew (Just (Glib.stringToGlib "Errors")) Gtk.set errorTag [ Gtk.textTagBackground Gtk.:= "pink" ] tagTable <- Gtk.textBufferGetTagTable buffer Gtk.textTagTableAdd tagTable errorTag scrolledWindow <- Gtk.scrolledWindowNew Nothing Nothing Gtk.set scrolledWindow [ Gtk.scrolledWindowHscrollbarPolicy Gtk.:= Gtk.PolicyAutomatic, Gtk.scrolledWindowVscrollbarPolicy Gtk.:= Gtk.PolicyAutomatic ] Gtk.containerAdd scrolledWindow text Gtk.notebookAppendPage fileNotebook scrolledWindow shortName Gtk.textViewSetCursorVisible text False let matchFile f1 (PosFile f2 _) = f1 == f2 matchFile _ _ = False findLocalError (Report pos _) = isJust (find (matchFile file) (posGetRoots posContext pos)) localErrors = filter findLocalError errors highlightError (Report pos _) = do let line = posGetLine pos start <- Gtk.textBufferGetIterAtLine buffer (line - 1) end <- Gtk.textBufferGetIterAtLine buffer line Gtk.textBufferApplyTag buffer errorTag start end mapM_ highlightError localErrors Gtk.on text Gtk.buttonPressEvent $ do (x, y) <- eventCoordinates (_, bY) <- lift $ Gtk.textViewWindowToBufferCoords text Gtk.TextWindowWidget (floor x, floor y) (line, _) <- lift $ Gtk.textViewGetLineAtY text bY lineNo <- liftM (+1) $ lift $ Gtk.textIterGetLine line let findError (Report pos _) = posGetLine pos == lineNo && isJust (find (matchFile file) (posGetRoots posContext pos)) maybeErrorNo = findIndex findError errors Just errorNo = maybeErrorNo lift $ when (isJust maybeErrorNo) $ do Gtk.treeSelectionSelectPath errorSelection [errorNo] return True -- important that this is True return (file, (i, buffer, text)) fileTexts <- mapM makeNotebookPage $ zip [0..] files pageSwitchConnect <- Gtk.onSwitchPage fileNotebook $ \_ -> do Gtk.treeSelectionUnselectAll errorSelection model <- Gtk.listStoreNew errors renderer <- Gtk.cellRendererTextNew positionColumn <- Gtk.treeViewColumnNew Gtk.treeViewColumnSetTitle positionColumn "Position" Gtk.treeViewColumnSetResizable positionColumn True Gtk.treeViewColumnPackStart positionColumn renderer True errorColumn <- Gtk.treeViewColumnNew Gtk.treeViewColumnSetTitle errorColumn "Error" Gtk.treeViewColumnSetResizable errorColumn True Gtk.treeViewColumnPackStart errorColumn renderer True let showPosition (Report pos _) = [ Gtk.cellText Gtk.:= showPosAdjustFilename shortenFilename posContext pos ] showError (Report _ msg) = [ Gtk.cellText Gtk.:= msg ] Gtk.cellLayoutSetAttributes positionColumn renderer model showPosition Gtk.cellLayoutSetAttributes errorColumn renderer model showError Gtk.treeViewAppendColumn errorTree positionColumn Gtk.treeViewAppendColumn errorTree errorColumn Gtk.treeViewSetModel errorTree model errorSelection <- Gtk.treeViewGetSelection errorTree Gtk.onSelectionChanged errorSelection $ do rows <- Gtk.treeSelectionGetSelectedRows errorSelection case rows of [[row]] -> do Report pos _ <- Gtk.listStoreGetValue model row let files = findPosFiles pos case files of [file] -> do let Just (page, buffer, view) = lookup file fileTexts line = posGetLine pos column = posGetColumn pos selectWholeLine = True (start, end) <- if selectWholeLine then do start <- Gtk.textBufferGetIterAtLine buffer (line - 1) end <- Gtk.textBufferGetIterAtLine buffer line return (start, end) else do start <- Gtk.textBufferGetIterAtLineOffset buffer (line - 1) (column - 1) end <- Gtk.textBufferGetIterAtLineOffset buffer (line - 1) column return (start, end) -- cursor <- Gtk.textBufferGetIterAtLineOffset buffer (line - 1) (column - 1) -- Gtk.textBufferPlaceCursor buffer cursor Gtk.textViewScrollToIter view start 0 Nothing Gtk.textBufferSelectRange buffer start end Gtk.signalBlock pageSwitchConnect Gtk.notebookSetCurrentPage fileNotebook page Gtk.signalUnblock pageSwitchConnect _ -> return () [] -> do mapM (\(_, (_, buffer, _)) -> do start <- Gtk.textBufferGetStartIter buffer Gtk.textBufferSelectRange buffer start start ) fileTexts return () _ -> return () paned <- makeVPaned fileNotebook errorTree Gtk.set paned [ Gtk.panedPosition Gtk.:= (height `div` 2)] close <- Gtk.buttonNewFromStock Gtk.stockClose window <- makeDialogue parent title [close] paned Gtk.widgetSetSizeRequest window width height Gtk.onClicked close $ Gtk.widgetHide window Gtk.on window Gtk.deleteEvent $ lift $ Gtk.widgetHide window >> return True Gtk.widgetShowAll window Gtk.treeSelectionSelectPath errorSelection [0] return window where width = 600 height = 500 makeAlignedScrolledWindow :: Gtk.WidgetClass widget => widget -> IO Gtk.ScrolledWindow makeAlignedScrolledWindow child = do scrolledWindow <- Gtk.scrolledWindowNew Nothing Nothing Gtk.set scrolledWindow [ Gtk.scrolledWindowHscrollbarPolicy Gtk.:= Gtk.PolicyNever, Gtk.scrolledWindowVscrollbarPolicy Gtk.:= Gtk.PolicyAutomatic ] -- Gtk.containerAdd scrolledWindow table alignment <- Gtk.alignmentNew 1 1 1 1 Gtk.containerAdd alignment child Gtk.scrolledWindowAddWithViewport scrolledWindow alignment return scrolledWindow data GuiDisplayMode = GuiDot | GuiSpring deriving (Eq, Enum) defaultGuiOptions :: [GuiOption] defaultGuiOptions = [GuiDisplayMode GuiDot, GuiDiffDepth 1, GuiOnlyPassingLeads, GuiShowLinkWidthColours, GuiShowMonitorEvents] instance Show GuiDisplayMode where showsPrec _ GuiSpring = showString "spring" showsPrec _ GuiDot = showString "dot" instance Read GuiDisplayMode where readsPrec _ str = maybeToList $ do (token, rest) <- maybeLex str case token of "spring" -> return (GuiSpring, rest) "dot" -> return (GuiDot, rest) _ -> fail "" data GuiOption = GuiDisplayMode GuiDisplayMode | GuiOnlyPassingLeads | GuiShowMonitorEvents | GuiShowLinkWidthColours | GuiDiffWhenStepping | GuiDiffDepth Int | GuiShowTimeWindow | GuiShowOWindow | GuiShowNetworkDiffWindow | GuiTimeStepSize Integer instance SubOption GuiOption where matchSubOption (GuiDisplayMode _) (GuiDisplayMode _) = True matchSubOption (GuiDiffDepth _) (GuiDiffDepth _) = True matchSubOption GuiOnlyPassingLeads GuiOnlyPassingLeads = True matchSubOption GuiShowMonitorEvents GuiShowMonitorEvents = True matchSubOption GuiShowLinkWidthColours GuiShowLinkWidthColours = True matchSubOption GuiDiffWhenStepping GuiDiffWhenStepping = True matchSubOption GuiShowTimeWindow GuiShowTimeWindow = True matchSubOption GuiShowOWindow GuiShowOWindow = True matchSubOption GuiShowNetworkDiffWindow GuiShowNetworkDiffWindow = True matchSubOption (GuiTimeStepSize {}) (GuiTimeStepSize {}) = True matchSubOption _ _ = False instance Show GuiOption where showsPrec _ (GuiDisplayMode mode) = shows mode showsPrec _ (GuiDiffDepth depth) = shows depth showsPrec _ (GuiTimeStepSize step) = shows step showsPrec _ _ = id guiOptionUsage :: SubOptionUsages GuiOption guiOptionUsage = SubOptionUsages "gui" show Nothing (Just defaultGuiOptions) [ ("display", SubOptionUsage False "mode" "network display mode {spring,dot}" "dot" (not . null . (reads :: String -> [(GuiDisplayMode, String)])) (\arg -> ([GuiDisplayMode (read arg)], []))), ("diff-depth", SubOptionUsage False "depth" "depth of netlist diff. component view" "1" (not . null . (reads :: String -> [(Int, String)])) (\arg -> ([GuiDiffDepth (read arg)], []))), ("only-passing-leads", boolSubOption "show only optimisation leads" GuiOnlyPassingLeads), ("show-step-diff", boolSubOption "show network diff. when stepping" GuiDiffWhenStepping), ("show-link-widths", boolSubOption "show link widths as colours" GuiShowLinkWidthColours), ("show-monitor-events", boolSubOption "show monitor events on links" GuiShowMonitorEvents), ("show-time-window", boolSubOption "show time window at startup" GuiShowTimeWindow), ("show-o-window", boolSubOption "show O component window at startup" GuiShowOWindow), ("show-diff-window", boolSubOption "show network diff. window at startup" GuiShowNetworkDiffWindow), ("time-step", SubOptionUsage False "time" "size of steps in Time window" "1" (not . null . (reads :: String -> [(Integer, String)])) (\arg -> ([GuiTimeStepSize (read arg)], []))) ]
Mahdi89/eTeak
src/GuiSupport.hs
bsd-3-clause
32,746
0
27
10,396
8,480
4,218
4,262
640
7
module Spec where import Test.Hspec import Challenge main :: IO () main = hspec $ do describe "Challenge.findTheDifference" $ do it "returns Nothing when no difference" $ do findTheDifference "a" "a" `shouldBe` Nothing it "returns the differing char" $ do findTheDifference "abcd" "adecb" `shouldBe` Just 'e' it "returns the differing char when the char shows up multiple times" $ do findTheDifference "abcde" "adecbb" `shouldBe` Just 'b'
DakRomo/2017Challenges
challenge_5/haskell/halogenandtoast/src/Spec.hs
mit
475
0
15
102
119
57
62
12
1
-- This module implements FIR filters, and compositions of them. -- The generated code looks OK, but the use of `force` leads to different space/time -- characteristics. -- -- In order to fuse filters without forcing the entire intermediate vector, one should use streams -- with a cyclic buffer; see example in the Stream library. import qualified Prelude import Feldspar import Feldspar.Vector import Feldspar.Matrix import Feldspar.Compiler causalMap :: Syntax a => (Vector a -> a) -> Vector a -> Vector a causalMap f = map (f . reverse) . inits -- | FIR filter fir :: Vector1 Float -- ^ Coefficients -> Vector1 Float -- ^ Input -> Vector1 Float fir coeffs = causalMap (coeffs***) -------------------------------------------------------------------------------- -- Composing filters composition boundary as bs = fir as . boundary . fir bs test1 :: Vector1 Float -> Vector1 Float -> Vector1 Float -> Vector1 Float test1 = composition id -:: newLen 10 >-> newLen 10 >-> newLen 100 >-> id -- Loop structure: -- -- parallel 100 -- forLoop 10 -- forLoop 10 test2 :: Vector1 Float -> Vector1 Float -> Vector1 Float -> Vector1 Float test2 = composition force -:: newLen 10 >-> newLen 10 >-> newLen 100 >-> id -- Loop structure: -- -- parallel 100 -- forLoop 10 -- parallel 100 -- forLoop 10 -------------------------------------------------------------------------------- -- Filters with hard-coded coefficients composition2 boundary = fir (value [0.3,0.4,0.5,0.6]) . boundary . fir (value [0.3,-0.4,0.5,-0.6]) test3 :: Vector1 Float -> Vector1 Float test3 = composition2 id -:: newLen 100 >-> id test4 :: Vector1 Float -> Vector1 Float test4 = composition2 force -:: newLen 100 >-> id
emwap/feldspar-compiler
benchs/FIR_Fusion.hs
bsd-3-clause
1,761
0
10
345
422
218
204
22
1
-- | -- Module: Control.Wire.Switch -- Copyright: (c) 2013 Ertugrul Soeylemez -- License: BSD3 -- Maintainer: Ertugrul Soeylemez <[email protected]> module Control.Wire.Switch ( -- * Simple switching (-->), (>--), -- * Context switching modes, -- * Event-based switching -- ** Intrinsic switch, dSwitch, -- ** Intrinsic continuable kSwitch, dkSwitch, -- ** Extrinsic rSwitch, drSwitch, alternate, -- ** Extrinsic continuable krSwitch, dkrSwitch ) where import qualified Data.Map as M import Control.Applicative import Control.Arrow import Control.Monad import Control.Wire.Core import Control.Wire.Event import Control.Wire.Unsafe.Event import Data.Monoid -- | Acts like the first wire until it inhibits, then switches to the -- second wire. Infixr 1. -- -- * Depends: like current wire. -- -- * Inhibits: after switching like the second wire. -- -- * Switch: now. (-->) :: (Monad m) => Wire s e m a b -> Wire s e m a b -> Wire s e m a b w1' --> w2' = WGen $ \ds mx' -> do (mx, w1) <- stepWire w1' ds mx' case mx of Left _ | Right _ <- mx' -> stepWire w2' ds mx' _ -> mx `seq` return (mx, w1 --> w2') infixr 1 --> -- | Acts like the first wire until the second starts producing, at which point -- it switches to the second wire. Infixr 1. -- -- * Depends: like current wire. -- -- * Inhibits: after switching like the second wire. -- -- * Switch: now. (>--) :: (Monad m) => Wire s e m a b -> Wire s e m a b -> Wire s e m a b w1' >-- w2' = WGen $ \ds mx' -> do (m2, w2) <- stepWire w2' ds mx' case m2 of Right _ -> m2 `seq` return (m2, w2) _ -> do (m1, w1) <- stepWire w1' ds mx' m1 `seq` return (m1, w1 >-- w2) infixr 1 >-- -- | Intrinsic continuable switch: Delayed version of 'kSwitch'. -- -- * Inhibits: like the first argument wire, like the new wire after -- switch. Inhibition of the second argument wire is ignored. -- -- * Switch: once, after now, restart state. dkSwitch :: (Monad m) => Wire s e m a b -> Wire s e m (a, b) (Event (Wire s e m a b -> Wire s e m a b)) -> Wire s e m a b dkSwitch w1' w2' = WGen $ \ds mx' -> do (mx, w1) <- stepWire w1' ds mx' (mev, w2) <- stepWire w2' ds (liftA2 (,) mx' mx) let w | Right (Event sw) <- mev = sw w1 | otherwise = dkSwitch w1 w2 return (mx, w) -- | Extrinsic switch: Delayed version of 'rSwitch'. -- -- * Inhibits: like the current wire. -- -- * Switch: recurrent, after now, restart state. drSwitch :: (Monad m) => Wire s e m a b -> Wire s e m (a, Event (Wire s e m a b)) b drSwitch w' = WGen $ \ds mx' -> let nw w | Right (_, Event w1) <- mx' = w1 | otherwise = w in liftM (second (drSwitch . nw)) (stepWire w' ds (fmap fst mx')) -- | Acts like the first wire until an event occurs then switches -- to the second wire. Behaves like this wire until the event occurs -- at which point a *new* instance of the first wire is switched to. -- -- * Depends: like current wire. -- -- * Inhibits: like the argument wires. -- -- * Switch: once, now, restart state. alternate :: (Monad m) => Wire s e m a b -> Wire s e m a b -> Wire s e m (a, Event x) b alternate w1 w2 = go w1 w2 w1 where go w1' w2' w' = WGen $ \ds mx' -> let (w1, w2, w) | Right (_, Event _) <- mx' = (w2', w1', w2') | otherwise = (w1', w2', w') in liftM (second (go w1 w2)) (stepWire w ds (fmap fst mx')) -- | Intrinsic switch: Delayed version of 'switch'. -- -- * Inhibits: like argument wire until switch, then like the new wire. -- -- * Switch: once, after now, restart state. dSwitch :: (Monad m) => Wire s e m a (b, Event (Wire s e m a b)) -> Wire s e m a b dSwitch w' = WGen $ \ds mx' -> do (mx, w) <- stepWire w' ds mx' let nw | Right (_, Event w1) <- mx = w1 | otherwise = dSwitch w return (fmap fst mx, nw) -- | Extrinsic continuable switch. Delayed version of 'krSwitch'. -- -- * Inhibits: like the current wire. -- -- * Switch: recurrent, after now, restart state. dkrSwitch :: (Monad m) => Wire s e m a b -> Wire s e m (a, Event (Wire s e m a b -> Wire s e m a b)) b dkrSwitch w' = WGen $ \ds mx' -> let nw w | Right (_, Event f) <- mx' = f w | otherwise = w in liftM (second (dkrSwitch . nw)) (stepWire w' ds (fmap fst mx')) -- | Intrinsic continuable switch: @kSwitch w1 w2@ starts with @w1@. -- Its signal is received by @w2@, which may choose to switch to a new -- wire. Passes the wire we are switching away from to the new wire, -- such that it may be reused in it. -- -- * Inhibits: like the first argument wire, like the new wire after -- switch. Inhibition of the second argument wire is ignored. -- -- * Switch: once, now, restart state. kSwitch :: (Monad m, Monoid s) => Wire s e m a b -> Wire s e m (a, b) (Event (Wire s e m a b -> Wire s e m a b)) -> Wire s e m a b kSwitch w1' w2' = WGen $ \ds mx' -> do (mx, w1) <- stepWire w1' ds mx' (mev, w2) <- stepWire w2' ds (liftA2 (,) mx' mx) case mev of Right (Event sw) -> stepWire (sw w1) mempty mx' _ -> return (mx, kSwitch w1 w2) -- | Extrinsic continuable switch. This switch works like 'rSwitch', -- except that it passes the wire we are switching away from to the new -- wire. -- -- * Inhibits: like the current wire. -- -- * Switch: recurrent, now, restart state. krSwitch :: (Monad m) => Wire s e m a b -> Wire s e m (a, Event (Wire s e m a b -> Wire s e m a b)) b krSwitch w'' = WGen $ \ds mx' -> let w' | Right (_, Event f) <- mx' = f w'' | otherwise = w'' in liftM (second krSwitch) (stepWire w' ds (fmap fst mx')) -- | Route the left input signal based on the current mode. The right -- input signal can be used to change the current mode. When switching -- away from a mode and then switching back to it, it will be resumed. -- Freezes time during inactivity. -- -- * Complexity: O(n * log n) space, O(log n) lookup time on switch wrt -- number of started, inactive modes. -- -- * Depends: like currently active wire (left), now (right). -- -- * Inhibits: when active wire inhibits. -- -- * Switch: now on mode change. modes :: (Monad m, Ord k) => k -- ^ Initial mode. -> (k -> Wire s e m a b) -- ^ Select wire for given mode. -> Wire s e m (a, Event k) b modes m0 select = loop M.empty m0 (select m0) where loop ms' m' w'' = WGen $ \ds mxev' -> case mxev' of Left _ -> do (mx, w) <- stepWire w'' ds (fmap fst mxev') return (mx, loop ms' m' w) Right (x', ev) -> do let (ms, m, w') = switch ms' m' w'' ev (mx, w) <- stepWire w' ds (Right x') return (mx, loop ms m w) switch ms' m' w' NoEvent = (ms', m', w') switch ms' m' w' (Event m) = let ms = M.insert m' w' ms' in case M.lookup m ms of Nothing -> (ms, m, select m) Just w -> (M.delete m ms, m, w) -- | Extrinsic switch: Start with the given wire. Each time the input -- event occurs, switch to the wire it carries. -- -- * Inhibits: like the current wire. -- -- * Switch: recurrent, now, restart state. rSwitch :: (Monad m) => Wire s e m a b -> Wire s e m (a, Event (Wire s e m a b)) b rSwitch w'' = WGen $ \ds mx' -> let w' | Right (_, Event w1) <- mx' = w1 | otherwise = w'' in liftM (second rSwitch) (stepWire w' ds (fmap fst mx')) -- | Intrinsic switch: Start with the given wire. As soon as its event -- occurs, switch to the wire in the event's value. -- -- * Inhibits: like argument wire until switch, then like the new wire. -- -- * Switch: once, now, restart state. switch :: (Monad m, Monoid s) => Wire s e m a (b, Event (Wire s e m a b)) -> Wire s e m a b switch w' = WGen $ \ds mx' -> do (mx, w) <- stepWire w' ds mx' case mx of Right (_, Event w1) -> stepWire w1 mempty mx' _ -> return (fmap fst mx, switch w)
jship/metronome
local_deps/netwire/Control/Wire/Switch.hs
bsd-3-clause
8,442
0
19
2,657
2,590
1,354
1,236
152
4
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd"> <helpset version="2.0" xml:lang="ms-MY"> <title>Import/Export</title> <maps> <homeID>exim</homeID> <mapref location="map.jhm"/> </maps> <view> <name>TOC</name> <label>Contents</label> <type>org.zaproxy.zap.extension.help.ZapTocView</type> <data>toc.xml</data> </view> <view> <name>Index</name> <label>Index</label> <type>javax.help.IndexView</type> <data>index.xml</data> </view> <view> <name>Search</name> <label>Search</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favorites</label> <type>javax.help.FavoritesView</type> </view> </helpset>
kingthorin/zap-extensions
addOns/exim/src/main/javahelp/help_ms_MY/helpset_ms_MY.hs
apache-2.0
959
77
67
155
408
207
201
-1
-1
module RmOneParameter.A2 where import RmOneParameter.D2 sumSq xs ys= sum (map sq xs) + sumSquares xs main = sumSq [1..4]
RefactoringTools/HaRe
test/testdata/RmOneParameter/A2.expected.hs
bsd-3-clause
125
0
8
23
52
27
25
4
1
{-@ LIQUID "--no-termination" @-} module Blank (quickSort, foo, qsort) where -- This is a blank file. {- foo :: xs:[Int] -> {v:[Int] | (len v) = (len xs)} @-} foo :: [Int] -> [Int] foo [] = [] foo (x:xs) = (x+1) : foo [y | y <- xs] {- qsort :: (Ord a) => xs:[a] -> {v:[a] | (len v) <= (len xs)} @-} qsort [] = [] qsort (x:xs) = x : qsort [y | y <- xs, y < x] {-@ quickSort :: (Ord a) => [a] -> SList a @-} quickSort [] = [] quickSort xs@(x:_) = append x lts gts where lts = quickSort [y | y <- xs, y < x] gts = quickSort [z | z <- xs, z >= x] {- append :: k:a -> SList {v:a | v<k} -> SList {v:a | v >= k} -> SList a @-} append k [] ys = k : ys append k (x:xs) ys = x : append k xs ys {-@ type SList a = [a]<{\x v -> (v >= x)}> @-}
mightymoose/liquidhaskell
tests/pos/comprehensionTerm.hs
bsd-3-clause
792
0
10
240
283
152
131
12
1
module T15005 ( OrderCell, ElementCell, rawAlgorithm, rawAlgorithmWithSize ) where -- Control import Control.Applicative import Control.Monad import Control.Monad.ST -- Data import Data.Word import Data.Bits import Data.STRef type RawOrder s o = STRef s (o s) type RawElement s e = STRef s (e s) data RawAlgorithm s o e = RawAlgorithm { newOrder :: ST s (RawOrder s o), compareElements :: RawElement s e -> RawElement s e -> RawOrder s o -> ST s Ordering, newMinimum :: RawOrder s o -> ST s (RawElement s e), newMaximum :: RawOrder s o -> ST s (RawElement s e), newAfter :: RawElement s e -> RawOrder s o -> ST s (RawElement s e), newBefore :: RawElement s e -> RawOrder s o -> ST s (RawElement s e), delete :: RawElement s e -> RawOrder s o -> ST s () } {-FIXME: If we ever allow users to plug in their own algorithms, we have to flag the respective function as unsafe and point out that referential transparency is in danger if the algorithm does not fulfill the specification. This is because element comparison is presented to the user as a pure function. The important condition is that for any two elements, compareElements must always return the same result as long as delete is not called on either element. -} type OrderCell = Cell type ElementCell = Cell data Cell s = Cell { label :: Label, next :: CellRef s, prev :: CellRef s } type CellRef s = STRef s (Cell s) newtype Label = Label LabelWord deriving (Eq, Ord) type LabelWord = Word64 labelWordSize :: Int labelWordSize = 64 initialBaseLabel :: Label initialBaseLabel = Label 0 rawAlgorithm :: RawAlgorithm s OrderCell ElementCell rawAlgorithm = rawAlgorithmWithSize defaultSize defaultSize :: Int defaultSize = 63 rawAlgorithmWithSize :: Int -> RawAlgorithm s OrderCell ElementCell rawAlgorithmWithSize size | size < 0 || size >= labelWordSize = error "Data.Order.Algorithm.dietzSleatorAmortizedLogWithSize: \ \Size out of bounds" | otherwise = RawAlgorithm { newOrder = fixST $ \ ref -> newSTRef $ Cell { label = initialBaseLabel, next = ref, prev = ref }, compareElements = \ ref1 ref2 baseRef -> do baseCell <- readSTRef baseRef cell1 <- readSTRef ref1 cell2 <- readSTRef ref2 let offset1 = labelDiff (label cell1) (label baseCell) let offset2 = labelDiff (label cell2) (label baseCell) return $ compare offset1 offset2, newMinimum = newAfterCell, newMaximum = newBeforeCell, newAfter = const . newAfterCell, newBefore = const . newBeforeCell, delete = \ ref _ -> do cell <- readSTRef ref modifySTRef (prev cell) (\ prevCell -> prevCell { next = next cell }) modifySTRef (next cell) (\ nextCell -> nextCell { prev = prev cell }) } where noOfLabels :: LabelWord noOfLabels = shiftL 1 size labelMask :: LabelWord labelMask = pred noOfLabels toLabel :: LabelWord -> Label toLabel = Label . (.&. labelMask) labelSum :: Label -> Label -> Label labelSum (Label word1) (Label word2) = toLabel (word1 + word2) labelDiff :: Label -> Label -> Label labelDiff (Label word1) (Label word2) = toLabel (word1 - word2) labelDistance :: Label -> Label -> LabelWord labelDistance lbl1 lbl2 = case labelDiff lbl1 lbl2 of Label word | word == 0 -> noOfLabels | otherwise -> word newAfterCell :: CellRef s -> ST s (CellRef s) newAfterCell ref = do relabel ref lbl <- label <$> readSTRef ref nextRef <- next <$> readSTRef ref nextLbl <- label <$> readSTRef nextRef newRef <- newSTRef $ Cell { label = labelSum lbl (Label (labelDistance nextLbl lbl `div` 2)), next = nextRef, prev = ref } modifySTRef ref (\ cell -> cell { next = newRef }) modifySTRef nextRef (\ nextCell -> nextCell { prev = newRef }) return newRef relabel :: CellRef s -> ST s () relabel startRef = do startCell <- readSTRef startRef let delimSearch ref gapCount = do cell <- readSTRef ref let gapSum = labelDistance (label cell) (label startCell) if gapSum <= gapCount ^ 2 then if ref == startRef then error "Data.Order.Algorithm.\ \dietzSleatorAmortizedLogWithSize: \ \Order full" else delimSearch (next cell) (succ gapCount) else return (ref, gapSum, gapCount) (delimRef, gapSum, gapCount) <- delimSearch (next startCell) 1 let smallGap = gapSum `div` gapCount let largeGapCount = gapSum `mod` gapCount let changeLabels ref ix = when (ref /= delimRef) $ do cell <- readSTRef ref let lbl = labelSum (label startCell) (Label (ix * smallGap + min largeGapCount ix)) writeSTRef ref (cell { label = lbl }) changeLabels (next cell) (succ ix) changeLabels (next startCell) 1 {-FIXME: We allow the number of cells to be larger than the square root of the number of possible labels as long as we find a sparse part in our circle of cells (since our order full condition is only true if the complete circle is congested). This should not influence correctness and probably also not time complexity, but we should check this more thoroughly. -} {-FIXME: We arrange the large and small gaps differently from Dietz and Sleator by putting all the large gaps at the beginning instead of distributing them over the relabeled area. However, this should not influence time complexity, as the complexity proof seems to only rely on the fact that gap sizes differ by at most 1. We should check this more thoroughly though. -} newBeforeCell :: CellRef s -> ST s (CellRef s) newBeforeCell ref = do cell <- readSTRef ref newAfterCell (prev cell)
sdiehl/ghc
testsuite/tests/simplCore/should_compile/T15005.hs
bsd-3-clause
7,442
0
23
3,091
1,573
806
767
125
3
import Database.Persist.Postgresql import Database.Persist.Store import Data.Yaml main :: IO () main = do Just yaml <- decodeFile "settings.yaml" conf <- parseMonad loadConfig yaml conf' <- applyEnv (conf :: PostgresConf) pool <- createPoolConfig conf' runPool conf' (return ()) pool
creichert/persistent-postgresql
test-settings.hs
mit
305
0
10
59
102
49
53
10
1
import Test.Tasty import LesserActionSpec import SemiLatticeActionSpec main :: IO () main = defaultMain $ testGroup "all" [ allLesserAction , allSemiLatticeAction ]
blargg/crdt
src-test/Main.hs
isc
209
0
7
65
42
23
19
7
1
module ClipSpaceZSimple where import qualified Matrix4f as M4x4; import qualified Vector4f as V4; clip_z_simple :: M4x4.T -> V4.T -> Float clip_z_simple m eye = let m22 = M4x4.row_column m (2, 2) m23 = M4x4.row_column m (2, 3) in ((V4.z eye) * m22) + m23
io7m/r2
com.io7m.r2.documentation/src/main/resources/com/io7m/r2/documentation/haskell/ClipSpaceZSimple.hs
isc
273
0
12
62
106
61
45
9
1
module Geometry.Vector2d where import Algebra.Vector as Vector import Prelude.Extensions as PreludeExt crossProduct :: Vector -> Vector -> Rational crossProduct = \a b -> let e = Vector.element in ((-) ((*) (e a 0) (e b 1)) ((*) (e a 1) (e b 0))) quadrant :: Vector -> Int quadrant = \vector -> let (x, y) = (Vector.element vector 0, Vector.element vector 1) case_list = [((&&) ((>) x 0) ((>=) y 0), 0), ((&&) ((>=) 0 x) ((>) y 0), 1), ((&&) ((>) 0 x) ((>=) 0 y), 2), ((&&) ((>=) x 0) ((>) 0 y), 3)] in (cases case_list (-1)) quadrantRatio :: Vector -> (Int, Rational) quadrantRatio = \vector -> let (x, y) = (Vector.element vector 0, Vector.element vector 1) quad = (quadrant vector) x_y = ((/) (abs x) (abs y)) y_x = ((/) (abs y) (abs x)) in (quad, (ifElse ((==) (mod quad 2) 0) y_x x_y)) fromAngle = \angle -> let a = (fromRational angle) cosa = (toRational (cos a)) sina = (toRational (sin a)) in Vector.fromList [cosa, sina] toAngle = \v -> let x = (fromRational (Vector.element v 0)) y = (fromRational (Vector.element v 1)) in (toRational (atan2 y x)) angle = \v0 v1 -> let in (normalizeAngle0 ((-) (toAngle v1) (toAngle v0))) positiveAngle = \v0 v1 -> let angle = (Geometry.Vector2d.angle v0 v1) in (ifElse ((==) angle 0) ((*) (toRational pi) 2) angle) rotate = \v angle -> (fromAngle ((+) (toAngle v) angle)) perpendicular :: Vector -> Vector perpendicular = \v -> Vector.fromList [(Prelude.negate (Vector.element v 1)), (Vector.element v 0)] normalizeAngle :: Rational -> Rational -> Rational normalizeAngle = \min angle -> let pi2 = (toRational ((*) pi 2)) max = ((+) min pi2) increment = \angle -> (ifElse ((<) angle min) (increment ((+) angle pi2)) angle) decrement = \angle -> (ifElse ((>) angle max) (decrement ((-) angle pi2)) angle) in (increment (decrement angle)) normalizeAngle0 = (normalizeAngle 0)
stevedonnelly/haskell
code/Geometry/Vector2d.hs
mit
1,958
0
16
451
1,034
573
461
47
1
-- Adopted from https://github.com/haskell/hackage-server/blob/master/Distribution/Server/Packages/ModuleForest.hs {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE ViewPatterns #-} module Distribution.Package.ModuleForest ( moduleName , moduleForest , ModuleTree(..) , ModuleForest , NameComponent ) where import Distribution.ModuleName (ModuleName) import qualified Distribution.ModuleName as ModuleName import RIO import RIO.Text (pack, unpack) type NameComponent = Text type ModuleForest = [ModuleTree] data ModuleTree = Node { component :: NameComponent , isModule :: Bool , subModules :: ModuleForest } deriving (Show, Eq) moduleName :: Text -> ModuleName moduleName = ModuleName.fromString . unpack moduleForest :: [ModuleName] -> ModuleForest moduleForest = foldr (addToForest . map pack . ModuleName.components) [] addToForest :: [NameComponent] -> ModuleForest -> ModuleForest addToForest [] trees = trees addToForest comps [] = mkSubTree comps addToForest comps@(comp1:cs) (t@(component -> comp2):ts) = case compare comp1 comp2 of GT -> t : addToForest comps ts EQ -> Node comp2 (isModule t || null cs) (addToForest cs (subModules t)) : ts LT -> mkSubTree comps ++ t : ts mkSubTree :: [Text] -> ModuleForest mkSubTree [] = [] mkSubTree (c:cs) = [Node c (null cs) (mkSubTree cs)]
fpco/stackage-server
src/Distribution/Package/ModuleForest.hs
mit
1,425
0
13
307
404
224
180
33
3
module DynamoDbEventStore (streamEventsProducer ,globalEventsProducer ,globalEventKeysProducer ,writeEvent ,readEvent ,buildTable ,doesTableExist ,runGlobalFeedWriter ,RuntimeEnvironment(..) ,GlobalFeedPosition(..) ,RecordedEvent(..) ,StreamId(..) ,EventStoreError(..) ,EventStoreActionError(..) ,EventStore ,Streams.EventWriteResult(..) ,EventEntry(..) ,EventType(..) ,EventTime(..) ,MetricLogs(..) ,MetricLogsPair(..) ,InterpreterError(..)) where import DynamoDbEventStore.ProjectPrelude import Control.Monad.State import qualified DynamoDbEventStore.Streams as Streams import DynamoDbEventStore.Types (RecordedEvent(..),QueryDirection,StreamId(..),EventStoreActionError,GlobalFeedPosition(..),EventKey) import DynamoDbEventStore.AmazonkaImplementation (RuntimeEnvironment(..), InterpreterError(..), MyAwsM(..),MetricLogs(..),MetricLogsPair(..)) import qualified DynamoDbEventStore.AmazonkaImplementation as AWS import DynamoDbEventStore.Storage.StreamItem (EventEntry(..),EventType(..),EventTime(..)) import qualified DynamoDbEventStore.GlobalFeedWriter as GlobalFeedWriter import Control.Monad.Trans.AWS import Control.Monad.Trans.Resource import Control.Monad.Morph data EventStoreError = EventStoreErrorInterpreter InterpreterError | EventStoreErrorAction EventStoreActionError deriving (Show, Eq) type EventStore = ExceptT EventStoreError (AWST' RuntimeEnvironment (ResourceT IO)) hoistDsl :: (ExceptT EventStoreActionError MyAwsM) a -> (ExceptT EventStoreError (AWST' RuntimeEnvironment (ResourceT IO))) a hoistDsl = combineErrors . hoist unMyAwsM buildTable :: Text -> EventStore () buildTable tableName = hoistDsl $ lift $ AWS.buildTable tableName doesTableExist :: Text -> EventStore Bool doesTableExist tableName = hoistDsl $ lift $ AWS.doesTableExist tableName streamEventsProducer :: QueryDirection -> StreamId -> Maybe Int64 -> Natural -> Producer RecordedEvent EventStore () streamEventsProducer direction streamId lastEvent batchSize = hoist hoistDsl $ Streams.streamEventsProducer direction streamId lastEvent batchSize globalEventsProducer :: QueryDirection -> Maybe GlobalFeedPosition -> Producer (GlobalFeedPosition, RecordedEvent) EventStore () globalEventsProducer direction startPosition = hoist hoistDsl $ Streams.globalEventsProducer direction startPosition globalEventKeysProducer :: QueryDirection -> Maybe GlobalFeedPosition -> Producer (GlobalFeedPosition, EventKey) EventStore () globalEventKeysProducer direction startPosition = hoist hoistDsl $ Streams.globalEventKeysProducer direction startPosition readEvent :: StreamId -> Int64 -> EventStore (Maybe RecordedEvent) readEvent streamId eventNumber = hoistDsl $ Streams.readEvent streamId eventNumber writeEvent :: StreamId -> Maybe Int64 -> NonEmpty EventEntry -> EventStore Streams.EventWriteResult writeEvent streamId ev eventEntries = hoistDsl $ Streams.writeEvent streamId ev eventEntries combineErrors :: ExceptT EventStoreActionError (ExceptT InterpreterError (AWST' RuntimeEnvironment (ResourceT IO))) a -> EventStore a combineErrors a = do r <- lift $ runExceptT (runExceptT a) case r of (Left e) -> throwError $ EventStoreErrorInterpreter e (Right (Left e)) -> throwError $ EventStoreErrorAction e (Right (Right result)) -> return result runGlobalFeedWriter :: EventStore () runGlobalFeedWriter = evalStateT (hoist hoistDsl GlobalFeedWriter.main) GlobalFeedWriter.emptyGlobalFeedWriterState
adbrowne/dynamodb-eventstore
dynamodb-eventstore/src/DynamoDbEventStore.hs
mit
3,602
0
13
523
908
503
405
75
3
{-# LANGUAGE PatternSynonyms #-} -- For HasCallStack compatibility {-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module JSDOM.Generated.CSSKeyframeRule (setKeyText, getKeyText, getStyle, CSSKeyframeRule(..), gTypeCSSKeyframeRule) where import Prelude ((.), (==), (>>=), return, IO, Int, Float, Double, Bool(..), Maybe, maybe, fromIntegral, round, realToFrac, fmap, Show, Read, Eq, Ord, Maybe(..)) import qualified Prelude (error) import Data.Typeable (Typeable) import Data.Traversable (mapM) import Language.Javascript.JSaddle (JSM(..), JSVal(..), JSString, strictEqual, toJSVal, valToStr, valToNumber, valToBool, js, jss, jsf, jsg, function, asyncFunction, new, array, jsUndefined, (!), (!!)) import Data.Int (Int64) import Data.Word (Word, Word64) import JSDOM.Types import Control.Applicative ((<$>)) import Control.Monad (void) import Control.Lens.Operators ((^.)) import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync) import JSDOM.Enums -- | <https://developer.mozilla.org/en-US/docs/Web/API/CSSKeyframeRule.keyText Mozilla CSSKeyframeRule.keyText documentation> setKeyText :: (MonadDOM m, ToJSString val) => CSSKeyframeRule -> val -> m () setKeyText self val = liftDOM (self ^. jss "keyText" (toJSVal val)) -- | <https://developer.mozilla.org/en-US/docs/Web/API/CSSKeyframeRule.keyText Mozilla CSSKeyframeRule.keyText documentation> getKeyText :: (MonadDOM m, FromJSString result) => CSSKeyframeRule -> m result getKeyText self = liftDOM ((self ^. js "keyText") >>= fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/CSSKeyframeRule.style Mozilla CSSKeyframeRule.style documentation> getStyle :: (MonadDOM m) => CSSKeyframeRule -> m CSSStyleDeclaration getStyle self = liftDOM ((self ^. js "style") >>= fromJSValUnchecked)
ghcjs/jsaddle-dom
src/JSDOM/Generated/CSSKeyframeRule.hs
mit
1,911
0
10
249
472
290
182
30
1
import Bio.Phylo main = do -- read in a Newick file tree <- parse_file "newick" "test.newick" -- print all of the terminal nodes putStrLn $ show $ terminals tree -- write the tree to a new output file write_file "newick" "output.newick" tree
bendmorris/biophylo
test.hs
mit
296
0
8
96
50
24
26
5
1
{-# LANGUAGE TemplateHaskell #-} -- | Types used during the rendering. module Graphics.Types where import Graphics.Rendering.OpenGL import Cghs.Types.Circle2 import Cghs.Types.Line2 import Cghs.Types.PlaneRegion2 import Cghs.Types.PointVector2 import Cghs.Types.Polygon2 import Cghs.Types.Segment2 import Cghs.Types.Triangle2 import Control.Lens -- | A renderable item. data RenderableItem a = RenderableCircle2 (Circle2 a) | RenderableLine2 (Line2 a) | RenderablePlaneRegion2 (PlaneRegion2 a) | RenderablePoint2 (Point2 a) | RenderablePolygon2 (Polygon2 a) | RenderableSegment2 (Segment2 a) | RenderableTriangle2 (Triangle2 a) deriving Show -- | A list of (renderable item, color, isSelected). type RenderableListItem = [(RenderableItem GLfloat, Color3 GLfloat, Bool)] -- | Selection mode. data SelectMode = PointMode | SegmentMode | LineMode | PolygonMode deriving (Bounded, Enum, Eq) -- | Particular instance of Show for SelectMode. instance Show SelectMode where show PointMode = "points" show SegmentMode = "segments" show LineMode = "lines" show PolygonMode = "polygons" -- | State of the viewer. data ViewerState = ViewerState { _renderList :: RenderableListItem , _selectionMode :: SelectMode } makeLenses ''ViewerState -- | Initial state for the viewer. initialViewerState :: ViewerState initialViewerState = ViewerState { _renderList = [], _selectionMode = PointMode } -- | The width of the window. width :: Int width = 800 -- | The height of the window. height :: Int height = 600
nyorem/cghs
viewer/Graphics/Types.hs
mit
1,790
0
8
499
324
192
132
40
1
{-# Language FlexibleContexts #-} {-# Language UndecidableInstances #-} {-# Language GeneralizedNewtypeDeriving #-} -- base import Control.Applicative -- lens import Control.Lens -- linear import Linear -- falling import Falling -- QuickCheck import Test.QuickCheck -- hspec import Test.Hspec instance Arbitrary a => Arbitrary (V3 a) where arbitrary = V3 <$> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary n => Arbitrary (Particle n) where arbitrary = Particle <$> arbitrary <*> arbitrary <*> arbitrary -- | Stupid type to improve inference for QuickCheck things. newtype Doubled f = D (f Double) instance Show (f Double) => Show (Doubled f) where show (D a) = show a instance Arbitrary (f Double) => Arbitrary (Doubled f) where arbitrary = D <$> arbitrary main :: IO () main = hspec $ do describe "gravitation" $ do it "gravitation a a = V3 NaN NaN NaN." . property $ \(D a) -> allOf traverse isNaN $ gravitation a a it "gravitation a b = negate (gravitation b a)." . property $ \(D a) b -> a == b || gravitation a b == negate (gravitation b a) it "with a /= b, gravitation a b has no NaN." . property $ \(D a) b -> a == b || allOf traverse (not . isNaN) (gravitation a b) describe "update" $ do it "with a ^. mass /= 0, update [a] = [a]." . property $ \(D a) -> a ^. mass == 0 || update [a] == [a] it "never produces NaNs." . property $ \as -> allOf (traverse . traverse) (not . isNaN) $ update (as :: [Particle Double]) it "preserves length." . property $ \as -> length (update as) == length (as :: [Particle Double])
startling/falling
test.hs
mit
1,633
0
17
381
552
279
273
37
1
module DiceTool.Random ( randomRCs ) where import System.Random (Random, RandomGen, randomR) randomRCs :: (Random a, RandomGen g) => (a, a) -> Int -> g -> ([a], g) randomRCs r n g | n <= 0 = ([], g) | otherwise = let (x, ng) = randomR r g (rest, fg) = randomRCs r (n-1) ng in (x:rest, fg)
garrettpauls/dicetool
src/DiceTool/Random.hs
mit
318
0
12
87
172
94
78
10
1
module BDD.Util where import BDD.Raw import Control.Exception (finally) -- | Brackets an action that requires a BDD manager with manager -- creation and destruction. withBddMgr :: Int -- ^ the number of variables -> (BddMgr -> IO a) -- ^ the action to run -> IO a withBddMgr nVars act | nVars <= 0 = error ("bad number of variables: " ++ show nVars) | otherwise = do mgr <- bdd_mgr_create (fromIntegral nVars) act mgr `finally` bdd_mgr_destroy mgr withBddMgrHint :: Int -> Int -> (BddMgr -> IO a) -> IO a withBddMgrHint nVars cHint act | nVars <= 0 = error ("bad number of variables: " ++ show nVars) | otherwise = do mgr <- bdd_mgr_create_with_hint (fromIntegral nVars) (fromIntegral cHint) act mgr `finally` bdd_mgr_destroy mgr
bradlarsen/bdd
hs-bdd/BDD/Util.hs
mit
814
0
11
209
237
116
121
22
1
module P19 where -- | Rotate a list N places to the left. -- >>> rotate ['a','b','c','d','e','f','g','h'] 3 -- "defghabc" -- >>> rotate ['a','b','c','d','e','f','g','h'] (-2) -- "ghabcdef" rotate :: [a] -> Int -> [a] rotate xs n | n == 0 = xs | n > 0 = drop n xs ++ take n xs | n < 0 = drop n' xs ++ take n' xs where n' = length xs + n
briancavalier/h99
p19.hs
mit
347
0
8
85
116
59
57
7
1
module Hero where import Nicknames import Data.Char import System.Random import City import Probability import CharacterSheet import BasicNames import FantasyName import FantasyProfession import FantasyRace import Alignment import StringHelpers data Hero = Hero { forename :: String , surname :: String , nickname :: String , sheet :: CharacterSheet , hometown :: City } deriving (Eq, Show, Read) -- generate random named hero genHero :: IO Hero genHero = do characterSheet <- genCharacterSheet --characterName <- genName characterSheet f <- genBasicName s <- genBasicName n <- pickFrom (nicknameGuesses characterSheet) city <- genCity return Hero { forename = f, surname = s, nickname = n, sheet = characterSheet, hometown = city } heroName (Hero {forename = f, surname = s, nickname = n}) = (capWord f ++ " " ++ capWord s ++ " the " ++ capWord n) characterBio hero = "\n\n " ++ capWord (forename hero) ++ " the " ++ humanizedRace (race (sheet hero)) ++ " and " ++ a ++ " works as " ++ j ++ " and is from " ++ cityDescription where cityDescription = describeCity (hometown hero) a = map toLower $ humanizedAlignment (alignment (sheet hero)) j = map toLower $ humanizedJob (job (sheet hero)) displayHero :: Hero -> String displayHero hero = hr ++ "\n " ++ n ++ bio ++ "\n\n" ++ description ++ "\n\n" where bio = characterBio hero description = characterDescription (sheet hero) n = heroName hero
jweissman/heroes
src/Hero.hs
mit
1,626
10
17
464
399
227
172
37
1
module BlocVoting.Bitcoin.Base58 where import qualified Data.ByteString.Base58 as B58 import qualified Network.Haskoin.Crypto as HCrypto (decodeBase58Check) encodeBase58 = B58.encodeBase58 B58.bitcoinAlphabet decodeBase58Check = HCrypto.decodeBase58Check
XertroV/blocvoting
src/BlocVoting/Bitcoin/Base58.hs
mit
259
0
6
25
49
32
17
5
1
-- | Author : John Allard -- | Date : Feb 19th 2016 -- | Class : CMPS 112 UCSC -- | I worked alone, no partners to list. -- | Homework #4 |-- {-# LANGUAGE FlexibleInstances, OverlappingInstances, UndecidableInstances #-} import Data.Char import Data.List import Data.Int import System.Random -- | 1. The following skeleton code includes the Gen typeclass for any test -- input that can be generated. Anything in the typeclass Random can be -- generated using randomIO. However, you still need to make Lists and -- Pairs (tuples with two elements) an instance of the Gen type class. -- The generated list should have a random length between 0 (empty) and 10 (inclusive). class (Show a) => Gen a where gen :: IO a instance (Show a, Random a) => Gen a where gen = randomIO instance (Gen a, Gen b) => Gen (a, b) where gen = do x <- gen y <- gen return (x, y) instance (Gen a) => Gen [a] where gen = do rlen <- gen :: IO Int8 let len = rlen `mod` 11 -- 0 to 10 baby mapM (\_ -> gen) [1..len] -- you don't want to know how many permutations of -- gen/IO code I went through before I found something -- that worked. -- | 2. As a next step, add the Testable typeclass which will be used to test predicates. -- These predicates are functions from an arbitary number of arguments to a boolean value. -- -- You have to complete the missing implementation of the test function, which will generate -- a random input and pass it to the function until the resulting boolean value indicates whether -- the test predicate holds or not. {-| This is my original answer to #2 for use with the quickCheck as described in #3 class Testable a where test :: a -> IO Bool instance Testable Bool where test b = return b instance (Gen a, Testable b) => Testable (a -> b) where test t = do n <- gen test (t n) |-} -- | This is the test code for the quickcheck for question #4 class Testable a where test :: String -> a -> IO (String, Bool) instance Testable Bool where test s b = do if b == True then return ("", True) else return (s, False) instance (Gen a, Testable b) => Testable (a -> b) where test s t = do n <- gen test (s ++ " " ++ show n) (t n) -- | 3. Finally, implement a quickCheck method. Given a number n and a Testable, it will -- perform up to n tests with random inputs, repeated calling test. Once a failing -- test was encountered, it will print an error and stop testing. {-| // commented out to not interfere with #4 quickCheck :: (Testable a) => Int -> a -> IO () quickCheck 0 b = do putStr "" quickCheck n t = do let m = (n-1) ret <- test t if ret then quickCheck m t else putStrLn "Tests Failed" |-} -- | 4. In order to improve the test output, quickCheck should also print a string -- representation of the counterexample. -- -- You may have to change the definition of test in order to return a string in addition -- to the boolean value. For curried, multi argument functions, the string will include -- all arguments in the right order. quickCheck :: (Testable a) => Int -> a -> IO () quickCheck 0 b = do putStr "" quickCheck n t = do let m = (n-1) (retstr, retbool) <- test "" t if retbool then quickCheck m t else putStrLn ("Failed :" ++ retstr) -- | 5. The following two sorting algorithms (insertion sort and quick sort) both have a bug isort :: [Int8] -> [Int8] isort [] = [] isort (x:xs) = insert (isort xs) where insert [] = [x] insert (h:t) | x > h = h:insert t | x <= h = h:x:t qsort :: [Int8] -> [Int8] qsort [] = [] qsort (x:xs) = qsort [a | a <- xs, a < x] ++ [x] ++ qsort [a | a <- xs, a > x] -- | Write a comprehensive test for sorting algorithms like qsort and isort which describes -- exactly the expected behavior. Using quickCheck with this test should give you a -- counterexample for both qsort and isort. testSort :: ([Int8] -> [Int8]) -> [Int8] -> Bool isSort [] = True isSort [x] = True isSort (x:xs) = (x <= head xs) && (isSort xs) testSort sort lst = do let res = sort lst (length res == length lst) && (isSort res) -- | counter example for qsort = [-109,-95,-73,-64,-53,-23,11,103,117] -- | counter example for isort = [25,-104,126,-127,-12,-71,-47,77,55,71] -- | 6. Fix the two sorting algorithms above -- | -- Woohoo I fixed both. Try the following -- | quickCheck 100 (testSort isortnew) -- | quickCheck 100 (testSort qsortnew) isortnew :: [Int8] -> [Int8] isortnew [] = [] isortnew (x:xs) = insert (isortnew xs) where insert [] = [x] insert (h:t) | x > h = h:insert t | x <= h = x:h:t qsortnew :: [Int8] -> [Int8] qsortnew [] = [] qsortnew (x:xs) = qsortnew [a | a <- xs, a < x] ++ [a | a<-xs, a==x] ++ [x] ++ qsortnew [a | a <- xs, a > x]
jhallard/WinterClasses16
CS112/hw/hw4/hw4.hs
mit
5,201
8
12
1,540
1,110
591
519
61
2
module XBattBar.Backend (getCharge, getPower, Power(..)) where data Power = AC | Battery deriving (Show) -- | retrieves battery charge getCharge :: IO Double getCharge = getChargeLinux -- | retrieves power status getPower :: IO Power getPower = getPowerLinux -- | get charge from ACPI on linux getChargeLinux :: IO Double getChargeLinux = do let path = "/sys/bus/acpi/drivers/battery/PNP0C0A:00/power_supply/BAT0/" fullS <- readFile $ path++"energy_full" nowS <- readFile $ path++"energy_now" let f = read fullS let n = read nowS return (n / f) -- | get power state from ACPI on linux getPowerLinux :: IO Power getPowerLinux = do let path = "/sys/bus/acpi/drivers/ac/ACPI0003:00/power_supply/AC/online" s <- readFile path return $ case (read s) of 0 -> Battery 1 -> AC
polachok/xbattbar
src/XBattBar/Backend.hs
mit
856
0
10
204
218
112
106
22
2
module Font (withFontTexture, drawText) where import Data.Word (Word8, Word32) import Data.Bits (shiftL, shiftR, (.&.)) import Data.Char (ord) import qualified Foreign.Marshal.Array (withArray) import qualified Data.Vector.Unboxed as VU import qualified Graphics.Rendering.OpenGL as GL import qualified Graphics.Rendering.OpenGL.GLU as GLU (build2DMipmaps) import Control.Exception import Control.Monad import GLHelpers import QuadRendering withFontTexture :: (GL.TextureObject -> IO a) -> IO a withFontTexture f = do traceOnGLError $ Just "withFontTexture begin" r <- bracket GL.genObjectName GL.deleteObjectName $ \tex -> do -- Font texture GL.textureBinding GL.Texture2D GL.$= Just tex setTextureFiltering GL.Texture2D TFMinOnly -- Convert font grid bitmap image from Word32 list into byte array let fontImgArray = VU.fromListN (fontGridWdh * fontGridHgt * fontCharWdh * fontCharHgt `div` 8) . concatMap (\x -> map (extractByte x) [0..3]) $ miscFixed6x12Data :: VU.Vector Word8 -- Extract bits (reversed in byte), store transparent / opaque pixels in square texture let fontTex = [toRGBA $ texel x y | y <- [0..fontTexWdh - 1], x <- [0..fontTexWdh - 1]] where texel x y = (srcLookup x y .&. (1 `shiftL` (7 - (srcIdx x y `mod` 8)))) srcLookup x y | (x < fontImgWdh && y < fontImgHgt) = fontImgArray VU.! (srcIdx x y `div` 8) | otherwise = 0 srcIdx x y = x + y * fontImgWdh toRGBA a = case a of 0 -> 0x0FFFFFF; _ -> 0xFFFFFFFF :: Word32 Foreign.Marshal.Array.withArray fontTex $ \ptr -> -- TODO: Just use GPU MIP-map generation GLU.build2DMipmaps GL.Texture2D GL.RGBA' (fromIntegral fontTexWdh) (fromIntegral fontTexWdh) (GL.PixelData GL.RGBA GL.UnsignedByte ptr) traceOnGLError $ Just "withFontTexture begin inner" f tex traceOnGLError $ Just "withFontTexture after cleanup" return r drawText :: GL.TextureObject -> QuadRenderBuffer -> Int -> Int -> Word32 -> String -> IO () drawText tex qb x y color str = do let charAndPos = filter (\(_, _, c) -> c /= '\n') . scanl (\(x', y', _) a -> if a == '\n' then ((-1) , y' - 1, a) else (x' + 1, y' , a) ) ((-1), 0, '\n') $ str forM_ charAndPos $ \(xc, yc, chr) -> let xoffs = xc * fontCharWdh yoffs = yc * (fontCharHgt - 1) idx = ord chr tx = (idx `mod` fontGridWdh); ty = fontGridHgt - ((idx - (idx `mod` fontGridWdh)) `div` fontGridWdh + 1); ftx = fromIntegral (tx * fontCharWdh) / fromIntegral fontTexWdh; fty = fromIntegral (ty * fontCharHgt) / fromIntegral fontTexWdh; fontCharWdhTex = fromIntegral fontCharWdh / fromIntegral fontTexWdh fontCharHgtTex = fromIntegral fontCharHgt / fromIntegral fontTexWdh channel i = fromIntegral (extractByte color i) / 255.0 in drawQuad qb (fromIntegral $ x + xoffs) (fromIntegral $ y + yoffs) (fromIntegral $ x + xoffs + fontCharWdh) (fromIntegral $ y + yoffs + fontCharHgt) 1 (FCSolid $ RGBA (channel 0) (channel 1) (channel 2) 1) TRSrcAlpha (Just tex) $ QuadUV ftx fty (ftx + fontCharWdhTex) (fty + fontCharHgtTex) extractByte :: Word32 -> Int -> Word8 extractByte x i = fromIntegral $ (x .&. (0xFF `shiftL` (i * 8))) `shiftR` (i * 8) -- Bit packed font data for a 16 x 16 character grid of 6 x 12 pixel characters fontGridWdh, fontGridHgt, fontImgWdh, fontImgHgt, fontCharWdh, fontCharHgt, fontTexWdh :: Int fontGridWdh = 16 fontGridHgt = 16 fontImgWdh = 96 fontImgHgt = 192 fontCharWdh = 6 fontCharHgt = 12 fontTexWdh = 256 {-# NOINLINE miscFixed6x12Data #-} miscFixed6x12Data :: [Word32] miscFixed6x12Data = [ 0x00000000, 0x00000000, 0x20080200, 0x00000000, 0x00000000, 0x10080100, 0x711c2772, 0xc7f100c7 , 0x088f701c, 0x8aa2288a, 0x28ca8828, 0x944889a2, 0x8aa2288a, 0x28aa8028, 0xa2288aa2, 0x8aa2288b , 0x289abe28, 0xa2288aa2, 0x711cc77a, 0x287a00c7, 0x222f8aa2, 0x00000008, 0x00000800, 0x00080000 , 0x5208c252, 0x820000c5, 0x14885014, 0x2104a421, 0x010100a0, 0x00400008, 0x00000050, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00001800, 0x00000000, 0x00000000 , 0x00000400, 0x00000000, 0x799ee779, 0xc7719ce7, 0x1cc7711c, 0x8aa2288a, 0x0882222a, 0x08822020 , 0x799ee779, 0xcff320e7, 0x0882203c, 0x08822008, 0x288aa222, 0x088220a2, 0x711cc771, 0xc7711cc7 , 0x1886611c, 0x00000000, 0x00000080, 0x00000000, 0x512c8520, 0x85200040, 0x14852014, 0x001a4240 , 0x42400080, 0x00424000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000, 0x00000000, 0x711c2772, 0xc77100c7 , 0x2c84701c, 0x8aa2284a, 0x28caa228, 0x228788a2, 0x8aa2684a, 0x28aa9428, 0xa48488a2, 0x8aa2a8ea , 0x28aa8828, 0xa88488a2, 0x8aa2284b, 0x28aa9428, 0xa44489a2, 0x8aa2284a, 0x289aa228, 0x22278aa2 , 0x711c2772, 0x287200c7, 0x1c248aa2, 0x00000000, 0x00080000, 0x00000000, 0x5208c202, 0x820000c5 , 0x00805014, 0x2104a401, 0x010100a0, 0x00400008, 0x00000000, 0x00001800, 0x00000000, 0x00000000 , 0x00000400, 0x00000000, 0x8aa2288a, 0xeffb9c2b, 0x1cc771be, 0x8aa2288a, 0x0882222a, 0x08822020 , 0x8aa2288a, 0x0882202a, 0x08822020, 0xfbbeeffb, 0xcff320ef, 0x0882203c, 0x8aa2288a, 0x0882202a , 0x08822020, 0x8aa2288a, 0x0882222a, 0x08822020, 0x711cc771, 0xeffb9cc7, 0x1cc771be, 0x00000000 , 0x00000080, 0x00000000, 0x512c8520, 0x85200040, 0x14852014, 0x001a4240, 0x42400080, 0x00424000 , 0x02000000, 0x00600000, 0x00000000, 0x02000000, 0x00100000, 0x00000000, 0x0300e003, 0x000080a2 , 0x1ce11028, 0x02000000, 0x00008062, 0x22811014, 0x02008000, 0x00008022, 0x9047780a, 0x02008000 , 0x00008c26, 0x08255014, 0x0200e003, 0x00008c2e, 0x08a33028, 0x40188730, 0xc701800e, 0x004d5100 , 0x20048248, 0x8000800e, 0x08024100, 0x10080148, 0x82008007, 0x00044100, 0x00040530, 0x85010000 , 0x0002c300, 0x00180200, 0x82000000, 0x000c4100, 0x00000000, 0x00000000, 0x00000000, 0x00000200 , 0x00000000, 0x00000000, 0xa82c8700, 0xe0011c82, 0x8007000a, 0x50928a00, 0x10020282, 0x40080814 , 0x8b108a00, 0x50020ce2, 0x400a0828, 0x50b88a00, 0x90021280, 0x40caf914, 0xab108700, 0x570212e2 , 0x400b000a, 0x01120200, 0x10020c42, 0x40080000, 0x020c8000, 0xe3011022, 0x80070000, 0x00000000 , 0x05500e00, 0x3e000000, 0x00000000, 0x03000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00002080, 0x00020000, 0x00000000, 0x00002080, 0x00010000, 0x00002104, 0x193ce8f1, 0x8f8814a2 , 0x00802088, 0x2202288a, 0x44512a65, 0x00802008, 0x221c288a, 0x2222aa28, 0x00892008, 0x22a02c8a , 0x2152a228, 0x804a2010, 0xfa1eebf1, 0x2f8aa228, 0x80842088, 0x20000000, 0x00000000, 0x00802008 , 0x20000000, 0x00000000, 0x00802008, 0x00000000, 0x00000000, 0x00002104, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x03001c00, 0x00000000, 0x00000000 , 0x04000200, 0x00000080, 0x791cef01, 0xc0891ec4, 0x9ca872a2, 0x8aa22802, 0x80882204, 0xa2a822a4 , 0x8ba0e801, 0x808822c4, 0xa2a822b8, 0x8aa22800, 0x8088222e, 0xa2ac22a4, 0x791ccf01, 0x81f11cc4 , 0x1c4b23a2, 0x08000810, 0x00808004, 0x00002020, 0x08000820, 0x80800003, 0x000060a0, 0x00000040 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x3e000000, 0x00000000, 0x00000000, 0x00c0011c, 0x219ca881, 0x8f8814c2 , 0x00400890, 0x22224982, 0x88882a25, 0x00401010, 0x2202aa82, 0x84502a25, 0x00401010, 0x221c2ff2 , 0x8220a228, 0x00402010, 0x22a0288a, 0x4151a228, 0x00404010, 0x22a2288a, 0x208aa228, 0x80484090 , 0xfa1ccff1, 0x2f8aa228, 0x00458090, 0x00000000, 0x00000000, 0x00c2011c, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0xf31c2f72, 0xc6891ce8, 0x9c28fa22, 0x4aa22482, 0x89882208, 0xa2288224 , 0x4aa024ba, 0x81882608, 0xa2298228, 0x4b20e7ab, 0x81f820cf, 0xa22a8230, 0x4aa024ba, 0x81882008 , 0xa2ac8228, 0x4aa2248a, 0x81882208, 0xa2688324, 0xf31ccf71, 0xc3899cef, 0x9c2882a2, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000030, 0x119ccf31, 0x867108c7 , 0x08000018, 0x12228448, 0x46888828, 0x00041018, 0xf8028248, 0x20888828, 0x08e22300, 0x900c8148 , 0xe671042f, 0x08014018, 0x53848048, 0x268a04c8, 0x04e22318, 0x32828849, 0x208a0204, 0x22041000 , 0x133e8730, 0xc0713ee3, 0x1c000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x20000000 , 0x00110000, 0x0000c000, 0x72148000, 0x82208066, 0x20066000, 0xaa3e0000, 0x8a200069, 0x10066088 , 0x29148000, 0x4740800a, 0x10000008, 0x70148000, 0x42400084, 0x08e0033e, 0xa03e8000, 0x4740004a , 0x04000008, 0xab148500, 0x8a20082a, 0x04000088, 0x73008500, 0x82200824, 0x02000000, 0x20000500 , 0x00110800, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 , 0xfc000000, 0x80200082, 0x00000000, 0x00000000, 0x80200082, 0x00000000, 0x00000000, 0x8f200082 , 0x000b51be, 0x003f0000, 0x80200082, 0x80045100, 0x00000000, 0x81200082, 0x00e453b0, 0x00c00f00 , 0x86fc3ffe, 0x0c8e500c, 0x00000000, 0x88000882, 0x0ce4fb02, 0x00000000, 0x86000882, 0x8044000c , 0x0000f003, 0x81000882, 0x004300b0, 0x00000000, 0x80000882, 0x00000000, 0x00000000, 0x80000882 , 0x00000000, 0x000000fc, 0x80000882, 0x00000000, 0x00400500, 0x00000000, 0x08002000, 0x00800a00 , 0x00000000, 0x08002000, 0x204405a8, 0x00f800a2, 0x08002000, 0x20848a00, 0x000000a3, 0x08002000 , 0x3044c589, 0x002000c2, 0x08002000, 0xa084ea03, 0x002080a3, 0xff03e038, 0xb96ec589, 0x00f800c0 , 0x08020008, 0xc2a88a00, 0x00200c0e, 0x08020008, 0x827805a8, 0x00201208, 0x08020008, 0xe2a80a00 , 0x00001208, 0x08020008, 0x01680500, 0x00000c88, 0x08020008, 0x00800a00, 0x00000000, 0x08020008 ]
blitzcode/rust-exp
hs-src/Font.hs
mit
11,624
0
25
2,426
2,991
1,840
1,151
154
2
{-# LANGUAGE DoAndIfThenElse , FlexibleContexts , OverloadedStrings , RecordWildCards #-} module CreateSendAPI.V3.List.Webhooks where import Control.Applicative ((<$>), (<*>)) import Control.Monad.IO.Class (MonadIO) import Data.Aeson (FromJSON (parseJSON), Value (Object), (.:), (.=), encode, fromJSON, object) import Data.Aeson.Parser (json) import Data.Aeson.Types (Result (..)) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Internal as B import qualified Data.ByteString.Lazy.Internal as LBS import Data.Conduit (($$+-)) import qualified Data.Conduit as C import Data.Conduit.Attoparsec (sinkParser) import qualified Data.Text as T import qualified Data.Text.Encoding as DTE import qualified Data.Vector as V import Network.HTTP.Conduit (Request, RequestBody (RequestBodyLBS), Response (..), applyBasicAuth, http, method, parseUrl, path, requestBody, withManager) import CreateSendAPI.V3.Session (ListRequest (..)) import CreateSendAPI.V3.Util (httpGetByteString) -- -- Data Types: -- data WebhookEvents = WebhookEvents { webhookEvtSubscribe :: Bool , webhookEvtDeactivate :: Bool , webhookEvtUpdate :: Bool } deriving (Show, Eq) data WebhookPayloadFormat = WebhookFmtJSON | WebhookFmtXML deriving (Show, Eq) data WebhookDetails = WebhookDetails { webhookID :: T.Text , webhookEvents :: WebhookEvents , webhookURL :: T.Text , webhookStatus :: T.Text , webhookPayloadFormat :: WebhookPayloadFormat } deriving (Show, Eq) -- -- Data Type Instances, and Utility Functions: -- webhookEventsToStrList :: WebhookEvents -> [String] webhookEventsToStrList (WebhookEvents {..}) = l3 where l1 = case webhookEvtUpdate of True -> ["Update"] _ -> [] l2 = case webhookEvtDeactivate of True -> "Deactivate":l1 _ -> l1 l3 = case webhookEvtSubscribe of True -> "Subscribe":l2 _ -> l2 webhookPayloadFormatToStr :: WebhookPayloadFormat -> String webhookPayloadFormatToStr WebhookFmtJSON = "json" webhookPayloadFormatToStr WebhookFmtXML = "xml" instance FromJSON WebhookEvents where parseJSON j = do o <- parseJSON j res <- V.foldM procsEvtObj (WebhookEvents False False False) o return res where procsEvtObj accum o = do evtName <- parseJSON o case evtName of "Subscribe" -> return $ accum { webhookEvtSubscribe = True } "Deactivate" -> return $ accum { webhookEvtDeactivate = True } "Update" -> return $ accum { webhookEvtUpdate = True } _ -> fail $ "Unrecognized event name: " ++ evtName instance FromJSON WebhookPayloadFormat where parseJSON j = do o <- parseJSON j case (o :: String) of "Json" -> return WebhookFmtJSON "Xml" -> return WebhookFmtXML _ -> fail $ "Unrecognized webhook payload format: " ++ (show o) instance FromJSON WebhookDetails where parseJSON (Object v) = WebhookDetails <$> v .: "WebhookID" <*> v .: "Events" <*> v .: "Url" <*> v .: "Status" <*> v .: "PayloadFormat" parseJSON _ = fail "Expected a JSON object when parsing WebhookDetails." -- -- HTTP Methods: -- getWebhooksJSON (ListRequest listReq) = withManager $ \manager -> do let req = listReq { path = (path listReq) `BS.append` "/webhooks.json" , method = "GET" } res <- http req manager responseBody res $$+- sinkParser json getWebhooks listReq = do v <- getWebhooksJSON listReq case fromJSON v of Error msg -> fail msg Success res -> return (res :: V.Vector WebhookDetails) createWebhook (ListRequest req) webhookEvents webhookURL payloadFormat = httpGetByteString $ req { path = (path req) `BS.append` "/webhooks.json" , method = "POST" , requestBody = RequestBodyLBS $ encode $ object [ "Events" .= webhookEventsToStrList webhookEvents, "Url" .= webhookURL, "PayloadFormat" .= webhookPayloadFormatToStr payloadFormat] } activateWebhook (ListRequest req) webhookID = httpGetByteString $ req { path = (path req) `BS.append` "/webhooks/" `BS.append` webhookID `BS.append` "/activate.json" , method = "PUT" } deactivateWebhook (ListRequest req) webhookID = httpGetByteString $ req { path = (path req) `BS.append` "/webhooks/" `BS.append` webhookID `BS.append` "/deactivate.json" , method = "PUT" } deleteWebhook (ListRequest req) webhookID = httpGetByteString $ req { path = (path req) `BS.append` "/webhooks/" `BS.append` webhookID `BS.append` ".json" , method = "DELETE" } testWebhook (ListRequest req) webhookID = httpGetByteString $ req { path = (path req) `BS.append` "/webhooks/" `BS.append` webhookID `BS.append` "/test.json" , method = "GET" }
pavpen/createsend-haskell
src/CreateSendAPI/V3/List/Webhooks.hs
gpl-2.0
4,893
101
18
1,095
1,403
801
602
115
4
main = do return () return "Hahaha" line <- getLine return "Blah blah blah" return 4 putStrLn line
softwaremechanic/Miscellaneous
Haskell/6.hs
gpl-2.0
111
0
8
30
45
17
28
7
1
{-# LANGUAGE FlexibleContexts, GeneralizedNewtypeDeriving #-} -- Haskell Music Player, client for the MPD (Music Player Daemon) -- Copyright (C) 2011 Ivan Vitjuk <[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 3 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, see <http://www.gnu.org/licenses/>. module HMP ( HMP, execHMP, getMpd ) where import Control.Monad import Control.Monad.Reader import Control.Monad.State import Network.MPD newtype HMP a = HMP { runHMP :: (StateT HMPState (ReaderT HMPConfig IO)) a } deriving (Functor, Monad, MonadIO) data HMPState = HMPState { dummy :: String -- this is for future use } data HMPConfig = HMPConfig { mpd :: MPDPersistent } execHMP :: Host -> Port -> Password -> HMP () -> IO () execHMP host port pw action = do Right mpd <- makeMPDPersistent host port pw runReaderT (evalStateT (runHMP action) (HMPState "")) (HMPConfig mpd) return () getMpd :: HMP MPDPersistent getMpd = HMP $ do cfg <- ask return (mpd cfg)
ivitjuk/Haskell-Music-Player
src/HMP.hs
gpl-3.0
1,599
0
11
371
269
148
121
25
1
module Interface.Peer.Behavior where import Interface.Peer.Handler import HTorrentPrelude import Peer.State import qualified Graphics.UI.Threepenny as UI import Graphics.UI.Threepenny.Core import Network.Socket import Reactive.Threepenny data PeerStateB = PeerStateB { _interestedB :: Behavior Bool, _chokedB :: Behavior Bool } $(makeLenses ''PeerStateB) data PeerBehavior = PeerBehavior { _peerAddress :: SockAddr, _localStateB :: PeerStateB, _remoteStateB :: PeerStateB } $(makeLenses ''PeerBehavior) mkPeersBehavior :: HashMap ByteString PeerState -> IO (HashMap ByteString PeerBehavior, HashMap ByteString PeerHandlerEnv) mkPeersBehavior ps = do peerBH <- mapMOf traverse mkPeerBehavior ps return (fst <$> peerBH, snd <$> peerBH) mkPeerBehavior :: PeerState -> IO (PeerBehavior, PeerHandlerEnv) mkPeerBehavior s = do chan <- atomically (dupTChan (s ^. events)) (localB, localH) <- mkPeerStateB (s ^. localState) (remoteB, remoteH) <- mkPeerStateB (s ^. remoteState) let peerB = PeerBehavior { _peerAddress = s ^. address, _localStateB = localB, _remoteStateB = remoteB } let peerH = PeerHandler { _localStateH = localH, _remoteStateH = remoteH } let peerHandlerEnv = PeerHandlerEnv { _peerHandler = peerH, _peerChan = chan } return (peerB, peerHandlerEnv) mkPeerStateB :: ConnectionState -> IO (PeerStateB, PeerStateH) mkPeerStateB connState = do interestedStart <- readTVarIO (connState ^. interested) (interestedEvent, interestedHandler) <- newEvent interestedBehavior <- stepper interestedStart interestedEvent chokedStart <- readTVarIO (connState ^. choked) (chokedEvent, chokedHandler) <- newEvent chokedBehavior <- stepper chokedStart chokedEvent let peerStateBehavior = PeerStateB { _interestedB = interestedBehavior, _chokedB = chokedBehavior } let peerStateHandler = PeerStateH { _interestedH = interestedHandler, _chokedH = chokedHandler } return (peerStateBehavior, peerStateHandler)
ian-mi/hTorrent
Interface/Peer/Behavior.hs
gpl-3.0
2,110
0
12
438
554
296
258
-1
-1
{-# OPTIONS_GHC -XNoMonomorphismRestriction #-} module Strategies where import Pattern import Dirt import Data.Ratio import Control.Applicative echo n p = combine [p, n ~> p] double f p = combine [p, f p] -- every 4 (smash 4 [1, 2, 3]) $ sound "[odx sn/2 [~ odx] sn/3, [~ hh]*4]" smash n xs p = cat $ map (\n -> slow n p') xs where p' = striate n p brak = every 2 (((1%4) <~) . (\x -> cat [x, silence])) -- samples "jvbass [~ latibro] [jvbass [latibro jvbass]]" ((1%2) <~ slow 6 "[1 6 8 7 3]") samples p p' = sample <$> p <*> p' spread f xs p = cat $ map (\x -> f x p) xs spread' :: (a -> Sequence b -> Sequence c) -> Sequence a -> Sequence b -> Sequence c spread' f timepat pat = Sequence $ \r -> concatMap (\(r', x) -> (range (f x pat) r')) (rs r) where rs r = mapFsts (mapSnd Just) $ range (filterOffsets timepat) r
yaxu/smooth
Strategies.hs
gpl-3.0
834
0
13
186
350
183
167
17
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.ObjectAccessControls.Delete -- 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) -- -- Permanently deletes the ACL entry for the specified entity on the -- specified object. -- -- /See:/ <https://developers.google.com/storage/docs/json_api/ Cloud Storage JSON API Reference> for @storage.objectAccessControls.delete@. module Network.Google.Resource.Storage.ObjectAccessControls.Delete ( -- * REST Resource ObjectAccessControlsDeleteResource -- * Creating a Request , objectAccessControlsDelete , ObjectAccessControlsDelete -- * Request Lenses , oacdBucket , oacdObject , oacdEntity , oacdGeneration ) where import Network.Google.Prelude import Network.Google.Storage.Types -- | A resource alias for @storage.objectAccessControls.delete@ method which the -- 'ObjectAccessControlsDelete' request conforms to. type ObjectAccessControlsDeleteResource = "storage" :> "v1" :> "b" :> Capture "bucket" Text :> "o" :> Capture "object" Text :> "acl" :> Capture "entity" Text :> QueryParam "generation" (Textual Int64) :> QueryParam "alt" AltJSON :> Delete '[JSON] () -- | Permanently deletes the ACL entry for the specified entity on the -- specified object. -- -- /See:/ 'objectAccessControlsDelete' smart constructor. data ObjectAccessControlsDelete = ObjectAccessControlsDelete' { _oacdBucket :: !Text , _oacdObject :: !Text , _oacdEntity :: !Text , _oacdGeneration :: !(Maybe (Textual Int64)) } deriving (Eq,Show,Data,Typeable,Generic) -- | Creates a value of 'ObjectAccessControlsDelete' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'oacdBucket' -- -- * 'oacdObject' -- -- * 'oacdEntity' -- -- * 'oacdGeneration' objectAccessControlsDelete :: Text -- ^ 'oacdBucket' -> Text -- ^ 'oacdObject' -> Text -- ^ 'oacdEntity' -> ObjectAccessControlsDelete objectAccessControlsDelete pOacdBucket_ pOacdObject_ pOacdEntity_ = ObjectAccessControlsDelete' { _oacdBucket = pOacdBucket_ , _oacdObject = pOacdObject_ , _oacdEntity = pOacdEntity_ , _oacdGeneration = Nothing } -- | Name of a bucket. oacdBucket :: Lens' ObjectAccessControlsDelete Text oacdBucket = lens _oacdBucket (\ s a -> s{_oacdBucket = a}) -- | Name of the object. For information about how to URL encode object names -- to be path safe, see Encoding URI Path Parts. oacdObject :: Lens' ObjectAccessControlsDelete Text oacdObject = lens _oacdObject (\ s a -> s{_oacdObject = a}) -- | The entity holding the permission. Can be user-userId, -- user-emailAddress, group-groupId, group-emailAddress, allUsers, or -- allAuthenticatedUsers. oacdEntity :: Lens' ObjectAccessControlsDelete Text oacdEntity = lens _oacdEntity (\ s a -> s{_oacdEntity = a}) -- | If present, selects a specific revision of this object (as opposed to -- the latest version, the default). oacdGeneration :: Lens' ObjectAccessControlsDelete (Maybe Int64) oacdGeneration = lens _oacdGeneration (\ s a -> s{_oacdGeneration = a}) . mapping _Coerce instance GoogleRequest ObjectAccessControlsDelete where type Rs ObjectAccessControlsDelete = () type Scopes ObjectAccessControlsDelete = '["https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/devstorage.full_control"] requestClient ObjectAccessControlsDelete'{..} = go _oacdBucket _oacdObject _oacdEntity _oacdGeneration (Just AltJSON) storageService where go = buildClient (Proxy :: Proxy ObjectAccessControlsDeleteResource) mempty
rueshyna/gogol
gogol-storage/gen/Network/Google/Resource/Storage/ObjectAccessControls/Delete.hs
mpl-2.0
4,611
0
17
1,058
572
338
234
87
1
{-# LANGUAGE OverloadedStrings #-} module CountdownGame.Database ( createPool , initializeDatabase , addPlayer , updatePlayer , getPlayer , checkPlayer , getPlayers , getPlayersMap , insertChallange , setPlayerScore , getHighscores ) where import Control.Monad (forM) import Control.Monad.Logger (runNoLoggingT) import Control.Monad.Trans.Resource (runResourceT) import Data.Function (on) import Data.Int (Int64) import Data.Text (Text) import Data.Time (UTCTime) import Data.List (groupBy, sortBy, foldl') import qualified Data.Map.Strict as M import Database.Persist import Database.Persist.Sql (ConnectionPool, SqlPersistT, insert, fromSqlKey, toSqlKey, runSqlPool, rawSql) import Database.Persist.Sqlite (runSqlite, createSqlitePool, runMigration) import Database.Persist.TH import CountdownGame.Database.Models import qualified Countdown.Game as G import qualified Countdown.Game.Players as P createPool :: Int -> IO ConnectionPool createPool n = runResourceT . runNoLoggingT $ createSqlitePool connectionString n runInPool :: ConnectionPool -> SqlPersistT IO a -> IO a runInPool = flip runSqlPool connectionString :: Text connectionString = "countdown.db" initializeDatabase :: ConnectionPool -> IO () initializeDatabase pool = runInPool pool $ do runMigration migrateAll addPlayer :: Text -> ConnectionPool -> IO P.Player addPlayer nick pool = runInPool pool $ addPlayer' nick getPlayer :: P.PlayerId -> ConnectionPool -> IO (Maybe P.Player) getPlayer id pool = runInPool pool $ getPlayer' id getPlayer' id = do pl <- get (toSqlKey $ fromIntegral id) return $ case pl of Nothing -> Nothing Just p -> Just $ P.Player (playerNickname p) id checkPlayer :: P.PlayerId -> Text -> ConnectionPool -> IO (Maybe P.Player) checkPlayer id nick pool = runInPool pool $ do pl <- get (toSqlKey $ fromIntegral id) return $ case pl of Nothing -> Nothing Just p -> let nick' = playerNickname p in if nick' == nick then Just $ P.Player (playerNickname p) id else Nothing updatePlayer :: P.PlayerId -> Text -> ConnectionPool -> IO P.Player updatePlayer id nick pool = runInPool pool $ do let pId = toSqlKey $ fromIntegral id pl <- get pId case pl of Nothing -> addPlayer' nick Just p -> do replace pId $ Player nick return $ P.Player nick id getPlayersMap :: ConnectionPool -> IO P.PlayersMap getPlayersMap pool = do ps <- map (\ p -> (P.playerId p, p)) <$> getPlayers pool return $ M.fromList ps getPlayers :: ConnectionPool -> IO [P.Player] getPlayers pool = runInPool pool $ do pls <- selectList [] [] return $ map fromEntity pls where fromEntity entity = P.Player (playerNickname $ entityVal entity) (fromIntegral . fromSqlKey $ entityKey entity) addPlayer' nick = do key <- insert $ Player nick let id = fromIntegral $ fromSqlKey key return $ P.Player nick id insertChallange :: G.Challange -> IO Int64 insertChallange ch = runSqlite connectionString $ do key <- insert $ Challange (G.targetNumber ch) (G.availableNumbers ch) return $ fromSqlKey key setPlayerScore :: Int64 -> P.PlayerId -> Int -> IO () setPlayerScore chId pId score = runSqlite connectionString $ do let id = toSqlKey chId pid = toSqlKey $ fromIntegral pId sc <- getBy $ Index pid id case sc of Nothing -> insert_ $ Score score pid id Just e -> update (entityKey e) [ ScoreScore =. score ] getScores = do pls <- selectList [] [Asc ScorePlayer] return $ map fromEntity pls where fromEntity entity = ((fromIntegral . fromSqlKey . scorePlayer $ entityVal entity), (scoreScore $ entityVal entity)) getHighscores :: ConnectionPool -> IO [(P.Player, Int)] getHighscores pool = runInPool pool $ do grps <- groupBy ((==) `on` fst) <$> getScores let scrs = map (foldl' (\ (_,sc) (pid,c) -> (pid, sc+c)) (0,0)) grps srts = sortBy (compare `on` (negate . snd)) scrs forM srts (\ (pid, scs) -> do (Just p) <- getPlayer' pid return (p, scs))
CarstenKoenig/DOS2015
CountdownGame/src/web/CountdownGame/Database.hs
unlicense
4,113
0
18
896
1,449
738
711
104
3
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Bantam.Service.View.Fight ( fightView , matchesView , lemmaView , lemmaReadView , reviewView ) where import Bantam.Service.Data import Bantam.Service.Data.Fight import Bantam.Service.Path import P import Text.Blaze.Html (Html, toHtml, (!)) import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as HA fightView :: FightId -> Matches -> [LemmaId] -> [LemmaId] -> Html fightView fid m lemmas inbox = H.main $ do H.a ! HA.class_ "btn btn-link pull-right" ! HA.href (H.textValue $ encodedPathText lemmasPath fid) $ "Create" matchesTable fid m H.h1 "Lemmas" for_ lemmas $ \lid -> H.div ! HA.class_ "form-group" $ H.a ! HA.class_ "btn btn-primary" ! HA.href (H.textValue $ encodedPathText lemmaPath (fid, lid)) $ toHtml (renderLemmaId lid) when (not . null $ inbox) $ do H.h2 "Inbox" for_ inbox $ \lid -> H.div ! HA.class_ "form-group" $ H.a ! HA.class_ "btn btn-primary" ! HA.href (H.textValue $ encodedPathText reviewPath (fid, lid)) $ toHtml (renderLemmaId lid) matchesView :: FightId -> Matches -> Html matchesView fid m = H.main $ matchesTable fid m matchesTable :: FightId -> Matches -> Html matchesTable fid ms = case matchesReady ms of [] -> mempty ms' -> do H.h1 "Matches" H.table ! HA.style "width: 100%;" $ do H.tr $ do H.th "Player 1" H.th "Player 2" H.th "Draws" H.th "Remaining" H.th "Current" for_ ms' $ \m -> H.tr $ do let rl l = H.a ! HA.href (H.textValue $ encodedPathText lemmaPath (fid, l)) $ (toHtml . mconcat $ [renderLemmaId $ l, " "]) rp r h = mconcat [ toHtml $ renderEmail h , " (" , mconcat . with (matchGames m) $ \(Game l r') -> if r == r' then rl l else "" , ")" ] H.td $ rp Winner1 (matchPlayer1 m) H.td $ rp Winner2 (matchPlayer2 m) H.td . mconcat . with (matchGames m) $ \(Game l r) -> case r of Draw -> rl l _ -> "" -- Don't link to the lemmas, they're not public yet H.td . toHtml . renderIntegral . length $ matchUpcoming m H.td $ case matchCurrent m of Nothing -> "" Just c -> rl c lemmaView :: FightId -> Maybe (LemmaId, Lemma) -> Html lemmaView fid l = H.main $ do H.h1 "Lemma" H.form ! HA.action (H.textValue $ maybe (encodedPathText lemmasPath fid) (encodedPathText lemmaPath . (,) fid . fst) l) ! HA.method "post" $ do H.div ! HA.class_ "form-group" $ do H.label ! HA.for "lemma" $ "Lemma" H.textarea ! HA.class_ "form-control lemma" ! HA.name "lemma" $ maybe (pure ()) (toHtml . renderLemma . snd) l H.div ! HA.class_ "form-group" $ H.button ! HA.class_ "btn btn-primary" ! HA.type_ "submit" $ "Save" lemmaReadView :: Lemma -> Html lemmaReadView l = H.main $ do H.h1 "Lemma" H.label ! HA.for "lemma" $ "Lemma" H.textarea ! HA.class_ "form-control lemma" ! HA.name "lemma" ! HA.readonly "true" $ toHtml . renderLemma $ l reviewView :: FightId -> LemmaId -> Lemma -> Html reviewView fid lid lemma = H.main $ do H.h1 "Lemma" H.form ! HA.action (H.textValue $ encodedPathText reviewPath (fid, lid)) ! HA.method "post" $ do H.div ! HA.class_ "form-group" $ do H.label ! HA.for "lemma" $ "Lemma" H.textarea ! HA.class_ "form-control lemma" ! HA.name "lemma" ! HA.readonly "true" $ toHtml . renderLemma $ lemma H.div ! HA.class_ "form-group" $ do H.label ! HA.for "lemma" $ "Comment" H.input ! HA.class_ "form-control" ! HA.name "review" H.div ! HA.class_ "form-group" $ H.button ! HA.class_ "btn btn-primary" ! HA.type_ "submit" $ "Review"
charleso/bantam
bantam-service/src/Bantam/Service/View/Fight.hs
unlicense
4,502
0
27
1,687
1,474
717
757
140
5
import Data.List f x@([d,v]:_) = sum $ g $ sortBy s x where s [a0,a1] [b0,b1] = let c0 = compare a0 b0 c1 = compare b1 a1 in if c0 /= EQ then c0 else c1 g [] = [] g ([d,v]:x) = let r = dropWhile (\ [d',v'] -> d == d' ) x in v:(g r) ans ([0,0]:_) = [] ans ([n,m]:x) = let d = take n x r = drop n x a = f d in a:(ans r) main = do c <- getContents let i = map (map read) $ map words $ lines c :: [[Int]] o = ans i mapM_ print o
a143753/AOJ
2823.hs
apache-2.0
542
1
14
228
347
176
171
22
3
{-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE TypeFamilies #-} module TypeFam where import Data.Kind (Type) import GHC.TypeNats (Nat) -- - @Foo defines/binding FamFoo -- - @n defines/binding _ -- - @Nat ref _ -- - @Type ref _ type family Foo (n :: Nat) :: Type -- It'd be nice to have the following setup, mirroring C++ template -- specialization: -- -- * @Foo defines/binding FooFam -- * FooFam.type abs -- type family Foo a (n :: Nat) :: Type -- -- * @Foo defines/binding FooInt4 -- * FooInt4 specializes AppFooInt4 -- * AppFooInt4.node/kind tapp -- * AppFooInt4 param.0 FooFam -- * AppFooInt4 param.1 Four -- * Four.node/kind constant -- * Four.text 4 -- type instance Foo Int 4 = Bool -- -- * @Foo ref FooInt4 -- type F'oo4 = Foo Int 4 -- -- * @Foo defines/binding Foo_5 -- type instance Foo a 5 = a -- -- * @Foo ref FooString5 -- * @String ref StringTy -- type F'oo5 = Foo String 5 -- -- * FooString5 instantiates AppFoo_5String -- * AppFoo_5String param.0 Foo_5 -- * AppFoo_5String param.1 StringTy -- -- * FooString5 specializes AppFooString5 -- * AppFooString5 param.0 FooFam -- * AppFooString5 param.1 StringTy -- * AppFooString5 param.2 _ -- Instead we have that instance declarations reference the family, for now. -- - @Foo ref FamFoo type instance Foo 4 = Int -- - @Foo ref FamFoo type F'oo4 = Foo 4
google/haskell-indexer
kythe-verification/testdata/basic/TypeFam.hs
apache-2.0
1,346
0
6
246
102
80
22
9
0
-- | -- Module : Main -- Copyright : (c) 2011 Kevin Cantu -- -- License : BSD3 -- Maintainer : Kevin Cantu <[email protected]> -- Stability : experimental -- -- A program to clear out old Twitter favorites module Main (main) where import Control.Monad (when) import Data.Time.Clock (addUTCTime, getCurrentTime, NominalDiffTime(), UTCTime()) import Data.Time.LocalTime (getCurrentTimeZone, localTimeToUTC) import Data.Time.Parse (strptime) import Network.OAuth.Consumer (Token()) import System.Environment (getArgs, getProgName) import System.Exit (exitWith, ExitCode(ExitSuccess)) import System.IO (stderr, hPutStrLn) import System.Console.GetOpt (getOpt, usageInfo, OptDescr(Option), ArgDescr(ReqArg, NoArg), ArgOrder(Permute)) -- provided by askitter import Web.Twitter (Favorite(), favorites, getFavorites, fcreated_at, getTotals, fid_str, unFavorite, Option(Page)) import Web.Twitter.OAuth (authenticate, Consumer(Consumer), readToken, writeToken) version :: String version = "0.2" -- command line options data Options = Options { genMode :: Bool , tokenFileName :: String , consumerKey :: String , consumerSecret :: String } -- command line defaults defaultOpts :: Options defaultOpts = Options { genMode = False , tokenFileName = error "no file specified..." , consumerKey = error "no consumer key specified..." , consumerSecret = error "no consumer secret specified..." } -- command line description -- this format is kinda bone headed: -- [Option short [long] (property setter-function hint) description] options :: [ OptDescr (Options -> IO Options) ] options = [ -- REGULAR OR GEN MODE Option "t" ["tokenFile"] (ReqArg (\arg opt -> return opt { tokenFileName = arg }) "FILE") "name of a file where the token is (or will be) saved" -- GEN MODE , Option "g" ["generate"] (NoArg $ \opt -> return opt { genMode = True }) $ "toggle generate mode, to save a Twitter API token\n" ++ "(requires a FILE, KEY, and SECRET, too)" , Option "k" ["key"] (ReqArg (\arg opt -> return opt { consumerKey = arg }) "KEY") "a consumer key for this app" , Option "s" ["secret"] (ReqArg (\arg opt -> return opt { consumerSecret = arg }) "SECRET") "a consumer secret for this app" -- HELP , Option "h" ["help"] (NoArg $ \_ -> do prg <- getProgName hPutStrLn stderr $ usageInfo prg options exitWith ExitSuccess) "display help" -- VERSION , Option "v" ["version"] (NoArg $ \_ -> do me <- getProgName hPutStrLn stderr $ me ++ " version " ++ version exitWith ExitSuccess) "display version" ] generateAndSaveToken :: FilePath -> String -> String -> IO () generateAndSaveToken filename key secret = do token <- authenticate $ Consumer key secret putStrLn "writing token file..." writeToken token filename oneWeekAgo :: IO UTCTime oneWeekAgo = do now <- getCurrentTime let oneWeek = 7 * (60 * 60 * 24) :: NominalDiffTime return $ addUTCTime (-oneWeek) now deleteOldOnes :: Token -> Favorite -> IO () deleteOldOnes token fav = do let ctime = strptime "%a %b %d %T %z %Y" $ fcreated_at fav oneWeekAgo' <- oneWeekAgo ctime' <- case ctime of Just (t,_) -> getCurrentTimeZone >>= \z -> return (localTimeToUTC z t) _ -> error "that created time is not recognized" when (ctime' <= oneWeekAgo') $ putStr "x" >> unFavorite (fid_str fav) token >> return () deleteOldFavorites :: Integer -> Integer -> Token -> IO () deleteOldFavorites page stopPage token = do putStr $ " <- getting page " ++ shows page "" ++ "... " favs <- getFavorites [Page page] token sequence_ $ return $ mapM (deleteOldOnes token) favs putStrLn "" when (favs == []) $ putStrLn "no more favorites received..." when (page < stopPage && favs /= []) $ deleteOldFavorites (page + 1) stopPage token main :: IO () main = do args <- getArgs -- call getOpt, ignoring errors let (actions, _, _) = getOpt Permute options args -- process the defaults with those actions opts <- foldl (>>=) (return defaultOpts) actions if genMode opts then generateAndSaveToken (tokenFileName opts) (consumerKey opts) (consumerSecret opts) else do token <- readToken (tokenFileName opts) totals <- getTotals token let max' = favorites totals `div` 20 + 1 putStrLn $ "number of favorites: " ++ shows (favorites totals) "" ++ "..." deleteOldFavorites 1 max' token
killerswan/twitter-unfav
Main.hs
bsd-2-clause
5,073
0
15
1,549
1,287
687
600
100
2
{-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DefaultSignatures #-} module Data.Authenticated (Prover, Verifier, AuthM, Auth, runProver, runVerifier, Digestible(..), Authenticated(..), GMapAuth(..), MapAuth(..), shallowAuth) where -- Implements the ideas from "Authenticated Data Structures, Generically" by Andrew Miller, Michael Hicks, Jonathan Katz, and Elaine Shi. import Control.Monad.State import Control.Monad.Writer import GHC.Generics (Generic1, to1, from1, Rep1) data Prover data Verifier class GMapAuth f where gmapAuth :: f Prover -> f Verifier -- Abstract data family AuthM a s t -- TODO: Use a better Monoid. newtype instance AuthM Prover s t = Output { runOutput :: Writer [s] t } deriving (Functor, Applicative, Monad, MonadWriter [s]) newtype instance AuthM Verifier s t = Input { runInput :: StateT [s] Maybe t } deriving (Functor, Applicative, Monad, MonadState [s]) -- Abstract data family Auth t a data instance Auth t Prover = WithDigest !t !(Digest t) newtype instance Auth t Verifier = OnlyDigest (Digest t) instance (Show t, Show (Digest t)) => Show (Auth t Prover) where showsPrec n (WithDigest t d) = showParen (n > 0) $ ("WithDigest "++) . showsPrec 11 t . (' ':) . showsPrec 11 d instance (Show (Digest t)) => Show (Auth t Verifier) where showsPrec n (OnlyDigest d) = showParen (n > 0) $ ("OnlyDigest "++) . showsPrec 11 d class (Eq (Digest t)) => Digestible t where type Digest t :: * digest :: t -> Digest t -- Is this instance right? instance (Eq (Digest t), Authenticated a) => Digestible (Auth t a) where type Digest (Auth t a) = Digest t digest a = getDigest a class Authenticated a where type AuthResult a s t :: * auth :: Digestible t => t -> Auth t a unauth :: Digestible t => Auth t a -> AuthM a t t getDigest :: Auth t a -> Digest t runAuthM :: AuthM a s t -> AuthResult a s t instance Authenticated Prover where type AuthResult Prover s t = (t, [s]) auth t = WithDigest t (digest t) unauth (WithDigest t _) = tell [t] >> return t getDigest (WithDigest _ d) = d runAuthM (Output m) = runWriter m instance Authenticated Verifier where type AuthResult Verifier s t = [s] -> Maybe t auth t = OnlyDigest (digest t) unauth (OnlyDigest d) = do ts <- get case ts of [] -> fail "Unexpected end of proof stream" (t:ts') -> do put ts' if digest t == d then return t else fail "Digest verification failed" getDigest (OnlyDigest d) = d runAuthM (Input m) = fmap fst . runStateT m runProver :: AuthM Prover s t -> AuthResult Prover s t runProver = runAuthM runVerifier :: AuthM Verifier s t -> AuthResult Verifier s t runVerifier = runAuthM class MapAuth f where mapAuth :: f Prover -> f Verifier default mapAuth :: (GMapAuth (Rep1 f), Generic1 f) => f Prover -> f Verifier mapAuth = to1 . gmapAuth . from1 instance MapAuth (Auth t) where mapAuth = shallowAuth shallowAuth :: (Digest s ~ Digest t) => Auth s Prover -> Auth t Verifier shallowAuth (WithDigest _ d) = OnlyDigest d
derekelkins/ads
Data/Authenticated.hs
bsd-2-clause
3,269
0
15
753
1,174
616
558
-1
-1
import Yesod.Default.Config (fromArgs) import Yesod.Default.Main (defaultMain) import Application (withCms) main :: IO () main = defaultMain fromArgs withCms
snoyberg/yesodcms
main.hs
bsd-2-clause
170
0
6
30
51
29
22
5
1
module DayOfTheWeek where data DayOfTheWeek = Mon | Tue | Wed | Thu | Fri | Sat | Sun -- Let's omit the last case to break this instance Eq DayOfTheWeek where (==) Mon Mon = True (==) Tue Tue = True (==) Wed Wed = True (==) Thu Thu = True (==) Fri Fri = True (==) Sat Sat = True (==) Sun Sun = True -- (==) _ _ = False
OCExercise/haskellbook-solutions
chapters/chapter06/scratch/dayoftheweek_broken.hs
bsd-2-clause
358
0
6
112
123
74
49
11
0
module Main where import Drasil.SWHS.Generate (generate) main :: IO () main = generate
JacquesCarette/literate-scientific-software
code/drasil-example/Drasil/SWHS/Main.hs
bsd-2-clause
89
0
6
15
30
18
12
4
1
module Main where import RunIdea import Options.Applicative import Data.Maybe import Data.Text data CommandLineArgs = CommandLineArgs { maybeJavaVersion :: Maybe JavaVersion , maybeIdeaVersion :: Maybe IdeaVersion , gwbArgs :: [Text] } main :: IO () main = do args <- execParser $ info commandLineArgsParser idm let(jv, iv, ga) = validate args exportEnvVars jv iv ga validate :: CommandLineArgs -> (JavaVersion, IdeaVersion, [Text]) validate args = case (maybeJavaVersion args, maybeIdeaVersion args, gwbArgs args) of (Nothing, _, _) -> error "Invalid Java version specified" (_, Nothing, _) -> error "Invalid Idea version specified" (Just jv, Just iv, ga) -> (jv, iv, ga) javaVersionParser :: Parser (Maybe JavaVersion) javaVersionParser = parseJavaVersion <$> (strOption . long $ "java") where parseJavaVersion :: String -> Maybe JavaVersion parseJavaVersion s = case s of "8" -> Just Java8 "7" -> Just Java7 _ -> Nothing ideaVersionParser :: Parser (Maybe IdeaVersion) ideaVersionParser = parseIdeaVersion <$> (strOption . long $ "idea") where parseIdeaVersion :: String -> Maybe IdeaVersion parseIdeaVersion s = case s of "14" -> Just Idea14 "15" -> Just Idea15 _ -> Nothing gwbArgsParser :: Parser [Text] gwbArgsParser = some $ pack <$> strArgument idm commandLineArgsParser :: Parser Main.CommandLineArgs commandLineArgsParser = CommandLineArgs <$> javaVersionParser <*> ideaVersionParser <*> gwbArgsParser
DPakJ989/d-env
app/Main.hs
bsd-3-clause
1,541
0
10
328
460
242
218
37
3
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ScopedTypeVariables #-} module VDPT.Parser ( traceTreeParser , parseIntoEither , module VDPT.Types ) where import Data.Monoid import Data.Tree import qualified Data.Map as M import Data.Attoparsec.Text import qualified Data.Attoparsec.Text as A import qualified Data.Attoparsec.Text.Lazy as AL import qualified Data.Aeson as JSON import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Control.Applicative import VDPT.Types traceTreeParser :: Parser (Tree (NodeId -> Attributes)) traceTreeParser = optional (char '\xfeff') *> skipSpace *> go where go = mkNode <$> nodeBegin <*> many1 attribute <*> many go <* nodeEnd mkNode nodeType' attrList' children' = Node (\nodeId' -> Attributes nodeId' nodeType' (M.fromList attrList')) children' notCharOrEOL :: Char -> Char -> Bool notCharOrEOL x = \c -> c /= x && not (isEndOfLine c) nodeBegin :: Parser T.Text nodeBegin = T.strip <$> (takeWhile1 (notCharOrEOL '(') <* char '(' <* skipWhile isHorizontalSpace <* skip isEndOfLine <* skipWhile isEndOfLine) nodeEnd :: Parser () nodeEnd = skipWhile isHorizontalSpace <* char ')' <* skipWhile isHorizontalSpace <* ((skip isEndOfLine <* skipWhile isEndOfLine) <|> endOfInput) attribute :: Parser (T.Text, JSON.Value) attribute = (,) <$> (T.strip <$> takeWhile1 (notCharOrEOL '=') <* char '=') <*> (skipWhile isHorizontalSpace *> attributeValue <* skip isEndOfLine <* skipWhile isEndOfLine) attributeValue :: Parser JSON.Value attributeValue = (pure JSON.Null <* char '-' <* skipWhile isHorizontalSpace) <|> (pure (JSON.Bool True) <* string "true" <* skipWhile isHorizontalSpace) <|> (pure (JSON.Bool False) <* string "false" <* skipWhile isHorizontalSpace) <|> (JSON.Number <$> scientific <* skipWhile isHorizontalSpace) <|> (JSON.toJSON <$> (char '[' *> sepBy' listElement (char ',') <* char ']' <* skipWhile isHorizontalSpace)) <|> (JSON.String . T.strip <$> AL.takeWhile (not . isEndOfLine)) listElement :: Parser JSON.Value listElement = JSON.String . T.strip <$> (topFragment1 <|> topFragment2) where topFragment1 = (\x xs->mconcat (x:xs)) <$> A.takeWhile1 elemChar <*> many topFragmentTrailed topFragment2 = (\xs->mconcat xs) <$> many1 topFragmentTrailed topFragmentTrailed = (<>) <$> parenFragment <*> A.takeWhile elemChar elemChar c = c /= ',' && c/= '[' && c/= ']' && c/= '(' && c/= ')' && not (isEndOfLine c) parenFragment = (\x t z -> T.cons x (T.snoc t z)) <$> char '(' <*> insideParentFragment <*> char ')' insideParentFragment = (\x xs->mconcat (x:xs)) <$> A.takeWhile nonParen <*> many parenFragmentTrailed parenFragmentTrailed = (<>) <$> parenFragment <*> A.takeWhile nonParen nonParen c = c/= '(' && c/= ')' && not (isEndOfLine c) parseIntoEither :: Parser a -> TL.Text -> Either String a parseIntoEither p lat = AL.eitherResult (AL.parse p lat)
danidiaz/vdpt
library/VDPT/Parser.hs
bsd-3-clause
3,125
0
16
575
1,030
536
494
60
1
module Talks.Free.Demo where import Talks.Free runbletch :: Int runbletch = bletch 5
markhibberd/fp-syd-free
demo/Talks/Free/Demo.hs
bsd-3-clause
87
0
5
14
25
15
10
4
1
-- Exercises/Ch2/Pt1/Ex5.hs module Ex5 where -- Exercise 5 -- Add a `Character` constructor to `LispVal`, and create a parser for character -- literals as defined in R5RS. import Data.Char (digitToInt, isSpace) import Control.Monad import Numeric import System.Environment import Text.ParserCombinators.Parsec hiding (spaces) data LispVal = Atom String | List [LispVal] | DottedList [LispVal] LispVal -- (a b c ... . z) | Number Integer | Character String | String String | Bool Bool deriving Show -- debug purposes parseCharacter :: Parser LispVal parseCharacter = do string "#\\" character <- many $ satisfy $ not . isSpace return $ Character character parseString :: Parser LispVal parseString = do char '"' -- order is important here; need to try parsing an escape sequence first because -- otherwise we fail when we reach the second character of the escape -- sequence x <- many $ choice $ escChars ++ [nonQuote] char '"' return $ String x where nonQuote = noneOf "\"" -- taken from here: -- https://en.wikipedia.org/wiki/Escape_sequences_in_C#Table_of_escape_sequences -- (excluded characters by oct/hex codes) escChars = [ char '\\' >> char x | x <- "abfnrtv\\'\"?" ] parseBool :: Parser LispVal parseBool = do try (char '#') v <- oneOf "tf" return $ case v of 't' -> Bool True 'f' -> Bool False parseAtom :: Parser LispVal parseAtom = do first <- letter <|> symbol rest <- many (letter <|> digit <|> symbol) return $ Atom (first:rest) parseNumber :: Parser LispVal parseNumber = (try parseBin) <|> (try parseOct) <|> (try parseHex) <|> parseDec where parseBin = do string "#b" binStr <- many1 $ oneOf "01" -- cribbed from http://stackoverflow.com/a/26961027/1893155 let binVal = foldl (\acc x -> acc * 2 + digitToInt x) 0 binStr return $ Number (toInteger binVal) parseOct = do string "#o" octStr <- many1 octDigit let octVal = fst $ (readOct octStr) !! 0 return $ Number octVal parseDec = parseDecNoPre <|> parseDecPre parseDecNoPre = do decStr <- many1 digit return $ (Number . read) decStr parseDecPre = do string "#d" decStr <- many1 digit return $ (Number . read) decStr parseHex = do string "#x" hexStr <- many1 hexDigit let hexVal = fst $ (readHex hexStr) !! 0 return $ Number hexVal -- TODO : I don't like all these `try`s -- better way to do this? parseExpr :: Parser LispVal parseExpr = (try parseNumber) <|> (try parseString) <|> (try parseCharacter) <|> (try parseBool) <|> (try parseAtom) symbol :: Parser Char symbol = oneOf "!$%&|*+-/:<=>?@^_~" spaces :: Parser () spaces = skipMany1 space readExpr :: String -> String readExpr input = case parse parseExpr "lisp" input of Left err -> "No match: " ++ show err Right val -> "Found value" main :: IO () main = do (expr:_) <- getArgs putStrLn (readExpr expr)
EFulmer/haskell-scheme-wikibook
src/Exercises/Ch2/Pt1/Ex5.hs
bsd-3-clause
3,143
0
16
868
870
432
438
82
2
module Atomo.Parser.Expr where import Control.Monad.State import Data.Maybe (fromJust) import Text.Parsec import Atomo.Parser.Base import Atomo.Pattern import Atomo.Types hiding (keyword, option, particle, string) import qualified Atomo.Types as T -- | The default precedence for an operator (5). defaultPrec :: Integer defaultPrec = 5 -- | Parses any Atomo expression. pExpr :: Parser Expr pExpr = choice [ pOperator , pMacro , pForMacro , pDispatch ] <?> "expression" -- | Parses any Atomo literal value. pLiteral :: Parser Expr pLiteral = choice [ pThis , pBlock , pMacroQuote , pList , pTuple , pParticle , pQuoted , pQuasiQuoted , pUnquoted , pPrimitive ] <?> "literal" -- | Parses a primitive value. -- -- Examples: @1@, @2.0@, @3\/4@, @$d@, @\"foo\"@, @True@, @False@ pPrimitive :: Parser Expr pPrimitive = tagged $ liftM (EPrimitive Nothing) primitive -- | The @this@ keyword, i.e. the toplevel object literal. pThis :: Parser Expr pThis = tagged (reserved "this" >> return (ETop Nothing)) <?> "this" -- | An expression literal. -- -- Example: @'1@, @'(2 + 2)@ pQuoted :: Parser Expr pQuoted = tagged (do punctuation '\'' e <- pSpacedExpr return (EPrimitive Nothing (Expression e))) <?> "quoted expression" -- | An expression literal that may contain "unquotes" - expressions to splice -- in to yield a different expression. -- -- Examples: @`a@, @`(1 + ~(2 + 2))@ pQuasiQuoted :: Parser Expr pQuasiQuoted = tagged (do punctuation '`' modifyState $ \ps -> ps { psInQuote = True } e <- pSpacedExpr modifyState $ \ps -> ps { psInQuote = False } return (EQuote Nothing e)) <?> "quasiquoted expression" -- | An unquote expression, used inside a quasiquote. -- -- Examples: @~1@, @~(2 + 2)@ pUnquoted :: Parser Expr pUnquoted = tagged (do punctuation '~' iq <- fmap psInQuote getState modifyState $ \ps -> ps { psInQuote = False } e <- pSpacedExpr modifyState $ \ps -> ps { psInQuote = iq } return (EUnquote Nothing e)) <?> "unquoted expression" -- | Any expression that fits into one lexical "space" - either a simple -- literal value, a single dispatch to the toplevel object, or an expression in -- parentheses. -- -- Examples: @1@, @[1, 2]@, @a@, @(2 + 2)@ pSpacedExpr :: Parser Expr pSpacedExpr = pLiteral <|> simpleDispatch <|> parens pExpr -- | A single message sent to the toplevel object. simpleDispatch :: Parser Expr simpleDispatch = tagged $ do name <- identifier return (EDispatch Nothing (single name (ETop Nothing))) -- | The for-macro "pragma." -- -- Example: @for-macro 1 print@ pForMacro :: Parser Expr pForMacro = tagged (do reserved "for-macro" e <- pExpr return (EForMacro Nothing e)) <?> "for-macro expression" -- | A macro definition. -- -- Example: @macro (n squared) `(~n * ~n)@ pMacro :: Parser Expr pMacro = tagged (do reserved "macro" p <- parens (liftM (fromJust . toMacroPattern) pExpr) e <- pExpr return (EMacro Nothing p e)) <?> "macro definition" -- | An operator "pragma" - tells the parser about precedence and associativity -- for the given operator(s). -- -- Examples: @operator right 0 ->@, @operator 7 * /@ pOperator :: Parser Expr pOperator = tagged (do reserved "operator" info <- choice [ do a <- choice [ symbol "right" >> return ARight , symbol "left" >> return ALeft ] prec <- option defaultPrec integer return (a, prec) , liftM ((,) ALeft) integer ] ops <- many operator forM_ ops $ \name -> modifyState $ \ps -> ps { psOperators = (name, info) : psOperators ps } return (uncurry (EOperator Nothing ops) info)) <?> "operator declaration" -- | A particle literal. -- -- Examples: @\@foo@, @\@(bar: 2)@, @\@bar:@, @\@(foo: 2 bar: _)@ pParticle :: Parser Expr pParticle = tagged (do msg <- choice [ do punctuation '@' liftM toMsg (cSingle <|> try cKeyword) <|> filledHead , liftM toMsg particle ] return (EParticle Nothing msg)) <?> "particle" where filledHead = do p <- parens pDispatch case p of EDispatch { eMessage = Single i n t os } -> return (Single i n (toRole t) (map toOpt os)) EDispatch { eMessage = Keyword i ns ts os } -> return (Keyword i ns (map toRole ts) (map toOpt os)) _ -> fail "non-message in particle" toOpt (Option i n e) = Option i n (toRole e) toMsg (CSingle n os) = single' n Nothing (map toOpt os) toMsg (CKeyword ns es os) = keyword' ns (Nothing:map toRole es) (map toOpt os) toRole (EDispatch { eMessage = Single { mName = "_", mTarget = ETop {} } }) = Nothing toRole e = Just e -- | A comma-separated list of zero or more expressions, surrounded by square -- brackets. -- -- Examples: @[]@, @[1, $a]@ pList :: Parser Expr pList = tagged (liftM (EList Nothing) (brackets (blockOf pExpr))) <?> "list" -- | A comma-separated list of zero or two or more expressions, surrounded by -- parentheses. -- -- Examples: @(1, $a)@ pTuple :: Parser Expr pTuple = (tagged . liftM (ETuple Nothing) . try . parens $ choice [ do v <- pExpr end vs <- blockOf1 pExpr return (v:vs) , return [] ]) <?> "tuple" -- | A block of expressions, surrounded by braces and optionally having -- arguments. -- -- Examples: @{ }@, @{ a b | a + b }@, @{ a = 1; a + 1 }@ pBlock :: Parser Expr pBlock = tagged . braces $ do as <- option [] (try $ manyTill pSpacedExpr (punctuation '|' >> optional end)) es <- blockOf pExpr return (EBlock Nothing (map (fromJust . toPattern) as) es) pMacroQuote :: Parser Expr pMacroQuote = tagged $ do (name, raw, flags) <- macroQuote return (EMacroQuote Nothing name raw flags) -- | Parse an expression possibly up to an operator dispatch. -- -- That is, this may be: -- - an operator dispatch -- - a keyword dispatch -- - a single dispatch -- - a literal or parenthesized expression pDispatch :: Parser Expr pDispatch = tagged (do s <- do h <- choice [ try (lookAhead (keyword <|> operator)) >> return (ETop Nothing) , pmSingle ] case h of EDispatch { eMessage = m@(Single { mOptionals = [] }) } -> do os <- pdOptionals return h { eMessage = m { mOptionals = os } } _ -> return h k <- followedBy keyword if k then keywordNext s else do o <- followedBy operator if o then operatorNext s else return s) <?> "dispatch" -- | Optional keyword arguments. pdOptionals :: Parser [Option Expr] pdOptionals = do os <- many (optionSegment prKeyword <|> optionFlag) return (map (uncurry T.option) os) -- | Parse an expr up to a single dispatch. -- -- That is, this may end up just being a literal or a parenthesized expression. pmSingle :: Parser Expr pmSingle = do target <- pSpacedExpr let restOf = case target of EDispatch {} -> many _ -> many1 chain <- option [] (try $ restOf (cSingle <|> cKeyword)) if null chain then return target else return (dispatches target chain) where dispatches = foldl sendTo sendTo t (CSingle n os) = EDispatch Nothing (single' n t os) sendTo t (CKeyword ns es os) = EDispatch Nothing (keyword' ns (t:es) os) -- | Parse an expr up to a keyword dispatch. -- -- That is, this may end up just being a single dispatch, or a literal, or -- a parenthesized expression, but it will not parse the rest of an operator -- dispatch. pmKeyword :: Parser Expr pmKeyword = do t <- choice [ try (lookAhead keyword) >> return (ETop Nothing) , pmSingle ] k <- followedBy keyword if not k then return t else do phKeyword t -- | Headless operator dispatch phOperator :: Parser Expr phOperator = do n <- operator t <- prOperator os <- pdOptionals return (EDispatch Nothing (keyword' [n] [ETop Nothing, t] os)) -- | Headless keyword dispatch phKeyword :: Expr -> Parser Expr phKeyword t = do (ns, ts) <- liftM unzip $ many1 (keywordSegment prKeyword) os <- pdOptionals return $ EDispatch Nothing (keyword' ns (t:ts) os) -- | Keyword (non-first) roles prKeyword :: Parser Expr prKeyword = phOperator <|> phKeyword (ETop Nothing) <|> pmSingle <?> "keyword role" -- | Operator (non-first) roles prOperator :: Parser Expr prOperator = phOperator <|> phKeyword (ETop Nothing) <|> pmKeyword <?> "operand" -- | Parse the rest of a keyword dispatch, possibly followed by an operator -- dispatch, with a given first role. keywordNext :: Expr -> Parser Expr keywordNext t = do keywd <- phKeyword t o <- followedBy operator if o then operatorNext keywd else return keywd -- | Parse the rest of an operator dispatch, with a given first role. operatorNext :: Expr -> Parser Expr operatorNext f = do (ns, ts, os) <- liftM unzip3 . many1 $ do n <- operator t <- prOperator os <- pdOptionals return (n, t, os) ops <- fmap psOperators getState return (EDispatch Nothing (opChain ops ns (f:ts) os)) -- | Chained single message cSingle :: Parser Chained cSingle = choice [ liftM (flip CSingle []) (anyReserved <|> identifier) , try . parens $ do n <- anyReserved <|> identifier os <- pdOptionals return (CSingle n os) ] -- | Chained keyword message cKeyword :: Parser Chained cKeyword = parens $ do (ns, es) <- choice [ liftM unzip $ many1 (keywordSegment prKeyword) , do o <- operator e <- prOperator return ([o], [e]) ] os <- pdOptionals return (CKeyword ns es os) -- | Work out precadence, associativity, etc. for binary dispatch. -- Takes the operator table, a list of operators, their operands, and their -- options, and creates a message dispatch with proper associativity/precedence -- worked out. -- -- Operators taking optional values are treated with highest precedence -- regardless of their settings in the operator table. -- -- For example, @1 -> 2 &x: 3 * 5@ is @(1 -> 2 &x: 3) * 5@, rather than -- @1 -> (2 * 5) &x: 3@ opChain :: Operators -> [String] -> [Expr] -> [[Option Expr]] -> Message Expr opChain _ [] [EDispatch { eMessage = done }] [] = done opChain _ [a] [w, x] [opts] = keyword' [a] [w, x] opts opChain os (a:b:cs) (w:x:y:zs) (aopts:bopts:opts) | nextFirst = keyword' [a] [w, disp $ opChain os (b:cs) (x:y:zs) (bopts:opts)] aopts | otherwise = opChain os (b:cs) (disp (keyword' [a] [w, x] aopts):y:zs) (bopts:opts) where disp = EDispatch Nothing nextFirst = null aopts && (prec b > prec a || (assoc a == ARight && prec b == prec a)) assoc o = maybe ALeft fst (lookup o os) prec o = maybe defaultPrec snd (lookup o os) opChain _ ns ts oss = error $ "opChain: " ++ show (ns, ts, oss) -- | Parse a block of expressions from a given input string. parser :: Parser [Expr] parser = do es <- blockOf pExpr endOfFile return es
vito/atomo
src/Atomo/Parser/Expr.hs
bsd-3-clause
11,410
0
24
3,104
3,239
1,647
1,592
-1
-1
module Web.ApiAi.Responses.Core where import ClassyPrelude import Data.Aeson data ResponseErrorType = ResponseSuccess | ResponseErrorType Text deriving Show instance FromJSON ResponseErrorType where parseJSON = withText "ResponseErrorType" $ return . errt where errt "success" = ResponseSuccess errt er = ResponseErrorType er data ResponseStatus = ResponseStatus { statusCode :: Int , statusErrorType :: ResponseErrorType , statusErrorId :: Maybe Text , statusErrorDetails :: Maybe Text } deriving Show instance FromJSON ResponseStatus where parseJSON = withObject "ResponseStatus" $ \o -> ResponseStatus <$> o .: "code" <*> o .: "errorType" <*> o .:? "errorId" <*> o .:? "errorDetails"
CthulhuDen/api-ai
src/Web/ApiAi/Responses/Core.hs
bsd-3-clause
1,083
0
15
487
175
96
79
18
0
{-# LANGUAGE TypeApplications #-} module Database.PostgreSQL.PQTypes.SQL ( SQL , mkSQL , sqlParam , (<?>) , isSqlEmpty ) where import Control.Concurrent.MVar import Data.Monoid import Data.String import Foreign.Marshal.Alloc import TextShow import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Unsafe as BS import qualified Data.Foldable as F import qualified Data.Semigroup as SG import qualified Data.Sequence as S import qualified Data.Text as T import qualified Data.Text.Encoding as T import Data.Monoid.Utils import Database.PostgreSQL.PQTypes.Format import Database.PostgreSQL.PQTypes.Internal.C.Put import Database.PostgreSQL.PQTypes.Internal.Utils import Database.PostgreSQL.PQTypes.SQL.Class import Database.PostgreSQL.PQTypes.ToSQL data SqlChunk where SqlString :: !T.Text -> SqlChunk SqlParam :: forall t. (Show t, ToSQL t) => !t -> SqlChunk -- | Primary SQL type that supports efficient -- concatenation and variable number of parameters. newtype SQL = SQL (S.Seq SqlChunk) unSQL :: SQL -> [SqlChunk] unSQL (SQL chunks) = F.toList chunks ---------------------------------------- -- | Construct 'SQL' from 'String'. instance IsString SQL where fromString = mkSQL . T.pack instance IsSQL SQL where withSQL sql pa@(ParamAllocator allocParam) execute = do alloca $ \err -> allocParam $ \param -> do nums <- newMVar (1::Int) query <- T.concat <$> mapM (f param err nums) (unSQL sql) BS.useAsCString (T.encodeUtf8 query) (execute param) where f param err nums chunk = case chunk of SqlString s -> return s SqlParam (v::t) -> toSQL v pa $ \base -> BS.unsafeUseAsCString (pqFormat0 @t) $ \fmt -> do verifyPQTRes err "withSQL (SQL)" =<< c_PQputf1 param err fmt base modifyMVar nums $ \n -> return . (, "$" <> showt n) $! n+1 instance SG.Semigroup SQL where SQL a <> SQL b = SQL (a S.>< b) instance Monoid SQL where mempty = mkSQL T.empty mappend = (SG.<>) instance Show SQL where showsPrec n sql = ("SQL " ++) . (showsPrec n . concatMap conv . unSQL $ sql) where conv (SqlString s) = T.unpack s conv (SqlParam v) = "<" ++ show v ++ ">" ---------------------------------------- -- | Convert a 'Text' SQL string to the 'SQL' type. mkSQL :: T.Text -> SQL mkSQL = SQL . S.singleton . SqlString -- | Embed parameter value inside 'SQL'. sqlParam :: (Show t, ToSQL t) => t -> SQL sqlParam = SQL . S.singleton . SqlParam -- | Embed parameter value inside existing 'SQL'. Example: -- -- > f :: Int32 -> String -> SQL -- > f idx name = "SELECT foo FROM bar WHERE id =" <?> idx <+> "AND name =" <?> name -- (<?>) :: (Show t, ToSQL t) => SQL -> t -> SQL s <?> v = s <+> sqlParam v infixr 7 <?> ---------------------------------------- -- | Test whether an 'SQL' is empty. isSqlEmpty :: SQL -> Bool isSqlEmpty (SQL chunks) = getAll $ F.foldMap (All . cmp) chunks where cmp (SqlString s) = s == T.empty cmp (SqlParam _) = False
scrive/hpqtypes
src/Database/PostgreSQL/PQTypes/SQL.hs
bsd-3-clause
3,000
0
24
608
904
499
405
-1
-1
{-# LANGUAGE FlexibleContexts #-} module Error ( module Error , Identity (..) , lift ) where import Util import Control.Applicative import Control.Monad.Trans.Class import Data.Functor.Identity newtype ErrorT m a = ErrorT { runErrorT :: m (Either String a) } instance Functor m => Functor (ErrorT m) where fmap f = ErrorT . fmap (fmap f) . runErrorT instance Applicative m => Applicative (ErrorT m) where pure = ErrorT . pure . Right mf <*> mx = ErrorT $ ((<*>) <$> runErrorT mf) <*> runErrorT mx instance (Monad m) => Monad (ErrorT m) where return a = ErrorT $ return $ Right a m >>= f = ErrorT $ either (return . Left) (runErrorT . f) =<< runErrorT m fail msg = ErrorT $ return $ Left msg instance MonadTrans ErrorT where lift m = ErrorT $ do a <- m return (Right a) type Error = ErrorT Identity runError :: Error a -> Either String a runError m = runIdentity $ runErrorT m lowerHandleError :: (Monad m) => ErrorT m a -> (String -> m b) -> (a -> m b) -> m b lowerHandleError m f s = either f s =<< runErrorT m handleError :: Error a -> (String -> b) -> (a -> b) -> b handleError m f s = runIdentity $ lowerHandleError m (Identity . f) (Identity . s) catch :: (Monad m) => ErrorT m a -> (String -> ErrorT m a) -> ErrorT m a catch m f = ErrorT $ do e <- runErrorT m case e of Left err -> runErrorT $ f err Right a -> return $ Right a lowerDropError :: (Monad m) => ErrorT m a -> m (Maybe a) lowerDropError m = return . either (const Nothing) Just =<< runErrorT m dropError :: Error a -> Maybe a dropError = either (const Nothing) Just . runError liftReportNothing :: (Monad m) => String -> m (Maybe a) -> ErrorT m a liftReportNothing msg m = ErrorT $ return . maybe (Left msg) Right =<< m reportNothing :: (Monad m) => String -> Maybe a -> ErrorT m a reportNothing msg m = case m of Just a -> return a Nothing -> fail msg fails :: (Monad m) => String -> String -> m a fails e1 e2 = fail $ unlines [e1,e2] wrapFail :: (Monad m) => String -> ErrorT m a -> ErrorT m a wrapFail msg m = catch m $ fail . addLine msg errorLookup' :: (Monad m, Eq a, Show a) => [(a,b)] -> a -> ErrorT m b errorLookup' al a = reportNothing err $ lookup a al where err = "Couldn't find key " ++ show a ++ "in assoc list" errorLookup :: (Monad m, Show a, Show b, Eq a) => [(a,b)] -> a -> ErrorT m b errorLookup al a = reportNothing err $ lookup a al where err = "Couldn't find key " ++ show a ++ " in assoc list " ++ show al fromEither :: Either String a -> Error a fromEither = ErrorT . Identity
kylcarte/wangtiles
src/Error.hs
bsd-3-clause
2,554
0
12
593
1,170
587
583
59
2
{-# LANGUAGE DataKinds, KindSignatures, TypeFamilies #-} module Main (main) where import Test.QuickCheck import Data.Hot.Pidgin import Control.Monad (replicateM) import Data.List (sort) import Data.Proxy (Proxy (Proxy)) import GHC.Exts (IsList, Item) import GHC.TypeLits (KnownNat, Nat, natVal) main :: IO () main = do quickCheck prop_merge2and3 prop_merge2and3 :: OrderedN 2 (PHot2 Int) Int -> OrderedN 3 (PHot3 Int) Int -> Bool prop_merge2and3 (OrderedN x xs) (OrderedN y ys) = merge2and3 x y == fromList (sort $ xs ++ ys) data OrderedN (n :: Nat) a e = OrderedN a [e] deriving (Show) instance (KnownNat n, IsList a, e ~ Item a, Arbitrary e, Ord e) => Arbitrary (OrderedN n a e) where arbitrary = do let n = fromIntegral $ natVal (Proxy :: Proxy n) xs <-replicateM n arbitrary let xs' = sort xs return $ OrderedN (fromList xs') xs'
tserduke/hot
test/PidginProp.hs
bsd-3-clause
867
0
14
169
351
186
165
22
1
{-# OPTIONS_GHC -Wall #-} {-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-} module Main where import Control.Applicative ((<$>),(<|>)) import Control.Monad (guard) import Control.Monad.Trans (MonadIO(liftIO)) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC import qualified Data.HashMap.Strict as Map import qualified Data.Version as Version import System.Console.CmdArgs import System.Directory import System.Exit import System.FilePath import System.Process import System.IO (hGetContents, Handle) import Paths_elm_server (version) import qualified Elm.Internal.Paths as Elm import Snap.Core import Snap.Http.Server import Snap.Util.FileServe data Flags = Flags { port :: Int , runtime :: Maybe FilePath } deriving (Data,Typeable,Show,Eq) flags :: Flags flags = Flags { port = 8000 &= help "set the port of the server" , runtime = Nothing &= typFile &= help "Specify a custom location for Elm's runtime system." } &= help "Quickly reload Elm projects in your browser. Just refresh to recompile.\n\ \It serves static files and freshly recompiled Elm files." &= helpArg [explicit, name "help", name "h"] &= versionArg [ explicit, name "version", name "v" , summary (Version.showVersion version) ] &= summary ("Elm Server " ++ Version.showVersion version ++ ", (c) Evan Czaplicki 2011-2014") config :: Config Snap a config = setAccessLog ConfigNoLog (setErrorLog ConfigNoLog defaultConfig) -- | Set up the server. main :: IO () main = do cargs <- cmdArgs flags putStrLn $ "Elm Server " ++ Version.showVersion version ++ ": Just refresh a page to recompile it!" httpServe (setPort (port cargs) config) $ serveRuntime (maybe Elm.runtime id (runtime cargs)) <|> serveElm <|> serveDirectoryWith directoryConfig "." directoryConfig :: MonadSnap m => DirectoryConfig m directoryConfig = fancyDirectoryConfig { indexGenerator = defaultIndexGenerator defaultMimeTypes indexStyle , mimeTypes = Map.insert ".elm" "text/html" defaultMimeTypes } indexStyle :: BS.ByteString indexStyle = "body { margin:0; font-family:sans-serif; background:rgb(245,245,245);\ \ font-family: calibri, verdana, helvetica, arial; }\ \div.header { padding: 40px 50px; font-size: 24px; }\ \div.content { padding: 0 40px }\ \div.footer { display:none; }\ \table { width:100%; border-collapse:collapse; }\ \td { padding: 6px 10px; }\ \tr:nth-child(odd) { background:rgb(216,221,225); }\ \td { font-family:monospace }\ \th { background:rgb(90,99,120); color:white; text-align:left;\ \ padding:10px; font-weight:normal; }" runtimeName :: String runtimeName = "elm-runtime.js" serveRuntime :: FilePath -> Snap () serveRuntime runtimePath = do file <- BSC.unpack . rqPathInfo <$> getRequest guard (file == runtimeName) serveFileAs "application/javascript" runtimePath serveElm :: Snap () serveElm = do file <- BSC.unpack . rqPathInfo <$> getRequest exists <- liftIO $ doesFileExist file guard (exists && takeExtension file == ".elm") onSuccess (compile file) (serve file) where compile file = let elmArgs = [ "--make", "--runtime=" ++ runtimeName, file ] in createProcess $ (proc "elm" elmArgs) { std_out = CreatePipe } serve file = serveFileAs "text/html; charset=UTF-8" ("build" </> replaceExtension file "html") failure :: String -> Snap () failure msg = do modifyResponse $ setResponseStatus 404 "Not found" writeBS $ BSC.pack msg onSuccess :: IO (t, Maybe Handle, t1, ProcessHandle) -> Snap () -> Snap () onSuccess action success = do (_, stdout, _, handle) <- liftIO action exitCode <- liftIO $ waitForProcess handle case (exitCode, stdout) of (ExitFailure 127, _) -> failure "Error: elm compiler not found in your path." (ExitFailure _, Just out) -> failure =<< liftIO (hGetContents out) (ExitFailure _, Nothing) -> failure "See command line for error message." (ExitSuccess, _) -> success {-- pageTitle :: String -> String pageTitle = dropExtension . takeBaseName --}
deadfoxygrandpa/Elm
server/Server.hs
bsd-3-clause
4,249
0
14
903
981
519
462
89
4
{-# LANGUAGE FlexibleContexts, FlexibleInstances, UndecidableInstances #-} -- Pure Haskell implementation of standard BFGS algorithm with cubic -- line search, with the BFGS step exposed to provide access to -- intermediate Hessian estimates. module Math.Probably.BFGS ( BFGSOpts (..) , LineSearchOpts (..) , BFGS (..) , bfgs, bfgsWith , bfgsInit , bfgsStep, bfgsStepWith ) where import Numeric.LinearAlgebra import Numeric.LinearAlgebra.Algorithms import Numeric.LinearAlgebra.Util import Data.Default import Debug.Trace -- Type synonyms mostly just for documentation purposes... type Point = Vector Double type Gradient = Vector Double type Direction = Vector Double type Fn = Point -> Double type GradFn = Point -> Vector Double type Hessian = Matrix Double -------------------------------------------------------------------------------- -- -- NaN CHECKING -- class Nanable a where hasnan :: a -> Bool instance Nanable Double where hasnan = isNaN instance (Nanable a, Container c a) => Nanable (c a) where hasnan = not . null . (find hasnan) -------------------------------------------------------------------------------- -- -- BFGS -- -- Options for BFGS solver: point tolerance, gradient tolerance, -- maximum iterations. -- data BFGSOpts = BFGSOpts { ptol :: Double , gtol :: Double , maxiters :: Int } deriving Show instance Default BFGSOpts where def = BFGSOpts 1.0E-7 1.0E-7 200 epsilon :: Double epsilon = 3.0E-8 -- BFGS solver data to carry between steps: current point, function -- value at point, gradient at point, current direction, current -- Hessian estimate, maximum line search step. -- data BFGS = BFGS { p :: Point , fp :: Double , g :: Gradient , xi :: Direction , h :: Matrix Double , stpmax :: Double } deriving Show -- Main solver interface with default options. -- bfgs :: Fn -> GradFn -> Point -> Either String (Point, Hessian) bfgs = bfgsWith def {- Collection solver state into an infinite list: useful as "take n $ -- bfgsCollect f df b0" -- bfgsCollect :: Fn -> GradFn -> BFGS -> [BFGS] bfgsCollect f df b0 = map snd $ iterate step (False,b0) where step (cvg,b) = if cvg then b else bfgsStep f df b -} -- Utility function to set up initial BFGS state for bfgsCollect. -- bfgsInit :: Fn -> GradFn -> Point -> Either String BFGS bfgsInit f df p0 = case (hasnan f0, hasnan g0) of (False, False) -> Right $ BFGS p0 f0 g0 (-g0) (ident n) (maxStep p0) errs -> Left $ nanMsg p0 (Just f0) (Just g0) where n = dim p0 ; f0 = f p0 ; g0 = df p0 -- Main iteration routine: sets up initial BFGS state, then steps -- until converged or maximum iterations exceeded. -- bfgsWith :: BFGSOpts -> Fn -> GradFn -> Point -> Either String (Point, Hessian) bfgsWith opt@(BFGSOpts _ _ maxiters) f df p0 = case (hasnan f0, hasnan g0) of (False, False) -> go 0 b0 errs -> Left $ nanMsg p0 (Just f0) (Just g0) where go iters b = if iters > maxiters then Left "maximum iterations exceeded in bfgs" else case bfgsStepWith opt f df b of Left err -> Left err Right (True, b') -> Right (p b', h b') Right (False, b') -> go (iters+1) b' f0 = f p0 ; g0 = df p0 b0 = BFGS p0 f0 g0 (-g0) (ident $ dim p0) (maxStep p0) -- Do a BFGS step with default parameters. -- bfgsStep :: Fn -> GradFn -> BFGS -> Either String (Bool, BFGS) bfgsStep = bfgsStepWith def -- Main BFGS step routine. This is a more or less verbatim -- translation of the description in Section 10.7 of Numerical Recipes -- in C, 2nd ed. -- bfgsStepWith :: BFGSOpts -> Fn -> GradFn -> BFGS -> Either String (Bool, BFGS) bfgsStepWith (BFGSOpts ptol gtol _) f df (BFGS p fp g xi h stpmax) = case lineSearch f p fp g xi stpmax of Left err -> Left err Right (pn, fpn) -> if hasnan gn then Left $ nanMsg pn Nothing (Just gn) else if cvg then Right (True, BFGS pn fpn gn xi h stpmax) else Right (False, BFGS pn fpn gn xin hn stpmax) where gn = df pn ; dp = pn - p ; dg = gn - g ; hdg = h <> dg dpdg = dp `dot` dg ; dghdg = dg `dot` hdg hn = h + ((dpdg + dghdg) / dpdg^2) `scale` (dp `outer` dp) - (1/dpdg) `scale` (h <> (dg `outer` dp) + (dp `outer` dg) <> h) xin = -hn <> gn cvg = maxabsratio dp p < ptol || maxabsratio' (fpn `max` 1) gn p < gtol -- Generate error messages for NaN production in function and gradient -- calculations. -- nanMsg :: Point -> Maybe Double -> Maybe Gradient -> String nanMsg p fval grad = "NaNs produced: p = " ++ show p ++ maybe "" ((" fval = " ++) . show) fval ++ maybe "" ((" grad = " ++) . show) grad -------------------------------------------------------------------------------- -- -- LINE SEARCH -- -- Options for line search routine: point tolerance, "acceptable -- decrease" parameter. -- data LineSearchOpts = LineSearchOpts { xtol :: Double , alpha :: Double } deriving Show instance Default LineSearchOpts where def = LineSearchOpts 1.0E-7 1.0E-4 -- Maximum line search step length. -- maxStep :: Point -> Double maxStep p0 = (100 * (norm p0 `max` n)) where n = fromIntegral (dim p0) -- Line search with default parameters. -- lineSearch :: Fn -> Point -> Double -> Gradient -> Direction -> Double -> Either String (Point, Double) lineSearch = lineSearchWith def -- Main line search routine. This is kind of nasty to translate into -- functional form because of the switching about between the -- quadratic and cubic approximations. It works, but it could be -- prettier. -- lineSearchWith :: LineSearchOpts -> Fn -> Point -> Double -> Gradient -> Direction -> Double -> Either String (Point, Double) lineSearchWith (LineSearchOpts xtol alpha) func xold fold g pin stpmax = go 1.0 Nothing where p = if pinnorm > stpmax then (stpmax/pinnorm) `scale` pin else pin pinnorm = norm pin slope = g `dot` p lammin = xtol / (maxabsratio p xold) go :: Double -> Maybe (Double,Double) -> Either String (Point,Double) go lam pass = if hasnan fnew then Left $ nanMsg xnew (Just fnew) Nothing else case check xnew fnew of Just xandf -> Right xandf Nothing -> case pass of -- First time. Nothing -> go (lambound $ quadlam fnew) $ Just (lam,fnew) -- Subsequent times. Just val2 -> case cubiclam fnew val2 of Right newlam -> go (lambound newlam) $ Just (lam,fnew) Left err -> Left err where xnew = xold + lam `scale` p fnew = func xnew -- Check for convergence or a "sufficiently large" step. check :: Vector Double -> Double -> Maybe (Vector Double,Double) check x f = if lam < lammin then Just (xold,fold) else if f <= fold + alpha * lam * slope then Just (x,f) else Nothing -- Keep step length within bounds. lambound lam' = max (0.1 * lam) (min lam' (0.5 * lam)) -- Quadratic and cubic approximations to better step -- value. quadlam fnew = -slope / (2 * (fnew - fold - slope)) cubiclam fnew (lam2,f2) = if a == 0 then Right (-slope / (2 * b)) else if disc < 0 then Left "Roundoff problem in lineSearch" else Right $ (-b + sqrt disc) / (3 * a) where rhs1 = fnew - fold - lam * slope rhs2 = f2 - fold - lam2 * slope a = (rhs1 / lam^2 - rhs2 / lam2^2) / (lam - lam2) b = (-lam2 * rhs1 / lam^2 + lam * rhs2 / lam2^2) / (lam - lam2) disc = b^2 - 3 * a * slope -- Utility functions for ratio testing. -- absratio :: Double -> Double -> Double absratio n d = abs n / (abs d `max` 1) absratio' :: Double -> Double -> Double -> Double absratio' scale n d = abs n / (abs d `max` 1) / scale maxabsratio :: Vector Double -> Vector Double -> Double maxabsratio n d = maxElement $ zipVectorWith absratio n d maxabsratio' :: Double -> Vector Double -> Vector Double -> Double maxabsratio' scale n d = maxElement $ zipVectorWith (absratio' scale) n d -------------------------------------------------------------------------------- -- -- TEST FUNCTIONS -- -- Simple test function. Minimum at (3,4): -- -- *BFGS> bfgs tstf1 tstgrad1 (fromList [-10,-10]) -- Right (fromList [3.0,4.0]) -- tstf1 :: Fn tstf1 p = (x-3)^2 + (y-4)^2 where [x,y] = toList p tstgrad1 :: GradFn tstgrad1 p = fromList [2*(x-3),2*(y-4)] where [x,y] = toList p -- Rosenbrock's function. Minimum at (1,1): -- -- *BFGS> bfgs tstf2 tstgrad2 (fromList [-10,-10]) -- Right (fromList [0.9999999992103538,0.9999999985219549]) tstf2 :: Fn tstf2 p = (1-x)^2 + 100*(y-x^2)^2 where [x,y] = toList p tstgrad2 :: GradFn tstgrad2 p = fromList [2*(x-1) - 400*x*(y-x^2), 200*(y-x^2)] where [x,y] = toList p -- Test function from Numerical Recipes. Minimum at (-2.0,0.89442719): -- -- *BFGS> bfgs tstfnr tstgradnr nrp0 -- Right (fromList [-1.9999999564447526,0.8944271925873616]) tstfnr :: Fn tstfnr p = 10*(y^2*(3-x)-x^2*(3+x))^2+(2+x)^2/(1+(2+x)^2) where [x,y] = toList p tstgradnr :: GradFn tstgradnr p = fromList [20*(y^2*x3m-x^2*x3p)*(-y^2-6*x-3*x^2)+ 2*x2p/(1+x2p^2)-2*x2p^3/(1+x2p^2)^2, 40*(y^2*x3m-x^2*x3p)*y*x3m] where [x,y] = toList p x3m = 3 - x x3p = 3 + x x2p = 2 + x nrp0 :: Point nrp0 = fromList [0.1,4.2] -- Test function to check NaN handling. -- -- *BFGS> bfgs nantstf nantstgrad (fromList [-10,-10]) -- Left "function application returned NaN" nantstf :: Fn nantstf p = log x + (x-3)^2 + (y-4)^2 where [x,y] = toList p nantstgrad :: GradFn nantstgrad p = fromList [1/x+2*(x-3),2*(y-4)] where [x,y] = toList p
glutamate/probably
Math/Probably/BFGS.hs
bsd-3-clause
10,481
0
23
3,129
3,235
1,759
1,476
171
10
{-# LANGUAGE MultiParamTypeClasses, TypeOperators #-} module SeqZip where import Data.Monoid import Data.List.Split import qualified Data.Sequence as S import Control.Applicative import Control.Monad.State import Control.Comonad import Debug.Trace data b :>: a = b :>: a deriving (Show, Eq, Ord) instance Functor ((:>:) b) where fmap f (b :>: a) = b :>: f a data Top = Top deriving (Show) --type families could give "split" type. type Layer0 a = Top :>: a type Layer1 a = S.Seq a :>: a type Layer2 a = (S.Seq (S.Seq a)) :>: S.Seq a :>: a combine as a as' = as S.>< (S.singleton a) S.>< as' upOne ((c :>: (b, b')) :>: a) = c :>: combine b a b' downOne (c :>: a) = (c :>: (S.empty, S.drop 1 a)) :>: (S.index a 0) downOver i (c :>: a) = (c :>: (S.take i a, S.drop (i+1) a)) :>: (S.index a i) zipRight 0 z = z zipRight i z@((c :>: (as, as')) :>: a) = case i <= S.length as' of True -> (c :>: (combine as a (S.take (i-1) as'), S.drop i as')) :>: S.index as' (i-1) False -> zipRight (S.length as') z remainingLeft ((c :>: (as, as')) :>: a) = S.length as remainingRight ((c :>: (as, as')) :>: a) = S.length as' unzipper :: (Top :>: a) -> a unzipper (_ :>: a) = a getTip (c :>: tip) = tip getsTip f (c :>: a) = f a zipper as = Top :>: as modifyWith :: (b :>: a) -> (a -> a) -> (b :>: a) modifyWith (as :>: a) f = as :>: (f a) modifyWithM :: (Monad m) => (b :>: a) -> (a -> m a) -> m (b :>: a) modifyWithM (as :>: a) f = do a' <- f a return $ as :>: a' skipOne = zipRight 1
nsmryan/Misc
src/SeqZip.hs
bsd-3-clause
1,587
0
16
428
822
441
381
41
2
{-# LANGUAGE Rank2Types, BangPatterns, ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- | -- Module : Numeric.AD.Halley -- Copyright : (c) Edward Kmett 2010 -- License : BSD3 -- Maintainer : [email protected] -- Stability : experimental -- Portability : GHC only -- -- Root finding using Halley's rational method (the second in -- the class of Householder methods). Assumes the function is three -- times continuously differentiable and converges cubically when -- progress can be made. -- ----------------------------------------------------------------------------- module Numeric.AD.Halley ( -- * Halley's Method (Tower AD) findZero , inverse , fixedPoint , extremum ) where import Prelude hiding (all) import Numeric.AD.Types import Numeric.AD.Mode.Tower (diffs0) import Numeric.AD.Mode.Forward (diff) -- , diff') import Numeric.AD.Internal.Composition -- | The 'findZero' function finds a zero of a scalar function using -- Halley's method; its output is a stream of increasingly accurate -- results. (Modulo the usual caveats.) If the stream becomes constant -- ("it converges"), no further elements are returned. -- -- Examples: -- -- >>> take 10 $ findZero (\x->x^2-4) 1 -- [1.0,1.8571428571428572,1.9997967892704736,1.9999999999994755,2.0] -- -- >>> import Data.Complex -- >>> last $ take 10 $ findZero ((+1).(^2)) (1 :+ 1) -- 0.0 :+ 1.0 findZero :: (Fractional a, Eq a) => (forall s. Mode s => AD s a -> AD s a) -> a -> [a] findZero f = go where go x = x : if x == xn then [] else go xn where (y:y':y'':_) = diffs0 f x xn = x - 2*y*y'/(2*y'*y'-y*y'') {-# INLINE findZero #-} -- | The 'inverse' function inverts a scalar function using -- Halley's method; its output is a stream of increasingly accurate -- results. (Modulo the usual caveats.) If the stream becomes constant -- ("it converges"), no further elements are returned. -- -- Note: the @take 10 $ inverse sqrt 1 (sqrt 10)@ example that works for Newton's method -- fails with Halley's method because the preconditions do not hold! inverse :: (Fractional a, Eq a) => (forall s. Mode s => AD s a -> AD s a) -> a -> a -> [a] inverse f x0 y = findZero (\x -> f x - lift y) x0 {-# INLINE inverse #-} -- | The 'fixedPoint' function find a fixedpoint of a scalar -- function using Halley's method; its output is a stream of -- increasingly accurate results. (Modulo the usual caveats.) -- -- If the stream becomes constant ("it converges"), no further -- elements are returned. -- -- >>> last $ take 10 $ fixedPoint cos 1 -- 0.7390851332151607 fixedPoint :: (Fractional a, Eq a) => (forall s. Mode s => AD s a -> AD s a) -> a -> [a] fixedPoint f = findZero (\x -> f x - x) {-# INLINE fixedPoint #-} -- | The 'extremum' function finds an extremum of a scalar -- function using Halley's method; produces a stream of increasingly -- accurate results. (Modulo the usual caveats.) If the stream becomes -- constant ("it converges"), no further elements are returned. -- -- >>> take 10 $ extremum cos 1 -- [1.0,0.29616942658570555,4.59979519460002e-3,1.6220740159042513e-8,0.0] extremum :: (Fractional a, Eq a) => (forall s. Mode s => AD s a -> AD s a) -> a -> [a] extremum f = findZero (diff (decomposeMode . f . composeMode)) {-# INLINE extremum #-}
yairchu/ad
src/Numeric/AD/Halley.hs
bsd-3-clause
3,334
0
14
611
565
328
237
27
2
{-# LANGUAGE RecordWildCards #-} module Sound.Sequencer.Vty where import Sound.Sequencer.Editor import Sound.Sequencer.Sequencer import Data.Char import Data.Maybe import Graphics.Vty import Control.Monad rootImage :: Editor -> Int -> Image rootImage Editor{..} h = renderPatternList Editor{..} <|> charFill defAttr ' ' 1 h <|> charFill defAttr '|' 1 h <|> pad 2 1 1 1 (translateY (if h > imageHeight pattern then 0 else scroll - snd cursorY) pattern) where pattern = foldr1 (<|>) $ (renderIndex : [ renderChannel i | i <- [0 .. numChannels-1]]) <*> pure Editor{..} numChannels = length $ head (snd $ patterns sqncr !! fst cursorY) scroll = floor (fromIntegral h / 4) renderIndex :: Editor -> Image renderIndex Editor{..} = pad 0 0 2 0 $ foldr1 (<->) [ row i | i <- [1 .. length curPat]] where curPat = snd $ patterns sqncr !! fst cursorY row i = string (defAttr `withForeColor` brightYellow) (replicate (4 - length (show i)) '0' ++ show i) renderChannel :: Int -> Editor -> Image renderChannel ch Editor{..} = pad 1 0 1 0 $ foldr1 (<->) [ renderCell Editor{..} ch i | i <- [0 .. length curPat - 1]] where curPat = snd $ patterns sqncr !! fst cursorY renderPatternList :: Editor -> Image renderPatternList Editor{..} = pad 1 1 1 0 $ resizeWidth 10 $ foldr1 (<->) (f <$> zip (fst <$> patterns sqncr) [0 .. numPat]) where f (n,c) = string ((if c == fst cursorY then flip withStyle reverseVideo else id) defAttr) n numPat = length $ patterns sqncr renderCell :: Editor -> Int -> Int -> Image renderCell Editor{..} ch i = string (w NoteCol brightWhite) (maybe "..." show (note cell)) <|> string defAttr " " <|> (string (w InsCol16 cyan) (print16th $ instrument cell)) <|> (string (w InsCol1 cyan) (print1st $ instrument cell)) <|> string defAttr " " <|> (string (w VolCol16 green) (print16th $ volume cell)) <|> (string (w VolCol1 green) (print1st $ volume cell)) <|> string defAttr " " <|> (string (w ETCol yellow) (print1st $ effectType cell)) <|> (string (w EPCol16 magenta) (print16th $ effectParam cell)) <|> (string (w EPCol1 magenta) (print1st $ effectParam cell)) <|> string defAttr " " where cell = snd (patterns sqncr !! fst cursorY) !! i !! ch w c t = (if cursorX == (ch, c) && snd cursorY == i then se else id) $ defAttr `withForeColor` t se x = if playing sqncr then x `withStyle` reverseVideo else x `withBackColor` red print1st a = if isNothing a then "." else [ intToDigit . fromIntegral $ fromJust a `mod` 16 ] print16th a = if isNothing a then "." else [ intToDigit . fromIntegral $ fromJust a `div` 16 ] run :: Editor -> IO () run ed = do cfg <- standardIOConfig vty <- mkVty cfg mainLoop vty ed shutdown vty mainLoop :: Vty -> Editor -> IO () mainLoop vty Editor{..} = do bounds <- displayBounds $ outputIface vty update vty $ picForImage $ rootImage Editor{..} (snd bounds) when running (fmap (handleEvents Editor{..}) (nextEvent vty) >>= mainLoop vty) handleEvents :: Editor -> Event -> Editor handleEvents ed@Editor{..} ev = case ev of EvKey KEsc [] -> e Quit EvKey (KFun i) [] -> e (SelectOctave i) EvKey (KChar '+') [] -> e AddRow EvKey (KChar '-') [] -> e RemoveRow EvKey (KChar c) [] -> e (Edit c) EvKey KDel [] -> e (Edit '\DEL') EvKey KUp [] -> e MoveUp EvKey KUp [MCtrl] -> e JumpUp EvKey KDown [] -> e MoveDown EvKey KDown [MCtrl] -> e JumpDown EvKey KRight [] -> e MoveRight EvKey KRight [MCtrl] -> e JumpRight EvKey KLeft [] -> e MoveLeft EvKey KLeft [MCtrl] -> e JumpLeft _ -> ed where e = edit ed
riottracker/sequencer
src/Sound/Sequencer/Vty.hs
bsd-3-clause
4,153
0
20
1,344
1,638
819
819
76
15
{-# LANGUAGE ConstraintKinds , EmptyDataDecls , FlexibleContexts , FlexibleInstances , FunctionalDependencies , GADTs , MultiParamTypeClasses , OverloadedStrings , UndecidableInstances , ScopedTypeVariables , InstanceSigs #-} -- | This is an internal module, anything exported by this module -- may change without a major version bump. Please use only -- "Database.Esqueleto" if possible. module Database.Esqueleto.Internal.Sql ( -- * The pretty face SqlQuery , SqlExpr , SqlEntity , select , selectSource , selectDistinct , selectDistinctSource , delete , deleteCount , update , updateCount , insertSelectDistinct , insertSelect -- * The guts , unsafeSqlCase , unsafeSqlBinOp , unsafeSqlBinOpComposite , unsafeSqlValue , unsafeSqlFunction , unsafeSqlExtractSubField , UnsafeSqlFunctionArgument , rawSelectSource , runSource , rawEsqueleto , toRawSql , Mode(..) , IdentState , initialIdentState , IdentInfo , SqlSelect(..) , veryUnsafeCoerceSqlExprValue , veryUnsafeCoerceSqlExprValueList ) where import Control.Applicative (Applicative(..), (<$>), (<$)) import Control.Arrow ((***), first) import Control.Exception (throw, throwIO) import Control.Monad (ap, MonadPlus(..), liftM) import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.Class (lift) import qualified Control.Monad.Trans.Reader as R import Data.Int (Int64) import Data.List (intersperse) import Data.Monoid (Last(..), Monoid(..), (<>)) import Data.Proxy (Proxy(..)) import Database.Esqueleto.Internal.PersistentImport import Database.Persist.Sql.Util ( entityColumnNames, entityColumnCount, parseEntityValues, isIdField , hasCompositeKey) import qualified Control.Monad.Trans.State as S import qualified Control.Monad.Trans.Writer as W import qualified Data.Conduit as C import qualified Data.Conduit.List as CL import qualified Data.HashSet as HS import qualified Data.Text as T import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Builder as TLB import Data.Acquire (with, allocateAcquire, Acquire) import Control.Monad.Trans.Resource (MonadResource) import Database.Esqueleto.Internal.Language -- | SQL backend for @esqueleto@ using 'SqlPersistT'. newtype SqlQuery a = Q { unQ :: W.WriterT SideData (S.State IdentState) a } instance Functor SqlQuery where fmap f = Q . fmap f . unQ instance Monad SqlQuery where return = Q . return m >>= f = Q (unQ m >>= unQ . f) instance Applicative SqlQuery where pure = return (<*>) = ap -- | Constraint synonym for @persistent@ entities whose backend -- is 'SqlPersistT'. type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend) ---------------------------------------------------------------------- -- | Side data written by 'SqlQuery'. data SideData = SideData { sdDistinctClause :: !DistinctClause , sdFromClause :: ![FromClause] , sdSetClause :: ![SetClause] , sdWhereClause :: !WhereClause , sdGroupByClause :: !GroupByClause , sdHavingClause :: !HavingClause , sdOrderByClause :: ![OrderByClause] , sdLimitClause :: !LimitClause , sdLockingClause :: !LockingClause } instance Monoid SideData where mempty = SideData mempty mempty mempty mempty mempty mempty mempty mempty mempty SideData d f s w g h o l k `mappend` SideData d' f' s' w' g' h' o' l' k' = SideData (d <> d') (f <> f') (s <> s') (w <> w') (g <> g') (h <> h') (o <> o') (l <> l') (k <> k') -- | The @DISTINCT@ "clause". data DistinctClause = DistinctAll -- ^ The default, everything. | DistinctStandard -- ^ Only @DISTINCT@, SQL standard. | DistinctOn [SqlExpr DistinctOn] -- ^ @DISTINCT ON@, PostgreSQL extension. instance Monoid DistinctClause where mempty = DistinctAll DistinctOn a `mappend` DistinctOn b = DistinctOn (a <> b) DistinctOn a `mappend` _ = DistinctOn a DistinctStandard `mappend` _ = DistinctStandard DistinctAll `mappend` b = b -- | A part of a @FROM@ clause. data FromClause = FromStart Ident EntityDef | FromJoin FromClause JoinKind FromClause (Maybe (SqlExpr (Value Bool))) | OnClause (SqlExpr (Value Bool)) -- | A part of a @SET@ clause. newtype SetClause = SetClause (SqlExpr (Value ())) -- | Collect 'OnClause's on 'FromJoin's. Returns the first -- unmatched 'OnClause's data on error. Returns a list without -- 'OnClauses' on success. collectOnClauses :: [FromClause] -> Either (SqlExpr (Value Bool)) [FromClause] collectOnClauses = go [] where go [] (f@(FromStart _ _):fs) = fmap (f:) (go [] fs) -- fast path go acc (OnClause expr :fs) = findMatching acc expr >>= flip go fs go acc (f:fs) = go (f:acc) fs go acc [] = return $ reverse acc findMatching (f : acc) expr = case tryMatch expr f of Just f' -> return (f' : acc) Nothing -> (f:) <$> findMatching acc expr findMatching [] expr = Left expr tryMatch expr (FromJoin l k r onClause) = matchR `mplus` matchC `mplus` matchL -- right to left where matchR = (\r' -> FromJoin l k r' onClause) <$> tryMatch expr r matchL = (\l' -> FromJoin l' k r onClause) <$> tryMatch expr l matchC = case onClause of Nothing | k /= CrossJoinKind -> return (FromJoin l k r (Just expr)) | otherwise -> mzero Just _ -> mzero tryMatch _ _ = mzero -- | A complete @WHERE@ clause. data WhereClause = Where (SqlExpr (Value Bool)) | NoWhere instance Monoid WhereClause where mempty = NoWhere NoWhere `mappend` w = w w `mappend` NoWhere = w Where e1 `mappend` Where e2 = Where (e1 &&. e2) -- | A @GROUP BY@ clause. newtype GroupByClause = GroupBy [SomeValue SqlExpr] instance Monoid GroupByClause where mempty = GroupBy [] GroupBy fs `mappend` GroupBy fs' = GroupBy (fs <> fs') -- | A @HAVING@ cause. type HavingClause = WhereClause -- | A @ORDER BY@ clause. type OrderByClause = SqlExpr OrderBy -- | A @LIMIT@ clause. data LimitClause = Limit (Maybe Int64) (Maybe Int64) instance Monoid LimitClause where mempty = Limit mzero mzero Limit l1 o1 `mappend` Limit l2 o2 = Limit (l2 `mplus` l1) (o2 `mplus` o1) -- More than one 'limit' or 'offset' is issued, we want to -- keep the latest one. That's why we use mplus with -- "reversed" arguments. -- | A locking clause. type LockingClause = Last LockingKind ---------------------------------------------------------------------- -- | Identifier used for table names. newtype Ident = I T.Text -- | List of identifiers already in use and supply of temporary -- identifiers. newtype IdentState = IdentState { inUse :: HS.HashSet T.Text } initialIdentState :: IdentState initialIdentState = IdentState mempty -- | Create a fresh 'Ident'. If possible, use the given -- 'DBName'. newIdentFor :: DBName -> SqlQuery Ident newIdentFor = Q . lift . try . unDBName where try orig = do s <- S.get let go (t:ts) | t `HS.member` inUse s = go ts | otherwise = use t go [] = error "Esqueleto/Sql/newIdentFor: never here" go (possibilities orig) possibilities t = t : map addNum [2..] where addNum :: Int -> T.Text addNum = T.append t . T.pack . show use t = do S.modify (\s -> s { inUse = HS.insert t (inUse s) }) return (I t) -- | Information needed to escape and use identifiers. type IdentInfo = (SqlBackend, IdentState) -- | Use an identifier. useIdent :: IdentInfo -> Ident -> TLB.Builder useIdent info (I ident) = fromDBName info $ DBName ident ---------------------------------------------------------------------- -- | An expression on the SQL backend. -- -- There are many comments describing the constructors of this -- data type. However, Haddock doesn't like GADTs, so you'll have to read them by hitting \"Source\". data SqlExpr a where -- An entity, created by 'from' (cf. 'fromStart'). EEntity :: Ident -> SqlExpr (Entity val) -- Just a tag stating that something is nullable. EMaybe :: SqlExpr a -> SqlExpr (Maybe a) -- Raw expression: states whether parenthesis are needed -- around this expression, and takes information about the SQL -- connection (mainly for escaping names) and returns both an -- string ('TLB.Builder') and a list of values to be -- interpolated by the SQL backend. ERaw :: NeedParens -> (IdentInfo -> (TLB.Builder, [PersistValue])) -> SqlExpr (Value a) -- A composite key. -- -- Persistent uses the same 'PersistList' constructor for both -- fields which are (homogeneous) lists of values and the -- (probably heterogeneous) values of a composite primary key. -- -- We need to treat composite keys as fields. For example, we -- have to support using ==., otherwise you wouldn't be able to -- join. OTOH, lists of values should be treated exactly the -- same as any other scalar value. -- -- In particular, this is valid for persistent via rawSql for -- an F field that is a list: -- -- A.F in ? -- [PersistList [foo, bar]] -- -- However, this is not for a composite key entity: -- -- A.ID = ? -- [PersistList [foo, bar]] -- -- The ID field doesn't exist on the DB for a composite key -- table, it exists only on the Haskell side. Those variations -- also don't work: -- -- (A.KeyA, A.KeyB) = ? -- [PersistList [foo, bar]] -- [A.KeyA, A.KeyB] = ? -- [PersistList [foo, bar]] -- -- We have to generate: -- -- A.KeyA = ? AND A.KeyB = ? -- [foo, bar] -- -- Note that the PersistList had to be deconstructed into its -- components. -- -- In order to disambiguate behaviors, this constructor is used -- /only/ to represent a composite field access. It does not -- represent a 'PersistList', not even if the 'PersistList' is -- used in the context of a composite key. That's because it's -- impossible, e.g., for 'val' to disambiguate between these -- uses. ECompositeKey :: (IdentInfo -> [TLB.Builder]) -> SqlExpr (Value a) -- 'EList' and 'EEmptyList' are used by list operators. EList :: SqlExpr (Value a) -> SqlExpr (ValueList a) EEmptyList :: SqlExpr (ValueList a) -- A 'SqlExpr' accepted only by 'orderBy'. EOrderBy :: OrderByType -> SqlExpr (Value a) -> SqlExpr OrderBy EOrderRandom :: SqlExpr OrderBy -- A 'SqlExpr' accepted only by 'distinctOn'. EDistinctOn :: SqlExpr (Value a) -> SqlExpr DistinctOn -- A 'SqlExpr' accepted only by 'set'. ESet :: (SqlExpr (Entity val) -> SqlExpr (Value ())) -> SqlExpr (Update val) -- An internal 'SqlExpr' used by the 'from' hack. EPreprocessedFrom :: a -> FromClause -> SqlExpr (PreprocessedFrom a) -- Used by 'insertSelect'. EInsert :: Proxy a -> (IdentInfo -> (TLB.Builder, [PersistValue])) -> SqlExpr (Insertion a) EInsertFinal :: PersistEntity a => SqlExpr (Insertion a) -> SqlExpr InsertFinal -- | Phantom type used to mark a @INSERT INTO@ query. data InsertFinal data NeedParens = Parens | Never parensM :: NeedParens -> TLB.Builder -> TLB.Builder parensM Never = id parensM Parens = parens data OrderByType = ASC | DESC instance Esqueleto SqlQuery SqlExpr SqlBackend where fromStart = x where x = do let ed = entityDef (getVal x) ident <- newIdentFor (entityDB ed) let ret = EEntity ident from_ = FromStart ident ed return (EPreprocessedFrom ret from_) getVal :: SqlQuery (SqlExpr (PreprocessedFrom (SqlExpr (Entity a)))) -> Proxy a getVal = const Proxy fromStartMaybe = maybelize <$> fromStart where maybelize :: SqlExpr (PreprocessedFrom (SqlExpr (Entity a))) -> SqlExpr (PreprocessedFrom (SqlExpr (Maybe (Entity a)))) maybelize (EPreprocessedFrom ret from_) = EPreprocessedFrom (EMaybe ret) from_ fromJoin (EPreprocessedFrom lhsRet lhsFrom) (EPreprocessedFrom rhsRet rhsFrom) = Q $ do let ret = smartJoin lhsRet rhsRet from_ = FromJoin lhsFrom -- LHS (reifyJoinKind ret) -- JOIN rhsFrom -- RHS Nothing -- ON return (EPreprocessedFrom ret from_) fromFinish (EPreprocessedFrom ret from_) = Q $ do W.tell mempty { sdFromClause = [from_] } return ret where_ expr = Q $ W.tell mempty { sdWhereClause = Where expr } on expr = Q $ W.tell mempty { sdFromClause = [OnClause expr] } groupBy expr = Q $ W.tell mempty { sdGroupByClause = GroupBy $ toSomeValues expr } having expr = Q $ W.tell mempty { sdHavingClause = Where expr } locking kind = Q $ W.tell mempty { sdLockingClause = Last (Just kind) } orderBy exprs = Q $ W.tell mempty { sdOrderByClause = exprs } asc = EOrderBy ASC desc = EOrderBy DESC rand = EOrderRandom limit n = Q $ W.tell mempty { sdLimitClause = Limit (Just n) Nothing } offset n = Q $ W.tell mempty { sdLimitClause = Limit Nothing (Just n) } distinct act = Q (W.tell mempty { sdDistinctClause = DistinctStandard }) >> act distinctOn exprs act = Q (W.tell mempty { sdDistinctClause = DistinctOn exprs }) >> act don = EDistinctOn distinctOnOrderBy exprs act = distinctOn (toDistinctOn <$> exprs) $ do orderBy exprs act where toDistinctOn :: SqlExpr OrderBy -> SqlExpr DistinctOn toDistinctOn (EOrderBy _ f) = EDistinctOn f sub_select = sub SELECT sub_selectDistinct = sub_select . distinct (^.) :: forall val typ. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ) EEntity ident ^. field | isComposite = ECompositeKey $ \info -> dot info <$> compositeFields pdef | otherwise = ERaw Never $ \info -> (dot info $ persistFieldDef field, []) where isComposite = isIdField field && hasCompositeKey ed dot info x = useIdent info ident <> "." <> fromDBName info (fieldDB x) ed = entityDef $ getEntityVal (Proxy :: Proxy (SqlExpr (Entity val))) Just pdef = entityPrimary ed EMaybe r ?. field = just (r ^. field) val v = ERaw Never $ const ("?", [toPersistValue v]) isNothing (ERaw p f) = ERaw Parens $ first ((<> " IS NULL") . parensM p) . f isNothing (ECompositeKey f) = ERaw Parens $ flip (,) [] . (intersperseB " AND " . map (<> " IS NULL")) . f just (ERaw p f) = ERaw p f just (ECompositeKey f) = ECompositeKey f nothing = unsafeSqlValue "NULL" joinV (ERaw p f) = ERaw p f joinV (ECompositeKey f) = ECompositeKey f countRows = unsafeSqlValue "COUNT(*)" count (ERaw _ f) = ERaw Never $ \info -> let (b, vals) = f info in ("COUNT" <> parens b, vals) count (ECompositeKey _) = unsafeSqlValue "COUNT(*)" -- Assumes no NULLs on a PK not_ (ERaw p f) = ERaw Never $ \info -> let (b, vals) = f info in ("NOT " <> parensM p b, vals) not_ (ECompositeKey _) = unexpectedCompositeKeyError "not_" (==.) = unsafeSqlBinOpComposite " = " " AND " (!=.) = unsafeSqlBinOpComposite " != " " OR " (>=.) = unsafeSqlBinOp " >= " (>.) = unsafeSqlBinOp " > " (<=.) = unsafeSqlBinOp " <= " (<.) = unsafeSqlBinOp " < " (&&.) = unsafeSqlBinOp " AND " (||.) = unsafeSqlBinOp " OR " (+.) = unsafeSqlBinOp " + " (-.) = unsafeSqlBinOp " - " (/.) = unsafeSqlBinOp " / " (*.) = unsafeSqlBinOp " * " random_ = unsafeSqlValue "RANDOM()" round_ = unsafeSqlFunction "ROUND" ceiling_ = unsafeSqlFunction "CEILING" floor_ = unsafeSqlFunction "FLOOR" sum_ = unsafeSqlFunction "SUM" min_ = unsafeSqlFunction "MIN" max_ = unsafeSqlFunction "MAX" avg_ = unsafeSqlFunction "AVG" castNum = veryUnsafeCoerceSqlExprValue castNumM = veryUnsafeCoerceSqlExprValue coalesce = unsafeSqlFunctionParens "COALESCE" coalesceDefault exprs = unsafeSqlFunctionParens "COALESCE" . (exprs ++) . return . just lower_ = unsafeSqlFunction "LOWER" like = unsafeSqlBinOp " LIKE " ilike = unsafeSqlBinOp " ILIKE " (%) = unsafeSqlValue "'%'" concat_ = unsafeSqlFunction "CONCAT" (++.) = unsafeSqlBinOp " || " subList_select = EList . sub_select subList_selectDistinct = subList_select . distinct valList [] = EEmptyList valList vals = EList $ ERaw Parens $ const ( uncommas ("?" <$ vals) , map toPersistValue vals ) v `in_` e = ifNotEmptyList e False $ unsafeSqlBinOp " IN " v (veryUnsafeCoerceSqlExprValueList e) v `notIn` e = ifNotEmptyList e True $ unsafeSqlBinOp " NOT IN " v (veryUnsafeCoerceSqlExprValueList e) exists = unsafeSqlFunction "EXISTS " . existsHelper notExists = unsafeSqlFunction "NOT EXISTS " . existsHelper set ent upds = Q $ W.tell mempty { sdSetClause = map apply upds } where apply (ESet f) = SetClause (f ent) field =. expr = setAux field (const expr) field +=. expr = setAux field (\ent -> ent ^. field +. expr) field -=. expr = setAux field (\ent -> ent ^. field -. expr) field *=. expr = setAux field (\ent -> ent ^. field *. expr) field /=. expr = setAux field (\ent -> ent ^. field /. expr) (<#) _ (ERaw _ f) = EInsert Proxy f (<#) _ (ECompositeKey _) = unexpectedCompositeKeyError "(<#)" (EInsert _ f) <&> (ERaw _ g) = EInsert Proxy $ \x -> let (fb, fv) = f x (gb, gv) = g x in (fb <> ", " <> gb, fv ++ gv) (EInsert _ _) <&> (ECompositeKey _) = unexpectedCompositeKeyError "(<&>)" case_ = unsafeSqlCase instance ToSomeValues SqlExpr (SqlExpr (Value a)) where toSomeValues a = [SomeValue a] fieldName :: (PersistEntity val, PersistField typ) => IdentInfo -> EntityField val typ -> TLB.Builder fieldName info = fromDBName info . fieldDB . persistFieldDef -- FIXME: Composite/non-id pKS not supported on set setAux :: (PersistEntity val, PersistField typ) => EntityField val typ -> (SqlExpr (Entity val) -> SqlExpr (Value typ)) -> SqlExpr (Update val) setAux field mkVal = ESet $ \ent -> unsafeSqlBinOp " = " name (mkVal ent) where name = ERaw Never $ \info -> (fieldName info field, mempty) sub :: PersistField a => Mode -> SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a) sub mode query = ERaw Parens $ \info -> toRawSql mode info query fromDBName :: IdentInfo -> DBName -> TLB.Builder fromDBName (conn, _) = TLB.fromText . connEscapeName conn existsHelper :: SqlQuery () -> SqlExpr (Value Bool) existsHelper = sub SELECT . (>> return true) where true :: SqlExpr (Value Bool) true = val True ifNotEmptyList :: SqlExpr (ValueList a) -> Bool -> SqlExpr (Value Bool) -> SqlExpr (Value Bool) ifNotEmptyList EEmptyList b _ = val b ifNotEmptyList (EList _) _ x = x ---------------------------------------------------------------------- -- | (Internal) Create a case statement. -- -- Since: 2.1.1 unsafeSqlCase :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a) unsafeSqlCase when (ERaw p1 f1) = ERaw Never buildCase where buildCase :: IdentInfo -> (TLB.Builder, [PersistValue]) buildCase info = let (b1, vals1) = f1 info (b2, vals2) = mapWhen when info in ( "CASE" <> b2 <> " ELSE " <> parensM p1 b1 <> " END", vals2 <> vals1) mapWhen :: [(SqlExpr (Value Bool), SqlExpr (Value a))] -> IdentInfo -> (TLB.Builder, [PersistValue]) mapWhen [] _ = error "unsafeSqlCase: empty when list." mapWhen when' info = foldl (foldHelp info) (mempty, mempty) when' foldHelp :: IdentInfo -> (TLB.Builder, [PersistValue]) -> (SqlExpr (Value Bool), SqlExpr (Value a)) -> (TLB.Builder, [PersistValue]) foldHelp info (b0, vals0) (ERaw p1' f1', ERaw p2 f2) = let (b1, vals1) = f1' info (b2, vals2) = f2 info in ( b0 <> " WHEN " <> parensM p1' b1 <> " THEN " <> parensM p2 b2, vals0 <> vals1 <> vals2 ) foldHelp _ _ _ = unexpectedCompositeKeyError "unsafeSqlCase/foldHelp" unsafeSqlCase _ (ECompositeKey _) = unexpectedCompositeKeyError "unsafeSqlCase" -- | (Internal) Create a custom binary operator. You /should/ -- /not/ use this function directly since its type is very -- general, you should always use it with an explicit type -- signature. For example: -- -- @ -- (==.) :: SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value Bool) -- (==.) = unsafeSqlBinOp " = " -- @ -- -- In the example above, we constraint the arguments to be of the -- same type and constraint the result to be a boolean value. unsafeSqlBinOp :: TLB.Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c) unsafeSqlBinOp op (ERaw p1 f1) (ERaw p2 f2) = ERaw Parens f where f info = let (b1, vals1) = f1 info (b2, vals2) = f2 info in ( parensM p1 b1 <> op <> parensM p2 b2 , vals1 <> vals2 ) unsafeSqlBinOp _ _ _ = unexpectedCompositeKeyError "unsafeSqlBinOp" {-# INLINE unsafeSqlBinOp #-} -- | Similar to 'unsafeSqlBinOp', but may also be applied to -- composite keys. Uses the operator given as the second -- argument whenever applied to composite keys. -- -- Usage example: -- -- @ -- (==.) :: SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value Bool) -- (==.) = unsafeSqlBinOpComposite " = " " AND " -- @ -- -- Persistent has a hack for implementing composite keys (see -- 'ECompositeKey' doc for more details), so we're forced to use -- a hack here as well. We deconstruct 'ERaw' values based on -- two rules: -- -- - If it is a single placeholder, then it's assumed to be -- coming from a 'PersistList' and thus its components are -- separated so that they may be applied to a composite key. -- -- - If it is not a single placeholder, then it's assumed to be -- a foreign (composite or not) key, so we enforce that it has -- no placeholders and split it on the commas. unsafeSqlBinOpComposite :: TLB.Builder -> TLB.Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c) unsafeSqlBinOpComposite op _ a@(ERaw _ _) b@(ERaw _ _) = unsafeSqlBinOp op a b unsafeSqlBinOpComposite op sep a b = ERaw Parens $ compose (listify a) (listify b) where listify :: SqlExpr (Value x) -> IdentInfo -> ([TLB.Builder], [PersistValue]) listify (ECompositeKey f) = flip (,) [] . f listify (ERaw _ f) = deconstruct . f deconstruct :: (TLB.Builder, [PersistValue]) -> ([TLB.Builder], [PersistValue]) deconstruct ("?", [PersistList vals]) = (replicate (length vals) "?", vals) deconstruct (b, []) = (TLB.fromLazyText <$> TL.splitOn "," (TLB.toLazyText b), []) deconstruct x = err $ "cannot deconstruct " ++ show x ++ "." compose f1 f2 info | not (null v1 || null v2) = err' "one side needs to have null placeholders" | length b1 /= length b2 = err' "mismatching lengths" | otherwise = (bc, vc) where (b1, v1) = f1 info (b2, v2) = f2 info bc = intersperseB sep [x <> op <> y | (x, y) <- zip b1 b2] vc = v1 <> v2 err' = err . (++ (", " ++ show ((b1, v1), (b2, v2)))) err = error . ("unsafeSqlBinOpComposite: " ++) -- | (Internal) A raw SQL value. The same warning from -- 'unsafeSqlBinOp' applies to this function as well. unsafeSqlValue :: TLB.Builder -> SqlExpr (Value a) unsafeSqlValue v = ERaw Never $ \_ -> (v, mempty) {-# INLINE unsafeSqlValue #-} -- | (Internal) A raw SQL function. Once again, the same warning -- from 'unsafeSqlBinOp' applies to this function as well. unsafeSqlFunction :: UnsafeSqlFunctionArgument a => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlFunction name arg = ERaw Never $ \info -> let (argsTLB, argsVals) = uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList arg in (name <> parens argsTLB, argsVals) -- | (Internal) An unsafe SQL function to extract a subfield from a compound -- field, e.g. datetime. See 'unsafeSqlBinOp' for warnings. -- -- Since: 1.3.6. unsafeSqlExtractSubField :: UnsafeSqlFunctionArgument a => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlExtractSubField subField arg = ERaw Never $ \info -> let (argsTLB, argsVals) = uncommas' $ map (\(ERaw _ f) -> f info) $ toArgList arg in ("EXTRACT" <> parens (subField <> " FROM " <> argsTLB), argsVals) -- | (Internal) A raw SQL function. Preserves parentheses around arguments. -- See 'unsafeSqlBinOp' for warnings. unsafeSqlFunctionParens :: UnsafeSqlFunctionArgument a => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlFunctionParens name arg = ERaw Never $ \info -> let (argsTLB, argsVals) = uncommas' $ map (\(ERaw p f) -> first (parensM p) (f info)) $ toArgList arg in (name <> parens argsTLB, argsVals) class UnsafeSqlFunctionArgument a where toArgList :: a -> [SqlExpr (Value ())] instance (a ~ Value b) => UnsafeSqlFunctionArgument (SqlExpr a) where toArgList = (:[]) . veryUnsafeCoerceSqlExprValue instance UnsafeSqlFunctionArgument a => UnsafeSqlFunctionArgument [a] where toArgList = concatMap toArgList instance ( UnsafeSqlFunctionArgument a , UnsafeSqlFunctionArgument b ) => UnsafeSqlFunctionArgument (a, b) where toArgList (a, b) = toArgList a ++ toArgList b instance ( UnsafeSqlFunctionArgument a , UnsafeSqlFunctionArgument b , UnsafeSqlFunctionArgument c ) => UnsafeSqlFunctionArgument (a, b, c) where toArgList = toArgList . from3 instance ( UnsafeSqlFunctionArgument a , UnsafeSqlFunctionArgument b , UnsafeSqlFunctionArgument c , UnsafeSqlFunctionArgument d ) => UnsafeSqlFunctionArgument (a, b, c, d) where toArgList = toArgList . from4 -- | (Internal) Coerce a value's type from 'SqlExpr (Value a)' to -- 'SqlExpr (Value b)'. You should /not/ use this function -- unless you know what you're doing! veryUnsafeCoerceSqlExprValue :: SqlExpr (Value a) -> SqlExpr (Value b) veryUnsafeCoerceSqlExprValue (ERaw p f) = ERaw p f veryUnsafeCoerceSqlExprValue (ECompositeKey f) = ECompositeKey f -- | (Internal) Coerce a value's type from 'SqlExpr (ValueList -- a)' to 'SqlExpr (Value a)'. Does not work with empty lists. veryUnsafeCoerceSqlExprValueList :: SqlExpr (ValueList a) -> SqlExpr (Value a) veryUnsafeCoerceSqlExprValueList (EList v) = v veryUnsafeCoerceSqlExprValueList EEmptyList = error "veryUnsafeCoerceSqlExprValueList: empty list." ---------------------------------------------------------------------- -- | (Internal) Execute an @esqueleto@ @SELECT@ 'SqlQuery' inside -- @persistent@'s 'SqlPersistT' monad. rawSelectSource :: ( SqlSelect a r , MonadIO m1 , MonadIO m2 ) => Mode -> SqlQuery a -> SqlPersistT m1 (Acquire (C.Source m2 r)) rawSelectSource mode query = do conn <- R.ask res <- run conn return $ (C.$= massage) `fmap` res where run conn = uncurry rawQueryRes $ first builderToText $ toRawSql mode (conn, initialIdentState) query massage = do mrow <- C.await case process <$> mrow of Just (Right r) -> C.yield r >> massage Just (Left err) -> liftIO $ throwIO $ PersistMarshalError err Nothing -> return () process = sqlSelectProcessRow -- | Execute an @esqueleto@ @SELECT@ query inside @persistent@'s -- 'SqlPersistT' monad and return a 'C.Source' of rows. selectSource :: ( SqlSelect a r , MonadResource m ) => SqlQuery a -> C.Source (SqlPersistT m) r selectSource query = do src <- lift $ do res <- rawSelectSource SELECT query fmap snd $ allocateAcquire res src -- | Execute an @esqueleto@ @SELECT@ query inside @persistent@'s -- 'SqlPersistT' monad and return a list of rows. -- -- We've seen that 'from' has some magic about which kinds of -- things you may bring into scope. This 'select' function also -- has some magic for which kinds of things you may bring back to -- Haskell-land by using @SqlQuery@'s @return@: -- -- * You may return a @SqlExpr ('Entity' v)@ for an entity @v@ -- (i.e., like the @*@ in SQL), which is then returned to -- Haskell-land as just @Entity v@. -- -- * You may return a @SqlExpr (Maybe (Entity v))@ for an entity -- @v@ that may be @NULL@, which is then returned to -- Haskell-land as @Maybe (Entity v)@. Used for @OUTER JOIN@s. -- -- * You may return a @SqlExpr ('Value' t)@ for a value @t@ -- (i.e., a single column), where @t@ is any instance of -- 'PersistField', which is then returned to Haskell-land as -- @Value t@. You may use @Value@ to return projections of an -- @Entity@ (see @('^.')@ and @('?.')@) or to return any other -- value calculated on the query (e.g., 'countRows' or -- 'sub_select'). -- -- The @SqlSelect a r@ class has functional dependencies that -- allow type information to flow both from @a@ to @r@ and -- vice-versa. This means that you'll almost never have to give -- any type signatures for @esqueleto@ queries. For example, the -- query @'select' $ from $ \\p -> return p@ alone is ambiguous, but -- in the context of -- -- @ -- do ps <- 'select' $ -- 'from' $ \\p -> -- return p -- liftIO $ mapM_ (putStrLn . personName . entityVal) ps -- @ -- -- we are able to infer from that single @personName . entityVal@ -- function composition that the @p@ inside the query is of type -- @SqlExpr (Entity Person)@. select :: ( SqlSelect a r , MonadIO m ) => SqlQuery a -> SqlPersistT m [r] select query = do res <- rawSelectSource SELECT query conn <- R.ask liftIO $ with res $ flip R.runReaderT conn . runSource -- | Execute an @esqueleto@ @SELECT DISTINCT@ query inside -- @persistent@'s 'SqlPersistT' monad and return a 'C.Source' of -- rows. selectDistinctSource :: ( SqlSelect a r , MonadResource m ) => SqlQuery a -> C.Source (SqlPersistT m) r selectDistinctSource = selectSource . distinct {-# DEPRECATED selectDistinctSource "Since 2.2.4: use 'selectSource' and 'distinct'." #-} -- | Execute an @esqueleto@ @SELECT DISTINCT@ query inside -- @persistent@'s 'SqlPersistT' monad and return a list of rows. selectDistinct :: ( SqlSelect a r , MonadIO m ) => SqlQuery a -> SqlPersistT m [r] selectDistinct = select . distinct {-# DEPRECATED selectDistinct "Since 2.2.4: use 'select' and 'distinct'." #-} -- | (Internal) Run a 'C.Source' of rows. runSource :: Monad m => C.Source (SqlPersistT m) r -> SqlPersistT m [r] runSource src = src C.$$ CL.consume ---------------------------------------------------------------------- -- | (Internal) Execute an @esqueleto@ statement inside -- @persistent@'s 'SqlPersistT' monad. rawEsqueleto :: ( MonadIO m, SqlSelect a r ) => Mode -> SqlQuery a -> SqlPersistT m Int64 rawEsqueleto mode query = do conn <- R.ask uncurry rawExecuteCount $ first builderToText $ toRawSql mode (conn, initialIdentState) query -- | Execute an @esqueleto@ @DELETE@ query inside @persistent@'s -- 'SqlPersistT' monad. Note that currently there are no type -- checks for statements that should not appear on a @DELETE@ -- query. -- -- Example of usage: -- -- @ -- 'delete' $ -- 'from' $ \\appointment -> -- 'where_' (appointment '^.' AppointmentDate '<.' 'val' now) -- @ -- -- Unlike 'select', there is a useful way of using 'delete' that -- will lead to type ambiguities. If you want to delete all rows -- (i.e., no 'where_' clause), you'll have to use a type signature: -- -- @ -- 'delete' $ -- 'from' $ \\(appointment :: 'SqlExpr' ('Entity' Appointment)) -> -- return () -- @ delete :: ( MonadIO m ) => SqlQuery () -> SqlPersistT m () delete = liftM (const ()) . deleteCount -- | Same as 'delete', but returns the number of rows affected. deleteCount :: ( MonadIO m ) => SqlQuery () -> SqlPersistT m Int64 deleteCount = rawEsqueleto DELETE -- | Execute an @esqueleto@ @UPDATE@ query inside @persistent@'s -- 'SqlPersistT' monad. Note that currently there are no type -- checks for statements that should not appear on a @UPDATE@ -- query. -- -- Example of usage: -- -- @ -- 'update' $ \p -> do -- 'set' p [ PersonAge '=.' 'just' ('val' thisYear) -. p '^.' PersonBorn ] -- 'where_' $ isNothing (p '^.' PersonAge) -- @ update :: ( MonadIO m , SqlEntity val ) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlPersistT m () update = liftM (const ()) . updateCount -- | Same as 'update', but returns the number of rows affected. updateCount :: ( MonadIO m , SqlEntity val ) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlPersistT m Int64 updateCount = rawEsqueleto UPDATE . from ---------------------------------------------------------------------- builderToText :: TLB.Builder -> T.Text builderToText = TL.toStrict . TLB.toLazyTextWith defaultChunkSize where defaultChunkSize = 1024 - 32 -- | (Internal) Pretty prints a 'SqlQuery' into a SQL query. -- -- Note: if you're curious about the SQL query being generated by -- @esqueleto@, instead of manually using this function (which is -- possible but tedious), you may just turn on query logging of -- @persistent@. toRawSql :: SqlSelect a r => Mode -> IdentInfo -> SqlQuery a -> (TLB.Builder, [PersistValue]) toRawSql mode (conn, firstIdentState) query = let ((ret, sd), finalIdentState) = flip S.runState firstIdentState $ W.runWriterT $ unQ query SideData distinctClause fromClauses setClauses whereClauses groupByClause havingClause orderByClauses limitClause lockingClause = sd -- Pass the finalIdentState (containing all identifiers -- that were used) to the subsequent calls. This ensures -- that no name clashes will occur on subqueries that may -- appear on the expressions below. info = (conn, finalIdentState) in mconcat [ makeInsertInto info mode ret , makeSelect info mode distinctClause ret , makeFrom info mode fromClauses , makeSet info setClauses , makeWhere info whereClauses , makeGroupBy info groupByClause , makeHaving info havingClause , makeOrderBy info orderByClauses , makeLimit info limitClause orderByClauses , makeLocking lockingClause ] -- | (Internal) Mode of query being converted by 'toRawSql'. data Mode = SELECT | DELETE | UPDATE | INSERT_INTO uncommas :: [TLB.Builder] -> TLB.Builder uncommas = intersperseB ", " intersperseB :: TLB.Builder -> [TLB.Builder] -> TLB.Builder intersperseB a = mconcat . intersperse a . filter (/= mempty) uncommas' :: Monoid a => [(TLB.Builder, a)] -> (TLB.Builder, a) uncommas' = (uncommas *** mconcat) . unzip makeInsertInto :: SqlSelect a r => IdentInfo -> Mode -> a -> (TLB.Builder, [PersistValue]) makeInsertInto info INSERT_INTO ret = sqlInsertInto info ret makeInsertInto _ _ _ = mempty makeSelect :: SqlSelect a r => IdentInfo -> Mode -> DistinctClause -> a -> (TLB.Builder, [PersistValue]) makeSelect info mode_ distinctClause ret = process mode_ where process mode = case mode of SELECT -> withCols selectKind DELETE -> plain "DELETE " UPDATE -> plain "UPDATE " INSERT_INTO -> process SELECT selectKind = case distinctClause of DistinctAll -> ("SELECT ", []) DistinctStandard -> ("SELECT DISTINCT ", []) DistinctOn exprs -> first (("SELECT DISTINCT ON (" <>) . (<> ") ")) $ uncommas' (processExpr <$> exprs) where processExpr (EDistinctOn f) = materializeExpr info f withCols v = v <> (sqlSelectCols info ret) plain v = (v, []) makeFrom :: IdentInfo -> Mode -> [FromClause] -> (TLB.Builder, [PersistValue]) makeFrom _ _ [] = mempty makeFrom info mode fs = ret where ret = case collectOnClauses fs of Left expr -> throw $ mkExc expr Right fs' -> keyword $ uncommas' (map (mk Never) fs') keyword = case mode of UPDATE -> id _ -> first ("\nFROM " <>) mk _ (FromStart i def) = base i def mk paren (FromJoin lhs kind rhs monClause) = first (parensM paren) $ mconcat [ mk Never lhs , (fromKind kind, mempty) , mk Parens rhs , maybe mempty makeOnClause monClause ] mk _ (OnClause _) = error "Esqueleto/Sql/makeFrom: never here (is collectOnClauses working?)" base ident@(I identText) def = let db@(DBName dbText) = entityDB def in ( if dbText == identText then fromDBName info db else fromDBName info db <> (" AS " <> useIdent info ident) , mempty ) fromKind InnerJoinKind = " INNER JOIN " fromKind CrossJoinKind = " CROSS JOIN " fromKind LeftOuterJoinKind = " LEFT OUTER JOIN " fromKind RightOuterJoinKind = " RIGHT OUTER JOIN " fromKind FullOuterJoinKind = " FULL OUTER JOIN " makeOnClause (ERaw _ f) = first (" ON " <>) (f info) makeOnClause (ECompositeKey _) = unexpectedCompositeKeyError "makeFrom/makeOnClause" mkExc :: SqlExpr (Value Bool) -> OnClauseWithoutMatchingJoinException mkExc (ERaw _ f) = OnClauseWithoutMatchingJoinException $ TL.unpack $ TLB.toLazyText $ fst (f info) mkExc (ECompositeKey _) = unexpectedCompositeKeyError "makeFrom/mkExc" unexpectedCompositeKeyError :: String -> a unexpectedCompositeKeyError w = error $ w ++ ": non-id/composite keys not expected here" makeSet :: IdentInfo -> [SetClause] -> (TLB.Builder, [PersistValue]) makeSet _ [] = mempty makeSet info os = first ("\nSET " <>) . uncommas' $ concatMap mk os where mk (SetClause (ERaw _ f)) = [f info] mk (SetClause (ECompositeKey _)) = unexpectedCompositeKeyError "makeSet" -- FIXME makeWhere :: IdentInfo -> WhereClause -> (TLB.Builder, [PersistValue]) makeWhere _ NoWhere = mempty makeWhere info (Where (ERaw _ f)) = first ("\nWHERE " <>) (f info) makeWhere _ (Where (ECompositeKey _)) = unexpectedCompositeKeyError "makeWhere" makeGroupBy :: IdentInfo -> GroupByClause -> (TLB.Builder, [PersistValue]) makeGroupBy _ (GroupBy []) = (mempty, []) makeGroupBy info (GroupBy fields) = first ("\nGROUP BY " <>) build where build = uncommas' $ map (\(SomeValue (ERaw _ f)) -> f info) fields makeHaving :: IdentInfo -> WhereClause -> (TLB.Builder, [PersistValue]) makeHaving _ NoWhere = mempty makeHaving info (Where (ERaw _ f)) = first ("\nHAVING " <>) (f info) makeHaving _ (Where (ECompositeKey _ )) = unexpectedCompositeKeyError "makeHaving" makeOrderBy :: IdentInfo -> [OrderByClause] -> (TLB.Builder, [PersistValue]) makeOrderBy _ [] = mempty makeOrderBy info os = first ("\nORDER BY " <>) . uncommas' $ concatMap mk os where mk :: OrderByClause -> [(TLB.Builder, [PersistValue])] mk (EOrderBy t (ERaw p f)) = [first ((<> orderByType t) . parensM p) (f info)] mk (EOrderBy t (ECompositeKey f)) = let fs = f info vals = repeat [] in zip (map (<> orderByType t) fs) vals mk EOrderRandom = [first ((<> "RANDOM()")) mempty] orderByType ASC = " ASC" orderByType DESC = " DESC" makeLimit :: IdentInfo -> LimitClause -> [OrderByClause] -> (TLB.Builder, [PersistValue]) makeLimit (conn, _) (Limit ml mo) orderByClauses = let limitRaw = connLimitOffset conn (v ml, v mo) hasOrderClause "\n" hasOrderClause = not (null orderByClauses) v = maybe 0 fromIntegral in (TLB.fromText limitRaw, mempty) makeLocking :: LockingClause -> (TLB.Builder, [PersistValue]) makeLocking = flip (,) [] . maybe mempty toTLB . getLast where toTLB ForUpdate = "\nFOR UPDATE" toTLB ForShare = "\nFOR SHARE" toTLB LockInShareMode = "\nLOCK IN SHARE MODE" parens :: TLB.Builder -> TLB.Builder parens b = "(" <> (b <> ")") ---------------------------------------------------------------------- -- | (Internal) Class for mapping results coming from 'SqlQuery' -- into actual results. -- -- This looks very similar to @RawSql@, and it is! However, -- there are some crucial differences and ultimately they're -- different classes. class SqlSelect a r | a -> r, r -> a where -- | Creates the variable part of the @SELECT@ query and -- returns the list of 'PersistValue's that will be given to -- 'rawQuery'. sqlSelectCols :: IdentInfo -> a -> (TLB.Builder, [PersistValue]) -- | Number of columns that will be consumed. sqlSelectColCount :: Proxy a -> Int -- | Transform a row of the result into the data type. sqlSelectProcessRow :: [PersistValue] -> Either T.Text r -- | Create @INSERT INTO@ clause instead. sqlInsertInto :: IdentInfo -> a -> (TLB.Builder, [PersistValue]) sqlInsertInto = error "Type does not support sqlInsertInto." -- | @INSERT INTO@ hack. instance SqlSelect (SqlExpr InsertFinal) InsertFinal where sqlInsertInto info (EInsertFinal (EInsert p _)) = let fields = uncommas $ map (fromDBName info . fieldDB) $ entityFields $ entityDef p table = fromDBName info . entityDB . entityDef $ p in ("INSERT INTO " <> table <> parens fields <> "\n", []) sqlSelectCols info (EInsertFinal (EInsert _ f)) = f info sqlSelectColCount = const 0 sqlSelectProcessRow = const (Right (error msg)) where msg = "sqlSelectProcessRow/SqlSelect/InsertionFinal: never here" -- | Not useful for 'select', but used for 'update' and 'delete'. instance SqlSelect () () where sqlSelectCols _ _ = ("1", []) sqlSelectColCount _ = 1 sqlSelectProcessRow _ = Right () -- | You may return an 'Entity' from a 'select' query. instance PersistEntity a => SqlSelect (SqlExpr (Entity a)) (Entity a) where sqlSelectCols info expr@(EEntity ident) = ret where process ed = uncommas $ map ((name <>) . TLB.fromText) $ entityColumnNames ed (fst info) -- 'name' is the biggest difference between 'RawSql' and -- 'SqlSelect'. We automatically create names for tables -- (since it's not the user who's writing the FROM -- clause), while 'rawSql' assumes that it's just the -- name of the table (which doesn't allow self-joins, for -- example). name = useIdent info ident <> "." ret = let ed = entityDef $ getEntityVal $ return expr in (process ed, mempty) sqlSelectColCount = entityColumnCount . entityDef . getEntityVal sqlSelectProcessRow = parseEntityValues ed where ed = entityDef $ getEntityVal $ (Proxy :: Proxy (SqlExpr (Entity a))) getEntityVal :: Proxy (SqlExpr (Entity a)) -> Proxy a getEntityVal = const Proxy -- | You may return a possibly-@NULL@ 'Entity' from a 'select' query. instance PersistEntity a => SqlSelect (SqlExpr (Maybe (Entity a))) (Maybe (Entity a)) where sqlSelectCols info (EMaybe ent) = sqlSelectCols info ent sqlSelectColCount = sqlSelectColCount . fromEMaybe where fromEMaybe :: Proxy (SqlExpr (Maybe e)) -> Proxy (SqlExpr e) fromEMaybe = const Proxy sqlSelectProcessRow cols | all (== PersistNull) cols = return Nothing | otherwise = Just <$> sqlSelectProcessRow cols -- | You may return any single value (i.e. a single column) from -- a 'select' query. instance PersistField a => SqlSelect (SqlExpr (Value a)) (Value a) where sqlSelectCols = materializeExpr sqlSelectColCount = const 1 sqlSelectProcessRow [pv] = Value <$> fromPersistValue pv sqlSelectProcessRow pvs = Value <$> fromPersistValue (PersistList pvs) -- | Materialize a @SqlExpr (Value a)@. materializeExpr :: IdentInfo -> SqlExpr (Value a) -> (TLB.Builder, [PersistValue]) materializeExpr info (ERaw p f) = let (b, vals) = f info in (parensM p b, vals) materializeExpr info (ECompositeKey f) = let bs = f info in (uncommas $ map (parensM Parens) bs, []) -- | You may return tuples (up to 16-tuples) and tuples of tuples -- from a 'select' query. instance ( SqlSelect a ra , SqlSelect b rb ) => SqlSelect (a, b) (ra, rb) where sqlSelectCols esc (a, b) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b ] sqlSelectColCount = uncurry (+) . (sqlSelectColCount *** sqlSelectColCount) . fromTuple where fromTuple :: Proxy (a,b) -> (Proxy a, Proxy b) fromTuple = const (Proxy, Proxy) sqlSelectProcessRow = let x = getType processRow getType :: SqlSelect a r => (z -> Either y (r,x)) -> Proxy a getType = const Proxy colCountFst = sqlSelectColCount x processRow row = let (rowFst, rowSnd) = splitAt colCountFst row in (,) <$> sqlSelectProcessRow rowFst <*> sqlSelectProcessRow rowSnd in colCountFst `seq` processRow -- Avoids recalculating 'colCountFst'. instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc ) => SqlSelect (a, b, c) (ra, rb, rc) where sqlSelectCols esc (a, b, c) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c ] sqlSelectColCount = sqlSelectColCount . from3P sqlSelectProcessRow = fmap to3 . sqlSelectProcessRow from3P :: Proxy (a,b,c) -> Proxy ((a,b),c) from3P = const Proxy from3 :: (a,b,c) -> ((a,b),c) from3 (a,b,c) = ((a,b),c) to3 :: ((a,b),c) -> (a,b,c) to3 ((a,b),c) = (a,b,c) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd ) => SqlSelect (a, b, c, d) (ra, rb, rc, rd) where sqlSelectCols esc (a, b, c, d) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d ] sqlSelectColCount = sqlSelectColCount . from4P sqlSelectProcessRow = fmap to4 . sqlSelectProcessRow from4P :: Proxy (a,b,c,d) -> Proxy ((a,b),(c,d)) from4P = const Proxy from4 :: (a,b,c,d) -> ((a,b),(c,d)) from4 (a,b,c,d) = ((a,b),(c,d)) to4 :: ((a,b),(c,d)) -> (a,b,c,d) to4 ((a,b),(c,d)) = (a,b,c,d) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re ) => SqlSelect (a, b, c, d, e) (ra, rb, rc, rd, re) where sqlSelectCols esc (a, b, c, d, e) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e ] sqlSelectColCount = sqlSelectColCount . from5P sqlSelectProcessRow = fmap to5 . sqlSelectProcessRow from5P :: Proxy (a,b,c,d,e) -> Proxy ((a,b),(c,d),e) from5P = const Proxy to5 :: ((a,b),(c,d),e) -> (a,b,c,d,e) to5 ((a,b),(c,d),e) = (a,b,c,d,e) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf ) => SqlSelect (a, b, c, d, e, f) (ra, rb, rc, rd, re, rf) where sqlSelectCols esc (a, b, c, d, e, f) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f ] sqlSelectColCount = sqlSelectColCount . from6P sqlSelectProcessRow = fmap to6 . sqlSelectProcessRow from6P :: Proxy (a,b,c,d,e,f) -> Proxy ((a,b),(c,d),(e,f)) from6P = const Proxy to6 :: ((a,b),(c,d),(e,f)) -> (a,b,c,d,e,f) to6 ((a,b),(c,d),(e,f)) = (a,b,c,d,e,f) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg ) => SqlSelect (a, b, c, d, e, f, g) (ra, rb, rc, rd, re, rf, rg) where sqlSelectCols esc (a, b, c, d, e, f, g) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g ] sqlSelectColCount = sqlSelectColCount . from7P sqlSelectProcessRow = fmap to7 . sqlSelectProcessRow from7P :: Proxy (a,b,c,d,e,f,g) -> Proxy ((a,b),(c,d),(e,f),g) from7P = const Proxy to7 :: ((a,b),(c,d),(e,f),g) -> (a,b,c,d,e,f,g) to7 ((a,b),(c,d),(e,f),g) = (a,b,c,d,e,f,g) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh ) => SqlSelect (a, b, c, d, e, f, g, h) (ra, rb, rc, rd, re, rf, rg, rh) where sqlSelectCols esc (a, b, c, d, e, f, g, h) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h ] sqlSelectColCount = sqlSelectColCount . from8P sqlSelectProcessRow = fmap to8 . sqlSelectProcessRow from8P :: Proxy (a,b,c,d,e,f,g,h) -> Proxy ((a,b),(c,d),(e,f),(g,h)) from8P = const Proxy to8 :: ((a,b),(c,d),(e,f),(g,h)) -> (a,b,c,d,e,f,g,h) to8 ((a,b),(c,d),(e,f),(g,h)) = (a,b,c,d,e,f,g,h) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri ) => SqlSelect (a, b, c, d, e, f, g, h, i) (ra, rb, rc, rd, re, rf, rg, rh, ri) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i ] sqlSelectColCount = sqlSelectColCount . from9P sqlSelectProcessRow = fmap to9 . sqlSelectProcessRow from9P :: Proxy (a,b,c,d,e,f,g,h,i) -> Proxy ((a,b),(c,d),(e,f),(g,h),i) from9P = const Proxy to9 :: ((a,b),(c,d),(e,f),(g,h),i) -> (a,b,c,d,e,f,g,h,i) to9 ((a,b),(c,d),(e,f),(g,h),i) = (a,b,c,d,e,f,g,h,i) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj ) => SqlSelect (a, b, c, d, e, f, g, h, i, j) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j ] sqlSelectColCount = sqlSelectColCount . from10P sqlSelectProcessRow = fmap to10 . sqlSelectProcessRow from10P :: Proxy (a,b,c,d,e,f,g,h,i,j) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j)) from10P = const Proxy to10 :: ((a,b),(c,d),(e,f),(g,h),(i,j)) -> (a,b,c,d,e,f,g,h,i,j) to10 ((a,b),(c,d),(e,f),(g,h),(i,j)) = (a,b,c,d,e,f,g,h,i,j) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj , SqlSelect k rk ) => SqlSelect (a, b, c, d, e, f, g, h, i, j, k) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j, k) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j , sqlSelectCols esc k ] sqlSelectColCount = sqlSelectColCount . from11P sqlSelectProcessRow = fmap to11 . sqlSelectProcessRow from11P :: Proxy (a,b,c,d,e,f,g,h,i,j,k) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j),k) from11P = const Proxy to11 :: ((a,b),(c,d),(e,f),(g,h),(i,j),k) -> (a,b,c,d,e,f,g,h,i,j,k) to11 ((a,b),(c,d),(e,f),(g,h),(i,j),k) = (a,b,c,d,e,f,g,h,i,j,k) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj , SqlSelect k rk , SqlSelect l rl ) => SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j, k, l) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j , sqlSelectCols esc k , sqlSelectCols esc l ] sqlSelectColCount = sqlSelectColCount . from12P sqlSelectProcessRow = fmap to12 . sqlSelectProcessRow from12P :: Proxy (a,b,c,d,e,f,g,h,i,j,k,l) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l)) from12P = const Proxy to12 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l)) -> (a,b,c,d,e,f,g,h,i,j,k,l) to12 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l)) = (a,b,c,d,e,f,g,h,i,j,k,l) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj , SqlSelect k rk , SqlSelect l rl , SqlSelect m rm ) => SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j, k, l, m) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j , sqlSelectCols esc k , sqlSelectCols esc l , sqlSelectCols esc m ] sqlSelectColCount = sqlSelectColCount . from13P sqlSelectProcessRow = fmap to13 . sqlSelectProcessRow from13P :: Proxy (a,b,c,d,e,f,g,h,i,j,k,l,m) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),m) from13P = const Proxy to13 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),m) -> (a,b,c,d,e,f,g,h,i,j,k,l,m) to13 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),m) = (a,b,c,d,e,f,g,h,i,j,k,l,m) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj , SqlSelect k rk , SqlSelect l rl , SqlSelect m rm , SqlSelect n rn ) => SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m, n) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j, k, l, m, n) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j , sqlSelectCols esc k , sqlSelectCols esc l , sqlSelectCols esc m , sqlSelectCols esc n ] sqlSelectColCount = sqlSelectColCount . from14P sqlSelectProcessRow = fmap to14 . sqlSelectProcessRow from14P :: Proxy (a,b,c,d,e,f,g,h,i,j,k,l,m,n) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n)) from14P = const Proxy to14 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n) to14 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj , SqlSelect k rk , SqlSelect l rl , SqlSelect m rm , SqlSelect n rn , SqlSelect o ro ) => SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn, ro) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j , sqlSelectCols esc k , sqlSelectCols esc l , sqlSelectCols esc m , sqlSelectCols esc n , sqlSelectCols esc o ] sqlSelectColCount = sqlSelectColCount . from15P sqlSelectProcessRow = fmap to15 . sqlSelectProcessRow from15P :: Proxy (a,b,c,d,e,f,g,h,i,j,k,l,m,n, o) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),o) from15P = const Proxy to15 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),o) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) to15 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),o) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) instance ( SqlSelect a ra , SqlSelect b rb , SqlSelect c rc , SqlSelect d rd , SqlSelect e re , SqlSelect f rf , SqlSelect g rg , SqlSelect h rh , SqlSelect i ri , SqlSelect j rj , SqlSelect k rk , SqlSelect l rl , SqlSelect m rm , SqlSelect n rn , SqlSelect o ro , SqlSelect p rp ) => SqlSelect (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) (ra, rb, rc, rd, re, rf, rg, rh, ri, rj, rk, rl, rm, rn, ro, rp) where sqlSelectCols esc (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) = uncommas' [ sqlSelectCols esc a , sqlSelectCols esc b , sqlSelectCols esc c , sqlSelectCols esc d , sqlSelectCols esc e , sqlSelectCols esc f , sqlSelectCols esc g , sqlSelectCols esc h , sqlSelectCols esc i , sqlSelectCols esc j , sqlSelectCols esc k , sqlSelectCols esc l , sqlSelectCols esc m , sqlSelectCols esc n , sqlSelectCols esc o , sqlSelectCols esc p ] sqlSelectColCount = sqlSelectColCount . from16P sqlSelectProcessRow = fmap to16 . sqlSelectProcessRow from16P :: Proxy (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) -> Proxy ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p)) from16P = const Proxy to16 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) to16 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) -- | Insert a 'PersistField' for every selected value. insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m () insertSelect = liftM (const ()) . rawEsqueleto INSERT_INTO . fmap EInsertFinal -- | Insert a 'PersistField' for every unique selected value. insertSelectDistinct :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlPersistT m () insertSelectDistinct = insertSelect . distinct {-# DEPRECATED insertSelectDistinct "Since 2.2.4: use 'insertSelect' and 'distinct'." #-}
krisajenkins/esqueleto
src/Database/Esqueleto/Internal/Sql.hs
bsd-3-clause
60,682
0
18
15,836
19,533
10,810
8,723
-1
-1
{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} {-# OPTIONS -fglasgow-exts -cpp #-} ----------------------------------------------------------------------------- -- | -- Module : Language.Haskell.Parser -- Copyright : (c) Simon Marlow, Sven Panne 1997-2000 -- License : BSD-style (see the file libraries/base/LICENSE) -- -- Maintainer : [email protected] -- Stability : experimental -- Portability : portable -- -- Haskell parser. -- ----------------------------------------------------------------------------- module Haskell.Parser.Parser ( parseModule, parseModuleWithMode, ParseMode(..), defaultParseMode, ParseResult(..)) where import Haskell.Syntax.Syntax import Haskell.Parser.ParseMonad import Haskell.Lexer.Lexer import Haskell.Parser.ParseUtils #if __GLASGOW_HASKELL__ >= 503 import qualified GHC.Exts as Happy_GHC_Exts #else import qualified GlaExts as Happy_GHC_Exts #endif -- parser produced by Happy Version 1.18.4 data HappyAbsSyn = HappyTerminal (Token) | HappyErrorToken Int | HappyAbsSyn4 (HsModule) | HappyAbsSyn5 (([HsImportDecl],[HsDecl])) | HappyAbsSyn7 (()) | HappyAbsSyn9 (Maybe [HsExportSpec]) | HappyAbsSyn10 ([HsExportSpec]) | HappyAbsSyn13 (HsExportSpec) | HappyAbsSyn14 ([HsImportDecl]) | HappyAbsSyn15 (HsImportDecl) | HappyAbsSyn16 (Bool) | HappyAbsSyn17 (Maybe Module) | HappyAbsSyn18 (Maybe (Bool, [HsImportSpec])) | HappyAbsSyn19 ((Bool, [HsImportSpec])) | HappyAbsSyn21 ([HsImportSpec]) | HappyAbsSyn22 (HsImportSpec) | HappyAbsSyn23 ([HsCName]) | HappyAbsSyn24 (HsCName) | HappyAbsSyn25 (HsDecl) | HappyAbsSyn26 (Int) | HappyAbsSyn27 (HsAssoc) | HappyAbsSyn28 ([HsOp]) | HappyAbsSyn29 ([HsDecl]) | HappyAbsSyn32 ([HsType]) | HappyAbsSyn38 ([HsName]) | HappyAbsSyn40 (HsSafety) | HappyAbsSyn41 (String) | HappyAbsSyn42 (HsName) | HappyAbsSyn43 (HsType) | HappyAbsSyn46 (HsQName) | HappyAbsSyn47 (HsQualType) | HappyAbsSyn48 (HsContext) | HappyAbsSyn50 ((HsName, [HsName])) | HappyAbsSyn52 ([HsConDecl]) | HappyAbsSyn53 (HsConDecl) | HappyAbsSyn54 ((HsName, [HsBangType])) | HappyAbsSyn56 (HsBangType) | HappyAbsSyn58 ([([HsName],HsBangType)]) | HappyAbsSyn59 (([HsName],HsBangType)) | HappyAbsSyn61 ([HsQName]) | HappyAbsSyn69 (HsRhs) | HappyAbsSyn70 ([HsGuardedRhs]) | HappyAbsSyn71 (HsGuardedRhs) | HappyAbsSyn72 (HsExp) | HappyAbsSyn79 ([HsPat]) | HappyAbsSyn80 (HsPat) | HappyAbsSyn85 ([HsExp]) | HappyAbsSyn88 ([HsStmt]) | HappyAbsSyn89 (HsStmt) | HappyAbsSyn90 ([HsAlt]) | HappyAbsSyn93 (HsAlt) | HappyAbsSyn94 (HsGuardedAlts) | HappyAbsSyn95 ([HsGuardedAlt]) | HappyAbsSyn96 (HsGuardedAlt) | HappyAbsSyn100 ([HsFieldUpdate]) | HappyAbsSyn101 (HsFieldUpdate) | HappyAbsSyn112 (HsOp) | HappyAbsSyn113 (HsQOp) | HappyAbsSyn127 (HsLiteral) | HappyAbsSyn128 (SrcLoc) | HappyAbsSyn131 (Module) {- to allow type-synonyms as our monads (likely - with explicitly-specified bind and return) - in Haskell98, it seems that with - /type M a = .../, then /(HappyReduction M)/ - is not allowed. But Happy is a - code-generator that can just substitute it. type HappyReduction m = Happy_GHC_Exts.Int# -> (Token) -> HappyState (Token) (HappyStk HappyAbsSyn -> m HappyAbsSyn) -> [HappyState (Token) (HappyStk HappyAbsSyn -> m HappyAbsSyn)] -> HappyStk HappyAbsSyn -> m HappyAbsSyn -} action_0, action_1, action_2, action_3, action_4, action_5, action_6, action_7, action_8, action_9, action_10, action_11, action_12, action_13, action_14, action_15, action_16, action_17, action_18, action_19, action_20, action_21, action_22, action_23, action_24, action_25, action_26, action_27, action_28, action_29, action_30, action_31, action_32, action_33, action_34, action_35, action_36, action_37, action_38, action_39, action_40, action_41, action_42, action_43, action_44, action_45, action_46, action_47, action_48, action_49, action_50, action_51, action_52, action_53, action_54, action_55, action_56, action_57, action_58, action_59, action_60, action_61, action_62, action_63, action_64, action_65, action_66, action_67, action_68, action_69, action_70, action_71, action_72, action_73, action_74, action_75, action_76, action_77, action_78, action_79, action_80, action_81, action_82, action_83, action_84, action_85, action_86, action_87, action_88, action_89, action_90, action_91, action_92, action_93, action_94, action_95, action_96, action_97, action_98, action_99, action_100, action_101, action_102, action_103, action_104, action_105, action_106, action_107, action_108, action_109, action_110, action_111, action_112, action_113, action_114, action_115, action_116, action_117, action_118, action_119, action_120, action_121, action_122, action_123, action_124, action_125, action_126, action_127, action_128, action_129, action_130, action_131, action_132, action_133, action_134, action_135, action_136, action_137, action_138, action_139, action_140, action_141, action_142, action_143, action_144, action_145, action_146, action_147, action_148, action_149, action_150, action_151, action_152, action_153, action_154, action_155, action_156, action_157, action_158, action_159, action_160, action_161, action_162, action_163, action_164, action_165, action_166, action_167, action_168, action_169, action_170, action_171, action_172, action_173, action_174, action_175, action_176, action_177, action_178, action_179, action_180, action_181, action_182, action_183, action_184, action_185, action_186, action_187, action_188, action_189, action_190, action_191, action_192, action_193, action_194, action_195, action_196, action_197, action_198, action_199, action_200, action_201, action_202, action_203, action_204, action_205, action_206, action_207, action_208, action_209, action_210, action_211, action_212, action_213, action_214, action_215, action_216, action_217, action_218, action_219, action_220, action_221, action_222, action_223, action_224, action_225, action_226, action_227, action_228, action_229, action_230, action_231, action_232, action_233, action_234, action_235, action_236, action_237, action_238, action_239, action_240, action_241, action_242, action_243, action_244, action_245, action_246, action_247, action_248, action_249, action_250, action_251, action_252, action_253, action_254, action_255, action_256, action_257, action_258, action_259, action_260, action_261, action_262, action_263, action_264, action_265, action_266, action_267, action_268, action_269, action_270, action_271, action_272, action_273, action_274, action_275, action_276, action_277, action_278, action_279, action_280, action_281, action_282, action_283, action_284, action_285, action_286, action_287, action_288, action_289, action_290, action_291, action_292, action_293, action_294, action_295, action_296, action_297, action_298, action_299, action_300, action_301, action_302, action_303, action_304, action_305, action_306, action_307, action_308, action_309, action_310, action_311, action_312, action_313, action_314, action_315, action_316, action_317, action_318, action_319, action_320, action_321, action_322, action_323, action_324, action_325, action_326, action_327, action_328, action_329, action_330, action_331, action_332, action_333, action_334, action_335, action_336, action_337, action_338, action_339, action_340, action_341, action_342, action_343, action_344, action_345, action_346, action_347, action_348, action_349, action_350, action_351, action_352, action_353, action_354, action_355, action_356, action_357, action_358, action_359, action_360, action_361, action_362, action_363, action_364, action_365, action_366, action_367, action_368, action_369, action_370, action_371, action_372, action_373, action_374, action_375, action_376, action_377, action_378, action_379, action_380, action_381, action_382, action_383, action_384, action_385, action_386, action_387, action_388, action_389, action_390, action_391, action_392, action_393, action_394, action_395, action_396, action_397, action_398, action_399, action_400, action_401, action_402, action_403, action_404, action_405, action_406, action_407, action_408, action_409, action_410, action_411, action_412, action_413, action_414, action_415, action_416, action_417, action_418, action_419, action_420, action_421, action_422, action_423, action_424, action_425, action_426, action_427, action_428, action_429, action_430, action_431, action_432, action_433, action_434, action_435, action_436, action_437, action_438, action_439, action_440, action_441, action_442, action_443, action_444, action_445, action_446, action_447, action_448, action_449, action_450, action_451, action_452, action_453, action_454, action_455, action_456, action_457, action_458, action_459, action_460, action_461, action_462, action_463, action_464, action_465, action_466, action_467, action_468, action_469, action_470, action_471, action_472, action_473, action_474, action_475, action_476, action_477, action_478, action_479, action_480, action_481, action_482, action_483, action_484, action_485, action_486, action_487, action_488, action_489, action_490, action_491, action_492, action_493, action_494, action_495, action_496, action_497, action_498, action_499, action_500, action_501, action_502, action_503, action_504, action_505, action_506, action_507, action_508, action_509, action_510, action_511, action_512, action_513, action_514, action_515, action_516, action_517, action_518, action_519 :: () => Happy_GHC_Exts.Int# -> ({-HappyReduction (P) = -} Happy_GHC_Exts.Int# -> (Token) -> HappyState (Token) (HappyStk HappyAbsSyn -> (P) HappyAbsSyn) -> [HappyState (Token) (HappyStk HappyAbsSyn -> (P) HappyAbsSyn)] -> HappyStk HappyAbsSyn -> (P) HappyAbsSyn) happyReduce_1, happyReduce_2, happyReduce_3, happyReduce_4, happyReduce_5, happyReduce_6, happyReduce_7, happyReduce_8, happyReduce_9, happyReduce_10, happyReduce_11, happyReduce_12, happyReduce_13, happyReduce_14, happyReduce_15, happyReduce_16, happyReduce_17, happyReduce_18, happyReduce_19, happyReduce_20, happyReduce_21, happyReduce_22, happyReduce_23, happyReduce_24, happyReduce_25, happyReduce_26, happyReduce_27, happyReduce_28, happyReduce_29, happyReduce_30, happyReduce_31, happyReduce_32, happyReduce_33, happyReduce_34, happyReduce_35, happyReduce_36, happyReduce_37, happyReduce_38, happyReduce_39, happyReduce_40, happyReduce_41, happyReduce_42, happyReduce_43, happyReduce_44, happyReduce_45, happyReduce_46, happyReduce_47, happyReduce_48, happyReduce_49, happyReduce_50, happyReduce_51, happyReduce_52, happyReduce_53, happyReduce_54, happyReduce_55, happyReduce_56, happyReduce_57, happyReduce_58, happyReduce_59, happyReduce_60, happyReduce_61, happyReduce_62, happyReduce_63, happyReduce_64, happyReduce_65, happyReduce_66, happyReduce_67, happyReduce_68, happyReduce_69, happyReduce_70, happyReduce_71, happyReduce_72, happyReduce_73, happyReduce_74, happyReduce_75, happyReduce_76, happyReduce_77, happyReduce_78, happyReduce_79, happyReduce_80, happyReduce_81, happyReduce_82, happyReduce_83, happyReduce_84, happyReduce_85, happyReduce_86, happyReduce_87, happyReduce_88, happyReduce_89, happyReduce_90, happyReduce_91, happyReduce_92, happyReduce_93, happyReduce_94, happyReduce_95, happyReduce_96, happyReduce_97, happyReduce_98, happyReduce_99, happyReduce_100, happyReduce_101, happyReduce_102, happyReduce_103, happyReduce_104, happyReduce_105, happyReduce_106, happyReduce_107, happyReduce_108, happyReduce_109, happyReduce_110, happyReduce_111, happyReduce_112, happyReduce_113, happyReduce_114, happyReduce_115, happyReduce_116, happyReduce_117, happyReduce_118, happyReduce_119, happyReduce_120, happyReduce_121, happyReduce_122, happyReduce_123, happyReduce_124, happyReduce_125, happyReduce_126, happyReduce_127, happyReduce_128, happyReduce_129, happyReduce_130, happyReduce_131, happyReduce_132, happyReduce_133, happyReduce_134, happyReduce_135, happyReduce_136, happyReduce_137, happyReduce_138, happyReduce_139, happyReduce_140, happyReduce_141, happyReduce_142, happyReduce_143, happyReduce_144, happyReduce_145, happyReduce_146, happyReduce_147, happyReduce_148, happyReduce_149, happyReduce_150, happyReduce_151, happyReduce_152, happyReduce_153, happyReduce_154, happyReduce_155, happyReduce_156, happyReduce_157, happyReduce_158, happyReduce_159, happyReduce_160, happyReduce_161, happyReduce_162, happyReduce_163, happyReduce_164, happyReduce_165, happyReduce_166, happyReduce_167, happyReduce_168, happyReduce_169, happyReduce_170, happyReduce_171, happyReduce_172, happyReduce_173, happyReduce_174, happyReduce_175, happyReduce_176, happyReduce_177, happyReduce_178, happyReduce_179, happyReduce_180, happyReduce_181, happyReduce_182, happyReduce_183, happyReduce_184, happyReduce_185, happyReduce_186, happyReduce_187, happyReduce_188, happyReduce_189, happyReduce_190, happyReduce_191, happyReduce_192, happyReduce_193, happyReduce_194, happyReduce_195, happyReduce_196, happyReduce_197, happyReduce_198, happyReduce_199, happyReduce_200, happyReduce_201, happyReduce_202, happyReduce_203, happyReduce_204, happyReduce_205, happyReduce_206, happyReduce_207, happyReduce_208, happyReduce_209, happyReduce_210, happyReduce_211, happyReduce_212, happyReduce_213, happyReduce_214, happyReduce_215, happyReduce_216, happyReduce_217, happyReduce_218, happyReduce_219, happyReduce_220, happyReduce_221, happyReduce_222, happyReduce_223, happyReduce_224, happyReduce_225, happyReduce_226, happyReduce_227, happyReduce_228, happyReduce_229, happyReduce_230, happyReduce_231, happyReduce_232, happyReduce_233, happyReduce_234, happyReduce_235, happyReduce_236, happyReduce_237, happyReduce_238, happyReduce_239, happyReduce_240, happyReduce_241, happyReduce_242, happyReduce_243, happyReduce_244, happyReduce_245, happyReduce_246, happyReduce_247, happyReduce_248, happyReduce_249, happyReduce_250, happyReduce_251, happyReduce_252, happyReduce_253, happyReduce_254, happyReduce_255, happyReduce_256, happyReduce_257, happyReduce_258, happyReduce_259, happyReduce_260, happyReduce_261, happyReduce_262, happyReduce_263, happyReduce_264, happyReduce_265, happyReduce_266, happyReduce_267, happyReduce_268, happyReduce_269, happyReduce_270, happyReduce_271, happyReduce_272, happyReduce_273, happyReduce_274, happyReduce_275, happyReduce_276, happyReduce_277, happyReduce_278, happyReduce_279, happyReduce_280, happyReduce_281, happyReduce_282, happyReduce_283, happyReduce_284, happyReduce_285, happyReduce_286, happyReduce_287, happyReduce_288, happyReduce_289, happyReduce_290, happyReduce_291, happyReduce_292, happyReduce_293, happyReduce_294, happyReduce_295, happyReduce_296, happyReduce_297, happyReduce_298, happyReduce_299, happyReduce_300, happyReduce_301, happyReduce_302, happyReduce_303 :: () => ({-HappyReduction (P) = -} Happy_GHC_Exts.Int# -> (Token) -> HappyState (Token) (HappyStk HappyAbsSyn -> (P) HappyAbsSyn) -> [HappyState (Token) (HappyStk HappyAbsSyn -> (P) HappyAbsSyn)] -> HappyStk HappyAbsSyn -> (P) HappyAbsSyn) action_0 (4#) = happyGoto action_3 action_0 (128#) = happyGoto action_4 action_0 x = happyTcHack x happyReduce_293 action_1 (128#) = happyGoto action_2 action_1 x = happyTcHack x happyFail action_2 (190#) = happyShift action_8 action_2 x = happyTcHack x happyFail action_3 (202#) = happyAccept action_3 x = happyTcHack x happyFail action_4 (152#) = happyShift action_7 action_4 (190#) = happyShift action_8 action_4 (5#) = happyGoto action_5 action_4 (129#) = happyGoto action_6 action_4 x = happyTcHack x happyReduce_294 action_5 x = happyTcHack x happyReduce_2 action_6 (6#) = happyGoto action_15 action_6 (7#) = happyGoto action_13 action_6 (8#) = happyGoto action_14 action_6 x = happyTcHack x happyReduce_11 action_7 (6#) = happyGoto action_12 action_7 (7#) = happyGoto action_13 action_7 (8#) = happyGoto action_14 action_7 x = happyTcHack x happyReduce_11 action_8 (139#) = happyShift action_10 action_8 (140#) = happyShift action_11 action_8 (131#) = happyGoto action_9 action_8 x = happyTcHack x happyFail action_9 (149#) = happyShift action_34 action_9 (9#) = happyGoto action_32 action_9 (10#) = happyGoto action_33 action_9 x = happyTcHack x happyReduce_13 action_10 x = happyTcHack x happyReduce_297 action_11 x = happyTcHack x happyReduce_298 action_12 (153#) = happyShift action_31 action_12 x = happyTcHack x happyFail action_13 x = happyTcHack x happyReduce_10 action_14 (137#) = happyReduce_293 action_14 (138#) = happyReduce_293 action_14 (139#) = happyReduce_293 action_14 (140#) = happyReduce_293 action_14 (145#) = happyReduce_293 action_14 (146#) = happyReduce_293 action_14 (147#) = happyReduce_293 action_14 (148#) = happyReduce_293 action_14 (149#) = happyReduce_293 action_14 (151#) = happyShift action_30 action_14 (155#) = happyReduce_293 action_14 (158#) = happyReduce_293 action_14 (170#) = happyReduce_293 action_14 (172#) = happyReduce_293 action_14 (174#) = happyReduce_293 action_14 (175#) = happyReduce_293 action_14 (176#) = happyReduce_293 action_14 (177#) = happyReduce_293 action_14 (179#) = happyReduce_293 action_14 (181#) = happyReduce_293 action_14 (183#) = happyReduce_293 action_14 (185#) = happyReduce_293 action_14 (186#) = happyReduce_293 action_14 (187#) = happyReduce_293 action_14 (188#) = happyReduce_293 action_14 (191#) = happyReduce_293 action_14 (194#) = happyReduce_293 action_14 (196#) = happyReduce_293 action_14 (197#) = happyReduce_293 action_14 (198#) = happyReduce_293 action_14 (199#) = happyReduce_293 action_14 (200#) = happyReduce_293 action_14 (201#) = happyReduce_293 action_14 (14#) = happyGoto action_19 action_14 (15#) = happyGoto action_20 action_14 (25#) = happyGoto action_21 action_14 (29#) = happyGoto action_22 action_14 (30#) = happyGoto action_23 action_14 (31#) = happyGoto action_24 action_14 (35#) = happyGoto action_25 action_14 (37#) = happyGoto action_26 action_14 (39#) = happyGoto action_27 action_14 (67#) = happyGoto action_28 action_14 (128#) = happyGoto action_29 action_14 x = happyTcHack x happyReduce_8 action_15 (1#) = happyShift action_17 action_15 (154#) = happyShift action_18 action_15 (130#) = happyGoto action_16 action_15 x = happyTcHack x happyFail action_16 x = happyTcHack x happyReduce_4 action_17 x = happyTcHack x happyReduce_296 action_18 x = happyTcHack x happyReduce_295 action_19 (7#) = happyGoto action_95 action_19 (8#) = happyGoto action_96 action_19 x = happyTcHack x happyReduce_11 action_20 x = happyTcHack x happyReduce_27 action_21 x = happyTcHack x happyReduce_77 action_22 x = happyTcHack x happyReduce_6 action_23 (7#) = happyGoto action_93 action_23 (8#) = happyGoto action_94 action_23 x = happyTcHack x happyReduce_11 action_24 x = happyTcHack x happyReduce_60 action_25 x = happyTcHack x happyReduce_68 action_26 x = happyTcHack x happyReduce_76 action_27 x = happyTcHack x happyReduce_67 action_28 x = happyTcHack x happyReduce_78 action_29 (137#) = happyShift action_44 action_29 (138#) = happyShift action_45 action_29 (139#) = happyShift action_46 action_29 (140#) = happyShift action_47 action_29 (145#) = happyShift action_71 action_29 (146#) = happyShift action_72 action_29 (147#) = happyShift action_73 action_29 (148#) = happyShift action_74 action_29 (149#) = happyShift action_75 action_29 (155#) = happyShift action_76 action_29 (158#) = happyShift action_77 action_29 (170#) = happyShift action_78 action_29 (172#) = happyShift action_79 action_29 (174#) = happyShift action_80 action_29 (175#) = happyShift action_81 action_29 (176#) = happyShift action_82 action_29 (177#) = happyShift action_83 action_29 (179#) = happyShift action_84 action_29 (181#) = happyShift action_85 action_29 (183#) = happyShift action_86 action_29 (185#) = happyShift action_87 action_29 (186#) = happyShift action_88 action_29 (187#) = happyShift action_89 action_29 (188#) = happyShift action_90 action_29 (191#) = happyShift action_91 action_29 (194#) = happyShift action_92 action_29 (196#) = happyShift action_51 action_29 (197#) = happyShift action_52 action_29 (198#) = happyShift action_53 action_29 (199#) = happyShift action_54 action_29 (200#) = happyShift action_55 action_29 (201#) = happyShift action_56 action_29 (27#) = happyGoto action_58 action_29 (38#) = happyGoto action_59 action_29 (75#) = happyGoto action_60 action_29 (77#) = happyGoto action_61 action_29 (78#) = happyGoto action_62 action_29 (81#) = happyGoto action_63 action_29 (82#) = happyGoto action_64 action_29 (83#) = happyGoto action_65 action_29 (102#) = happyGoto action_66 action_29 (104#) = happyGoto action_67 action_29 (106#) = happyGoto action_68 action_29 (116#) = happyGoto action_39 action_29 (117#) = happyGoto action_40 action_29 (118#) = happyGoto action_69 action_29 (119#) = happyGoto action_42 action_29 (127#) = happyGoto action_70 action_29 x = happyTcHack x happyFail action_30 x = happyTcHack x happyReduce_9 action_31 x = happyTcHack x happyReduce_3 action_32 (195#) = happyShift action_57 action_32 x = happyTcHack x happyFail action_33 x = happyTcHack x happyReduce_12 action_34 (137#) = happyShift action_44 action_34 (138#) = happyShift action_45 action_34 (139#) = happyShift action_46 action_34 (140#) = happyShift action_47 action_34 (149#) = happyShift action_48 action_34 (157#) = happyShift action_49 action_34 (190#) = happyShift action_50 action_34 (196#) = happyShift action_51 action_34 (197#) = happyShift action_52 action_34 (198#) = happyShift action_53 action_34 (199#) = happyShift action_54 action_34 (200#) = happyShift action_55 action_34 (201#) = happyShift action_56 action_34 (11#) = happyGoto action_35 action_34 (12#) = happyGoto action_36 action_34 (13#) = happyGoto action_37 action_34 (104#) = happyGoto action_38 action_34 (116#) = happyGoto action_39 action_34 (117#) = happyGoto action_40 action_34 (118#) = happyGoto action_41 action_34 (119#) = happyGoto action_42 action_34 (134#) = happyGoto action_43 action_34 x = happyTcHack x happyReduce_17 action_35 (150#) = happyShift action_193 action_35 x = happyTcHack x happyFail action_36 (157#) = happyShift action_192 action_36 (11#) = happyGoto action_191 action_36 x = happyTcHack x happyReduce_17 action_37 x = happyTcHack x happyReduce_19 action_38 x = happyTcHack x happyReduce_20 action_39 x = happyTcHack x happyReduce_240 action_40 x = happyTcHack x happyReduce_264 action_41 x = happyTcHack x happyReduce_301 action_42 x = happyTcHack x happyReduce_273 action_43 (149#) = happyShift action_190 action_43 x = happyTcHack x happyReduce_21 action_44 x = happyTcHack x happyReduce_266 action_45 x = happyTcHack x happyReduce_265 action_46 x = happyTcHack x happyReduce_275 action_47 x = happyTcHack x happyReduce_274 action_48 (141#) = happyShift action_179 action_48 (143#) = happyShift action_158 action_48 (172#) = happyShift action_182 action_48 (173#) = happyShift action_183 action_48 (122#) = happyGoto action_151 action_48 (124#) = happyGoto action_153 action_48 (126#) = happyGoto action_177 action_48 x = happyTcHack x happyFail action_49 x = happyTcHack x happyReduce_16 action_50 (139#) = happyShift action_10 action_50 (140#) = happyShift action_11 action_50 (131#) = happyGoto action_189 action_50 x = happyTcHack x happyFail action_51 x = happyTcHack x happyReduce_267 action_52 x = happyTcHack x happyReduce_268 action_53 x = happyTcHack x happyReduce_269 action_54 x = happyTcHack x happyReduce_270 action_55 x = happyTcHack x happyReduce_271 action_56 x = happyTcHack x happyReduce_272 action_57 (152#) = happyShift action_7 action_57 (5#) = happyGoto action_188 action_57 (129#) = happyGoto action_6 action_57 x = happyTcHack x happyReduce_294 action_58 (145#) = happyShift action_187 action_58 (26#) = happyGoto action_186 action_58 x = happyTcHack x happyReduce_51 action_59 (157#) = happyShift action_184 action_59 (162#) = happyShift action_185 action_59 x = happyTcHack x happyFail action_60 (141#) = happyShift action_179 action_60 (142#) = happyShift action_157 action_60 (143#) = happyShift action_158 action_60 (144#) = happyShift action_159 action_60 (159#) = happyShift action_180 action_60 (161#) = happyShift action_163 action_60 (163#) = happyShift action_181 action_60 (172#) = happyShift action_182 action_60 (173#) = happyShift action_183 action_60 (69#) = happyGoto action_169 action_60 (70#) = happyGoto action_170 action_60 (71#) = happyGoto action_171 action_60 (108#) = happyGoto action_172 action_60 (111#) = happyGoto action_173 action_60 (113#) = happyGoto action_174 action_60 (115#) = happyGoto action_175 action_60 (120#) = happyGoto action_149 action_60 (121#) = happyGoto action_150 action_60 (122#) = happyGoto action_176 action_60 (124#) = happyGoto action_153 action_60 (126#) = happyGoto action_177 action_60 (128#) = happyGoto action_178 action_60 x = happyTcHack x happyReduce_293 action_61 x = happyTcHack x happyReduce_165 action_62 (137#) = happyShift action_44 action_62 (138#) = happyShift action_45 action_62 (139#) = happyShift action_46 action_62 (140#) = happyShift action_47 action_62 (145#) = happyShift action_71 action_62 (146#) = happyShift action_72 action_62 (147#) = happyShift action_73 action_62 (148#) = happyShift action_74 action_62 (149#) = happyShift action_75 action_62 (155#) = happyShift action_76 action_62 (158#) = happyShift action_77 action_62 (170#) = happyShift action_78 action_62 (196#) = happyShift action_51 action_62 (197#) = happyShift action_52 action_62 (198#) = happyShift action_53 action_62 (199#) = happyShift action_54 action_62 (200#) = happyShift action_55 action_62 (201#) = happyShift action_56 action_62 (81#) = happyGoto action_168 action_62 (82#) = happyGoto action_64 action_62 (83#) = happyGoto action_65 action_62 (102#) = happyGoto action_66 action_62 (104#) = happyGoto action_131 action_62 (106#) = happyGoto action_68 action_62 (116#) = happyGoto action_39 action_62 (117#) = happyGoto action_40 action_62 (118#) = happyGoto action_69 action_62 (119#) = happyGoto action_42 action_62 (127#) = happyGoto action_70 action_62 x = happyTcHack x happyReduce_172 action_63 x = happyTcHack x happyReduce_174 action_64 (152#) = happyShift action_167 action_64 x = happyTcHack x happyReduce_180 action_65 x = happyTcHack x happyReduce_183 action_66 x = happyTcHack x happyReduce_185 action_67 (157#) = happyReduce_83 action_67 (162#) = happyReduce_83 action_67 (169#) = happyShift action_166 action_67 x = happyTcHack x happyReduce_184 action_68 x = happyTcHack x happyReduce_237 action_69 x = happyTcHack x happyReduce_244 action_70 x = happyTcHack x happyReduce_186 action_71 x = happyTcHack x happyReduce_289 action_72 x = happyTcHack x happyReduce_291 action_73 x = happyTcHack x happyReduce_290 action_74 x = happyTcHack x happyReduce_292 action_75 (137#) = happyShift action_44 action_75 (138#) = happyShift action_45 action_75 (139#) = happyShift action_46 action_75 (140#) = happyShift action_47 action_75 (141#) = happyShift action_156 action_75 (142#) = happyShift action_157 action_75 (143#) = happyShift action_158 action_75 (144#) = happyShift action_159 action_75 (145#) = happyShift action_71 action_75 (146#) = happyShift action_72 action_75 (147#) = happyShift action_73 action_75 (148#) = happyShift action_74 action_75 (149#) = happyShift action_75 action_75 (150#) = happyShift action_160 action_75 (155#) = happyShift action_76 action_75 (157#) = happyShift action_161 action_75 (158#) = happyShift action_77 action_75 (159#) = happyShift action_162 action_75 (161#) = happyShift action_163 action_75 (164#) = happyShift action_132 action_75 (170#) = happyShift action_78 action_75 (172#) = happyShift action_164 action_75 (173#) = happyShift action_165 action_75 (174#) = happyShift action_80 action_75 (179#) = happyShift action_84 action_75 (182#) = happyShift action_133 action_75 (189#) = happyShift action_134 action_75 (196#) = happyShift action_51 action_75 (197#) = happyShift action_52 action_75 (198#) = happyShift action_53 action_75 (199#) = happyShift action_54 action_75 (200#) = happyShift action_55 action_75 (201#) = happyShift action_56 action_75 (72#) = happyGoto action_141 action_75 (73#) = happyGoto action_127 action_75 (74#) = happyGoto action_128 action_75 (75#) = happyGoto action_142 action_75 (76#) = happyGoto action_130 action_75 (77#) = happyGoto action_61 action_75 (78#) = happyGoto action_62 action_75 (81#) = happyGoto action_63 action_75 (82#) = happyGoto action_64 action_75 (83#) = happyGoto action_65 action_75 (84#) = happyGoto action_143 action_75 (85#) = happyGoto action_144 action_75 (102#) = happyGoto action_66 action_75 (104#) = happyGoto action_131 action_75 (106#) = happyGoto action_68 action_75 (109#) = happyGoto action_145 action_75 (111#) = happyGoto action_146 action_75 (114#) = happyGoto action_147 action_75 (115#) = happyGoto action_148 action_75 (116#) = happyGoto action_39 action_75 (117#) = happyGoto action_40 action_75 (118#) = happyGoto action_69 action_75 (119#) = happyGoto action_42 action_75 (120#) = happyGoto action_149 action_75 (121#) = happyGoto action_150 action_75 (122#) = happyGoto action_151 action_75 (123#) = happyGoto action_152 action_75 (124#) = happyGoto action_153 action_75 (125#) = happyGoto action_154 action_75 (126#) = happyGoto action_155 action_75 (127#) = happyGoto action_70 action_75 x = happyTcHack x happyFail action_76 (137#) = happyShift action_44 action_76 (138#) = happyShift action_45 action_76 (139#) = happyShift action_46 action_76 (140#) = happyShift action_47 action_76 (145#) = happyShift action_71 action_76 (146#) = happyShift action_72 action_76 (147#) = happyShift action_73 action_76 (148#) = happyShift action_74 action_76 (149#) = happyShift action_75 action_76 (155#) = happyShift action_76 action_76 (156#) = happyShift action_140 action_76 (158#) = happyShift action_77 action_76 (164#) = happyShift action_132 action_76 (170#) = happyShift action_78 action_76 (172#) = happyShift action_79 action_76 (174#) = happyShift action_80 action_76 (179#) = happyShift action_84 action_76 (182#) = happyShift action_133 action_76 (189#) = happyShift action_134 action_76 (196#) = happyShift action_51 action_76 (197#) = happyShift action_52 action_76 (198#) = happyShift action_53 action_76 (199#) = happyShift action_54 action_76 (200#) = happyShift action_55 action_76 (201#) = happyShift action_56 action_76 (72#) = happyGoto action_137 action_76 (73#) = happyGoto action_127 action_76 (74#) = happyGoto action_128 action_76 (75#) = happyGoto action_129 action_76 (76#) = happyGoto action_130 action_76 (77#) = happyGoto action_61 action_76 (78#) = happyGoto action_62 action_76 (81#) = happyGoto action_63 action_76 (82#) = happyGoto action_64 action_76 (83#) = happyGoto action_65 action_76 (86#) = happyGoto action_138 action_76 (87#) = happyGoto action_139 action_76 (102#) = happyGoto action_66 action_76 (104#) = happyGoto action_131 action_76 (106#) = happyGoto action_68 action_76 (116#) = happyGoto action_39 action_76 (117#) = happyGoto action_40 action_76 (118#) = happyGoto action_69 action_76 (119#) = happyGoto action_42 action_76 (127#) = happyGoto action_70 action_76 x = happyTcHack x happyFail action_77 x = happyTcHack x happyReduce_192 action_78 (137#) = happyShift action_44 action_78 (138#) = happyShift action_45 action_78 (139#) = happyShift action_46 action_78 (140#) = happyShift action_47 action_78 (145#) = happyShift action_71 action_78 (146#) = happyShift action_72 action_78 (147#) = happyShift action_73 action_78 (148#) = happyShift action_74 action_78 (149#) = happyShift action_75 action_78 (155#) = happyShift action_76 action_78 (158#) = happyShift action_77 action_78 (170#) = happyShift action_78 action_78 (196#) = happyShift action_51 action_78 (197#) = happyShift action_52 action_78 (198#) = happyShift action_53 action_78 (199#) = happyShift action_54 action_78 (200#) = happyShift action_55 action_78 (201#) = happyShift action_56 action_78 (81#) = happyGoto action_136 action_78 (82#) = happyGoto action_64 action_78 (83#) = happyGoto action_65 action_78 (102#) = happyGoto action_66 action_78 (104#) = happyGoto action_131 action_78 (106#) = happyGoto action_68 action_78 (116#) = happyGoto action_39 action_78 (117#) = happyGoto action_40 action_78 (118#) = happyGoto action_69 action_78 (119#) = happyGoto action_42 action_78 (127#) = happyGoto action_70 action_78 x = happyTcHack x happyFail action_79 (137#) = happyShift action_44 action_79 (138#) = happyShift action_45 action_79 (139#) = happyShift action_46 action_79 (140#) = happyShift action_47 action_79 (145#) = happyShift action_71 action_79 (146#) = happyShift action_72 action_79 (147#) = happyShift action_73 action_79 (148#) = happyShift action_74 action_79 (149#) = happyShift action_75 action_79 (155#) = happyShift action_76 action_79 (158#) = happyShift action_77 action_79 (170#) = happyShift action_78 action_79 (196#) = happyShift action_51 action_79 (197#) = happyShift action_52 action_79 (198#) = happyShift action_53 action_79 (199#) = happyShift action_54 action_79 (200#) = happyShift action_55 action_79 (201#) = happyShift action_56 action_79 (78#) = happyGoto action_135 action_79 (81#) = happyGoto action_63 action_79 (82#) = happyGoto action_64 action_79 (83#) = happyGoto action_65 action_79 (102#) = happyGoto action_66 action_79 (104#) = happyGoto action_131 action_79 (106#) = happyGoto action_68 action_79 (116#) = happyGoto action_39 action_79 (117#) = happyGoto action_40 action_79 (118#) = happyGoto action_69 action_79 (119#) = happyGoto action_42 action_79 (127#) = happyGoto action_70 action_79 x = happyTcHack x happyFail action_80 (137#) = happyShift action_44 action_80 (138#) = happyShift action_45 action_80 (139#) = happyShift action_46 action_80 (140#) = happyShift action_47 action_80 (145#) = happyShift action_71 action_80 (146#) = happyShift action_72 action_80 (147#) = happyShift action_73 action_80 (148#) = happyShift action_74 action_80 (149#) = happyShift action_75 action_80 (155#) = happyShift action_76 action_80 (158#) = happyShift action_77 action_80 (164#) = happyShift action_132 action_80 (170#) = happyShift action_78 action_80 (172#) = happyShift action_79 action_80 (174#) = happyShift action_80 action_80 (179#) = happyShift action_84 action_80 (182#) = happyShift action_133 action_80 (189#) = happyShift action_134 action_80 (196#) = happyShift action_51 action_80 (197#) = happyShift action_52 action_80 (198#) = happyShift action_53 action_80 (199#) = happyShift action_54 action_80 (200#) = happyShift action_55 action_80 (201#) = happyShift action_56 action_80 (72#) = happyGoto action_126 action_80 (73#) = happyGoto action_127 action_80 (74#) = happyGoto action_128 action_80 (75#) = happyGoto action_129 action_80 (76#) = happyGoto action_130 action_80 (77#) = happyGoto action_61 action_80 (78#) = happyGoto action_62 action_80 (81#) = happyGoto action_63 action_80 (82#) = happyGoto action_64 action_80 (83#) = happyGoto action_65 action_80 (102#) = happyGoto action_66 action_80 (104#) = happyGoto action_131 action_80 (106#) = happyGoto action_68 action_80 (116#) = happyGoto action_39 action_80 (117#) = happyGoto action_40 action_80 (118#) = happyGoto action_69 action_80 (119#) = happyGoto action_42 action_80 (127#) = happyGoto action_70 action_80 x = happyTcHack x happyFail action_81 (137#) = happyShift action_44 action_81 (139#) = happyShift action_46 action_81 (140#) = happyShift action_47 action_81 (149#) = happyShift action_113 action_81 (155#) = happyShift action_114 action_81 (196#) = happyShift action_51 action_81 (197#) = happyShift action_52 action_81 (198#) = happyShift action_53 action_81 (199#) = happyShift action_54 action_81 (200#) = happyShift action_55 action_81 (201#) = happyShift action_56 action_81 (43#) = happyGoto action_104 action_81 (44#) = happyGoto action_105 action_81 (45#) = happyGoto action_106 action_81 (46#) = happyGoto action_107 action_81 (47#) = happyGoto action_125 action_81 (48#) = happyGoto action_109 action_81 (117#) = happyGoto action_110 action_81 (118#) = happyGoto action_111 action_81 (119#) = happyGoto action_42 action_81 (136#) = happyGoto action_112 action_81 x = happyTcHack x happyFail action_82 (137#) = happyShift action_44 action_82 (139#) = happyShift action_46 action_82 (140#) = happyShift action_47 action_82 (149#) = happyShift action_113 action_82 (155#) = happyShift action_114 action_82 (196#) = happyShift action_51 action_82 (197#) = happyShift action_52 action_82 (198#) = happyShift action_53 action_82 (199#) = happyShift action_54 action_82 (200#) = happyShift action_55 action_82 (201#) = happyShift action_56 action_82 (43#) = happyGoto action_104 action_82 (44#) = happyGoto action_105 action_82 (45#) = happyGoto action_106 action_82 (46#) = happyGoto action_107 action_82 (47#) = happyGoto action_124 action_82 (48#) = happyGoto action_109 action_82 (117#) = happyGoto action_110 action_82 (118#) = happyGoto action_111 action_82 (119#) = happyGoto action_42 action_82 (136#) = happyGoto action_112 action_82 x = happyTcHack x happyFail action_83 (149#) = happyShift action_123 action_83 x = happyTcHack x happyFail action_84 (152#) = happyShift action_122 action_84 (98#) = happyGoto action_120 action_84 (129#) = happyGoto action_121 action_84 x = happyTcHack x happyReduce_294 action_85 (183#) = happyShift action_118 action_85 (197#) = happyShift action_119 action_85 x = happyTcHack x happyFail action_86 (199#) = happyShift action_117 action_86 (16#) = happyGoto action_116 action_86 x = happyTcHack x happyReduce_30 action_87 x = happyTcHack x happyReduce_53 action_88 x = happyTcHack x happyReduce_54 action_89 x = happyTcHack x happyReduce_55 action_90 (137#) = happyShift action_44 action_90 (139#) = happyShift action_46 action_90 (140#) = happyShift action_47 action_90 (149#) = happyShift action_113 action_90 (155#) = happyShift action_114 action_90 (196#) = happyShift action_51 action_90 (197#) = happyShift action_52 action_90 (198#) = happyShift action_53 action_90 (199#) = happyShift action_54 action_90 (200#) = happyShift action_55 action_90 (201#) = happyShift action_56 action_90 (43#) = happyGoto action_104 action_90 (44#) = happyGoto action_105 action_90 (45#) = happyGoto action_106 action_90 (46#) = happyGoto action_107 action_90 (47#) = happyGoto action_115 action_90 (48#) = happyGoto action_109 action_90 (117#) = happyGoto action_110 action_90 (118#) = happyGoto action_111 action_90 (119#) = happyGoto action_42 action_90 (136#) = happyGoto action_112 action_90 x = happyTcHack x happyFail action_91 (137#) = happyShift action_44 action_91 (139#) = happyShift action_46 action_91 (140#) = happyShift action_47 action_91 (149#) = happyShift action_113 action_91 (155#) = happyShift action_114 action_91 (196#) = happyShift action_51 action_91 (197#) = happyShift action_52 action_91 (198#) = happyShift action_53 action_91 (199#) = happyShift action_54 action_91 (200#) = happyShift action_55 action_91 (201#) = happyShift action_56 action_91 (43#) = happyGoto action_104 action_91 (44#) = happyGoto action_105 action_91 (45#) = happyGoto action_106 action_91 (46#) = happyGoto action_107 action_91 (47#) = happyGoto action_108 action_91 (48#) = happyGoto action_109 action_91 (117#) = happyGoto action_110 action_91 (118#) = happyGoto action_111 action_91 (119#) = happyGoto action_42 action_91 (136#) = happyGoto action_112 action_91 x = happyTcHack x happyFail action_92 (139#) = happyShift action_46 action_92 (50#) = happyGoto action_101 action_92 (119#) = happyGoto action_102 action_92 (133#) = happyGoto action_103 action_92 x = happyTcHack x happyFail action_93 (137#) = happyReduce_293 action_93 (138#) = happyReduce_293 action_93 (139#) = happyReduce_293 action_93 (140#) = happyReduce_293 action_93 (145#) = happyReduce_293 action_93 (146#) = happyReduce_293 action_93 (147#) = happyReduce_293 action_93 (148#) = happyReduce_293 action_93 (149#) = happyReduce_293 action_93 (155#) = happyReduce_293 action_93 (158#) = happyReduce_293 action_93 (170#) = happyReduce_293 action_93 (172#) = happyReduce_293 action_93 (174#) = happyReduce_293 action_93 (175#) = happyReduce_293 action_93 (176#) = happyReduce_293 action_93 (177#) = happyReduce_293 action_93 (179#) = happyReduce_293 action_93 (181#) = happyReduce_293 action_93 (185#) = happyReduce_293 action_93 (186#) = happyReduce_293 action_93 (187#) = happyReduce_293 action_93 (188#) = happyReduce_293 action_93 (191#) = happyReduce_293 action_93 (194#) = happyReduce_293 action_93 (196#) = happyReduce_293 action_93 (197#) = happyReduce_293 action_93 (198#) = happyReduce_293 action_93 (199#) = happyReduce_293 action_93 (200#) = happyReduce_293 action_93 (201#) = happyReduce_293 action_93 (25#) = happyGoto action_21 action_93 (31#) = happyGoto action_99 action_93 (35#) = happyGoto action_25 action_93 (37#) = happyGoto action_26 action_93 (39#) = happyGoto action_27 action_93 (67#) = happyGoto action_28 action_93 (128#) = happyGoto action_100 action_93 x = happyTcHack x happyReduce_10 action_94 (151#) = happyShift action_30 action_94 x = happyTcHack x happyReduce_58 action_95 (137#) = happyReduce_293 action_95 (138#) = happyReduce_293 action_95 (139#) = happyReduce_293 action_95 (140#) = happyReduce_293 action_95 (145#) = happyReduce_293 action_95 (146#) = happyReduce_293 action_95 (147#) = happyReduce_293 action_95 (148#) = happyReduce_293 action_95 (149#) = happyReduce_293 action_95 (155#) = happyReduce_293 action_95 (158#) = happyReduce_293 action_95 (170#) = happyReduce_293 action_95 (172#) = happyReduce_293 action_95 (174#) = happyReduce_293 action_95 (175#) = happyReduce_293 action_95 (176#) = happyReduce_293 action_95 (177#) = happyReduce_293 action_95 (179#) = happyReduce_293 action_95 (181#) = happyReduce_293 action_95 (183#) = happyReduce_293 action_95 (185#) = happyReduce_293 action_95 (186#) = happyReduce_293 action_95 (187#) = happyReduce_293 action_95 (188#) = happyReduce_293 action_95 (191#) = happyReduce_293 action_95 (194#) = happyReduce_293 action_95 (196#) = happyReduce_293 action_95 (197#) = happyReduce_293 action_95 (198#) = happyReduce_293 action_95 (199#) = happyReduce_293 action_95 (200#) = happyReduce_293 action_95 (201#) = happyReduce_293 action_95 (15#) = happyGoto action_97 action_95 (25#) = happyGoto action_21 action_95 (29#) = happyGoto action_98 action_95 (30#) = happyGoto action_23 action_95 (31#) = happyGoto action_24 action_95 (35#) = happyGoto action_25 action_95 (37#) = happyGoto action_26 action_95 (39#) = happyGoto action_27 action_95 (67#) = happyGoto action_28 action_95 (128#) = happyGoto action_29 action_95 x = happyTcHack x happyReduce_10 action_96 (151#) = happyShift action_30 action_96 x = happyTcHack x happyReduce_7 action_97 x = happyTcHack x happyReduce_26 action_98 x = happyTcHack x happyReduce_5 action_99 x = happyTcHack x happyReduce_59 action_100 (137#) = happyShift action_44 action_100 (138#) = happyShift action_45 action_100 (139#) = happyShift action_46 action_100 (140#) = happyShift action_47 action_100 (145#) = happyShift action_71 action_100 (146#) = happyShift action_72 action_100 (147#) = happyShift action_73 action_100 (148#) = happyShift action_74 action_100 (149#) = happyShift action_75 action_100 (155#) = happyShift action_76 action_100 (158#) = happyShift action_77 action_100 (170#) = happyShift action_78 action_100 (172#) = happyShift action_79 action_100 (174#) = happyShift action_80 action_100 (175#) = happyShift action_81 action_100 (176#) = happyShift action_82 action_100 (177#) = happyShift action_83 action_100 (179#) = happyShift action_84 action_100 (181#) = happyShift action_85 action_100 (185#) = happyShift action_87 action_100 (186#) = happyShift action_88 action_100 (187#) = happyShift action_89 action_100 (188#) = happyShift action_90 action_100 (191#) = happyShift action_91 action_100 (194#) = happyShift action_92 action_100 (196#) = happyShift action_51 action_100 (197#) = happyShift action_52 action_100 (198#) = happyShift action_53 action_100 (199#) = happyShift action_54 action_100 (200#) = happyShift action_55 action_100 (201#) = happyShift action_56 action_100 (27#) = happyGoto action_58 action_100 (38#) = happyGoto action_59 action_100 (75#) = happyGoto action_60 action_100 (77#) = happyGoto action_61 action_100 (78#) = happyGoto action_62 action_100 (81#) = happyGoto action_63 action_100 (82#) = happyGoto action_64 action_100 (83#) = happyGoto action_65 action_100 (102#) = happyGoto action_66 action_100 (104#) = happyGoto action_67 action_100 (106#) = happyGoto action_68 action_100 (116#) = happyGoto action_39 action_100 (117#) = happyGoto action_40 action_100 (118#) = happyGoto action_69 action_100 (119#) = happyGoto action_42 action_100 (127#) = happyGoto action_70 action_100 x = happyTcHack x happyFail action_101 (163#) = happyShift action_285 action_101 x = happyTcHack x happyFail action_102 x = happyTcHack x happyReduce_300 action_103 (51#) = happyGoto action_284 action_103 x = happyTcHack x happyReduce_115 action_104 (168#) = happyShift action_283 action_104 x = happyTcHack x happyReduce_109 action_105 (137#) = happyShift action_44 action_105 (139#) = happyShift action_46 action_105 (140#) = happyShift action_47 action_105 (149#) = happyShift action_113 action_105 (155#) = happyShift action_114 action_105 (167#) = happyShift action_282 action_105 (171#) = happyReduce_110 action_105 (196#) = happyShift action_51 action_105 (197#) = happyShift action_52 action_105 (198#) = happyShift action_53 action_105 (199#) = happyShift action_54 action_105 (200#) = happyShift action_55 action_105 (201#) = happyShift action_56 action_105 (45#) = happyGoto action_281 action_105 (46#) = happyGoto action_107 action_105 (117#) = happyGoto action_110 action_105 (118#) = happyGoto action_111 action_105 (119#) = happyGoto action_42 action_105 (136#) = happyGoto action_112 action_105 x = happyTcHack x happyReduce_95 action_106 x = happyTcHack x happyReduce_97 action_107 x = happyTcHack x happyReduce_98 action_108 (163#) = happyShift action_280 action_108 x = happyTcHack x happyFail action_109 (171#) = happyShift action_279 action_109 x = happyTcHack x happyFail action_110 x = happyTcHack x happyReduce_303 action_111 x = happyTcHack x happyReduce_103 action_112 x = happyTcHack x happyReduce_99 action_113 (137#) = happyShift action_44 action_113 (139#) = happyShift action_46 action_113 (140#) = happyShift action_47 action_113 (149#) = happyShift action_113 action_113 (150#) = happyShift action_277 action_113 (155#) = happyShift action_114 action_113 (157#) = happyShift action_161 action_113 (167#) = happyShift action_278 action_113 (196#) = happyShift action_51 action_113 (197#) = happyShift action_52 action_113 (198#) = happyShift action_53 action_113 (199#) = happyShift action_54 action_113 (200#) = happyShift action_55 action_113 (201#) = happyShift action_56 action_113 (43#) = happyGoto action_274 action_113 (44#) = happyGoto action_258 action_113 (45#) = happyGoto action_106 action_113 (46#) = happyGoto action_107 action_113 (49#) = happyGoto action_275 action_113 (84#) = happyGoto action_276 action_113 (117#) = happyGoto action_110 action_113 (118#) = happyGoto action_111 action_113 (119#) = happyGoto action_42 action_113 (136#) = happyGoto action_112 action_113 x = happyTcHack x happyFail action_114 (137#) = happyShift action_44 action_114 (139#) = happyShift action_46 action_114 (140#) = happyShift action_47 action_114 (149#) = happyShift action_113 action_114 (155#) = happyShift action_114 action_114 (156#) = happyShift action_273 action_114 (196#) = happyShift action_51 action_114 (197#) = happyShift action_52 action_114 (198#) = happyShift action_53 action_114 (199#) = happyShift action_54 action_114 (200#) = happyShift action_55 action_114 (201#) = happyShift action_56 action_114 (43#) = happyGoto action_272 action_114 (44#) = happyGoto action_258 action_114 (45#) = happyGoto action_106 action_114 (46#) = happyGoto action_107 action_114 (117#) = happyGoto action_110 action_114 (118#) = happyGoto action_111 action_114 (119#) = happyGoto action_42 action_114 (136#) = happyGoto action_112 action_114 x = happyTcHack x happyFail action_115 (195#) = happyShift action_271 action_115 (64#) = happyGoto action_270 action_115 x = happyTcHack x happyReduce_145 action_116 (139#) = happyShift action_10 action_116 (140#) = happyShift action_11 action_116 (131#) = happyGoto action_269 action_116 x = happyTcHack x happyFail action_117 x = happyTcHack x happyReduce_29 action_118 (137#) = happyShift action_268 action_118 x = happyTcHack x happyFail action_119 (137#) = happyShift action_267 action_119 x = happyTcHack x happyFail action_120 x = happyTcHack x happyReduce_171 action_121 (137#) = happyShift action_44 action_121 (138#) = happyShift action_45 action_121 (139#) = happyShift action_46 action_121 (140#) = happyShift action_47 action_121 (145#) = happyShift action_71 action_121 (146#) = happyShift action_72 action_121 (147#) = happyShift action_73 action_121 (148#) = happyShift action_74 action_121 (149#) = happyShift action_75 action_121 (151#) = happyShift action_264 action_121 (155#) = happyShift action_76 action_121 (158#) = happyShift action_77 action_121 (164#) = happyShift action_132 action_121 (170#) = happyShift action_78 action_121 (172#) = happyShift action_79 action_121 (174#) = happyShift action_80 action_121 (179#) = happyShift action_84 action_121 (182#) = happyShift action_133 action_121 (189#) = happyShift action_265 action_121 (196#) = happyShift action_51 action_121 (197#) = happyShift action_52 action_121 (198#) = happyShift action_53 action_121 (199#) = happyShift action_54 action_121 (200#) = happyShift action_55 action_121 (201#) = happyShift action_56 action_121 (72#) = happyGoto action_260 action_121 (73#) = happyGoto action_127 action_121 (74#) = happyGoto action_128 action_121 (75#) = happyGoto action_261 action_121 (76#) = happyGoto action_130 action_121 (77#) = happyGoto action_61 action_121 (78#) = happyGoto action_62 action_121 (81#) = happyGoto action_63 action_121 (82#) = happyGoto action_64 action_121 (83#) = happyGoto action_65 action_121 (97#) = happyGoto action_262 action_121 (99#) = happyGoto action_266 action_121 (102#) = happyGoto action_66 action_121 (104#) = happyGoto action_131 action_121 (106#) = happyGoto action_68 action_121 (116#) = happyGoto action_39 action_121 (117#) = happyGoto action_40 action_121 (118#) = happyGoto action_69 action_121 (119#) = happyGoto action_42 action_121 (127#) = happyGoto action_70 action_121 x = happyTcHack x happyFail action_122 (137#) = happyShift action_44 action_122 (138#) = happyShift action_45 action_122 (139#) = happyShift action_46 action_122 (140#) = happyShift action_47 action_122 (145#) = happyShift action_71 action_122 (146#) = happyShift action_72 action_122 (147#) = happyShift action_73 action_122 (148#) = happyShift action_74 action_122 (149#) = happyShift action_75 action_122 (151#) = happyShift action_264 action_122 (155#) = happyShift action_76 action_122 (158#) = happyShift action_77 action_122 (164#) = happyShift action_132 action_122 (170#) = happyShift action_78 action_122 (172#) = happyShift action_79 action_122 (174#) = happyShift action_80 action_122 (179#) = happyShift action_84 action_122 (182#) = happyShift action_133 action_122 (189#) = happyShift action_265 action_122 (196#) = happyShift action_51 action_122 (197#) = happyShift action_52 action_122 (198#) = happyShift action_53 action_122 (199#) = happyShift action_54 action_122 (200#) = happyShift action_55 action_122 (201#) = happyShift action_56 action_122 (72#) = happyGoto action_260 action_122 (73#) = happyGoto action_127 action_122 (74#) = happyGoto action_128 action_122 (75#) = happyGoto action_261 action_122 (76#) = happyGoto action_130 action_122 (77#) = happyGoto action_61 action_122 (78#) = happyGoto action_62 action_122 (81#) = happyGoto action_63 action_122 (82#) = happyGoto action_64 action_122 (83#) = happyGoto action_65 action_122 (97#) = happyGoto action_262 action_122 (99#) = happyGoto action_263 action_122 (102#) = happyGoto action_66 action_122 (104#) = happyGoto action_131 action_122 (106#) = happyGoto action_68 action_122 (116#) = happyGoto action_39 action_122 (117#) = happyGoto action_40 action_122 (118#) = happyGoto action_69 action_122 (119#) = happyGoto action_42 action_122 (127#) = happyGoto action_70 action_122 x = happyTcHack x happyFail action_123 (137#) = happyShift action_44 action_123 (139#) = happyShift action_46 action_123 (140#) = happyShift action_47 action_123 (149#) = happyShift action_113 action_123 (155#) = happyShift action_114 action_123 (196#) = happyShift action_51 action_123 (197#) = happyShift action_52 action_123 (198#) = happyShift action_53 action_123 (199#) = happyShift action_54 action_123 (200#) = happyShift action_55 action_123 (201#) = happyShift action_56 action_123 (32#) = happyGoto action_256 action_123 (43#) = happyGoto action_257 action_123 (44#) = happyGoto action_258 action_123 (45#) = happyGoto action_106 action_123 (46#) = happyGoto action_107 action_123 (49#) = happyGoto action_259 action_123 (117#) = happyGoto action_110 action_123 (118#) = happyGoto action_111 action_123 (119#) = happyGoto action_42 action_123 (136#) = happyGoto action_112 action_123 x = happyTcHack x happyReduce_71 action_124 (163#) = happyShift action_255 action_124 x = happyTcHack x happyFail action_125 (195#) = happyShift action_254 action_125 (63#) = happyGoto action_253 action_125 x = happyTcHack x happyReduce_142 action_126 (192#) = happyShift action_252 action_126 x = happyTcHack x happyFail action_127 x = happyTcHack x happyReduce_159 action_128 x = happyTcHack x happyReduce_160 action_129 (141#) = happyShift action_179 action_129 (142#) = happyShift action_157 action_129 (143#) = happyShift action_158 action_129 (144#) = happyShift action_159 action_129 (159#) = happyShift action_180 action_129 (161#) = happyShift action_163 action_129 (162#) = happyShift action_238 action_129 (172#) = happyShift action_182 action_129 (173#) = happyShift action_183 action_129 (108#) = happyGoto action_172 action_129 (111#) = happyGoto action_173 action_129 (113#) = happyGoto action_251 action_129 (115#) = happyGoto action_175 action_129 (120#) = happyGoto action_149 action_129 (121#) = happyGoto action_150 action_129 (122#) = happyGoto action_176 action_129 (124#) = happyGoto action_153 action_129 (126#) = happyGoto action_177 action_129 x = happyTcHack x happyReduce_161 action_130 x = happyTcHack x happyReduce_163 action_131 (169#) = happyShift action_166 action_131 x = happyTcHack x happyReduce_184 action_132 (128#) = happyGoto action_250 action_132 x = happyTcHack x happyReduce_293 action_133 (137#) = happyShift action_44 action_133 (138#) = happyShift action_45 action_133 (139#) = happyShift action_46 action_133 (140#) = happyShift action_47 action_133 (145#) = happyShift action_71 action_133 (146#) = happyShift action_72 action_133 (147#) = happyShift action_73 action_133 (148#) = happyShift action_74 action_133 (149#) = happyShift action_75 action_133 (155#) = happyShift action_76 action_133 (158#) = happyShift action_77 action_133 (164#) = happyShift action_132 action_133 (170#) = happyShift action_78 action_133 (172#) = happyShift action_79 action_133 (174#) = happyShift action_80 action_133 (179#) = happyShift action_84 action_133 (182#) = happyShift action_133 action_133 (189#) = happyShift action_134 action_133 (196#) = happyShift action_51 action_133 (197#) = happyShift action_52 action_133 (198#) = happyShift action_53 action_133 (199#) = happyShift action_54 action_133 (200#) = happyShift action_55 action_133 (201#) = happyShift action_56 action_133 (72#) = happyGoto action_249 action_133 (73#) = happyGoto action_127 action_133 (74#) = happyGoto action_128 action_133 (75#) = happyGoto action_129 action_133 (76#) = happyGoto action_130 action_133 (77#) = happyGoto action_61 action_133 (78#) = happyGoto action_62 action_133 (81#) = happyGoto action_63 action_133 (82#) = happyGoto action_64 action_133 (83#) = happyGoto action_65 action_133 (102#) = happyGoto action_66 action_133 (104#) = happyGoto action_131 action_133 (106#) = happyGoto action_68 action_133 (116#) = happyGoto action_39 action_133 (117#) = happyGoto action_40 action_133 (118#) = happyGoto action_69 action_133 (119#) = happyGoto action_42 action_133 (127#) = happyGoto action_70 action_133 x = happyTcHack x happyFail action_134 (152#) = happyShift action_248 action_134 (36#) = happyGoto action_246 action_134 (129#) = happyGoto action_247 action_134 x = happyTcHack x happyReduce_294 action_135 (137#) = happyShift action_44 action_135 (138#) = happyShift action_45 action_135 (139#) = happyShift action_46 action_135 (140#) = happyShift action_47 action_135 (145#) = happyShift action_71 action_135 (146#) = happyShift action_72 action_135 (147#) = happyShift action_73 action_135 (148#) = happyShift action_74 action_135 (149#) = happyShift action_75 action_135 (155#) = happyShift action_76 action_135 (158#) = happyShift action_77 action_135 (170#) = happyShift action_78 action_135 (196#) = happyShift action_51 action_135 (197#) = happyShift action_52 action_135 (198#) = happyShift action_53 action_135 (199#) = happyShift action_54 action_135 (200#) = happyShift action_55 action_135 (201#) = happyShift action_56 action_135 (81#) = happyGoto action_168 action_135 (82#) = happyGoto action_64 action_135 (83#) = happyGoto action_65 action_135 (102#) = happyGoto action_66 action_135 (104#) = happyGoto action_131 action_135 (106#) = happyGoto action_68 action_135 (116#) = happyGoto action_39 action_135 (117#) = happyGoto action_40 action_135 (118#) = happyGoto action_69 action_135 (119#) = happyGoto action_42 action_135 (127#) = happyGoto action_70 action_135 x = happyTcHack x happyReduce_170 action_136 x = happyTcHack x happyReduce_179 action_137 (157#) = happyShift action_243 action_137 (160#) = happyShift action_244 action_137 (165#) = happyShift action_245 action_137 x = happyTcHack x happyReduce_197 action_138 (156#) = happyShift action_242 action_138 x = happyTcHack x happyFail action_139 (157#) = happyShift action_241 action_139 x = happyTcHack x happyReduce_198 action_140 x = happyTcHack x happyReduce_235 action_141 (150#) = happyShift action_239 action_141 (157#) = happyShift action_240 action_141 x = happyTcHack x happyFail action_142 (141#) = happyShift action_179 action_142 (142#) = happyShift action_157 action_142 (143#) = happyShift action_158 action_142 (144#) = happyShift action_159 action_142 (159#) = happyShift action_180 action_142 (161#) = happyShift action_163 action_142 (162#) = happyShift action_238 action_142 (172#) = happyShift action_182 action_142 (173#) = happyShift action_183 action_142 (108#) = happyGoto action_172 action_142 (111#) = happyGoto action_173 action_142 (113#) = happyGoto action_237 action_142 (115#) = happyGoto action_175 action_142 (120#) = happyGoto action_149 action_142 (121#) = happyGoto action_150 action_142 (122#) = happyGoto action_176 action_142 (124#) = happyGoto action_153 action_142 (126#) = happyGoto action_177 action_142 x = happyTcHack x happyReduce_161 action_143 (150#) = happyShift action_235 action_143 (157#) = happyShift action_236 action_143 x = happyTcHack x happyFail action_144 (150#) = happyShift action_233 action_144 (157#) = happyShift action_234 action_144 x = happyTcHack x happyFail action_145 x = happyTcHack x happyReduce_260 action_146 x = happyTcHack x happyReduce_261 action_147 (137#) = happyShift action_44 action_147 (138#) = happyShift action_45 action_147 (139#) = happyShift action_46 action_147 (140#) = happyShift action_47 action_147 (145#) = happyShift action_71 action_147 (146#) = happyShift action_72 action_147 (147#) = happyShift action_73 action_147 (148#) = happyShift action_74 action_147 (149#) = happyShift action_75 action_147 (155#) = happyShift action_76 action_147 (158#) = happyShift action_77 action_147 (164#) = happyShift action_132 action_147 (170#) = happyShift action_78 action_147 (172#) = happyShift action_79 action_147 (174#) = happyShift action_80 action_147 (179#) = happyShift action_84 action_147 (182#) = happyShift action_133 action_147 (189#) = happyShift action_134 action_147 (196#) = happyShift action_51 action_147 (197#) = happyShift action_52 action_147 (198#) = happyShift action_53 action_147 (199#) = happyShift action_54 action_147 (200#) = happyShift action_55 action_147 (201#) = happyShift action_56 action_147 (73#) = happyGoto action_231 action_147 (74#) = happyGoto action_128 action_147 (75#) = happyGoto action_232 action_147 (76#) = happyGoto action_130 action_147 (77#) = happyGoto action_61 action_147 (78#) = happyGoto action_62 action_147 (81#) = happyGoto action_63 action_147 (82#) = happyGoto action_64 action_147 (83#) = happyGoto action_65 action_147 (102#) = happyGoto action_66 action_147 (104#) = happyGoto action_131 action_147 (106#) = happyGoto action_68 action_147 (116#) = happyGoto action_39 action_147 (117#) = happyGoto action_40 action_147 (118#) = happyGoto action_69 action_147 (119#) = happyGoto action_42 action_147 (127#) = happyGoto action_70 action_147 x = happyTcHack x happyFail action_148 (150#) = happyShift action_230 action_148 x = happyTcHack x happyReduce_254 action_149 x = happyTcHack x happyReduce_263 action_150 x = happyTcHack x happyReduce_276 action_151 (150#) = happyShift action_229 action_151 x = happyTcHack x happyFail action_152 x = happyTcHack x happyReduce_250 action_153 x = happyTcHack x happyReduce_279 action_154 x = happyTcHack x happyReduce_281 action_155 (150#) = happyReduce_280 action_155 x = happyTcHack x happyReduce_282 action_156 (150#) = happyReduce_283 action_156 x = happyTcHack x happyReduce_286 action_157 x = happyTcHack x happyReduce_278 action_158 x = happyTcHack x happyReduce_288 action_159 x = happyTcHack x happyReduce_277 action_160 x = happyTcHack x happyReduce_234 action_161 x = happyTcHack x happyReduce_194 action_162 (137#) = happyShift action_44 action_162 (138#) = happyShift action_45 action_162 (139#) = happyShift action_46 action_162 (140#) = happyShift action_47 action_162 (196#) = happyShift action_51 action_162 (197#) = happyShift action_52 action_162 (198#) = happyShift action_53 action_162 (199#) = happyShift action_54 action_162 (200#) = happyShift action_55 action_162 (201#) = happyShift action_56 action_162 (116#) = happyGoto action_228 action_162 (117#) = happyGoto action_40 action_162 (118#) = happyGoto action_217 action_162 (119#) = happyGoto action_42 action_162 x = happyTcHack x happyFail action_163 x = happyTcHack x happyReduce_262 action_164 (137#) = happyShift action_44 action_164 (138#) = happyShift action_45 action_164 (139#) = happyShift action_46 action_164 (140#) = happyShift action_47 action_164 (145#) = happyShift action_71 action_164 (146#) = happyShift action_72 action_164 (147#) = happyShift action_73 action_164 (148#) = happyShift action_74 action_164 (149#) = happyShift action_75 action_164 (155#) = happyShift action_76 action_164 (158#) = happyShift action_77 action_164 (170#) = happyShift action_78 action_164 (196#) = happyShift action_51 action_164 (197#) = happyShift action_52 action_164 (198#) = happyShift action_53 action_164 (199#) = happyShift action_54 action_164 (200#) = happyShift action_55 action_164 (201#) = happyShift action_56 action_164 (78#) = happyGoto action_135 action_164 (81#) = happyGoto action_63 action_164 (82#) = happyGoto action_64 action_164 (83#) = happyGoto action_65 action_164 (102#) = happyGoto action_66 action_164 (104#) = happyGoto action_131 action_164 (106#) = happyGoto action_68 action_164 (116#) = happyGoto action_39 action_164 (117#) = happyGoto action_40 action_164 (118#) = happyGoto action_69 action_164 (119#) = happyGoto action_42 action_164 (127#) = happyGoto action_70 action_164 x = happyTcHack x happyReduce_284 action_165 (150#) = happyReduce_285 action_165 x = happyTcHack x happyReduce_287 action_166 (137#) = happyShift action_44 action_166 (138#) = happyShift action_45 action_166 (139#) = happyShift action_46 action_166 (140#) = happyShift action_47 action_166 (145#) = happyShift action_71 action_166 (146#) = happyShift action_72 action_166 (147#) = happyShift action_73 action_166 (148#) = happyShift action_74 action_166 (149#) = happyShift action_75 action_166 (155#) = happyShift action_76 action_166 (158#) = happyShift action_77 action_166 (170#) = happyShift action_78 action_166 (196#) = happyShift action_51 action_166 (197#) = happyShift action_52 action_166 (198#) = happyShift action_53 action_166 (199#) = happyShift action_54 action_166 (200#) = happyShift action_55 action_166 (201#) = happyShift action_56 action_166 (81#) = happyGoto action_227 action_166 (82#) = happyGoto action_64 action_166 (83#) = happyGoto action_65 action_166 (102#) = happyGoto action_66 action_166 (104#) = happyGoto action_131 action_166 (106#) = happyGoto action_68 action_166 (116#) = happyGoto action_39 action_166 (117#) = happyGoto action_40 action_166 (118#) = happyGoto action_69 action_166 (119#) = happyGoto action_42 action_166 (127#) = happyGoto action_70 action_166 x = happyTcHack x happyFail action_167 (137#) = happyShift action_44 action_167 (138#) = happyShift action_45 action_167 (149#) = happyShift action_48 action_167 (153#) = happyShift action_226 action_167 (196#) = happyShift action_51 action_167 (197#) = happyShift action_52 action_167 (198#) = happyShift action_53 action_167 (199#) = happyShift action_54 action_167 (200#) = happyShift action_55 action_167 (201#) = happyShift action_56 action_167 (100#) = happyGoto action_223 action_167 (101#) = happyGoto action_224 action_167 (104#) = happyGoto action_225 action_167 (116#) = happyGoto action_39 action_167 (117#) = happyGoto action_40 action_167 x = happyTcHack x happyFail action_168 x = happyTcHack x happyReduce_173 action_169 (195#) = happyShift action_222 action_169 (68#) = happyGoto action_221 action_169 x = happyTcHack x happyReduce_152 action_170 (165#) = happyReduce_293 action_170 (71#) = happyGoto action_220 action_170 (128#) = happyGoto action_178 action_170 x = happyTcHack x happyReduce_154 action_171 x = happyTcHack x happyReduce_156 action_172 x = happyTcHack x happyReduce_258 action_173 x = happyTcHack x happyReduce_259 action_174 (137#) = happyShift action_44 action_174 (138#) = happyShift action_45 action_174 (139#) = happyShift action_46 action_174 (140#) = happyShift action_47 action_174 (145#) = happyShift action_71 action_174 (146#) = happyShift action_72 action_174 (147#) = happyShift action_73 action_174 (148#) = happyShift action_74 action_174 (149#) = happyShift action_75 action_174 (155#) = happyShift action_76 action_174 (158#) = happyShift action_77 action_174 (170#) = happyShift action_78 action_174 (172#) = happyShift action_79 action_174 (174#) = happyShift action_80 action_174 (179#) = happyShift action_84 action_174 (196#) = happyShift action_51 action_174 (197#) = happyShift action_52 action_174 (198#) = happyShift action_53 action_174 (199#) = happyShift action_54 action_174 (200#) = happyShift action_55 action_174 (201#) = happyShift action_56 action_174 (77#) = happyGoto action_219 action_174 (78#) = happyGoto action_62 action_174 (81#) = happyGoto action_63 action_174 (82#) = happyGoto action_64 action_174 (83#) = happyGoto action_65 action_174 (102#) = happyGoto action_66 action_174 (104#) = happyGoto action_131 action_174 (106#) = happyGoto action_68 action_174 (116#) = happyGoto action_39 action_174 (117#) = happyGoto action_40 action_174 (118#) = happyGoto action_69 action_174 (119#) = happyGoto action_42 action_174 (127#) = happyGoto action_70 action_174 x = happyTcHack x happyFail action_175 x = happyTcHack x happyReduce_254 action_176 x = happyTcHack x happyReduce_248 action_177 x = happyTcHack x happyReduce_280 action_178 (165#) = happyShift action_218 action_178 x = happyTcHack x happyFail action_179 x = happyTcHack x happyReduce_283 action_180 (137#) = happyShift action_44 action_180 (138#) = happyShift action_45 action_180 (139#) = happyShift action_46 action_180 (140#) = happyShift action_47 action_180 (196#) = happyShift action_51 action_180 (197#) = happyShift action_52 action_180 (198#) = happyShift action_53 action_180 (199#) = happyShift action_54 action_180 (200#) = happyShift action_55 action_180 (201#) = happyShift action_56 action_180 (116#) = happyGoto action_216 action_180 (117#) = happyGoto action_40 action_180 (118#) = happyGoto action_217 action_180 (119#) = happyGoto action_42 action_180 x = happyTcHack x happyFail action_181 (137#) = happyShift action_44 action_181 (138#) = happyShift action_45 action_181 (139#) = happyShift action_46 action_181 (140#) = happyShift action_47 action_181 (145#) = happyShift action_71 action_181 (146#) = happyShift action_72 action_181 (147#) = happyShift action_73 action_181 (148#) = happyShift action_74 action_181 (149#) = happyShift action_75 action_181 (155#) = happyShift action_76 action_181 (158#) = happyShift action_77 action_181 (164#) = happyShift action_132 action_181 (170#) = happyShift action_78 action_181 (172#) = happyShift action_79 action_181 (174#) = happyShift action_80 action_181 (179#) = happyShift action_84 action_181 (182#) = happyShift action_133 action_181 (189#) = happyShift action_134 action_181 (196#) = happyShift action_51 action_181 (197#) = happyShift action_52 action_181 (198#) = happyShift action_53 action_181 (199#) = happyShift action_54 action_181 (200#) = happyShift action_55 action_181 (201#) = happyShift action_56 action_181 (72#) = happyGoto action_215 action_181 (73#) = happyGoto action_127 action_181 (74#) = happyGoto action_128 action_181 (75#) = happyGoto action_129 action_181 (76#) = happyGoto action_130 action_181 (77#) = happyGoto action_61 action_181 (78#) = happyGoto action_62 action_181 (81#) = happyGoto action_63 action_181 (82#) = happyGoto action_64 action_181 (83#) = happyGoto action_65 action_181 (102#) = happyGoto action_66 action_181 (104#) = happyGoto action_131 action_181 (106#) = happyGoto action_68 action_181 (116#) = happyGoto action_39 action_181 (117#) = happyGoto action_40 action_181 (118#) = happyGoto action_69 action_181 (119#) = happyGoto action_42 action_181 (127#) = happyGoto action_70 action_181 x = happyTcHack x happyFail action_182 x = happyTcHack x happyReduce_284 action_183 x = happyTcHack x happyReduce_285 action_184 (137#) = happyShift action_44 action_184 (149#) = happyShift action_214 action_184 (196#) = happyShift action_51 action_184 (197#) = happyShift action_52 action_184 (198#) = happyShift action_53 action_184 (199#) = happyShift action_54 action_184 (200#) = happyShift action_55 action_184 (201#) = happyShift action_56 action_184 (103#) = happyGoto action_213 action_184 (117#) = happyGoto action_200 action_184 x = happyTcHack x happyFail action_185 (137#) = happyShift action_44 action_185 (139#) = happyShift action_46 action_185 (140#) = happyShift action_47 action_185 (149#) = happyShift action_113 action_185 (155#) = happyShift action_114 action_185 (196#) = happyShift action_51 action_185 (197#) = happyShift action_52 action_185 (198#) = happyShift action_53 action_185 (199#) = happyShift action_54 action_185 (200#) = happyShift action_55 action_185 (201#) = happyShift action_56 action_185 (43#) = happyGoto action_104 action_185 (44#) = happyGoto action_105 action_185 (45#) = happyGoto action_106 action_185 (46#) = happyGoto action_107 action_185 (47#) = happyGoto action_212 action_185 (48#) = happyGoto action_109 action_185 (117#) = happyGoto action_110 action_185 (118#) = happyGoto action_111 action_185 (119#) = happyGoto action_42 action_185 (136#) = happyGoto action_112 action_185 x = happyTcHack x happyFail action_186 (141#) = happyShift action_179 action_186 (142#) = happyShift action_157 action_186 (159#) = happyShift action_211 action_186 (172#) = happyShift action_182 action_186 (173#) = happyShift action_183 action_186 (28#) = happyGoto action_205 action_186 (107#) = happyGoto action_206 action_186 (110#) = happyGoto action_207 action_186 (112#) = happyGoto action_208 action_186 (121#) = happyGoto action_209 action_186 (124#) = happyGoto action_210 action_186 x = happyTcHack x happyFail action_187 x = happyTcHack x happyReduce_52 action_188 x = happyTcHack x happyReduce_1 action_189 x = happyTcHack x happyReduce_25 action_190 (137#) = happyShift action_44 action_190 (139#) = happyShift action_46 action_190 (149#) = happyShift action_202 action_190 (150#) = happyShift action_203 action_190 (160#) = happyShift action_204 action_190 (196#) = happyShift action_51 action_190 (197#) = happyShift action_52 action_190 (198#) = happyShift action_53 action_190 (199#) = happyShift action_54 action_190 (200#) = happyShift action_55 action_190 (201#) = happyShift action_56 action_190 (23#) = happyGoto action_196 action_190 (24#) = happyGoto action_197 action_190 (103#) = happyGoto action_198 action_190 (105#) = happyGoto action_199 action_190 (117#) = happyGoto action_200 action_190 (119#) = happyGoto action_201 action_190 x = happyTcHack x happyFail action_191 (150#) = happyShift action_195 action_191 x = happyTcHack x happyFail action_192 (137#) = happyShift action_44 action_192 (138#) = happyShift action_45 action_192 (139#) = happyShift action_46 action_192 (140#) = happyShift action_47 action_192 (149#) = happyShift action_48 action_192 (190#) = happyShift action_50 action_192 (196#) = happyShift action_51 action_192 (197#) = happyShift action_52 action_192 (198#) = happyShift action_53 action_192 (199#) = happyShift action_54 action_192 (200#) = happyShift action_55 action_192 (201#) = happyShift action_56 action_192 (13#) = happyGoto action_194 action_192 (104#) = happyGoto action_38 action_192 (116#) = happyGoto action_39 action_192 (117#) = happyGoto action_40 action_192 (118#) = happyGoto action_41 action_192 (119#) = happyGoto action_42 action_192 (134#) = happyGoto action_43 action_192 x = happyTcHack x happyReduce_16 action_193 x = happyTcHack x happyReduce_15 action_194 x = happyTcHack x happyReduce_18 action_195 x = happyTcHack x happyReduce_14 action_196 (150#) = happyShift action_358 action_196 (157#) = happyShift action_359 action_196 x = happyTcHack x happyFail action_197 x = happyTcHack x happyReduce_47 action_198 x = happyTcHack x happyReduce_48 action_199 x = happyTcHack x happyReduce_49 action_200 x = happyTcHack x happyReduce_238 action_201 x = happyTcHack x happyReduce_242 action_202 (141#) = happyShift action_179 action_202 (142#) = happyShift action_157 action_202 (172#) = happyShift action_182 action_202 (173#) = happyShift action_183 action_202 (121#) = happyGoto action_357 action_202 (124#) = happyGoto action_352 action_202 x = happyTcHack x happyFail action_203 x = happyTcHack x happyReduce_23 action_204 (150#) = happyShift action_356 action_204 x = happyTcHack x happyFail action_205 (157#) = happyShift action_355 action_205 x = happyTcHack x happyReduce_50 action_206 x = happyTcHack x happyReduce_256 action_207 x = happyTcHack x happyReduce_257 action_208 x = happyTcHack x happyReduce_57 action_209 x = happyTcHack x happyReduce_252 action_210 x = happyTcHack x happyReduce_246 action_211 (137#) = happyShift action_44 action_211 (139#) = happyShift action_46 action_211 (196#) = happyShift action_51 action_211 (197#) = happyShift action_52 action_211 (198#) = happyShift action_53 action_211 (199#) = happyShift action_54 action_211 (200#) = happyShift action_55 action_211 (201#) = happyShift action_56 action_211 (117#) = happyGoto action_353 action_211 (119#) = happyGoto action_354 action_211 x = happyTcHack x happyFail action_212 x = happyTcHack x happyReduce_81 action_213 x = happyTcHack x happyReduce_82 action_214 (141#) = happyShift action_179 action_214 (172#) = happyShift action_182 action_214 (173#) = happyShift action_183 action_214 (124#) = happyGoto action_352 action_214 x = happyTcHack x happyFail action_215 x = happyTcHack x happyReduce_153 action_216 (159#) = happyShift action_351 action_216 x = happyTcHack x happyFail action_217 (159#) = happyShift action_350 action_217 x = happyTcHack x happyFail action_218 (137#) = happyShift action_44 action_218 (138#) = happyShift action_45 action_218 (139#) = happyShift action_46 action_218 (140#) = happyShift action_47 action_218 (145#) = happyShift action_71 action_218 (146#) = happyShift action_72 action_218 (147#) = happyShift action_73 action_218 (148#) = happyShift action_74 action_218 (149#) = happyShift action_75 action_218 (155#) = happyShift action_76 action_218 (158#) = happyShift action_77 action_218 (164#) = happyShift action_132 action_218 (170#) = happyShift action_78 action_218 (172#) = happyShift action_79 action_218 (174#) = happyShift action_80 action_218 (179#) = happyShift action_84 action_218 (182#) = happyShift action_133 action_218 (189#) = happyShift action_134 action_218 (196#) = happyShift action_51 action_218 (197#) = happyShift action_52 action_218 (198#) = happyShift action_53 action_218 (199#) = happyShift action_54 action_218 (200#) = happyShift action_55 action_218 (201#) = happyShift action_56 action_218 (73#) = happyGoto action_349 action_218 (74#) = happyGoto action_128 action_218 (75#) = happyGoto action_232 action_218 (76#) = happyGoto action_130 action_218 (77#) = happyGoto action_61 action_218 (78#) = happyGoto action_62 action_218 (81#) = happyGoto action_63 action_218 (82#) = happyGoto action_64 action_218 (83#) = happyGoto action_65 action_218 (102#) = happyGoto action_66 action_218 (104#) = happyGoto action_131 action_218 (106#) = happyGoto action_68 action_218 (116#) = happyGoto action_39 action_218 (117#) = happyGoto action_40 action_218 (118#) = happyGoto action_69 action_218 (119#) = happyGoto action_42 action_218 (127#) = happyGoto action_70 action_218 x = happyTcHack x happyFail action_219 x = happyTcHack x happyReduce_164 action_220 x = happyTcHack x happyReduce_155 action_221 x = happyTcHack x happyReduce_150 action_222 (152#) = happyShift action_248 action_222 (36#) = happyGoto action_348 action_222 (129#) = happyGoto action_247 action_222 x = happyTcHack x happyReduce_294 action_223 (153#) = happyShift action_346 action_223 (157#) = happyShift action_347 action_223 x = happyTcHack x happyFail action_224 x = happyTcHack x happyReduce_232 action_225 (163#) = happyShift action_345 action_225 x = happyTcHack x happyFail action_226 x = happyTcHack x happyReduce_181 action_227 x = happyTcHack x happyReduce_178 action_228 (159#) = happyShift action_344 action_228 x = happyTcHack x happyFail action_229 x = happyTcHack x happyReduce_241 action_230 x = happyTcHack x happyReduce_245 action_231 (150#) = happyShift action_343 action_231 x = happyTcHack x happyFail action_232 (141#) = happyShift action_179 action_232 (142#) = happyShift action_157 action_232 (143#) = happyShift action_158 action_232 (144#) = happyShift action_159 action_232 (159#) = happyShift action_180 action_232 (161#) = happyShift action_163 action_232 (172#) = happyShift action_182 action_232 (173#) = happyShift action_183 action_232 (108#) = happyGoto action_172 action_232 (111#) = happyGoto action_173 action_232 (113#) = happyGoto action_251 action_232 (115#) = happyGoto action_175 action_232 (120#) = happyGoto action_149 action_232 (121#) = happyGoto action_150 action_232 (122#) = happyGoto action_176 action_232 (124#) = happyGoto action_153 action_232 (126#) = happyGoto action_177 action_232 x = happyTcHack x happyReduce_161 action_233 x = happyTcHack x happyReduce_188 action_234 (137#) = happyShift action_44 action_234 (138#) = happyShift action_45 action_234 (139#) = happyShift action_46 action_234 (140#) = happyShift action_47 action_234 (145#) = happyShift action_71 action_234 (146#) = happyShift action_72 action_234 (147#) = happyShift action_73 action_234 (148#) = happyShift action_74 action_234 (149#) = happyShift action_75 action_234 (155#) = happyShift action_76 action_234 (158#) = happyShift action_77 action_234 (164#) = happyShift action_132 action_234 (170#) = happyShift action_78 action_234 (172#) = happyShift action_79 action_234 (174#) = happyShift action_80 action_234 (179#) = happyShift action_84 action_234 (182#) = happyShift action_133 action_234 (189#) = happyShift action_134 action_234 (196#) = happyShift action_51 action_234 (197#) = happyShift action_52 action_234 (198#) = happyShift action_53 action_234 (199#) = happyShift action_54 action_234 (200#) = happyShift action_55 action_234 (201#) = happyShift action_56 action_234 (72#) = happyGoto action_342 action_234 (73#) = happyGoto action_127 action_234 (74#) = happyGoto action_128 action_234 (75#) = happyGoto action_129 action_234 (76#) = happyGoto action_130 action_234 (77#) = happyGoto action_61 action_234 (78#) = happyGoto action_62 action_234 (81#) = happyGoto action_63 action_234 (82#) = happyGoto action_64 action_234 (83#) = happyGoto action_65 action_234 (102#) = happyGoto action_66 action_234 (104#) = happyGoto action_131 action_234 (106#) = happyGoto action_68 action_234 (116#) = happyGoto action_39 action_234 (117#) = happyGoto action_40 action_234 (118#) = happyGoto action_69 action_234 (119#) = happyGoto action_42 action_234 (127#) = happyGoto action_70 action_234 x = happyTcHack x happyFail action_235 x = happyTcHack x happyReduce_236 action_236 x = happyTcHack x happyReduce_193 action_237 (137#) = happyShift action_44 action_237 (138#) = happyShift action_45 action_237 (139#) = happyShift action_46 action_237 (140#) = happyShift action_47 action_237 (145#) = happyShift action_71 action_237 (146#) = happyShift action_72 action_237 (147#) = happyShift action_73 action_237 (148#) = happyShift action_74 action_237 (149#) = happyShift action_75 action_237 (150#) = happyShift action_341 action_237 (155#) = happyShift action_76 action_237 (158#) = happyShift action_77 action_237 (164#) = happyShift action_132 action_237 (170#) = happyShift action_78 action_237 (172#) = happyShift action_79 action_237 (174#) = happyShift action_80 action_237 (179#) = happyShift action_84 action_237 (182#) = happyShift action_133 action_237 (189#) = happyShift action_134 action_237 (196#) = happyShift action_51 action_237 (197#) = happyShift action_52 action_237 (198#) = happyShift action_53 action_237 (199#) = happyShift action_54 action_237 (200#) = happyShift action_55 action_237 (201#) = happyShift action_56 action_237 (76#) = happyGoto action_322 action_237 (77#) = happyGoto action_219 action_237 (78#) = happyGoto action_62 action_237 (81#) = happyGoto action_63 action_237 (82#) = happyGoto action_64 action_237 (83#) = happyGoto action_65 action_237 (102#) = happyGoto action_66 action_237 (104#) = happyGoto action_131 action_237 (106#) = happyGoto action_68 action_237 (116#) = happyGoto action_39 action_237 (117#) = happyGoto action_40 action_237 (118#) = happyGoto action_69 action_237 (119#) = happyGoto action_42 action_237 (127#) = happyGoto action_70 action_237 x = happyTcHack x happyFail action_238 (128#) = happyGoto action_340 action_238 x = happyTcHack x happyReduce_293 action_239 x = happyTcHack x happyReduce_187 action_240 (137#) = happyShift action_44 action_240 (138#) = happyShift action_45 action_240 (139#) = happyShift action_46 action_240 (140#) = happyShift action_47 action_240 (145#) = happyShift action_71 action_240 (146#) = happyShift action_72 action_240 (147#) = happyShift action_73 action_240 (148#) = happyShift action_74 action_240 (149#) = happyShift action_75 action_240 (155#) = happyShift action_76 action_240 (158#) = happyShift action_77 action_240 (164#) = happyShift action_132 action_240 (170#) = happyShift action_78 action_240 (172#) = happyShift action_79 action_240 (174#) = happyShift action_80 action_240 (179#) = happyShift action_84 action_240 (182#) = happyShift action_133 action_240 (189#) = happyShift action_134 action_240 (196#) = happyShift action_51 action_240 (197#) = happyShift action_52 action_240 (198#) = happyShift action_53 action_240 (199#) = happyShift action_54 action_240 (200#) = happyShift action_55 action_240 (201#) = happyShift action_56 action_240 (72#) = happyGoto action_339 action_240 (73#) = happyGoto action_127 action_240 (74#) = happyGoto action_128 action_240 (75#) = happyGoto action_129 action_240 (76#) = happyGoto action_130 action_240 (77#) = happyGoto action_61 action_240 (78#) = happyGoto action_62 action_240 (81#) = happyGoto action_63 action_240 (82#) = happyGoto action_64 action_240 (83#) = happyGoto action_65 action_240 (102#) = happyGoto action_66 action_240 (104#) = happyGoto action_131 action_240 (106#) = happyGoto action_68 action_240 (116#) = happyGoto action_39 action_240 (117#) = happyGoto action_40 action_240 (118#) = happyGoto action_69 action_240 (119#) = happyGoto action_42 action_240 (127#) = happyGoto action_70 action_240 x = happyTcHack x happyFail action_241 (137#) = happyShift action_44 action_241 (138#) = happyShift action_45 action_241 (139#) = happyShift action_46 action_241 (140#) = happyShift action_47 action_241 (145#) = happyShift action_71 action_241 (146#) = happyShift action_72 action_241 (147#) = happyShift action_73 action_241 (148#) = happyShift action_74 action_241 (149#) = happyShift action_75 action_241 (155#) = happyShift action_76 action_241 (158#) = happyShift action_77 action_241 (164#) = happyShift action_132 action_241 (170#) = happyShift action_78 action_241 (172#) = happyShift action_79 action_241 (174#) = happyShift action_80 action_241 (179#) = happyShift action_84 action_241 (182#) = happyShift action_133 action_241 (189#) = happyShift action_134 action_241 (196#) = happyShift action_51 action_241 (197#) = happyShift action_52 action_241 (198#) = happyShift action_53 action_241 (199#) = happyShift action_54 action_241 (200#) = happyShift action_55 action_241 (201#) = happyShift action_56 action_241 (72#) = happyGoto action_338 action_241 (73#) = happyGoto action_127 action_241 (74#) = happyGoto action_128 action_241 (75#) = happyGoto action_129 action_241 (76#) = happyGoto action_130 action_241 (77#) = happyGoto action_61 action_241 (78#) = happyGoto action_62 action_241 (81#) = happyGoto action_63 action_241 (82#) = happyGoto action_64 action_241 (83#) = happyGoto action_65 action_241 (102#) = happyGoto action_66 action_241 (104#) = happyGoto action_131 action_241 (106#) = happyGoto action_68 action_241 (116#) = happyGoto action_39 action_241 (117#) = happyGoto action_40 action_241 (118#) = happyGoto action_69 action_241 (119#) = happyGoto action_42 action_241 (127#) = happyGoto action_70 action_241 x = happyTcHack x happyFail action_242 x = happyTcHack x happyReduce_189 action_243 (137#) = happyShift action_44 action_243 (138#) = happyShift action_45 action_243 (139#) = happyShift action_46 action_243 (140#) = happyShift action_47 action_243 (145#) = happyShift action_71 action_243 (146#) = happyShift action_72 action_243 (147#) = happyShift action_73 action_243 (148#) = happyShift action_74 action_243 (149#) = happyShift action_75 action_243 (155#) = happyShift action_76 action_243 (158#) = happyShift action_77 action_243 (164#) = happyShift action_132 action_243 (170#) = happyShift action_78 action_243 (172#) = happyShift action_79 action_243 (174#) = happyShift action_80 action_243 (179#) = happyShift action_84 action_243 (182#) = happyShift action_133 action_243 (189#) = happyShift action_134 action_243 (196#) = happyShift action_51 action_243 (197#) = happyShift action_52 action_243 (198#) = happyShift action_53 action_243 (199#) = happyShift action_54 action_243 (200#) = happyShift action_55 action_243 (201#) = happyShift action_56 action_243 (72#) = happyGoto action_337 action_243 (73#) = happyGoto action_127 action_243 (74#) = happyGoto action_128 action_243 (75#) = happyGoto action_129 action_243 (76#) = happyGoto action_130 action_243 (77#) = happyGoto action_61 action_243 (78#) = happyGoto action_62 action_243 (81#) = happyGoto action_63 action_243 (82#) = happyGoto action_64 action_243 (83#) = happyGoto action_65 action_243 (102#) = happyGoto action_66 action_243 (104#) = happyGoto action_131 action_243 (106#) = happyGoto action_68 action_243 (116#) = happyGoto action_39 action_243 (117#) = happyGoto action_40 action_243 (118#) = happyGoto action_69 action_243 (119#) = happyGoto action_42 action_243 (127#) = happyGoto action_70 action_243 x = happyTcHack x happyFail action_244 (137#) = happyShift action_44 action_244 (138#) = happyShift action_45 action_244 (139#) = happyShift action_46 action_244 (140#) = happyShift action_47 action_244 (145#) = happyShift action_71 action_244 (146#) = happyShift action_72 action_244 (147#) = happyShift action_73 action_244 (148#) = happyShift action_74 action_244 (149#) = happyShift action_75 action_244 (155#) = happyShift action_76 action_244 (158#) = happyShift action_77 action_244 (164#) = happyShift action_132 action_244 (170#) = happyShift action_78 action_244 (172#) = happyShift action_79 action_244 (174#) = happyShift action_80 action_244 (179#) = happyShift action_84 action_244 (182#) = happyShift action_133 action_244 (189#) = happyShift action_134 action_244 (196#) = happyShift action_51 action_244 (197#) = happyShift action_52 action_244 (198#) = happyShift action_53 action_244 (199#) = happyShift action_54 action_244 (200#) = happyShift action_55 action_244 (201#) = happyShift action_56 action_244 (72#) = happyGoto action_336 action_244 (73#) = happyGoto action_127 action_244 (74#) = happyGoto action_128 action_244 (75#) = happyGoto action_129 action_244 (76#) = happyGoto action_130 action_244 (77#) = happyGoto action_61 action_244 (78#) = happyGoto action_62 action_244 (81#) = happyGoto action_63 action_244 (82#) = happyGoto action_64 action_244 (83#) = happyGoto action_65 action_244 (102#) = happyGoto action_66 action_244 (104#) = happyGoto action_131 action_244 (106#) = happyGoto action_68 action_244 (116#) = happyGoto action_39 action_244 (117#) = happyGoto action_40 action_244 (118#) = happyGoto action_69 action_244 (119#) = happyGoto action_42 action_244 (127#) = happyGoto action_70 action_244 x = happyTcHack x happyReduce_199 action_245 (137#) = happyShift action_44 action_245 (138#) = happyShift action_45 action_245 (139#) = happyShift action_46 action_245 (140#) = happyShift action_47 action_245 (145#) = happyShift action_71 action_245 (146#) = happyShift action_72 action_245 (147#) = happyShift action_73 action_245 (148#) = happyShift action_74 action_245 (149#) = happyShift action_75 action_245 (155#) = happyShift action_76 action_245 (158#) = happyShift action_77 action_245 (164#) = happyShift action_132 action_245 (170#) = happyShift action_78 action_245 (172#) = happyShift action_79 action_245 (174#) = happyShift action_80 action_245 (179#) = happyShift action_84 action_245 (182#) = happyShift action_133 action_245 (189#) = happyShift action_335 action_245 (196#) = happyShift action_51 action_245 (197#) = happyShift action_52 action_245 (198#) = happyShift action_53 action_245 (199#) = happyShift action_54 action_245 (200#) = happyShift action_55 action_245 (201#) = happyShift action_56 action_245 (72#) = happyGoto action_331 action_245 (73#) = happyGoto action_127 action_245 (74#) = happyGoto action_128 action_245 (75#) = happyGoto action_261 action_245 (76#) = happyGoto action_130 action_245 (77#) = happyGoto action_61 action_245 (78#) = happyGoto action_62 action_245 (81#) = happyGoto action_63 action_245 (82#) = happyGoto action_64 action_245 (83#) = happyGoto action_65 action_245 (88#) = happyGoto action_332 action_245 (89#) = happyGoto action_333 action_245 (97#) = happyGoto action_334 action_245 (102#) = happyGoto action_66 action_245 (104#) = happyGoto action_131 action_245 (106#) = happyGoto action_68 action_245 (116#) = happyGoto action_39 action_245 (117#) = happyGoto action_40 action_245 (118#) = happyGoto action_69 action_245 (119#) = happyGoto action_42 action_245 (127#) = happyGoto action_70 action_245 x = happyTcHack x happyFail action_246 (184#) = happyShift action_330 action_246 x = happyTcHack x happyFail action_247 (7#) = happyGoto action_13 action_247 (8#) = happyGoto action_327 action_247 (33#) = happyGoto action_329 action_247 x = happyTcHack x happyReduce_11 action_248 (7#) = happyGoto action_13 action_248 (8#) = happyGoto action_327 action_248 (33#) = happyGoto action_328 action_248 x = happyTcHack x happyReduce_11 action_249 (193#) = happyShift action_326 action_249 x = happyTcHack x happyFail action_250 (137#) = happyShift action_44 action_250 (138#) = happyShift action_45 action_250 (139#) = happyShift action_46 action_250 (140#) = happyShift action_47 action_250 (145#) = happyShift action_71 action_250 (146#) = happyShift action_72 action_250 (147#) = happyShift action_73 action_250 (148#) = happyShift action_74 action_250 (149#) = happyShift action_75 action_250 (155#) = happyShift action_76 action_250 (158#) = happyShift action_77 action_250 (170#) = happyShift action_78 action_250 (196#) = happyShift action_51 action_250 (197#) = happyShift action_52 action_250 (198#) = happyShift action_53 action_250 (199#) = happyShift action_54 action_250 (200#) = happyShift action_55 action_250 (201#) = happyShift action_56 action_250 (79#) = happyGoto action_323 action_250 (80#) = happyGoto action_324 action_250 (81#) = happyGoto action_325 action_250 (82#) = happyGoto action_64 action_250 (83#) = happyGoto action_65 action_250 (102#) = happyGoto action_66 action_250 (104#) = happyGoto action_131 action_250 (106#) = happyGoto action_68 action_250 (116#) = happyGoto action_39 action_250 (117#) = happyGoto action_40 action_250 (118#) = happyGoto action_69 action_250 (119#) = happyGoto action_42 action_250 (127#) = happyGoto action_70 action_250 x = happyTcHack x happyFail action_251 (137#) = happyShift action_44 action_251 (138#) = happyShift action_45 action_251 (139#) = happyShift action_46 action_251 (140#) = happyShift action_47 action_251 (145#) = happyShift action_71 action_251 (146#) = happyShift action_72 action_251 (147#) = happyShift action_73 action_251 (148#) = happyShift action_74 action_251 (149#) = happyShift action_75 action_251 (155#) = happyShift action_76 action_251 (158#) = happyShift action_77 action_251 (164#) = happyShift action_132 action_251 (170#) = happyShift action_78 action_251 (172#) = happyShift action_79 action_251 (174#) = happyShift action_80 action_251 (179#) = happyShift action_84 action_251 (182#) = happyShift action_133 action_251 (189#) = happyShift action_134 action_251 (196#) = happyShift action_51 action_251 (197#) = happyShift action_52 action_251 (198#) = happyShift action_53 action_251 (199#) = happyShift action_54 action_251 (200#) = happyShift action_55 action_251 (201#) = happyShift action_56 action_251 (76#) = happyGoto action_322 action_251 (77#) = happyGoto action_219 action_251 (78#) = happyGoto action_62 action_251 (81#) = happyGoto action_63 action_251 (82#) = happyGoto action_64 action_251 (83#) = happyGoto action_65 action_251 (102#) = happyGoto action_66 action_251 (104#) = happyGoto action_131 action_251 (106#) = happyGoto action_68 action_251 (116#) = happyGoto action_39 action_251 (117#) = happyGoto action_40 action_251 (118#) = happyGoto action_69 action_251 (119#) = happyGoto action_42 action_251 (127#) = happyGoto action_70 action_251 x = happyTcHack x happyFail action_252 (152#) = happyShift action_321 action_252 (90#) = happyGoto action_319 action_252 (129#) = happyGoto action_320 action_252 x = happyTcHack x happyReduce_294 action_253 x = happyTcHack x happyReduce_64 action_254 (152#) = happyShift action_248 action_254 (36#) = happyGoto action_318 action_254 (129#) = happyGoto action_247 action_254 x = happyTcHack x happyReduce_294 action_255 (52#) = happyGoto action_316 action_255 (53#) = happyGoto action_317 action_255 (128#) = happyGoto action_291 action_255 x = happyTcHack x happyReduce_293 action_256 (150#) = happyShift action_315 action_256 x = happyTcHack x happyFail action_257 (157#) = happyShift action_298 action_257 (168#) = happyShift action_283 action_257 x = happyTcHack x happyReduce_70 action_258 (137#) = happyShift action_44 action_258 (139#) = happyShift action_46 action_258 (140#) = happyShift action_47 action_258 (149#) = happyShift action_113 action_258 (155#) = happyShift action_114 action_258 (167#) = happyShift action_282 action_258 (196#) = happyShift action_51 action_258 (197#) = happyShift action_52 action_258 (198#) = happyShift action_53 action_258 (199#) = happyShift action_54 action_258 (200#) = happyShift action_55 action_258 (201#) = happyShift action_56 action_258 (45#) = happyGoto action_281 action_258 (46#) = happyGoto action_107 action_258 (117#) = happyGoto action_110 action_258 (118#) = happyGoto action_111 action_258 (119#) = happyGoto action_42 action_258 (136#) = happyGoto action_112 action_258 x = happyTcHack x happyReduce_95 action_259 (157#) = happyShift action_296 action_259 x = happyTcHack x happyReduce_69 action_260 (151#) = happyShift action_314 action_260 x = happyTcHack x happyReduce_230 action_261 (141#) = happyShift action_179 action_261 (142#) = happyShift action_157 action_261 (143#) = happyShift action_158 action_261 (144#) = happyShift action_159 action_261 (159#) = happyShift action_180 action_261 (161#) = happyShift action_163 action_261 (162#) = happyShift action_238 action_261 (166#) = happyReduce_222 action_261 (172#) = happyShift action_182 action_261 (173#) = happyShift action_183 action_261 (108#) = happyGoto action_172 action_261 (111#) = happyGoto action_173 action_261 (113#) = happyGoto action_251 action_261 (115#) = happyGoto action_175 action_261 (120#) = happyGoto action_149 action_261 (121#) = happyGoto action_150 action_261 (122#) = happyGoto action_176 action_261 (124#) = happyGoto action_153 action_261 (126#) = happyGoto action_177 action_261 x = happyTcHack x happyReduce_161 action_262 (128#) = happyGoto action_313 action_262 x = happyTcHack x happyReduce_293 action_263 (153#) = happyShift action_312 action_263 x = happyTcHack x happyFail action_264 (137#) = happyShift action_44 action_264 (138#) = happyShift action_45 action_264 (139#) = happyShift action_46 action_264 (140#) = happyShift action_47 action_264 (145#) = happyShift action_71 action_264 (146#) = happyShift action_72 action_264 (147#) = happyShift action_73 action_264 (148#) = happyShift action_74 action_264 (149#) = happyShift action_75 action_264 (151#) = happyShift action_264 action_264 (155#) = happyShift action_76 action_264 (158#) = happyShift action_77 action_264 (164#) = happyShift action_132 action_264 (170#) = happyShift action_78 action_264 (172#) = happyShift action_79 action_264 (174#) = happyShift action_80 action_264 (179#) = happyShift action_84 action_264 (182#) = happyShift action_133 action_264 (189#) = happyShift action_265 action_264 (196#) = happyShift action_51 action_264 (197#) = happyShift action_52 action_264 (198#) = happyShift action_53 action_264 (199#) = happyShift action_54 action_264 (200#) = happyShift action_55 action_264 (201#) = happyShift action_56 action_264 (72#) = happyGoto action_260 action_264 (73#) = happyGoto action_127 action_264 (74#) = happyGoto action_128 action_264 (75#) = happyGoto action_261 action_264 (76#) = happyGoto action_130 action_264 (77#) = happyGoto action_61 action_264 (78#) = happyGoto action_62 action_264 (81#) = happyGoto action_63 action_264 (82#) = happyGoto action_64 action_264 (83#) = happyGoto action_65 action_264 (97#) = happyGoto action_262 action_264 (99#) = happyGoto action_311 action_264 (102#) = happyGoto action_66 action_264 (104#) = happyGoto action_131 action_264 (106#) = happyGoto action_68 action_264 (116#) = happyGoto action_39 action_264 (117#) = happyGoto action_40 action_264 (118#) = happyGoto action_69 action_264 (119#) = happyGoto action_42 action_264 (127#) = happyGoto action_70 action_264 x = happyTcHack x happyFail action_265 (152#) = happyShift action_248 action_265 (36#) = happyGoto action_310 action_265 (129#) = happyGoto action_247 action_265 x = happyTcHack x happyReduce_294 action_266 (1#) = happyShift action_17 action_266 (154#) = happyShift action_18 action_266 (130#) = happyGoto action_309 action_266 x = happyTcHack x happyFail action_267 (148#) = happyShift action_308 action_267 (41#) = happyGoto action_307 action_267 x = happyTcHack x happyReduce_90 action_268 (200#) = happyShift action_305 action_268 (201#) = happyShift action_306 action_268 (40#) = happyGoto action_304 action_268 x = happyTcHack x happyReduce_88 action_269 (196#) = happyShift action_303 action_269 (17#) = happyGoto action_302 action_269 x = happyTcHack x happyReduce_32 action_270 x = happyTcHack x happyReduce_65 action_271 (152#) = happyShift action_301 action_271 (129#) = happyGoto action_300 action_271 x = happyTcHack x happyReduce_294 action_272 (156#) = happyShift action_299 action_272 (168#) = happyShift action_283 action_272 x = happyTcHack x happyFail action_273 x = happyTcHack x happyReduce_106 action_274 (150#) = happyShift action_297 action_274 (157#) = happyShift action_298 action_274 (168#) = happyShift action_283 action_274 x = happyTcHack x happyFail action_275 (150#) = happyShift action_295 action_275 (157#) = happyShift action_296 action_275 x = happyTcHack x happyFail action_276 (150#) = happyShift action_294 action_276 (157#) = happyShift action_236 action_276 x = happyTcHack x happyFail action_277 x = happyTcHack x happyReduce_104 action_278 (150#) = happyShift action_293 action_278 x = happyTcHack x happyFail action_279 (137#) = happyShift action_44 action_279 (139#) = happyShift action_46 action_279 (140#) = happyShift action_47 action_279 (149#) = happyShift action_113 action_279 (155#) = happyShift action_114 action_279 (196#) = happyShift action_51 action_279 (197#) = happyShift action_52 action_279 (198#) = happyShift action_53 action_279 (199#) = happyShift action_54 action_279 (200#) = happyShift action_55 action_279 (201#) = happyShift action_56 action_279 (43#) = happyGoto action_292 action_279 (44#) = happyGoto action_258 action_279 (45#) = happyGoto action_106 action_279 (46#) = happyGoto action_107 action_279 (117#) = happyGoto action_110 action_279 (118#) = happyGoto action_111 action_279 (119#) = happyGoto action_42 action_279 (136#) = happyGoto action_112 action_279 x = happyTcHack x happyFail action_280 (53#) = happyGoto action_290 action_280 (128#) = happyGoto action_291 action_280 x = happyTcHack x happyReduce_293 action_281 x = happyTcHack x happyReduce_96 action_282 (137#) = happyShift action_44 action_282 (139#) = happyShift action_46 action_282 (140#) = happyShift action_47 action_282 (149#) = happyShift action_113 action_282 (155#) = happyShift action_114 action_282 (196#) = happyShift action_51 action_282 (197#) = happyShift action_52 action_282 (198#) = happyShift action_53 action_282 (199#) = happyShift action_54 action_282 (200#) = happyShift action_55 action_282 (201#) = happyShift action_56 action_282 (43#) = happyGoto action_289 action_282 (44#) = happyGoto action_258 action_282 (45#) = happyGoto action_106 action_282 (46#) = happyGoto action_107 action_282 (117#) = happyGoto action_110 action_282 (118#) = happyGoto action_111 action_282 (119#) = happyGoto action_42 action_282 (136#) = happyGoto action_112 action_282 x = happyTcHack x happyFail action_283 (137#) = happyShift action_44 action_283 (139#) = happyShift action_46 action_283 (140#) = happyShift action_47 action_283 (149#) = happyShift action_113 action_283 (155#) = happyShift action_114 action_283 (196#) = happyShift action_51 action_283 (197#) = happyShift action_52 action_283 (198#) = happyShift action_53 action_283 (199#) = happyShift action_54 action_283 (200#) = happyShift action_55 action_283 (201#) = happyShift action_56 action_283 (43#) = happyGoto action_288 action_283 (44#) = happyGoto action_258 action_283 (45#) = happyGoto action_106 action_283 (46#) = happyGoto action_107 action_283 (117#) = happyGoto action_110 action_283 (118#) = happyGoto action_111 action_283 (119#) = happyGoto action_42 action_283 (136#) = happyGoto action_112 action_283 x = happyTcHack x happyFail action_284 (137#) = happyShift action_44 action_284 (196#) = happyShift action_51 action_284 (197#) = happyShift action_52 action_284 (198#) = happyShift action_53 action_284 (199#) = happyShift action_54 action_284 (200#) = happyShift action_55 action_284 (201#) = happyShift action_56 action_284 (117#) = happyGoto action_110 action_284 (136#) = happyGoto action_287 action_284 x = happyTcHack x happyReduce_113 action_285 (137#) = happyShift action_44 action_285 (139#) = happyShift action_46 action_285 (140#) = happyShift action_47 action_285 (149#) = happyShift action_113 action_285 (155#) = happyShift action_114 action_285 (196#) = happyShift action_51 action_285 (197#) = happyShift action_52 action_285 (198#) = happyShift action_53 action_285 (199#) = happyShift action_54 action_285 (200#) = happyShift action_55 action_285 (201#) = happyShift action_56 action_285 (43#) = happyGoto action_286 action_285 (44#) = happyGoto action_258 action_285 (45#) = happyGoto action_106 action_285 (46#) = happyGoto action_107 action_285 (117#) = happyGoto action_110 action_285 (118#) = happyGoto action_111 action_285 (119#) = happyGoto action_42 action_285 (136#) = happyGoto action_112 action_285 x = happyTcHack x happyFail action_286 (168#) = happyShift action_283 action_286 x = happyTcHack x happyReduce_61 action_287 x = happyTcHack x happyReduce_114 action_288 (168#) = happyShift action_283 action_288 x = happyTcHack x happyReduce_94 action_289 x = happyTcHack x happyReduce_93 action_290 (178#) = happyShift action_388 action_290 (61#) = happyGoto action_414 action_290 x = happyTcHack x happyReduce_135 action_291 (137#) = happyShift action_44 action_291 (139#) = happyShift action_46 action_291 (140#) = happyShift action_47 action_291 (149#) = happyShift action_412 action_291 (155#) = happyShift action_114 action_291 (173#) = happyShift action_413 action_291 (196#) = happyShift action_51 action_291 (197#) = happyShift action_52 action_291 (198#) = happyShift action_53 action_291 (199#) = happyShift action_54 action_291 (200#) = happyShift action_55 action_291 (201#) = happyShift action_56 action_291 (44#) = happyGoto action_406 action_291 (45#) = happyGoto action_106 action_291 (46#) = happyGoto action_107 action_291 (54#) = happyGoto action_407 action_291 (55#) = happyGoto action_408 action_291 (57#) = happyGoto action_409 action_291 (105#) = happyGoto action_410 action_291 (117#) = happyGoto action_110 action_291 (118#) = happyGoto action_111 action_291 (119#) = happyGoto action_411 action_291 (136#) = happyGoto action_112 action_291 x = happyTcHack x happyFail action_292 (168#) = happyShift action_283 action_292 x = happyTcHack x happyReduce_108 action_293 x = happyTcHack x happyReduce_105 action_294 x = happyTcHack x happyReduce_107 action_295 x = happyTcHack x happyReduce_100 action_296 (137#) = happyShift action_44 action_296 (139#) = happyShift action_46 action_296 (140#) = happyShift action_47 action_296 (149#) = happyShift action_113 action_296 (155#) = happyShift action_114 action_296 (196#) = happyShift action_51 action_296 (197#) = happyShift action_52 action_296 (198#) = happyShift action_53 action_296 (199#) = happyShift action_54 action_296 (200#) = happyShift action_55 action_296 (201#) = happyShift action_56 action_296 (43#) = happyGoto action_405 action_296 (44#) = happyGoto action_258 action_296 (45#) = happyGoto action_106 action_296 (46#) = happyGoto action_107 action_296 (117#) = happyGoto action_110 action_296 (118#) = happyGoto action_111 action_296 (119#) = happyGoto action_42 action_296 (136#) = happyGoto action_112 action_296 x = happyTcHack x happyFail action_297 x = happyTcHack x happyReduce_102 action_298 (137#) = happyShift action_44 action_298 (139#) = happyShift action_46 action_298 (140#) = happyShift action_47 action_298 (149#) = happyShift action_113 action_298 (155#) = happyShift action_114 action_298 (196#) = happyShift action_51 action_298 (197#) = happyShift action_52 action_298 (198#) = happyShift action_53 action_298 (199#) = happyShift action_54 action_298 (200#) = happyShift action_55 action_298 (201#) = happyShift action_56 action_298 (43#) = happyGoto action_404 action_298 (44#) = happyGoto action_258 action_298 (45#) = happyGoto action_106 action_298 (46#) = happyGoto action_107 action_298 (117#) = happyGoto action_110 action_298 (118#) = happyGoto action_111 action_298 (119#) = happyGoto action_42 action_298 (136#) = happyGoto action_112 action_298 x = happyTcHack x happyFail action_299 x = happyTcHack x happyReduce_101 action_300 (7#) = happyGoto action_13 action_300 (8#) = happyGoto action_401 action_300 (65#) = happyGoto action_403 action_300 x = happyTcHack x happyReduce_11 action_301 (7#) = happyGoto action_13 action_301 (8#) = happyGoto action_401 action_301 (65#) = happyGoto action_402 action_301 x = happyTcHack x happyReduce_11 action_302 (149#) = happyReduce_38 action_302 (198#) = happyShift action_400 action_302 (18#) = happyGoto action_397 action_302 (19#) = happyGoto action_398 action_302 (20#) = happyGoto action_399 action_302 x = happyTcHack x happyReduce_34 action_303 (139#) = happyShift action_10 action_303 (140#) = happyShift action_11 action_303 (131#) = happyGoto action_396 action_303 x = happyTcHack x happyFail action_304 (148#) = happyShift action_308 action_304 (41#) = happyGoto action_395 action_304 x = happyTcHack x happyReduce_90 action_305 x = happyTcHack x happyReduce_86 action_306 x = happyTcHack x happyReduce_87 action_307 (137#) = happyShift action_393 action_307 (149#) = happyShift action_394 action_307 (42#) = happyGoto action_392 action_307 x = happyTcHack x happyFail action_308 x = happyTcHack x happyReduce_89 action_309 x = happyTcHack x happyReduce_224 action_310 (151#) = happyShift action_391 action_310 (184#) = happyShift action_330 action_310 x = happyTcHack x happyFail action_311 x = happyTcHack x happyReduce_228 action_312 x = happyTcHack x happyReduce_223 action_313 (166#) = happyShift action_390 action_313 x = happyTcHack x happyFail action_314 (137#) = happyShift action_44 action_314 (138#) = happyShift action_45 action_314 (139#) = happyShift action_46 action_314 (140#) = happyShift action_47 action_314 (145#) = happyShift action_71 action_314 (146#) = happyShift action_72 action_314 (147#) = happyShift action_73 action_314 (148#) = happyShift action_74 action_314 (149#) = happyShift action_75 action_314 (151#) = happyShift action_264 action_314 (155#) = happyShift action_76 action_314 (158#) = happyShift action_77 action_314 (164#) = happyShift action_132 action_314 (170#) = happyShift action_78 action_314 (172#) = happyShift action_79 action_314 (174#) = happyShift action_80 action_314 (179#) = happyShift action_84 action_314 (182#) = happyShift action_133 action_314 (189#) = happyShift action_265 action_314 (196#) = happyShift action_51 action_314 (197#) = happyShift action_52 action_314 (198#) = happyShift action_53 action_314 (199#) = happyShift action_54 action_314 (200#) = happyShift action_55 action_314 (201#) = happyShift action_56 action_314 (72#) = happyGoto action_260 action_314 (73#) = happyGoto action_127 action_314 (74#) = happyGoto action_128 action_314 (75#) = happyGoto action_261 action_314 (76#) = happyGoto action_130 action_314 (77#) = happyGoto action_61 action_314 (78#) = happyGoto action_62 action_314 (81#) = happyGoto action_63 action_314 (82#) = happyGoto action_64 action_314 (83#) = happyGoto action_65 action_314 (97#) = happyGoto action_262 action_314 (99#) = happyGoto action_389 action_314 (102#) = happyGoto action_66 action_314 (104#) = happyGoto action_131 action_314 (106#) = happyGoto action_68 action_314 (116#) = happyGoto action_39 action_314 (117#) = happyGoto action_40 action_314 (118#) = happyGoto action_69 action_314 (119#) = happyGoto action_42 action_314 (127#) = happyGoto action_70 action_314 x = happyTcHack x happyReduce_229 action_315 x = happyTcHack x happyReduce_66 action_316 (165#) = happyShift action_387 action_316 (178#) = happyShift action_388 action_316 (61#) = happyGoto action_386 action_316 x = happyTcHack x happyReduce_135 action_317 x = happyTcHack x happyReduce_117 action_318 x = happyTcHack x happyReduce_141 action_319 x = happyTcHack x happyReduce_169 action_320 (7#) = happyGoto action_13 action_320 (8#) = happyGoto action_383 action_320 (91#) = happyGoto action_385 action_320 x = happyTcHack x happyReduce_11 action_321 (7#) = happyGoto action_13 action_321 (8#) = happyGoto action_383 action_321 (91#) = happyGoto action_384 action_321 x = happyTcHack x happyReduce_11 action_322 x = happyTcHack x happyReduce_162 action_323 (137#) = happyShift action_44 action_323 (138#) = happyShift action_45 action_323 (139#) = happyShift action_46 action_323 (140#) = happyShift action_47 action_323 (145#) = happyShift action_71 action_323 (146#) = happyShift action_72 action_323 (147#) = happyShift action_73 action_323 (148#) = happyShift action_74 action_323 (149#) = happyShift action_75 action_323 (155#) = happyShift action_76 action_323 (158#) = happyShift action_77 action_323 (167#) = happyShift action_382 action_323 (170#) = happyShift action_78 action_323 (196#) = happyShift action_51 action_323 (197#) = happyShift action_52 action_323 (198#) = happyShift action_53 action_323 (199#) = happyShift action_54 action_323 (200#) = happyShift action_55 action_323 (201#) = happyShift action_56 action_323 (80#) = happyGoto action_381 action_323 (81#) = happyGoto action_325 action_323 (82#) = happyGoto action_64 action_323 (83#) = happyGoto action_65 action_323 (102#) = happyGoto action_66 action_323 (104#) = happyGoto action_131 action_323 (106#) = happyGoto action_68 action_323 (116#) = happyGoto action_39 action_323 (117#) = happyGoto action_40 action_323 (118#) = happyGoto action_69 action_323 (119#) = happyGoto action_42 action_323 (127#) = happyGoto action_70 action_323 x = happyTcHack x happyFail action_324 x = happyTcHack x happyReduce_176 action_325 x = happyTcHack x happyReduce_177 action_326 (137#) = happyShift action_44 action_326 (138#) = happyShift action_45 action_326 (139#) = happyShift action_46 action_326 (140#) = happyShift action_47 action_326 (145#) = happyShift action_71 action_326 (146#) = happyShift action_72 action_326 (147#) = happyShift action_73 action_326 (148#) = happyShift action_74 action_326 (149#) = happyShift action_75 action_326 (155#) = happyShift action_76 action_326 (158#) = happyShift action_77 action_326 (164#) = happyShift action_132 action_326 (170#) = happyShift action_78 action_326 (172#) = happyShift action_79 action_326 (174#) = happyShift action_80 action_326 (179#) = happyShift action_84 action_326 (182#) = happyShift action_133 action_326 (189#) = happyShift action_134 action_326 (196#) = happyShift action_51 action_326 (197#) = happyShift action_52 action_326 (198#) = happyShift action_53 action_326 (199#) = happyShift action_54 action_326 (200#) = happyShift action_55 action_326 (201#) = happyShift action_56 action_326 (72#) = happyGoto action_380 action_326 (73#) = happyGoto action_127 action_326 (74#) = happyGoto action_128 action_326 (75#) = happyGoto action_129 action_326 (76#) = happyGoto action_130 action_326 (77#) = happyGoto action_61 action_326 (78#) = happyGoto action_62 action_326 (81#) = happyGoto action_63 action_326 (82#) = happyGoto action_64 action_326 (83#) = happyGoto action_65 action_326 (102#) = happyGoto action_66 action_326 (104#) = happyGoto action_131 action_326 (106#) = happyGoto action_68 action_326 (116#) = happyGoto action_39 action_326 (117#) = happyGoto action_40 action_326 (118#) = happyGoto action_69 action_326 (119#) = happyGoto action_42 action_326 (127#) = happyGoto action_70 action_326 x = happyTcHack x happyFail action_327 (137#) = happyReduce_293 action_327 (138#) = happyReduce_293 action_327 (139#) = happyReduce_293 action_327 (140#) = happyReduce_293 action_327 (145#) = happyReduce_293 action_327 (146#) = happyReduce_293 action_327 (147#) = happyReduce_293 action_327 (148#) = happyReduce_293 action_327 (149#) = happyReduce_293 action_327 (151#) = happyShift action_30 action_327 (155#) = happyReduce_293 action_327 (158#) = happyReduce_293 action_327 (170#) = happyReduce_293 action_327 (172#) = happyReduce_293 action_327 (174#) = happyReduce_293 action_327 (179#) = happyReduce_293 action_327 (185#) = happyReduce_293 action_327 (186#) = happyReduce_293 action_327 (187#) = happyReduce_293 action_327 (196#) = happyReduce_293 action_327 (197#) = happyReduce_293 action_327 (198#) = happyReduce_293 action_327 (199#) = happyReduce_293 action_327 (200#) = happyReduce_293 action_327 (201#) = happyReduce_293 action_327 (25#) = happyGoto action_21 action_327 (34#) = happyGoto action_377 action_327 (35#) = happyGoto action_378 action_327 (37#) = happyGoto action_26 action_327 (67#) = happyGoto action_28 action_327 (128#) = happyGoto action_379 action_327 x = happyTcHack x happyReduce_73 action_328 (153#) = happyShift action_376 action_328 x = happyTcHack x happyFail action_329 (1#) = happyShift action_17 action_329 (154#) = happyShift action_18 action_329 (130#) = happyGoto action_375 action_329 x = happyTcHack x happyFail action_330 (137#) = happyShift action_44 action_330 (138#) = happyShift action_45 action_330 (139#) = happyShift action_46 action_330 (140#) = happyShift action_47 action_330 (145#) = happyShift action_71 action_330 (146#) = happyShift action_72 action_330 (147#) = happyShift action_73 action_330 (148#) = happyShift action_74 action_330 (149#) = happyShift action_75 action_330 (155#) = happyShift action_76 action_330 (158#) = happyShift action_77 action_330 (164#) = happyShift action_132 action_330 (170#) = happyShift action_78 action_330 (172#) = happyShift action_79 action_330 (174#) = happyShift action_80 action_330 (179#) = happyShift action_84 action_330 (182#) = happyShift action_133 action_330 (189#) = happyShift action_134 action_330 (196#) = happyShift action_51 action_330 (197#) = happyShift action_52 action_330 (198#) = happyShift action_53 action_330 (199#) = happyShift action_54 action_330 (200#) = happyShift action_55 action_330 (201#) = happyShift action_56 action_330 (72#) = happyGoto action_374 action_330 (73#) = happyGoto action_127 action_330 (74#) = happyGoto action_128 action_330 (75#) = happyGoto action_129 action_330 (76#) = happyGoto action_130 action_330 (77#) = happyGoto action_61 action_330 (78#) = happyGoto action_62 action_330 (81#) = happyGoto action_63 action_330 (82#) = happyGoto action_64 action_330 (83#) = happyGoto action_65 action_330 (102#) = happyGoto action_66 action_330 (104#) = happyGoto action_131 action_330 (106#) = happyGoto action_68 action_330 (116#) = happyGoto action_39 action_330 (117#) = happyGoto action_40 action_330 (118#) = happyGoto action_69 action_330 (119#) = happyGoto action_42 action_330 (127#) = happyGoto action_70 action_330 x = happyTcHack x happyFail action_331 x = happyTcHack x happyReduce_209 action_332 (157#) = happyShift action_373 action_332 x = happyTcHack x happyReduce_203 action_333 x = happyTcHack x happyReduce_207 action_334 (128#) = happyGoto action_372 action_334 x = happyTcHack x happyReduce_293 action_335 (152#) = happyShift action_248 action_335 (36#) = happyGoto action_371 action_335 (129#) = happyGoto action_247 action_335 x = happyTcHack x happyReduce_294 action_336 x = happyTcHack x happyReduce_201 action_337 (160#) = happyShift action_370 action_337 x = happyTcHack x happyReduce_205 action_338 x = happyTcHack x happyReduce_204 action_339 x = happyTcHack x happyReduce_196 action_340 (137#) = happyShift action_44 action_340 (139#) = happyShift action_46 action_340 (140#) = happyShift action_47 action_340 (149#) = happyShift action_113 action_340 (155#) = happyShift action_114 action_340 (196#) = happyShift action_51 action_340 (197#) = happyShift action_52 action_340 (198#) = happyShift action_53 action_340 (199#) = happyShift action_54 action_340 (200#) = happyShift action_55 action_340 (201#) = happyShift action_56 action_340 (43#) = happyGoto action_104 action_340 (44#) = happyGoto action_105 action_340 (45#) = happyGoto action_106 action_340 (46#) = happyGoto action_107 action_340 (47#) = happyGoto action_369 action_340 (48#) = happyGoto action_109 action_340 (117#) = happyGoto action_110 action_340 (118#) = happyGoto action_111 action_340 (119#) = happyGoto action_42 action_340 (136#) = happyGoto action_112 action_340 x = happyTcHack x happyFail action_341 x = happyTcHack x happyReduce_190 action_342 x = happyTcHack x happyReduce_195 action_343 x = happyTcHack x happyReduce_191 action_344 x = happyTcHack x happyReduce_251 action_345 (137#) = happyShift action_44 action_345 (138#) = happyShift action_45 action_345 (139#) = happyShift action_46 action_345 (140#) = happyShift action_47 action_345 (145#) = happyShift action_71 action_345 (146#) = happyShift action_72 action_345 (147#) = happyShift action_73 action_345 (148#) = happyShift action_74 action_345 (149#) = happyShift action_75 action_345 (155#) = happyShift action_76 action_345 (158#) = happyShift action_77 action_345 (164#) = happyShift action_132 action_345 (170#) = happyShift action_78 action_345 (172#) = happyShift action_79 action_345 (174#) = happyShift action_80 action_345 (179#) = happyShift action_84 action_345 (182#) = happyShift action_133 action_345 (189#) = happyShift action_134 action_345 (196#) = happyShift action_51 action_345 (197#) = happyShift action_52 action_345 (198#) = happyShift action_53 action_345 (199#) = happyShift action_54 action_345 (200#) = happyShift action_55 action_345 (201#) = happyShift action_56 action_345 (72#) = happyGoto action_368 action_345 (73#) = happyGoto action_127 action_345 (74#) = happyGoto action_128 action_345 (75#) = happyGoto action_129 action_345 (76#) = happyGoto action_130 action_345 (77#) = happyGoto action_61 action_345 (78#) = happyGoto action_62 action_345 (81#) = happyGoto action_63 action_345 (82#) = happyGoto action_64 action_345 (83#) = happyGoto action_65 action_345 (102#) = happyGoto action_66 action_345 (104#) = happyGoto action_131 action_345 (106#) = happyGoto action_68 action_345 (116#) = happyGoto action_39 action_345 (117#) = happyGoto action_40 action_345 (118#) = happyGoto action_69 action_345 (119#) = happyGoto action_42 action_345 (127#) = happyGoto action_70 action_345 x = happyTcHack x happyFail action_346 x = happyTcHack x happyReduce_182 action_347 (137#) = happyShift action_44 action_347 (138#) = happyShift action_45 action_347 (149#) = happyShift action_48 action_347 (196#) = happyShift action_51 action_347 (197#) = happyShift action_52 action_347 (198#) = happyShift action_53 action_347 (199#) = happyShift action_54 action_347 (200#) = happyShift action_55 action_347 (201#) = happyShift action_56 action_347 (101#) = happyGoto action_367 action_347 (104#) = happyGoto action_225 action_347 (116#) = happyGoto action_39 action_347 (117#) = happyGoto action_40 action_347 x = happyTcHack x happyFail action_348 x = happyTcHack x happyReduce_151 action_349 (163#) = happyShift action_366 action_349 x = happyTcHack x happyFail action_350 x = happyTcHack x happyReduce_255 action_351 x = happyTcHack x happyReduce_249 action_352 (150#) = happyShift action_365 action_352 x = happyTcHack x happyFail action_353 (159#) = happyShift action_364 action_353 x = happyTcHack x happyFail action_354 (159#) = happyShift action_363 action_354 x = happyTcHack x happyFail action_355 (141#) = happyShift action_179 action_355 (142#) = happyShift action_157 action_355 (159#) = happyShift action_211 action_355 (172#) = happyShift action_182 action_355 (173#) = happyShift action_183 action_355 (107#) = happyGoto action_206 action_355 (110#) = happyGoto action_207 action_355 (112#) = happyGoto action_362 action_355 (121#) = happyGoto action_209 action_355 (124#) = happyGoto action_210 action_355 x = happyTcHack x happyFail action_356 x = happyTcHack x happyReduce_22 action_357 (150#) = happyShift action_361 action_357 x = happyTcHack x happyFail action_358 x = happyTcHack x happyReduce_24 action_359 (137#) = happyShift action_44 action_359 (139#) = happyShift action_46 action_359 (149#) = happyShift action_202 action_359 (196#) = happyShift action_51 action_359 (197#) = happyShift action_52 action_359 (198#) = happyShift action_53 action_359 (199#) = happyShift action_54 action_359 (200#) = happyShift action_55 action_359 (201#) = happyShift action_56 action_359 (24#) = happyGoto action_360 action_359 (103#) = happyGoto action_198 action_359 (105#) = happyGoto action_199 action_359 (117#) = happyGoto action_200 action_359 (119#) = happyGoto action_201 action_359 x = happyTcHack x happyFail action_360 x = happyTcHack x happyReduce_46 action_361 x = happyTcHack x happyReduce_243 action_362 x = happyTcHack x happyReduce_56 action_363 x = happyTcHack x happyReduce_253 action_364 x = happyTcHack x happyReduce_247 action_365 x = happyTcHack x happyReduce_239 action_366 (137#) = happyShift action_44 action_366 (138#) = happyShift action_45 action_366 (139#) = happyShift action_46 action_366 (140#) = happyShift action_47 action_366 (145#) = happyShift action_71 action_366 (146#) = happyShift action_72 action_366 (147#) = happyShift action_73 action_366 (148#) = happyShift action_74 action_366 (149#) = happyShift action_75 action_366 (155#) = happyShift action_76 action_366 (158#) = happyShift action_77 action_366 (164#) = happyShift action_132 action_366 (170#) = happyShift action_78 action_366 (172#) = happyShift action_79 action_366 (174#) = happyShift action_80 action_366 (179#) = happyShift action_84 action_366 (182#) = happyShift action_133 action_366 (189#) = happyShift action_134 action_366 (196#) = happyShift action_51 action_366 (197#) = happyShift action_52 action_366 (198#) = happyShift action_53 action_366 (199#) = happyShift action_54 action_366 (200#) = happyShift action_55 action_366 (201#) = happyShift action_56 action_366 (72#) = happyGoto action_450 action_366 (73#) = happyGoto action_127 action_366 (74#) = happyGoto action_128 action_366 (75#) = happyGoto action_129 action_366 (76#) = happyGoto action_130 action_366 (77#) = happyGoto action_61 action_366 (78#) = happyGoto action_62 action_366 (81#) = happyGoto action_63 action_366 (82#) = happyGoto action_64 action_366 (83#) = happyGoto action_65 action_366 (102#) = happyGoto action_66 action_366 (104#) = happyGoto action_131 action_366 (106#) = happyGoto action_68 action_366 (116#) = happyGoto action_39 action_366 (117#) = happyGoto action_40 action_366 (118#) = happyGoto action_69 action_366 (119#) = happyGoto action_42 action_366 (127#) = happyGoto action_70 action_366 x = happyTcHack x happyFail action_367 x = happyTcHack x happyReduce_231 action_368 x = happyTcHack x happyReduce_233 action_369 x = happyTcHack x happyReduce_158 action_370 (137#) = happyShift action_44 action_370 (138#) = happyShift action_45 action_370 (139#) = happyShift action_46 action_370 (140#) = happyShift action_47 action_370 (145#) = happyShift action_71 action_370 (146#) = happyShift action_72 action_370 (147#) = happyShift action_73 action_370 (148#) = happyShift action_74 action_370 (149#) = happyShift action_75 action_370 (155#) = happyShift action_76 action_370 (158#) = happyShift action_77 action_370 (164#) = happyShift action_132 action_370 (170#) = happyShift action_78 action_370 (172#) = happyShift action_79 action_370 (174#) = happyShift action_80 action_370 (179#) = happyShift action_84 action_370 (182#) = happyShift action_133 action_370 (189#) = happyShift action_134 action_370 (196#) = happyShift action_51 action_370 (197#) = happyShift action_52 action_370 (198#) = happyShift action_53 action_370 (199#) = happyShift action_54 action_370 (200#) = happyShift action_55 action_370 (201#) = happyShift action_56 action_370 (72#) = happyGoto action_449 action_370 (73#) = happyGoto action_127 action_370 (74#) = happyGoto action_128 action_370 (75#) = happyGoto action_129 action_370 (76#) = happyGoto action_130 action_370 (77#) = happyGoto action_61 action_370 (78#) = happyGoto action_62 action_370 (81#) = happyGoto action_63 action_370 (82#) = happyGoto action_64 action_370 (83#) = happyGoto action_65 action_370 (102#) = happyGoto action_66 action_370 (104#) = happyGoto action_131 action_370 (106#) = happyGoto action_68 action_370 (116#) = happyGoto action_39 action_370 (117#) = happyGoto action_40 action_370 (118#) = happyGoto action_69 action_370 (119#) = happyGoto action_42 action_370 (127#) = happyGoto action_70 action_370 x = happyTcHack x happyReduce_200 action_371 (184#) = happyShift action_330 action_371 x = happyTcHack x happyReduce_210 action_372 (166#) = happyShift action_448 action_372 x = happyTcHack x happyFail action_373 (137#) = happyShift action_44 action_373 (138#) = happyShift action_45 action_373 (139#) = happyShift action_46 action_373 (140#) = happyShift action_47 action_373 (145#) = happyShift action_71 action_373 (146#) = happyShift action_72 action_373 (147#) = happyShift action_73 action_373 (148#) = happyShift action_74 action_373 (149#) = happyShift action_75 action_373 (155#) = happyShift action_76 action_373 (158#) = happyShift action_77 action_373 (164#) = happyShift action_132 action_373 (170#) = happyShift action_78 action_373 (172#) = happyShift action_79 action_373 (174#) = happyShift action_80 action_373 (179#) = happyShift action_84 action_373 (182#) = happyShift action_133 action_373 (189#) = happyShift action_335 action_373 (196#) = happyShift action_51 action_373 (197#) = happyShift action_52 action_373 (198#) = happyShift action_53 action_373 (199#) = happyShift action_54 action_373 (200#) = happyShift action_55 action_373 (201#) = happyShift action_56 action_373 (72#) = happyGoto action_331 action_373 (73#) = happyGoto action_127 action_373 (74#) = happyGoto action_128 action_373 (75#) = happyGoto action_261 action_373 (76#) = happyGoto action_130 action_373 (77#) = happyGoto action_61 action_373 (78#) = happyGoto action_62 action_373 (81#) = happyGoto action_63 action_373 (82#) = happyGoto action_64 action_373 (83#) = happyGoto action_65 action_373 (89#) = happyGoto action_447 action_373 (97#) = happyGoto action_334 action_373 (102#) = happyGoto action_66 action_373 (104#) = happyGoto action_131 action_373 (106#) = happyGoto action_68 action_373 (116#) = happyGoto action_39 action_373 (117#) = happyGoto action_40 action_373 (118#) = happyGoto action_69 action_373 (119#) = happyGoto action_42 action_373 (127#) = happyGoto action_70 action_373 x = happyTcHack x happyFail action_374 x = happyTcHack x happyReduce_167 action_375 x = happyTcHack x happyReduce_80 action_376 x = happyTcHack x happyReduce_79 action_377 (7#) = happyGoto action_445 action_377 (8#) = happyGoto action_446 action_377 x = happyTcHack x happyReduce_11 action_378 x = happyTcHack x happyReduce_75 action_379 (137#) = happyShift action_44 action_379 (138#) = happyShift action_45 action_379 (139#) = happyShift action_46 action_379 (140#) = happyShift action_47 action_379 (145#) = happyShift action_71 action_379 (146#) = happyShift action_72 action_379 (147#) = happyShift action_73 action_379 (148#) = happyShift action_74 action_379 (149#) = happyShift action_75 action_379 (155#) = happyShift action_76 action_379 (158#) = happyShift action_77 action_379 (170#) = happyShift action_78 action_379 (172#) = happyShift action_79 action_379 (174#) = happyShift action_80 action_379 (179#) = happyShift action_84 action_379 (185#) = happyShift action_87 action_379 (186#) = happyShift action_88 action_379 (187#) = happyShift action_89 action_379 (196#) = happyShift action_51 action_379 (197#) = happyShift action_52 action_379 (198#) = happyShift action_53 action_379 (199#) = happyShift action_54 action_379 (200#) = happyShift action_55 action_379 (201#) = happyShift action_56 action_379 (27#) = happyGoto action_58 action_379 (38#) = happyGoto action_59 action_379 (75#) = happyGoto action_60 action_379 (77#) = happyGoto action_61 action_379 (78#) = happyGoto action_62 action_379 (81#) = happyGoto action_63 action_379 (82#) = happyGoto action_64 action_379 (83#) = happyGoto action_65 action_379 (102#) = happyGoto action_66 action_379 (104#) = happyGoto action_67 action_379 (106#) = happyGoto action_68 action_379 (116#) = happyGoto action_39 action_379 (117#) = happyGoto action_40 action_379 (118#) = happyGoto action_69 action_379 (119#) = happyGoto action_42 action_379 (127#) = happyGoto action_70 action_379 x = happyTcHack x happyFail action_380 (180#) = happyShift action_444 action_380 x = happyTcHack x happyFail action_381 x = happyTcHack x happyReduce_175 action_382 (137#) = happyShift action_44 action_382 (138#) = happyShift action_45 action_382 (139#) = happyShift action_46 action_382 (140#) = happyShift action_47 action_382 (145#) = happyShift action_71 action_382 (146#) = happyShift action_72 action_382 (147#) = happyShift action_73 action_382 (148#) = happyShift action_74 action_382 (149#) = happyShift action_75 action_382 (155#) = happyShift action_76 action_382 (158#) = happyShift action_77 action_382 (164#) = happyShift action_132 action_382 (170#) = happyShift action_78 action_382 (172#) = happyShift action_79 action_382 (174#) = happyShift action_80 action_382 (179#) = happyShift action_84 action_382 (182#) = happyShift action_133 action_382 (189#) = happyShift action_134 action_382 (196#) = happyShift action_51 action_382 (197#) = happyShift action_52 action_382 (198#) = happyShift action_53 action_382 (199#) = happyShift action_54 action_382 (200#) = happyShift action_55 action_382 (201#) = happyShift action_56 action_382 (72#) = happyGoto action_443 action_382 (73#) = happyGoto action_127 action_382 (74#) = happyGoto action_128 action_382 (75#) = happyGoto action_129 action_382 (76#) = happyGoto action_130 action_382 (77#) = happyGoto action_61 action_382 (78#) = happyGoto action_62 action_382 (81#) = happyGoto action_63 action_382 (82#) = happyGoto action_64 action_382 (83#) = happyGoto action_65 action_382 (102#) = happyGoto action_66 action_382 (104#) = happyGoto action_131 action_382 (106#) = happyGoto action_68 action_382 (116#) = happyGoto action_39 action_382 (117#) = happyGoto action_40 action_382 (118#) = happyGoto action_69 action_382 (119#) = happyGoto action_42 action_382 (127#) = happyGoto action_70 action_382 x = happyTcHack x happyFail action_383 (151#) = happyShift action_30 action_383 (92#) = happyGoto action_440 action_383 (93#) = happyGoto action_441 action_383 (128#) = happyGoto action_442 action_383 x = happyTcHack x happyReduce_293 action_384 (153#) = happyShift action_439 action_384 x = happyTcHack x happyFail action_385 (1#) = happyShift action_17 action_385 (154#) = happyShift action_18 action_385 (130#) = happyGoto action_438 action_385 x = happyTcHack x happyFail action_386 x = happyTcHack x happyReduce_62 action_387 (53#) = happyGoto action_437 action_387 (128#) = happyGoto action_291 action_387 x = happyTcHack x happyReduce_293 action_388 (139#) = happyShift action_46 action_388 (140#) = happyShift action_47 action_388 (149#) = happyShift action_436 action_388 (118#) = happyGoto action_434 action_388 (119#) = happyGoto action_42 action_388 (135#) = happyGoto action_435 action_388 x = happyTcHack x happyFail action_389 x = happyTcHack x happyReduce_227 action_390 (137#) = happyShift action_44 action_390 (138#) = happyShift action_45 action_390 (139#) = happyShift action_46 action_390 (140#) = happyShift action_47 action_390 (145#) = happyShift action_71 action_390 (146#) = happyShift action_72 action_390 (147#) = happyShift action_73 action_390 (148#) = happyShift action_74 action_390 (149#) = happyShift action_75 action_390 (155#) = happyShift action_76 action_390 (158#) = happyShift action_77 action_390 (164#) = happyShift action_132 action_390 (170#) = happyShift action_78 action_390 (172#) = happyShift action_79 action_390 (174#) = happyShift action_80 action_390 (179#) = happyShift action_84 action_390 (182#) = happyShift action_133 action_390 (189#) = happyShift action_134 action_390 (196#) = happyShift action_51 action_390 (197#) = happyShift action_52 action_390 (198#) = happyShift action_53 action_390 (199#) = happyShift action_54 action_390 (200#) = happyShift action_55 action_390 (201#) = happyShift action_56 action_390 (72#) = happyGoto action_433 action_390 (73#) = happyGoto action_127 action_390 (74#) = happyGoto action_128 action_390 (75#) = happyGoto action_129 action_390 (76#) = happyGoto action_130 action_390 (77#) = happyGoto action_61 action_390 (78#) = happyGoto action_62 action_390 (81#) = happyGoto action_63 action_390 (82#) = happyGoto action_64 action_390 (83#) = happyGoto action_65 action_390 (102#) = happyGoto action_66 action_390 (104#) = happyGoto action_131 action_390 (106#) = happyGoto action_68 action_390 (116#) = happyGoto action_39 action_390 (117#) = happyGoto action_40 action_390 (118#) = happyGoto action_69 action_390 (119#) = happyGoto action_42 action_390 (127#) = happyGoto action_70 action_390 x = happyTcHack x happyFail action_391 (137#) = happyShift action_44 action_391 (138#) = happyShift action_45 action_391 (139#) = happyShift action_46 action_391 (140#) = happyShift action_47 action_391 (145#) = happyShift action_71 action_391 (146#) = happyShift action_72 action_391 (147#) = happyShift action_73 action_391 (148#) = happyShift action_74 action_391 (149#) = happyShift action_75 action_391 (151#) = happyShift action_264 action_391 (155#) = happyShift action_76 action_391 (158#) = happyShift action_77 action_391 (164#) = happyShift action_132 action_391 (170#) = happyShift action_78 action_391 (172#) = happyShift action_79 action_391 (174#) = happyShift action_80 action_391 (179#) = happyShift action_84 action_391 (182#) = happyShift action_133 action_391 (189#) = happyShift action_265 action_391 (196#) = happyShift action_51 action_391 (197#) = happyShift action_52 action_391 (198#) = happyShift action_53 action_391 (199#) = happyShift action_54 action_391 (200#) = happyShift action_55 action_391 (201#) = happyShift action_56 action_391 (72#) = happyGoto action_260 action_391 (73#) = happyGoto action_127 action_391 (74#) = happyGoto action_128 action_391 (75#) = happyGoto action_261 action_391 (76#) = happyGoto action_130 action_391 (77#) = happyGoto action_61 action_391 (78#) = happyGoto action_62 action_391 (81#) = happyGoto action_63 action_391 (82#) = happyGoto action_64 action_391 (83#) = happyGoto action_65 action_391 (97#) = happyGoto action_262 action_391 (99#) = happyGoto action_432 action_391 (102#) = happyGoto action_66 action_391 (104#) = happyGoto action_131 action_391 (106#) = happyGoto action_68 action_391 (116#) = happyGoto action_39 action_391 (117#) = happyGoto action_40 action_391 (118#) = happyGoto action_69 action_391 (119#) = happyGoto action_42 action_391 (127#) = happyGoto action_70 action_391 x = happyTcHack x happyFail action_392 (162#) = happyShift action_431 action_392 x = happyTcHack x happyFail action_393 x = happyTcHack x happyReduce_91 action_394 (141#) = happyShift action_179 action_394 (172#) = happyShift action_182 action_394 (173#) = happyShift action_183 action_394 (124#) = happyGoto action_430 action_394 x = happyTcHack x happyFail action_395 (137#) = happyShift action_393 action_395 (149#) = happyShift action_394 action_395 (42#) = happyGoto action_429 action_395 x = happyTcHack x happyFail action_396 x = happyTcHack x happyReduce_31 action_397 x = happyTcHack x happyReduce_28 action_398 x = happyTcHack x happyReduce_33 action_399 (149#) = happyShift action_428 action_399 x = happyTcHack x happyFail action_400 x = happyTcHack x happyReduce_37 action_401 (137#) = happyReduce_293 action_401 (138#) = happyReduce_293 action_401 (139#) = happyReduce_293 action_401 (140#) = happyReduce_293 action_401 (145#) = happyReduce_293 action_401 (146#) = happyReduce_293 action_401 (147#) = happyReduce_293 action_401 (148#) = happyReduce_293 action_401 (149#) = happyReduce_293 action_401 (151#) = happyShift action_30 action_401 (155#) = happyReduce_293 action_401 (158#) = happyReduce_293 action_401 (170#) = happyReduce_293 action_401 (172#) = happyReduce_293 action_401 (174#) = happyReduce_293 action_401 (179#) = happyReduce_293 action_401 (196#) = happyReduce_293 action_401 (197#) = happyReduce_293 action_401 (198#) = happyReduce_293 action_401 (199#) = happyReduce_293 action_401 (200#) = happyReduce_293 action_401 (201#) = happyReduce_293 action_401 (66#) = happyGoto action_425 action_401 (67#) = happyGoto action_426 action_401 (128#) = happyGoto action_427 action_401 x = happyTcHack x happyReduce_147 action_402 (153#) = happyShift action_424 action_402 x = happyTcHack x happyFail action_403 (1#) = happyShift action_17 action_403 (154#) = happyShift action_18 action_403 (130#) = happyGoto action_423 action_403 x = happyTcHack x happyFail action_404 (168#) = happyShift action_283 action_404 x = happyTcHack x happyReduce_112 action_405 (168#) = happyShift action_283 action_405 x = happyTcHack x happyReduce_111 action_406 (137#) = happyShift action_44 action_406 (139#) = happyShift action_46 action_406 (140#) = happyShift action_47 action_406 (142#) = happyReduce_128 action_406 (149#) = happyShift action_113 action_406 (155#) = happyShift action_114 action_406 (159#) = happyReduce_128 action_406 (173#) = happyShift action_422 action_406 (196#) = happyShift action_51 action_406 (197#) = happyShift action_52 action_406 (198#) = happyShift action_53 action_406 (199#) = happyShift action_54 action_406 (200#) = happyShift action_55 action_406 (201#) = happyShift action_56 action_406 (45#) = happyGoto action_281 action_406 (46#) = happyGoto action_107 action_406 (117#) = happyGoto action_110 action_406 (118#) = happyGoto action_111 action_406 (119#) = happyGoto action_42 action_406 (136#) = happyGoto action_112 action_406 x = happyTcHack x happyReduce_122 action_407 x = happyTcHack x happyReduce_118 action_408 (137#) = happyShift action_44 action_408 (139#) = happyShift action_46 action_408 (140#) = happyShift action_47 action_408 (149#) = happyShift action_113 action_408 (155#) = happyShift action_114 action_408 (173#) = happyShift action_421 action_408 (196#) = happyShift action_51 action_408 (197#) = happyShift action_52 action_408 (198#) = happyShift action_53 action_408 (199#) = happyShift action_54 action_408 (200#) = happyShift action_55 action_408 (201#) = happyShift action_56 action_408 (45#) = happyGoto action_419 action_408 (46#) = happyGoto action_107 action_408 (56#) = happyGoto action_420 action_408 (117#) = happyGoto action_110 action_408 (118#) = happyGoto action_111 action_408 (119#) = happyGoto action_42 action_408 (136#) = happyGoto action_112 action_408 x = happyTcHack x happyReduce_123 action_409 (142#) = happyShift action_157 action_409 (159#) = happyShift action_418 action_409 (110#) = happyGoto action_417 action_409 (121#) = happyGoto action_209 action_409 x = happyTcHack x happyFail action_410 (152#) = happyShift action_416 action_410 x = happyTcHack x happyFail action_411 (152#) = happyReduce_242 action_411 x = happyTcHack x happyReduce_273 action_412 (137#) = happyShift action_44 action_412 (139#) = happyShift action_46 action_412 (140#) = happyShift action_47 action_412 (142#) = happyShift action_157 action_412 (149#) = happyShift action_113 action_412 (150#) = happyShift action_277 action_412 (155#) = happyShift action_114 action_412 (157#) = happyShift action_161 action_412 (167#) = happyShift action_278 action_412 (196#) = happyShift action_51 action_412 (197#) = happyShift action_52 action_412 (198#) = happyShift action_53 action_412 (199#) = happyShift action_54 action_412 (200#) = happyShift action_55 action_412 (201#) = happyShift action_56 action_412 (43#) = happyGoto action_274 action_412 (44#) = happyGoto action_258 action_412 (45#) = happyGoto action_106 action_412 (46#) = happyGoto action_107 action_412 (49#) = happyGoto action_275 action_412 (84#) = happyGoto action_276 action_412 (117#) = happyGoto action_110 action_412 (118#) = happyGoto action_111 action_412 (119#) = happyGoto action_42 action_412 (121#) = happyGoto action_357 action_412 (136#) = happyGoto action_112 action_412 x = happyTcHack x happyFail action_413 (137#) = happyShift action_44 action_413 (139#) = happyShift action_46 action_413 (140#) = happyShift action_47 action_413 (149#) = happyShift action_113 action_413 (155#) = happyShift action_114 action_413 (196#) = happyShift action_51 action_413 (197#) = happyShift action_52 action_413 (198#) = happyShift action_53 action_413 (199#) = happyShift action_54 action_413 (200#) = happyShift action_55 action_413 (201#) = happyShift action_56 action_413 (45#) = happyGoto action_415 action_413 (46#) = happyGoto action_107 action_413 (117#) = happyGoto action_110 action_413 (118#) = happyGoto action_111 action_413 (119#) = happyGoto action_42 action_413 (136#) = happyGoto action_112 action_413 x = happyTcHack x happyFail action_414 x = happyTcHack x happyReduce_63 action_415 x = happyTcHack x happyReduce_129 action_416 (137#) = happyShift action_44 action_416 (138#) = happyShift action_45 action_416 (149#) = happyShift action_48 action_416 (153#) = happyShift action_481 action_416 (196#) = happyShift action_51 action_416 (197#) = happyShift action_52 action_416 (198#) = happyShift action_53 action_416 (199#) = happyShift action_54 action_416 (200#) = happyShift action_55 action_416 (201#) = happyShift action_56 action_416 (38#) = happyGoto action_477 action_416 (58#) = happyGoto action_478 action_416 (59#) = happyGoto action_479 action_416 (104#) = happyGoto action_480 action_416 (116#) = happyGoto action_39 action_416 (117#) = happyGoto action_40 action_416 x = happyTcHack x happyFail action_417 (137#) = happyShift action_44 action_417 (139#) = happyShift action_46 action_417 (140#) = happyShift action_47 action_417 (149#) = happyShift action_113 action_417 (155#) = happyShift action_114 action_417 (173#) = happyShift action_413 action_417 (196#) = happyShift action_51 action_417 (197#) = happyShift action_52 action_417 (198#) = happyShift action_53 action_417 (199#) = happyShift action_54 action_417 (200#) = happyShift action_55 action_417 (201#) = happyShift action_56 action_417 (44#) = happyGoto action_475 action_417 (45#) = happyGoto action_106 action_417 (46#) = happyGoto action_107 action_417 (57#) = happyGoto action_476 action_417 (117#) = happyGoto action_110 action_417 (118#) = happyGoto action_111 action_417 (119#) = happyGoto action_42 action_417 (136#) = happyGoto action_112 action_417 x = happyTcHack x happyFail action_418 (139#) = happyShift action_46 action_418 (119#) = happyGoto action_354 action_418 x = happyTcHack x happyFail action_419 x = happyTcHack x happyReduce_126 action_420 x = happyTcHack x happyReduce_125 action_421 (137#) = happyShift action_44 action_421 (139#) = happyShift action_46 action_421 (140#) = happyShift action_47 action_421 (149#) = happyShift action_113 action_421 (155#) = happyShift action_114 action_421 (196#) = happyShift action_51 action_421 (197#) = happyShift action_52 action_421 (198#) = happyShift action_53 action_421 (199#) = happyShift action_54 action_421 (200#) = happyShift action_55 action_421 (201#) = happyShift action_56 action_421 (45#) = happyGoto action_474 action_421 (46#) = happyGoto action_107 action_421 (117#) = happyGoto action_110 action_421 (118#) = happyGoto action_111 action_421 (119#) = happyGoto action_42 action_421 (136#) = happyGoto action_112 action_421 x = happyTcHack x happyFail action_422 (137#) = happyShift action_44 action_422 (139#) = happyShift action_46 action_422 (140#) = happyShift action_47 action_422 (149#) = happyShift action_113 action_422 (155#) = happyShift action_114 action_422 (196#) = happyShift action_51 action_422 (197#) = happyShift action_52 action_422 (198#) = happyShift action_53 action_422 (199#) = happyShift action_54 action_422 (200#) = happyShift action_55 action_422 (201#) = happyShift action_56 action_422 (45#) = happyGoto action_473 action_422 (46#) = happyGoto action_107 action_422 (117#) = happyGoto action_110 action_422 (118#) = happyGoto action_111 action_422 (119#) = happyGoto action_42 action_422 (136#) = happyGoto action_112 action_422 x = happyTcHack x happyFail action_423 x = happyTcHack x happyReduce_144 action_424 x = happyTcHack x happyReduce_143 action_425 (7#) = happyGoto action_471 action_425 (8#) = happyGoto action_472 action_425 x = happyTcHack x happyReduce_11 action_426 x = happyTcHack x happyReduce_149 action_427 (137#) = happyShift action_44 action_427 (138#) = happyShift action_45 action_427 (139#) = happyShift action_46 action_427 (140#) = happyShift action_47 action_427 (145#) = happyShift action_71 action_427 (146#) = happyShift action_72 action_427 (147#) = happyShift action_73 action_427 (148#) = happyShift action_74 action_427 (149#) = happyShift action_75 action_427 (155#) = happyShift action_76 action_427 (158#) = happyShift action_77 action_427 (170#) = happyShift action_78 action_427 (172#) = happyShift action_79 action_427 (174#) = happyShift action_80 action_427 (179#) = happyShift action_84 action_427 (196#) = happyShift action_51 action_427 (197#) = happyShift action_52 action_427 (198#) = happyShift action_53 action_427 (199#) = happyShift action_54 action_427 (200#) = happyShift action_55 action_427 (201#) = happyShift action_56 action_427 (75#) = happyGoto action_60 action_427 (77#) = happyGoto action_61 action_427 (78#) = happyGoto action_62 action_427 (81#) = happyGoto action_63 action_427 (82#) = happyGoto action_64 action_427 (83#) = happyGoto action_65 action_427 (102#) = happyGoto action_66 action_427 (104#) = happyGoto action_131 action_427 (106#) = happyGoto action_68 action_427 (116#) = happyGoto action_39 action_427 (117#) = happyGoto action_40 action_427 (118#) = happyGoto action_69 action_427 (119#) = happyGoto action_42 action_427 (127#) = happyGoto action_70 action_427 x = happyTcHack x happyFail action_428 (137#) = happyShift action_44 action_428 (139#) = happyShift action_46 action_428 (149#) = happyShift action_214 action_428 (157#) = happyShift action_49 action_428 (196#) = happyShift action_51 action_428 (197#) = happyShift action_52 action_428 (198#) = happyShift action_53 action_428 (199#) = happyShift action_54 action_428 (200#) = happyShift action_55 action_428 (201#) = happyShift action_56 action_428 (11#) = happyGoto action_465 action_428 (21#) = happyGoto action_466 action_428 (22#) = happyGoto action_467 action_428 (103#) = happyGoto action_468 action_428 (117#) = happyGoto action_200 action_428 (119#) = happyGoto action_469 action_428 (132#) = happyGoto action_470 action_428 x = happyTcHack x happyReduce_17 action_429 (162#) = happyShift action_464 action_429 x = happyTcHack x happyFail action_430 (150#) = happyShift action_463 action_430 x = happyTcHack x happyFail action_431 (137#) = happyShift action_44 action_431 (139#) = happyShift action_46 action_431 (140#) = happyShift action_47 action_431 (149#) = happyShift action_113 action_431 (155#) = happyShift action_114 action_431 (196#) = happyShift action_51 action_431 (197#) = happyShift action_52 action_431 (198#) = happyShift action_53 action_431 (199#) = happyShift action_54 action_431 (200#) = happyShift action_55 action_431 (201#) = happyShift action_56 action_431 (43#) = happyGoto action_462 action_431 (44#) = happyGoto action_258 action_431 (45#) = happyGoto action_106 action_431 (46#) = happyGoto action_107 action_431 (117#) = happyGoto action_110 action_431 (118#) = happyGoto action_111 action_431 (119#) = happyGoto action_42 action_431 (136#) = happyGoto action_112 action_431 x = happyTcHack x happyFail action_432 x = happyTcHack x happyReduce_225 action_433 (151#) = happyShift action_461 action_433 x = happyTcHack x happyFail action_434 x = happyTcHack x happyReduce_302 action_435 x = happyTcHack x happyReduce_136 action_436 (139#) = happyShift action_46 action_436 (140#) = happyShift action_47 action_436 (150#) = happyShift action_460 action_436 (62#) = happyGoto action_458 action_436 (118#) = happyGoto action_434 action_436 (119#) = happyGoto action_42 action_436 (135#) = happyGoto action_459 action_436 x = happyTcHack x happyFail action_437 x = happyTcHack x happyReduce_116 action_438 x = happyTcHack x happyReduce_212 action_439 x = happyTcHack x happyReduce_211 action_440 (7#) = happyGoto action_456 action_440 (8#) = happyGoto action_457 action_440 x = happyTcHack x happyReduce_11 action_441 x = happyTcHack x happyReduce_215 action_442 (137#) = happyShift action_44 action_442 (138#) = happyShift action_45 action_442 (139#) = happyShift action_46 action_442 (140#) = happyShift action_47 action_442 (145#) = happyShift action_71 action_442 (146#) = happyShift action_72 action_442 (147#) = happyShift action_73 action_442 (148#) = happyShift action_74 action_442 (149#) = happyShift action_75 action_442 (155#) = happyShift action_76 action_442 (158#) = happyShift action_77 action_442 (170#) = happyShift action_78 action_442 (172#) = happyShift action_79 action_442 (174#) = happyShift action_80 action_442 (179#) = happyShift action_84 action_442 (196#) = happyShift action_51 action_442 (197#) = happyShift action_52 action_442 (198#) = happyShift action_53 action_442 (199#) = happyShift action_54 action_442 (200#) = happyShift action_55 action_442 (201#) = happyShift action_56 action_442 (75#) = happyGoto action_454 action_442 (77#) = happyGoto action_61 action_442 (78#) = happyGoto action_62 action_442 (81#) = happyGoto action_63 action_442 (82#) = happyGoto action_64 action_442 (83#) = happyGoto action_65 action_442 (97#) = happyGoto action_455 action_442 (102#) = happyGoto action_66 action_442 (104#) = happyGoto action_131 action_442 (106#) = happyGoto action_68 action_442 (116#) = happyGoto action_39 action_442 (117#) = happyGoto action_40 action_442 (118#) = happyGoto action_69 action_442 (119#) = happyGoto action_42 action_442 (127#) = happyGoto action_70 action_442 x = happyTcHack x happyFail action_443 x = happyTcHack x happyReduce_166 action_444 (137#) = happyShift action_44 action_444 (138#) = happyShift action_45 action_444 (139#) = happyShift action_46 action_444 (140#) = happyShift action_47 action_444 (145#) = happyShift action_71 action_444 (146#) = happyShift action_72 action_444 (147#) = happyShift action_73 action_444 (148#) = happyShift action_74 action_444 (149#) = happyShift action_75 action_444 (155#) = happyShift action_76 action_444 (158#) = happyShift action_77 action_444 (164#) = happyShift action_132 action_444 (170#) = happyShift action_78 action_444 (172#) = happyShift action_79 action_444 (174#) = happyShift action_80 action_444 (179#) = happyShift action_84 action_444 (182#) = happyShift action_133 action_444 (189#) = happyShift action_134 action_444 (196#) = happyShift action_51 action_444 (197#) = happyShift action_52 action_444 (198#) = happyShift action_53 action_444 (199#) = happyShift action_54 action_444 (200#) = happyShift action_55 action_444 (201#) = happyShift action_56 action_444 (72#) = happyGoto action_453 action_444 (73#) = happyGoto action_127 action_444 (74#) = happyGoto action_128 action_444 (75#) = happyGoto action_129 action_444 (76#) = happyGoto action_130 action_444 (77#) = happyGoto action_61 action_444 (78#) = happyGoto action_62 action_444 (81#) = happyGoto action_63 action_444 (82#) = happyGoto action_64 action_444 (83#) = happyGoto action_65 action_444 (102#) = happyGoto action_66 action_444 (104#) = happyGoto action_131 action_444 (106#) = happyGoto action_68 action_444 (116#) = happyGoto action_39 action_444 (117#) = happyGoto action_40 action_444 (118#) = happyGoto action_69 action_444 (119#) = happyGoto action_42 action_444 (127#) = happyGoto action_70 action_444 x = happyTcHack x happyFail action_445 (137#) = happyReduce_293 action_445 (138#) = happyReduce_293 action_445 (139#) = happyReduce_293 action_445 (140#) = happyReduce_293 action_445 (145#) = happyReduce_293 action_445 (146#) = happyReduce_293 action_445 (147#) = happyReduce_293 action_445 (148#) = happyReduce_293 action_445 (149#) = happyReduce_293 action_445 (155#) = happyReduce_293 action_445 (158#) = happyReduce_293 action_445 (170#) = happyReduce_293 action_445 (172#) = happyReduce_293 action_445 (174#) = happyReduce_293 action_445 (179#) = happyReduce_293 action_445 (185#) = happyReduce_293 action_445 (186#) = happyReduce_293 action_445 (187#) = happyReduce_293 action_445 (196#) = happyReduce_293 action_445 (197#) = happyReduce_293 action_445 (198#) = happyReduce_293 action_445 (199#) = happyReduce_293 action_445 (200#) = happyReduce_293 action_445 (201#) = happyReduce_293 action_445 (25#) = happyGoto action_21 action_445 (35#) = happyGoto action_452 action_445 (37#) = happyGoto action_26 action_445 (67#) = happyGoto action_28 action_445 (128#) = happyGoto action_379 action_445 x = happyTcHack x happyReduce_10 action_446 (151#) = happyShift action_30 action_446 x = happyTcHack x happyReduce_72 action_447 x = happyTcHack x happyReduce_206 action_448 (137#) = happyShift action_44 action_448 (138#) = happyShift action_45 action_448 (139#) = happyShift action_46 action_448 (140#) = happyShift action_47 action_448 (145#) = happyShift action_71 action_448 (146#) = happyShift action_72 action_448 (147#) = happyShift action_73 action_448 (148#) = happyShift action_74 action_448 (149#) = happyShift action_75 action_448 (155#) = happyShift action_76 action_448 (158#) = happyShift action_77 action_448 (164#) = happyShift action_132 action_448 (170#) = happyShift action_78 action_448 (172#) = happyShift action_79 action_448 (174#) = happyShift action_80 action_448 (179#) = happyShift action_84 action_448 (182#) = happyShift action_133 action_448 (189#) = happyShift action_134 action_448 (196#) = happyShift action_51 action_448 (197#) = happyShift action_52 action_448 (198#) = happyShift action_53 action_448 (199#) = happyShift action_54 action_448 (200#) = happyShift action_55 action_448 (201#) = happyShift action_56 action_448 (72#) = happyGoto action_451 action_448 (73#) = happyGoto action_127 action_448 (74#) = happyGoto action_128 action_448 (75#) = happyGoto action_129 action_448 (76#) = happyGoto action_130 action_448 (77#) = happyGoto action_61 action_448 (78#) = happyGoto action_62 action_448 (81#) = happyGoto action_63 action_448 (82#) = happyGoto action_64 action_448 (83#) = happyGoto action_65 action_448 (102#) = happyGoto action_66 action_448 (104#) = happyGoto action_131 action_448 (106#) = happyGoto action_68 action_448 (116#) = happyGoto action_39 action_448 (117#) = happyGoto action_40 action_448 (118#) = happyGoto action_69 action_448 (119#) = happyGoto action_42 action_448 (127#) = happyGoto action_70 action_448 x = happyTcHack x happyFail action_449 x = happyTcHack x happyReduce_202 action_450 x = happyTcHack x happyReduce_157 action_451 x = happyTcHack x happyReduce_208 action_452 x = happyTcHack x happyReduce_74 action_453 x = happyTcHack x happyReduce_168 action_454 (141#) = happyShift action_179 action_454 (142#) = happyShift action_157 action_454 (143#) = happyShift action_158 action_454 (144#) = happyShift action_159 action_454 (159#) = happyShift action_180 action_454 (161#) = happyShift action_163 action_454 (172#) = happyShift action_182 action_454 (173#) = happyShift action_183 action_454 (108#) = happyGoto action_172 action_454 (111#) = happyGoto action_173 action_454 (113#) = happyGoto action_174 action_454 (115#) = happyGoto action_175 action_454 (120#) = happyGoto action_149 action_454 (121#) = happyGoto action_150 action_454 (122#) = happyGoto action_176 action_454 (124#) = happyGoto action_153 action_454 (126#) = happyGoto action_177 action_454 x = happyTcHack x happyReduce_222 action_455 (167#) = happyShift action_499 action_455 (94#) = happyGoto action_495 action_455 (95#) = happyGoto action_496 action_455 (96#) = happyGoto action_497 action_455 (128#) = happyGoto action_498 action_455 x = happyTcHack x happyReduce_293 action_456 (137#) = happyReduce_293 action_456 (138#) = happyReduce_293 action_456 (139#) = happyReduce_293 action_456 (140#) = happyReduce_293 action_456 (145#) = happyReduce_293 action_456 (146#) = happyReduce_293 action_456 (147#) = happyReduce_293 action_456 (148#) = happyReduce_293 action_456 (149#) = happyReduce_293 action_456 (155#) = happyReduce_293 action_456 (158#) = happyReduce_293 action_456 (170#) = happyReduce_293 action_456 (172#) = happyReduce_293 action_456 (174#) = happyReduce_293 action_456 (179#) = happyReduce_293 action_456 (196#) = happyReduce_293 action_456 (197#) = happyReduce_293 action_456 (198#) = happyReduce_293 action_456 (199#) = happyReduce_293 action_456 (200#) = happyReduce_293 action_456 (201#) = happyReduce_293 action_456 (93#) = happyGoto action_494 action_456 (128#) = happyGoto action_442 action_456 x = happyTcHack x happyReduce_10 action_457 (151#) = happyShift action_30 action_457 x = happyTcHack x happyReduce_213 action_458 (150#) = happyShift action_492 action_458 (157#) = happyShift action_493 action_458 x = happyTcHack x happyFail action_459 x = happyTcHack x happyReduce_140 action_460 x = happyTcHack x happyReduce_137 action_461 (137#) = happyShift action_44 action_461 (138#) = happyShift action_45 action_461 (139#) = happyShift action_46 action_461 (140#) = happyShift action_47 action_461 (145#) = happyShift action_71 action_461 (146#) = happyShift action_72 action_461 (147#) = happyShift action_73 action_461 (148#) = happyShift action_74 action_461 (149#) = happyShift action_75 action_461 (151#) = happyShift action_264 action_461 (155#) = happyShift action_76 action_461 (158#) = happyShift action_77 action_461 (164#) = happyShift action_132 action_461 (170#) = happyShift action_78 action_461 (172#) = happyShift action_79 action_461 (174#) = happyShift action_80 action_461 (179#) = happyShift action_84 action_461 (182#) = happyShift action_133 action_461 (189#) = happyShift action_265 action_461 (196#) = happyShift action_51 action_461 (197#) = happyShift action_52 action_461 (198#) = happyShift action_53 action_461 (199#) = happyShift action_54 action_461 (200#) = happyShift action_55 action_461 (201#) = happyShift action_56 action_461 (72#) = happyGoto action_260 action_461 (73#) = happyGoto action_127 action_461 (74#) = happyGoto action_128 action_461 (75#) = happyGoto action_261 action_461 (76#) = happyGoto action_130 action_461 (77#) = happyGoto action_61 action_461 (78#) = happyGoto action_62 action_461 (81#) = happyGoto action_63 action_461 (82#) = happyGoto action_64 action_461 (83#) = happyGoto action_65 action_461 (97#) = happyGoto action_262 action_461 (99#) = happyGoto action_491 action_461 (102#) = happyGoto action_66 action_461 (104#) = happyGoto action_131 action_461 (106#) = happyGoto action_68 action_461 (116#) = happyGoto action_39 action_461 (117#) = happyGoto action_40 action_461 (118#) = happyGoto action_69 action_461 (119#) = happyGoto action_42 action_461 (127#) = happyGoto action_70 action_461 x = happyTcHack x happyFail action_462 (168#) = happyShift action_283 action_462 x = happyTcHack x happyReduce_85 action_463 x = happyTcHack x happyReduce_92 action_464 (137#) = happyShift action_44 action_464 (139#) = happyShift action_46 action_464 (140#) = happyShift action_47 action_464 (149#) = happyShift action_113 action_464 (155#) = happyShift action_114 action_464 (196#) = happyShift action_51 action_464 (197#) = happyShift action_52 action_464 (198#) = happyShift action_53 action_464 (199#) = happyShift action_54 action_464 (200#) = happyShift action_55 action_464 (201#) = happyShift action_56 action_464 (43#) = happyGoto action_490 action_464 (44#) = happyGoto action_258 action_464 (45#) = happyGoto action_106 action_464 (46#) = happyGoto action_107 action_464 (117#) = happyGoto action_110 action_464 (118#) = happyGoto action_111 action_464 (119#) = happyGoto action_42 action_464 (136#) = happyGoto action_112 action_464 x = happyTcHack x happyFail action_465 (150#) = happyShift action_489 action_465 x = happyTcHack x happyFail action_466 (157#) = happyShift action_488 action_466 (11#) = happyGoto action_487 action_466 x = happyTcHack x happyReduce_17 action_467 x = happyTcHack x happyReduce_40 action_468 x = happyTcHack x happyReduce_41 action_469 x = happyTcHack x happyReduce_299 action_470 (149#) = happyShift action_486 action_470 x = happyTcHack x happyReduce_42 action_471 (137#) = happyReduce_293 action_471 (138#) = happyReduce_293 action_471 (139#) = happyReduce_293 action_471 (140#) = happyReduce_293 action_471 (145#) = happyReduce_293 action_471 (146#) = happyReduce_293 action_471 (147#) = happyReduce_293 action_471 (148#) = happyReduce_293 action_471 (149#) = happyReduce_293 action_471 (155#) = happyReduce_293 action_471 (158#) = happyReduce_293 action_471 (170#) = happyReduce_293 action_471 (172#) = happyReduce_293 action_471 (174#) = happyReduce_293 action_471 (179#) = happyReduce_293 action_471 (196#) = happyReduce_293 action_471 (197#) = happyReduce_293 action_471 (198#) = happyReduce_293 action_471 (199#) = happyReduce_293 action_471 (200#) = happyReduce_293 action_471 (201#) = happyReduce_293 action_471 (67#) = happyGoto action_485 action_471 (128#) = happyGoto action_427 action_471 x = happyTcHack x happyReduce_10 action_472 (151#) = happyShift action_30 action_472 x = happyTcHack x happyReduce_146 action_473 x = happyTcHack x happyReduce_124 action_474 x = happyTcHack x happyReduce_127 action_475 (137#) = happyShift action_44 action_475 (139#) = happyShift action_46 action_475 (140#) = happyShift action_47 action_475 (149#) = happyShift action_113 action_475 (155#) = happyShift action_114 action_475 (196#) = happyShift action_51 action_475 (197#) = happyShift action_52 action_475 (198#) = happyShift action_53 action_475 (199#) = happyShift action_54 action_475 (200#) = happyShift action_55 action_475 (201#) = happyShift action_56 action_475 (45#) = happyGoto action_281 action_475 (46#) = happyGoto action_107 action_475 (117#) = happyGoto action_110 action_475 (118#) = happyGoto action_111 action_475 (119#) = happyGoto action_42 action_475 (136#) = happyGoto action_112 action_475 x = happyTcHack x happyReduce_128 action_476 x = happyTcHack x happyReduce_119 action_477 (157#) = happyShift action_184 action_477 (162#) = happyShift action_484 action_477 x = happyTcHack x happyFail action_478 (153#) = happyShift action_482 action_478 (157#) = happyShift action_483 action_478 x = happyTcHack x happyFail action_479 x = happyTcHack x happyReduce_131 action_480 x = happyTcHack x happyReduce_83 action_481 x = happyTcHack x happyReduce_120 action_482 x = happyTcHack x happyReduce_121 action_483 (137#) = happyShift action_44 action_483 (138#) = happyShift action_45 action_483 (149#) = happyShift action_48 action_483 (196#) = happyShift action_51 action_483 (197#) = happyShift action_52 action_483 (198#) = happyShift action_53 action_483 (199#) = happyShift action_54 action_483 (200#) = happyShift action_55 action_483 (201#) = happyShift action_56 action_483 (38#) = happyGoto action_477 action_483 (59#) = happyGoto action_513 action_483 (104#) = happyGoto action_480 action_483 (116#) = happyGoto action_39 action_483 (117#) = happyGoto action_40 action_483 x = happyTcHack x happyFail action_484 (137#) = happyShift action_44 action_484 (139#) = happyShift action_46 action_484 (140#) = happyShift action_47 action_484 (149#) = happyShift action_113 action_484 (155#) = happyShift action_114 action_484 (173#) = happyShift action_512 action_484 (196#) = happyShift action_51 action_484 (197#) = happyShift action_52 action_484 (198#) = happyShift action_53 action_484 (199#) = happyShift action_54 action_484 (200#) = happyShift action_55 action_484 (201#) = happyShift action_56 action_484 (43#) = happyGoto action_510 action_484 (44#) = happyGoto action_258 action_484 (45#) = happyGoto action_106 action_484 (46#) = happyGoto action_107 action_484 (60#) = happyGoto action_511 action_484 (117#) = happyGoto action_110 action_484 (118#) = happyGoto action_111 action_484 (119#) = happyGoto action_42 action_484 (136#) = happyGoto action_112 action_484 x = happyTcHack x happyFail action_485 x = happyTcHack x happyReduce_148 action_486 (137#) = happyShift action_44 action_486 (139#) = happyShift action_46 action_486 (149#) = happyShift action_202 action_486 (150#) = happyShift action_508 action_486 (160#) = happyShift action_509 action_486 (196#) = happyShift action_51 action_486 (197#) = happyShift action_52 action_486 (198#) = happyShift action_53 action_486 (199#) = happyShift action_54 action_486 (200#) = happyShift action_55 action_486 (201#) = happyShift action_56 action_486 (23#) = happyGoto action_507 action_486 (24#) = happyGoto action_197 action_486 (103#) = happyGoto action_198 action_486 (105#) = happyGoto action_199 action_486 (117#) = happyGoto action_200 action_486 (119#) = happyGoto action_201 action_486 x = happyTcHack x happyFail action_487 (150#) = happyShift action_506 action_487 x = happyTcHack x happyFail action_488 (137#) = happyShift action_44 action_488 (139#) = happyShift action_46 action_488 (149#) = happyShift action_214 action_488 (196#) = happyShift action_51 action_488 (197#) = happyShift action_52 action_488 (198#) = happyShift action_53 action_488 (199#) = happyShift action_54 action_488 (200#) = happyShift action_55 action_488 (201#) = happyShift action_56 action_488 (22#) = happyGoto action_505 action_488 (103#) = happyGoto action_468 action_488 (117#) = happyGoto action_200 action_488 (119#) = happyGoto action_469 action_488 (132#) = happyGoto action_470 action_488 x = happyTcHack x happyReduce_16 action_489 x = happyTcHack x happyReduce_36 action_490 (168#) = happyShift action_283 action_490 x = happyTcHack x happyReduce_84 action_491 x = happyTcHack x happyReduce_226 action_492 x = happyTcHack x happyReduce_138 action_493 (139#) = happyShift action_46 action_493 (140#) = happyShift action_47 action_493 (118#) = happyGoto action_434 action_493 (119#) = happyGoto action_42 action_493 (135#) = happyGoto action_504 action_493 x = happyTcHack x happyFail action_494 x = happyTcHack x happyReduce_214 action_495 (195#) = happyShift action_222 action_495 (68#) = happyGoto action_503 action_495 x = happyTcHack x happyReduce_152 action_496 (165#) = happyReduce_293 action_496 (96#) = happyGoto action_502 action_496 (128#) = happyGoto action_498 action_496 x = happyTcHack x happyReduce_218 action_497 x = happyTcHack x happyReduce_220 action_498 (165#) = happyShift action_501 action_498 x = happyTcHack x happyFail action_499 (137#) = happyShift action_44 action_499 (138#) = happyShift action_45 action_499 (139#) = happyShift action_46 action_499 (140#) = happyShift action_47 action_499 (145#) = happyShift action_71 action_499 (146#) = happyShift action_72 action_499 (147#) = happyShift action_73 action_499 (148#) = happyShift action_74 action_499 (149#) = happyShift action_75 action_499 (155#) = happyShift action_76 action_499 (158#) = happyShift action_77 action_499 (164#) = happyShift action_132 action_499 (170#) = happyShift action_78 action_499 (172#) = happyShift action_79 action_499 (174#) = happyShift action_80 action_499 (179#) = happyShift action_84 action_499 (182#) = happyShift action_133 action_499 (189#) = happyShift action_134 action_499 (196#) = happyShift action_51 action_499 (197#) = happyShift action_52 action_499 (198#) = happyShift action_53 action_499 (199#) = happyShift action_54 action_499 (200#) = happyShift action_55 action_499 (201#) = happyShift action_56 action_499 (72#) = happyGoto action_500 action_499 (73#) = happyGoto action_127 action_499 (74#) = happyGoto action_128 action_499 (75#) = happyGoto action_129 action_499 (76#) = happyGoto action_130 action_499 (77#) = happyGoto action_61 action_499 (78#) = happyGoto action_62 action_499 (81#) = happyGoto action_63 action_499 (82#) = happyGoto action_64 action_499 (83#) = happyGoto action_65 action_499 (102#) = happyGoto action_66 action_499 (104#) = happyGoto action_131 action_499 (106#) = happyGoto action_68 action_499 (116#) = happyGoto action_39 action_499 (117#) = happyGoto action_40 action_499 (118#) = happyGoto action_69 action_499 (119#) = happyGoto action_42 action_499 (127#) = happyGoto action_70 action_499 x = happyTcHack x happyFail action_500 x = happyTcHack x happyReduce_217 action_501 (137#) = happyShift action_44 action_501 (138#) = happyShift action_45 action_501 (139#) = happyShift action_46 action_501 (140#) = happyShift action_47 action_501 (145#) = happyShift action_71 action_501 (146#) = happyShift action_72 action_501 (147#) = happyShift action_73 action_501 (148#) = happyShift action_74 action_501 (149#) = happyShift action_75 action_501 (155#) = happyShift action_76 action_501 (158#) = happyShift action_77 action_501 (164#) = happyShift action_132 action_501 (170#) = happyShift action_78 action_501 (172#) = happyShift action_79 action_501 (174#) = happyShift action_80 action_501 (179#) = happyShift action_84 action_501 (182#) = happyShift action_133 action_501 (189#) = happyShift action_134 action_501 (196#) = happyShift action_51 action_501 (197#) = happyShift action_52 action_501 (198#) = happyShift action_53 action_501 (199#) = happyShift action_54 action_501 (200#) = happyShift action_55 action_501 (201#) = happyShift action_56 action_501 (73#) = happyGoto action_517 action_501 (74#) = happyGoto action_128 action_501 (75#) = happyGoto action_232 action_501 (76#) = happyGoto action_130 action_501 (77#) = happyGoto action_61 action_501 (78#) = happyGoto action_62 action_501 (81#) = happyGoto action_63 action_501 (82#) = happyGoto action_64 action_501 (83#) = happyGoto action_65 action_501 (102#) = happyGoto action_66 action_501 (104#) = happyGoto action_131 action_501 (106#) = happyGoto action_68 action_501 (116#) = happyGoto action_39 action_501 (117#) = happyGoto action_40 action_501 (118#) = happyGoto action_69 action_501 (119#) = happyGoto action_42 action_501 (127#) = happyGoto action_70 action_501 x = happyTcHack x happyFail action_502 x = happyTcHack x happyReduce_219 action_503 x = happyTcHack x happyReduce_216 action_504 x = happyTcHack x happyReduce_139 action_505 x = happyTcHack x happyReduce_39 action_506 x = happyTcHack x happyReduce_35 action_507 (150#) = happyShift action_516 action_507 (157#) = happyShift action_359 action_507 x = happyTcHack x happyFail action_508 x = happyTcHack x happyReduce_44 action_509 (150#) = happyShift action_515 action_509 x = happyTcHack x happyFail action_510 (168#) = happyShift action_283 action_510 x = happyTcHack x happyReduce_133 action_511 x = happyTcHack x happyReduce_132 action_512 (137#) = happyShift action_44 action_512 (139#) = happyShift action_46 action_512 (140#) = happyShift action_47 action_512 (149#) = happyShift action_113 action_512 (155#) = happyShift action_114 action_512 (196#) = happyShift action_51 action_512 (197#) = happyShift action_52 action_512 (198#) = happyShift action_53 action_512 (199#) = happyShift action_54 action_512 (200#) = happyShift action_55 action_512 (201#) = happyShift action_56 action_512 (45#) = happyGoto action_514 action_512 (46#) = happyGoto action_107 action_512 (117#) = happyGoto action_110 action_512 (118#) = happyGoto action_111 action_512 (119#) = happyGoto action_42 action_512 (136#) = happyGoto action_112 action_512 x = happyTcHack x happyFail action_513 x = happyTcHack x happyReduce_130 action_514 x = happyTcHack x happyReduce_134 action_515 x = happyTcHack x happyReduce_43 action_516 x = happyTcHack x happyReduce_45 action_517 (167#) = happyShift action_518 action_517 x = happyTcHack x happyFail action_518 (137#) = happyShift action_44 action_518 (138#) = happyShift action_45 action_518 (139#) = happyShift action_46 action_518 (140#) = happyShift action_47 action_518 (145#) = happyShift action_71 action_518 (146#) = happyShift action_72 action_518 (147#) = happyShift action_73 action_518 (148#) = happyShift action_74 action_518 (149#) = happyShift action_75 action_518 (155#) = happyShift action_76 action_518 (158#) = happyShift action_77 action_518 (164#) = happyShift action_132 action_518 (170#) = happyShift action_78 action_518 (172#) = happyShift action_79 action_518 (174#) = happyShift action_80 action_518 (179#) = happyShift action_84 action_518 (182#) = happyShift action_133 action_518 (189#) = happyShift action_134 action_518 (196#) = happyShift action_51 action_518 (197#) = happyShift action_52 action_518 (198#) = happyShift action_53 action_518 (199#) = happyShift action_54 action_518 (200#) = happyShift action_55 action_518 (201#) = happyShift action_56 action_518 (72#) = happyGoto action_519 action_518 (73#) = happyGoto action_127 action_518 (74#) = happyGoto action_128 action_518 (75#) = happyGoto action_129 action_518 (76#) = happyGoto action_130 action_518 (77#) = happyGoto action_61 action_518 (78#) = happyGoto action_62 action_518 (81#) = happyGoto action_63 action_518 (82#) = happyGoto action_64 action_518 (83#) = happyGoto action_65 action_518 (102#) = happyGoto action_66 action_518 (104#) = happyGoto action_131 action_518 (106#) = happyGoto action_68 action_518 (116#) = happyGoto action_39 action_518 (117#) = happyGoto action_40 action_518 (118#) = happyGoto action_69 action_518 (119#) = happyGoto action_42 action_518 (127#) = happyGoto action_70 action_518 x = happyTcHack x happyFail action_519 x = happyTcHack x happyReduce_221 happyReduce_1 = happyReduce 6# 4# happyReduction_1 happyReduction_1 ((HappyAbsSyn5 happy_var_6) `HappyStk` _ `HappyStk` (HappyAbsSyn9 happy_var_4) `HappyStk` (HappyAbsSyn131 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn4 (HsModule happy_var_1 happy_var_3 happy_var_4 (fst happy_var_6) (snd happy_var_6) ) `HappyStk` happyRest happyReduce_2 = happySpecReduce_2 4# happyReduction_2 happyReduction_2 (HappyAbsSyn5 happy_var_2) (HappyAbsSyn128 happy_var_1) = HappyAbsSyn4 (HsModule happy_var_1 main_mod (Just [HsEVar (UnQual main_name)]) (fst happy_var_2) (snd happy_var_2) ) happyReduction_2 _ _ = notHappyAtAll happyReduce_3 = happySpecReduce_3 5# happyReduction_3 happyReduction_3 _ (HappyAbsSyn5 happy_var_2) _ = HappyAbsSyn5 (happy_var_2 ) happyReduction_3 _ _ _ = notHappyAtAll happyReduce_4 = happySpecReduce_3 5# happyReduction_4 happyReduction_4 _ (HappyAbsSyn5 happy_var_2) _ = HappyAbsSyn5 (happy_var_2 ) happyReduction_4 _ _ _ = notHappyAtAll happyReduce_5 = happyReduce 4# 6# happyReduction_5 happyReduction_5 ((HappyAbsSyn29 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn14 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn5 ((reverse happy_var_2, happy_var_4) ) `HappyStk` happyRest happyReduce_6 = happySpecReduce_2 6# happyReduction_6 happyReduction_6 (HappyAbsSyn29 happy_var_2) _ = HappyAbsSyn5 (([], happy_var_2) ) happyReduction_6 _ _ = notHappyAtAll happyReduce_7 = happySpecReduce_3 6# happyReduction_7 happyReduction_7 _ (HappyAbsSyn14 happy_var_2) _ = HappyAbsSyn5 ((reverse happy_var_2, []) ) happyReduction_7 _ _ _ = notHappyAtAll happyReduce_8 = happySpecReduce_1 6# happyReduction_8 happyReduction_8 _ = HappyAbsSyn5 (([], []) ) happyReduce_9 = happySpecReduce_2 7# happyReduction_9 happyReduction_9 _ _ = HappyAbsSyn7 (() ) happyReduce_10 = happySpecReduce_1 8# happyReduction_10 happyReduction_10 _ = HappyAbsSyn7 (() ) happyReduce_11 = happySpecReduce_0 8# happyReduction_11 happyReduction_11 = HappyAbsSyn7 (() ) happyReduce_12 = happySpecReduce_1 9# happyReduction_12 happyReduction_12 (HappyAbsSyn10 happy_var_1) = HappyAbsSyn9 (Just happy_var_1 ) happyReduction_12 _ = notHappyAtAll happyReduce_13 = happySpecReduce_0 9# happyReduction_13 happyReduction_13 = HappyAbsSyn9 (Nothing ) happyReduce_14 = happyReduce 4# 10# happyReduction_14 happyReduction_14 (_ `HappyStk` _ `HappyStk` (HappyAbsSyn10 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn10 (reverse happy_var_2 ) `HappyStk` happyRest happyReduce_15 = happySpecReduce_3 10# happyReduction_15 happyReduction_15 _ _ _ = HappyAbsSyn10 ([] ) happyReduce_16 = happySpecReduce_1 11# happyReduction_16 happyReduction_16 _ = HappyAbsSyn7 (() ) happyReduce_17 = happySpecReduce_0 11# happyReduction_17 happyReduction_17 = HappyAbsSyn7 (() ) happyReduce_18 = happySpecReduce_3 12# happyReduction_18 happyReduction_18 (HappyAbsSyn13 happy_var_3) _ (HappyAbsSyn10 happy_var_1) = HappyAbsSyn10 (happy_var_3 : happy_var_1 ) happyReduction_18 _ _ _ = notHappyAtAll happyReduce_19 = happySpecReduce_1 12# happyReduction_19 happyReduction_19 (HappyAbsSyn13 happy_var_1) = HappyAbsSyn10 ([happy_var_1] ) happyReduction_19 _ = notHappyAtAll happyReduce_20 = happySpecReduce_1 13# happyReduction_20 happyReduction_20 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn13 (HsEVar happy_var_1 ) happyReduction_20 _ = notHappyAtAll happyReduce_21 = happySpecReduce_1 13# happyReduction_21 happyReduction_21 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn13 (HsEAbs happy_var_1 ) happyReduction_21 _ = notHappyAtAll happyReduce_22 = happyReduce 4# 13# happyReduction_22 happyReduction_22 (_ `HappyStk` _ `HappyStk` _ `HappyStk` (HappyAbsSyn46 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn13 (HsEThingAll happy_var_1 ) `HappyStk` happyRest happyReduce_23 = happySpecReduce_3 13# happyReduction_23 happyReduction_23 _ _ (HappyAbsSyn46 happy_var_1) = HappyAbsSyn13 (HsEThingWith happy_var_1 [] ) happyReduction_23 _ _ _ = notHappyAtAll happyReduce_24 = happyReduce 4# 13# happyReduction_24 happyReduction_24 (_ `HappyStk` (HappyAbsSyn23 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn46 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn13 (HsEThingWith happy_var_1 (reverse happy_var_3) ) `HappyStk` happyRest happyReduce_25 = happySpecReduce_2 13# happyReduction_25 happyReduction_25 (HappyAbsSyn131 happy_var_2) _ = HappyAbsSyn13 (HsEModuleContents happy_var_2 ) happyReduction_25 _ _ = notHappyAtAll happyReduce_26 = happySpecReduce_3 14# happyReduction_26 happyReduction_26 (HappyAbsSyn15 happy_var_3) _ (HappyAbsSyn14 happy_var_1) = HappyAbsSyn14 (happy_var_3 : happy_var_1 ) happyReduction_26 _ _ _ = notHappyAtAll happyReduce_27 = happySpecReduce_1 14# happyReduction_27 happyReduction_27 (HappyAbsSyn15 happy_var_1) = HappyAbsSyn14 ([happy_var_1] ) happyReduction_27 _ = notHappyAtAll happyReduce_28 = happyReduce 6# 15# happyReduction_28 happyReduction_28 ((HappyAbsSyn18 happy_var_6) `HappyStk` (HappyAbsSyn17 happy_var_5) `HappyStk` (HappyAbsSyn131 happy_var_4) `HappyStk` (HappyAbsSyn16 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn15 (HsImportDecl happy_var_1 happy_var_4 happy_var_3 happy_var_5 happy_var_6 ) `HappyStk` happyRest happyReduce_29 = happySpecReduce_1 16# happyReduction_29 happyReduction_29 _ = HappyAbsSyn16 (True ) happyReduce_30 = happySpecReduce_0 16# happyReduction_30 happyReduction_30 = HappyAbsSyn16 (False ) happyReduce_31 = happySpecReduce_2 17# happyReduction_31 happyReduction_31 (HappyAbsSyn131 happy_var_2) _ = HappyAbsSyn17 (Just happy_var_2 ) happyReduction_31 _ _ = notHappyAtAll happyReduce_32 = happySpecReduce_0 17# happyReduction_32 happyReduction_32 = HappyAbsSyn17 (Nothing ) happyReduce_33 = happySpecReduce_1 18# happyReduction_33 happyReduction_33 (HappyAbsSyn19 happy_var_1) = HappyAbsSyn18 (Just happy_var_1 ) happyReduction_33 _ = notHappyAtAll happyReduce_34 = happySpecReduce_0 18# happyReduction_34 happyReduction_34 = HappyAbsSyn18 (Nothing ) happyReduce_35 = happyReduce 5# 19# happyReduction_35 happyReduction_35 (_ `HappyStk` _ `HappyStk` (HappyAbsSyn21 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn16 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn19 ((happy_var_1, reverse happy_var_3) ) `HappyStk` happyRest happyReduce_36 = happyReduce 4# 19# happyReduction_36 happyReduction_36 (_ `HappyStk` _ `HappyStk` _ `HappyStk` (HappyAbsSyn16 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn19 ((happy_var_1, []) ) `HappyStk` happyRest happyReduce_37 = happySpecReduce_1 20# happyReduction_37 happyReduction_37 _ = HappyAbsSyn16 (True ) happyReduce_38 = happySpecReduce_0 20# happyReduction_38 happyReduction_38 = HappyAbsSyn16 (False ) happyReduce_39 = happySpecReduce_3 21# happyReduction_39 happyReduction_39 (HappyAbsSyn22 happy_var_3) _ (HappyAbsSyn21 happy_var_1) = HappyAbsSyn21 (happy_var_3 : happy_var_1 ) happyReduction_39 _ _ _ = notHappyAtAll happyReduce_40 = happySpecReduce_1 21# happyReduction_40 happyReduction_40 (HappyAbsSyn22 happy_var_1) = HappyAbsSyn21 ([happy_var_1] ) happyReduction_40 _ = notHappyAtAll happyReduce_41 = happySpecReduce_1 22# happyReduction_41 happyReduction_41 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn22 (HsIVar happy_var_1 ) happyReduction_41 _ = notHappyAtAll happyReduce_42 = happySpecReduce_1 22# happyReduction_42 happyReduction_42 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn22 (HsIAbs happy_var_1 ) happyReduction_42 _ = notHappyAtAll happyReduce_43 = happyReduce 4# 22# happyReduction_43 happyReduction_43 (_ `HappyStk` _ `HappyStk` _ `HappyStk` (HappyAbsSyn42 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn22 (HsIThingAll happy_var_1 ) `HappyStk` happyRest happyReduce_44 = happySpecReduce_3 22# happyReduction_44 happyReduction_44 _ _ (HappyAbsSyn42 happy_var_1) = HappyAbsSyn22 (HsIThingWith happy_var_1 [] ) happyReduction_44 _ _ _ = notHappyAtAll happyReduce_45 = happyReduce 4# 22# happyReduction_45 happyReduction_45 (_ `HappyStk` (HappyAbsSyn23 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn42 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn22 (HsIThingWith happy_var_1 (reverse happy_var_3) ) `HappyStk` happyRest happyReduce_46 = happySpecReduce_3 23# happyReduction_46 happyReduction_46 (HappyAbsSyn24 happy_var_3) _ (HappyAbsSyn23 happy_var_1) = HappyAbsSyn23 (happy_var_3 : happy_var_1 ) happyReduction_46 _ _ _ = notHappyAtAll happyReduce_47 = happySpecReduce_1 23# happyReduction_47 happyReduction_47 (HappyAbsSyn24 happy_var_1) = HappyAbsSyn23 ([happy_var_1] ) happyReduction_47 _ = notHappyAtAll happyReduce_48 = happySpecReduce_1 24# happyReduction_48 happyReduction_48 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn24 (HsVarName happy_var_1 ) happyReduction_48 _ = notHappyAtAll happyReduce_49 = happySpecReduce_1 24# happyReduction_49 happyReduction_49 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn24 (HsConName happy_var_1 ) happyReduction_49 _ = notHappyAtAll happyReduce_50 = happyReduce 4# 25# happyReduction_50 happyReduction_50 ((HappyAbsSyn28 happy_var_4) `HappyStk` (HappyAbsSyn26 happy_var_3) `HappyStk` (HappyAbsSyn27 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn25 (HsInfixDecl happy_var_1 happy_var_2 happy_var_3 (reverse happy_var_4) ) `HappyStk` happyRest happyReduce_51 = happySpecReduce_0 26# happyReduction_51 happyReduction_51 = HappyAbsSyn26 (9 ) happyReduce_52 = happyMonadReduce 1# 26# happyReduction_52 happyReduction_52 ((HappyTerminal (IntTok happy_var_1)) `HappyStk` happyRest) tk = happyThen (( checkPrec happy_var_1) ) (\r -> happyReturn (HappyAbsSyn26 r)) happyReduce_53 = happySpecReduce_1 27# happyReduction_53 happyReduction_53 _ = HappyAbsSyn27 (HsAssocNone ) happyReduce_54 = happySpecReduce_1 27# happyReduction_54 happyReduction_54 _ = HappyAbsSyn27 (HsAssocLeft ) happyReduce_55 = happySpecReduce_1 27# happyReduction_55 happyReduction_55 _ = HappyAbsSyn27 (HsAssocRight ) happyReduce_56 = happySpecReduce_3 28# happyReduction_56 happyReduction_56 (HappyAbsSyn112 happy_var_3) _ (HappyAbsSyn28 happy_var_1) = HappyAbsSyn28 (happy_var_3 : happy_var_1 ) happyReduction_56 _ _ _ = notHappyAtAll happyReduce_57 = happySpecReduce_1 28# happyReduction_57 happyReduction_57 (HappyAbsSyn112 happy_var_1) = HappyAbsSyn28 ([happy_var_1] ) happyReduction_57 _ = notHappyAtAll happyReduce_58 = happyMonadReduce 2# 29# happyReduction_58 happyReduction_58 (_ `HappyStk` (HappyAbsSyn29 happy_var_1) `HappyStk` happyRest) tk = happyThen (( checkRevDecls happy_var_1) ) (\r -> happyReturn (HappyAbsSyn29 r)) happyReduce_59 = happySpecReduce_3 30# happyReduction_59 happyReduction_59 (HappyAbsSyn25 happy_var_3) _ (HappyAbsSyn29 happy_var_1) = HappyAbsSyn29 (happy_var_3 : happy_var_1 ) happyReduction_59 _ _ _ = notHappyAtAll happyReduce_60 = happySpecReduce_1 30# happyReduction_60 happyReduction_60 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn29 ([happy_var_1] ) happyReduction_60 _ = notHappyAtAll happyReduce_61 = happyReduce 5# 31# happyReduction_61 happyReduction_61 ((HappyAbsSyn43 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn50 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn25 (HsTypeDecl happy_var_1 (fst happy_var_3) (snd happy_var_3) happy_var_5 ) `HappyStk` happyRest happyReduce_62 = happyMonadReduce 6# 31# happyReduction_62 happyReduction_62 ((HappyAbsSyn61 happy_var_6) `HappyStk` (HappyAbsSyn52 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn47 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { (cs,c,t) <- checkDataHeader happy_var_3; return (HsDataDecl happy_var_1 cs c t (reverse happy_var_5) happy_var_6) }) ) (\r -> happyReturn (HappyAbsSyn25 r)) happyReduce_63 = happyMonadReduce 6# 31# happyReduction_63 happyReduction_63 ((HappyAbsSyn61 happy_var_6) `HappyStk` (HappyAbsSyn53 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn47 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { (cs,c,t) <- checkDataHeader happy_var_3; return (HsNewTypeDecl happy_var_1 cs c t happy_var_5 happy_var_6) }) ) (\r -> happyReturn (HappyAbsSyn25 r)) happyReduce_64 = happyMonadReduce 4# 31# happyReduction_64 happyReduction_64 ((HappyAbsSyn29 happy_var_4) `HappyStk` (HappyAbsSyn47 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { (cs,c,vs) <- checkClassHeader happy_var_3; return (HsClassDecl happy_var_1 cs c vs happy_var_4) }) ) (\r -> happyReturn (HappyAbsSyn25 r)) happyReduce_65 = happyMonadReduce 4# 31# happyReduction_65 happyReduction_65 ((HappyAbsSyn29 happy_var_4) `HappyStk` (HappyAbsSyn47 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { (cs,c,ts) <- checkInstHeader happy_var_3; return (HsInstDecl happy_var_1 cs c ts happy_var_4) }) ) (\r -> happyReturn (HappyAbsSyn25 r)) happyReduce_66 = happyReduce 5# 31# happyReduction_66 happyReduction_66 (_ `HappyStk` (HappyAbsSyn32 happy_var_4) `HappyStk` _ `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn25 (HsDefaultDecl happy_var_1 happy_var_4 ) `HappyStk` happyRest happyReduce_67 = happySpecReduce_1 31# happyReduction_67 happyReduction_67 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn25 (happy_var_1 ) happyReduction_67 _ = notHappyAtAll happyReduce_68 = happySpecReduce_1 31# happyReduction_68 happyReduction_68 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn25 (happy_var_1 ) happyReduction_68 _ = notHappyAtAll happyReduce_69 = happySpecReduce_1 32# happyReduction_69 happyReduction_69 (HappyAbsSyn32 happy_var_1) = HappyAbsSyn32 (reverse happy_var_1 ) happyReduction_69 _ = notHappyAtAll happyReduce_70 = happySpecReduce_1 32# happyReduction_70 happyReduction_70 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn32 ([happy_var_1] ) happyReduction_70 _ = notHappyAtAll happyReduce_71 = happySpecReduce_0 32# happyReduction_71 happyReduction_71 = HappyAbsSyn32 ([] ) happyReduce_72 = happyMonadReduce 3# 33# happyReduction_72 happyReduction_72 (_ `HappyStk` (HappyAbsSyn29 happy_var_2) `HappyStk` _ `HappyStk` happyRest) tk = happyThen (( checkRevDecls happy_var_2) ) (\r -> happyReturn (HappyAbsSyn29 r)) happyReduce_73 = happySpecReduce_1 33# happyReduction_73 happyReduction_73 _ = HappyAbsSyn29 ([] ) happyReduce_74 = happySpecReduce_3 34# happyReduction_74 happyReduction_74 (HappyAbsSyn25 happy_var_3) _ (HappyAbsSyn29 happy_var_1) = HappyAbsSyn29 (happy_var_3 : happy_var_1 ) happyReduction_74 _ _ _ = notHappyAtAll happyReduce_75 = happySpecReduce_1 34# happyReduction_75 happyReduction_75 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn29 ([happy_var_1] ) happyReduction_75 _ = notHappyAtAll happyReduce_76 = happySpecReduce_1 35# happyReduction_76 happyReduction_76 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn25 (happy_var_1 ) happyReduction_76 _ = notHappyAtAll happyReduce_77 = happySpecReduce_1 35# happyReduction_77 happyReduction_77 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn25 (happy_var_1 ) happyReduction_77 _ = notHappyAtAll happyReduce_78 = happySpecReduce_1 35# happyReduction_78 happyReduction_78 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn25 (happy_var_1 ) happyReduction_78 _ = notHappyAtAll happyReduce_79 = happySpecReduce_3 36# happyReduction_79 happyReduction_79 _ (HappyAbsSyn29 happy_var_2) _ = HappyAbsSyn29 (happy_var_2 ) happyReduction_79 _ _ _ = notHappyAtAll happyReduce_80 = happySpecReduce_3 36# happyReduction_80 happyReduction_80 _ (HappyAbsSyn29 happy_var_2) _ = HappyAbsSyn29 (happy_var_2 ) happyReduction_80 _ _ _ = notHappyAtAll happyReduce_81 = happyReduce 4# 37# happyReduction_81 happyReduction_81 ((HappyAbsSyn47 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn38 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn25 (HsTypeSig happy_var_1 (reverse happy_var_2) happy_var_4 ) `HappyStk` happyRest happyReduce_82 = happySpecReduce_3 38# happyReduction_82 happyReduction_82 (HappyAbsSyn42 happy_var_3) _ (HappyAbsSyn38 happy_var_1) = HappyAbsSyn38 (happy_var_3 : happy_var_1 ) happyReduction_82 _ _ _ = notHappyAtAll happyReduce_83 = happyMonadReduce 1# 38# happyReduction_83 happyReduction_83 ((HappyAbsSyn46 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { n <- checkUnQual happy_var_1; return [n] }) ) (\r -> happyReturn (HappyAbsSyn38 r)) happyReduce_84 = happyReduce 9# 39# happyReduction_84 happyReduction_84 ((HappyAbsSyn43 happy_var_9) `HappyStk` _ `HappyStk` (HappyAbsSyn42 happy_var_7) `HappyStk` (HappyAbsSyn41 happy_var_6) `HappyStk` (HappyAbsSyn40 happy_var_5) `HappyStk` (HappyTerminal (VarId happy_var_4)) `HappyStk` _ `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn25 (HsForeignImport happy_var_1 happy_var_4 happy_var_5 happy_var_6 happy_var_7 happy_var_9 ) `HappyStk` happyRest happyReduce_85 = happyReduce 8# 39# happyReduction_85 happyReduction_85 ((HappyAbsSyn43 happy_var_8) `HappyStk` _ `HappyStk` (HappyAbsSyn42 happy_var_6) `HappyStk` (HappyAbsSyn41 happy_var_5) `HappyStk` (HappyTerminal (VarId happy_var_4)) `HappyStk` _ `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn25 (HsForeignExport happy_var_1 happy_var_4 happy_var_5 happy_var_6 happy_var_8 ) `HappyStk` happyRest happyReduce_86 = happySpecReduce_1 40# happyReduction_86 happyReduction_86 _ = HappyAbsSyn40 (HsSafe ) happyReduce_87 = happySpecReduce_1 40# happyReduction_87 happyReduction_87 _ = HappyAbsSyn40 (HsUnsafe ) happyReduce_88 = happySpecReduce_0 40# happyReduction_88 happyReduction_88 = HappyAbsSyn40 (HsSafe ) happyReduce_89 = happySpecReduce_1 41# happyReduction_89 happyReduction_89 (HappyTerminal (StringTok happy_var_1)) = HappyAbsSyn41 (happy_var_1 ) happyReduction_89 _ = notHappyAtAll happyReduce_90 = happySpecReduce_0 41# happyReduction_90 happyReduction_90 = HappyAbsSyn41 ("" ) happyReduce_91 = happySpecReduce_1 42# happyReduction_91 happyReduction_91 (HappyTerminal (VarId happy_var_1)) = HappyAbsSyn42 (HsIdent happy_var_1 ) happyReduction_91 _ = notHappyAtAll happyReduce_92 = happySpecReduce_3 42# happyReduction_92 happyReduction_92 _ (HappyAbsSyn42 happy_var_2) _ = HappyAbsSyn42 (happy_var_2 ) happyReduction_92 _ _ _ = notHappyAtAll happyReduce_93 = happySpecReduce_3 43# happyReduction_93 happyReduction_93 (HappyAbsSyn43 happy_var_3) _ (HappyAbsSyn43 happy_var_1) = HappyAbsSyn43 (HsTyFun happy_var_1 happy_var_3 ) happyReduction_93 _ _ _ = notHappyAtAll happyReduce_94 = happySpecReduce_3 43# happyReduction_94 happyReduction_94 (HappyAbsSyn43 happy_var_3) _ (HappyAbsSyn43 happy_var_1) = HappyAbsSyn43 (mkAndType happy_var_1 happy_var_3 ) happyReduction_94 _ _ _ = notHappyAtAll happyReduce_95 = happySpecReduce_1 43# happyReduction_95 happyReduction_95 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn43 (happy_var_1 ) happyReduction_95 _ = notHappyAtAll happyReduce_96 = happySpecReduce_2 44# happyReduction_96 happyReduction_96 (HappyAbsSyn43 happy_var_2) (HappyAbsSyn43 happy_var_1) = HappyAbsSyn43 (HsTyApp happy_var_1 happy_var_2 ) happyReduction_96 _ _ = notHappyAtAll happyReduce_97 = happySpecReduce_1 44# happyReduction_97 happyReduction_97 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn43 (happy_var_1 ) happyReduction_97 _ = notHappyAtAll happyReduce_98 = happySpecReduce_1 45# happyReduction_98 happyReduction_98 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn43 (HsTyCon happy_var_1 ) happyReduction_98 _ = notHappyAtAll happyReduce_99 = happySpecReduce_1 45# happyReduction_99 happyReduction_99 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn43 (HsTyVar happy_var_1 ) happyReduction_99 _ = notHappyAtAll happyReduce_100 = happySpecReduce_3 45# happyReduction_100 happyReduction_100 _ (HappyAbsSyn32 happy_var_2) _ = HappyAbsSyn43 (HsTyTuple (reverse happy_var_2) ) happyReduction_100 _ _ _ = notHappyAtAll happyReduce_101 = happySpecReduce_3 45# happyReduction_101 happyReduction_101 _ (HappyAbsSyn43 happy_var_2) _ = HappyAbsSyn43 (HsTyApp list_tycon happy_var_2 ) happyReduction_101 _ _ _ = notHappyAtAll happyReduce_102 = happySpecReduce_3 45# happyReduction_102 happyReduction_102 _ (HappyAbsSyn43 happy_var_2) _ = HappyAbsSyn43 (happy_var_2 ) happyReduction_102 _ _ _ = notHappyAtAll happyReduce_103 = happySpecReduce_1 46# happyReduction_103 happyReduction_103 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_103 _ = notHappyAtAll happyReduce_104 = happySpecReduce_2 46# happyReduction_104 happyReduction_104 _ _ = HappyAbsSyn46 (unit_tycon_name ) happyReduce_105 = happySpecReduce_3 46# happyReduction_105 happyReduction_105 _ _ _ = HappyAbsSyn46 (fun_tycon_name ) happyReduce_106 = happySpecReduce_2 46# happyReduction_106 happyReduction_106 _ _ = HappyAbsSyn46 (list_tycon_name ) happyReduce_107 = happySpecReduce_3 46# happyReduction_107 happyReduction_107 _ (HappyAbsSyn26 happy_var_2) _ = HappyAbsSyn46 (tuple_tycon_name happy_var_2 ) happyReduction_107 _ _ _ = notHappyAtAll happyReduce_108 = happySpecReduce_3 47# happyReduction_108 happyReduction_108 (HappyAbsSyn43 happy_var_3) _ (HappyAbsSyn48 happy_var_1) = HappyAbsSyn47 (HsQualType happy_var_1 happy_var_3 ) happyReduction_108 _ _ _ = notHappyAtAll happyReduce_109 = happySpecReduce_1 47# happyReduction_109 happyReduction_109 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn47 (HsQualType [] happy_var_1 ) happyReduction_109 _ = notHappyAtAll happyReduce_110 = happyMonadReduce 1# 48# happyReduction_110 happyReduction_110 ((HappyAbsSyn43 happy_var_1) `HappyStk` happyRest) tk = happyThen (( checkContext happy_var_1) ) (\r -> happyReturn (HappyAbsSyn48 r)) happyReduce_111 = happySpecReduce_3 49# happyReduction_111 happyReduction_111 (HappyAbsSyn43 happy_var_3) _ (HappyAbsSyn32 happy_var_1) = HappyAbsSyn32 (happy_var_3 : happy_var_1 ) happyReduction_111 _ _ _ = notHappyAtAll happyReduce_112 = happySpecReduce_3 49# happyReduction_112 happyReduction_112 (HappyAbsSyn43 happy_var_3) _ (HappyAbsSyn43 happy_var_1) = HappyAbsSyn32 ([happy_var_3, happy_var_1] ) happyReduction_112 _ _ _ = notHappyAtAll happyReduce_113 = happySpecReduce_2 50# happyReduction_113 happyReduction_113 (HappyAbsSyn38 happy_var_2) (HappyAbsSyn42 happy_var_1) = HappyAbsSyn50 ((happy_var_1,reverse happy_var_2) ) happyReduction_113 _ _ = notHappyAtAll happyReduce_114 = happySpecReduce_2 51# happyReduction_114 happyReduction_114 (HappyAbsSyn42 happy_var_2) (HappyAbsSyn38 happy_var_1) = HappyAbsSyn38 (happy_var_2 : happy_var_1 ) happyReduction_114 _ _ = notHappyAtAll happyReduce_115 = happySpecReduce_0 51# happyReduction_115 happyReduction_115 = HappyAbsSyn38 ([] ) happyReduce_116 = happySpecReduce_3 52# happyReduction_116 happyReduction_116 (HappyAbsSyn53 happy_var_3) _ (HappyAbsSyn52 happy_var_1) = HappyAbsSyn52 (happy_var_3 : happy_var_1 ) happyReduction_116 _ _ _ = notHappyAtAll happyReduce_117 = happySpecReduce_1 52# happyReduction_117 happyReduction_117 (HappyAbsSyn53 happy_var_1) = HappyAbsSyn52 ([happy_var_1] ) happyReduction_117 _ = notHappyAtAll happyReduce_118 = happySpecReduce_2 53# happyReduction_118 happyReduction_118 (HappyAbsSyn54 happy_var_2) (HappyAbsSyn128 happy_var_1) = HappyAbsSyn53 (HsConDecl happy_var_1 (fst happy_var_2) (snd happy_var_2) ) happyReduction_118 _ _ = notHappyAtAll happyReduce_119 = happyReduce 4# 53# happyReduction_119 happyReduction_119 ((HappyAbsSyn56 happy_var_4) `HappyStk` (HappyAbsSyn42 happy_var_3) `HappyStk` (HappyAbsSyn56 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn53 (HsConDecl happy_var_1 happy_var_3 [happy_var_2,happy_var_4] ) `HappyStk` happyRest happyReduce_120 = happyReduce 4# 53# happyReduction_120 happyReduction_120 (_ `HappyStk` _ `HappyStk` (HappyAbsSyn42 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn53 (HsRecDecl happy_var_1 happy_var_2 [] ) `HappyStk` happyRest happyReduce_121 = happyReduce 5# 53# happyReduction_121 happyReduction_121 (_ `HappyStk` (HappyAbsSyn58 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn42 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn53 (HsRecDecl happy_var_1 happy_var_2 (reverse happy_var_4) ) `HappyStk` happyRest happyReduce_122 = happyMonadReduce 1# 54# happyReduction_122 happyReduction_122 ((HappyAbsSyn43 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { (c,ts) <- splitTyConApp happy_var_1; return (c,map HsUnBangedTy ts) }) ) (\r -> happyReturn (HappyAbsSyn54 r)) happyReduce_123 = happySpecReduce_1 54# happyReduction_123 happyReduction_123 (HappyAbsSyn54 happy_var_1) = HappyAbsSyn54 (happy_var_1 ) happyReduction_123 _ = notHappyAtAll happyReduce_124 = happyMonadReduce 3# 55# happyReduction_124 happyReduction_124 ((HappyAbsSyn43 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn43 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { (c,ts) <- splitTyConApp happy_var_1; return (c,map HsUnBangedTy ts++ [HsBangedTy happy_var_3]) }) ) (\r -> happyReturn (HappyAbsSyn54 r)) happyReduce_125 = happySpecReduce_2 55# happyReduction_125 happyReduction_125 (HappyAbsSyn56 happy_var_2) (HappyAbsSyn54 happy_var_1) = HappyAbsSyn54 ((fst happy_var_1, snd happy_var_1 ++ [happy_var_2] ) ) happyReduction_125 _ _ = notHappyAtAll happyReduce_126 = happySpecReduce_1 56# happyReduction_126 happyReduction_126 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn56 (HsUnBangedTy happy_var_1 ) happyReduction_126 _ = notHappyAtAll happyReduce_127 = happySpecReduce_2 56# happyReduction_127 happyReduction_127 (HappyAbsSyn43 happy_var_2) _ = HappyAbsSyn56 (HsBangedTy happy_var_2 ) happyReduction_127 _ _ = notHappyAtAll happyReduce_128 = happySpecReduce_1 57# happyReduction_128 happyReduction_128 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn56 (HsUnBangedTy happy_var_1 ) happyReduction_128 _ = notHappyAtAll happyReduce_129 = happySpecReduce_2 57# happyReduction_129 happyReduction_129 (HappyAbsSyn43 happy_var_2) _ = HappyAbsSyn56 (HsBangedTy happy_var_2 ) happyReduction_129 _ _ = notHappyAtAll happyReduce_130 = happySpecReduce_3 58# happyReduction_130 happyReduction_130 (HappyAbsSyn59 happy_var_3) _ (HappyAbsSyn58 happy_var_1) = HappyAbsSyn58 (happy_var_3 : happy_var_1 ) happyReduction_130 _ _ _ = notHappyAtAll happyReduce_131 = happySpecReduce_1 58# happyReduction_131 happyReduction_131 (HappyAbsSyn59 happy_var_1) = HappyAbsSyn58 ([happy_var_1] ) happyReduction_131 _ = notHappyAtAll happyReduce_132 = happySpecReduce_3 59# happyReduction_132 happyReduction_132 (HappyAbsSyn56 happy_var_3) _ (HappyAbsSyn38 happy_var_1) = HappyAbsSyn59 ((reverse happy_var_1, happy_var_3) ) happyReduction_132 _ _ _ = notHappyAtAll happyReduce_133 = happySpecReduce_1 60# happyReduction_133 happyReduction_133 (HappyAbsSyn43 happy_var_1) = HappyAbsSyn56 (HsUnBangedTy happy_var_1 ) happyReduction_133 _ = notHappyAtAll happyReduce_134 = happySpecReduce_2 60# happyReduction_134 happyReduction_134 (HappyAbsSyn43 happy_var_2) _ = HappyAbsSyn56 (HsBangedTy happy_var_2 ) happyReduction_134 _ _ = notHappyAtAll happyReduce_135 = happySpecReduce_0 61# happyReduction_135 happyReduction_135 = HappyAbsSyn61 ([] ) happyReduce_136 = happySpecReduce_2 61# happyReduction_136 happyReduction_136 (HappyAbsSyn46 happy_var_2) _ = HappyAbsSyn61 ([happy_var_2] ) happyReduction_136 _ _ = notHappyAtAll happyReduce_137 = happySpecReduce_3 61# happyReduction_137 happyReduction_137 _ _ _ = HappyAbsSyn61 ([] ) happyReduce_138 = happyReduce 4# 61# happyReduction_138 happyReduction_138 (_ `HappyStk` (HappyAbsSyn61 happy_var_3) `HappyStk` _ `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn61 (reverse happy_var_3 ) `HappyStk` happyRest happyReduce_139 = happySpecReduce_3 62# happyReduction_139 happyReduction_139 (HappyAbsSyn46 happy_var_3) _ (HappyAbsSyn61 happy_var_1) = HappyAbsSyn61 (happy_var_3 : happy_var_1 ) happyReduction_139 _ _ _ = notHappyAtAll happyReduce_140 = happySpecReduce_1 62# happyReduction_140 happyReduction_140 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn61 ([happy_var_1] ) happyReduction_140 _ = notHappyAtAll happyReduce_141 = happyMonadReduce 2# 63# happyReduction_141 happyReduction_141 ((HappyAbsSyn29 happy_var_2) `HappyStk` _ `HappyStk` happyRest) tk = happyThen (( checkClassBody happy_var_2) ) (\r -> happyReturn (HappyAbsSyn29 r)) happyReduce_142 = happySpecReduce_0 63# happyReduction_142 happyReduction_142 = HappyAbsSyn29 ([] ) happyReduce_143 = happyMonadReduce 4# 64# happyReduction_143 happyReduction_143 (_ `HappyStk` (HappyAbsSyn29 happy_var_3) `HappyStk` _ `HappyStk` _ `HappyStk` happyRest) tk = happyThen (( checkClassBody happy_var_3) ) (\r -> happyReturn (HappyAbsSyn29 r)) happyReduce_144 = happyMonadReduce 4# 64# happyReduction_144 happyReduction_144 (_ `HappyStk` (HappyAbsSyn29 happy_var_3) `HappyStk` _ `HappyStk` _ `HappyStk` happyRest) tk = happyThen (( checkClassBody happy_var_3) ) (\r -> happyReturn (HappyAbsSyn29 r)) happyReduce_145 = happySpecReduce_0 64# happyReduction_145 happyReduction_145 = HappyAbsSyn29 ([] ) happyReduce_146 = happyMonadReduce 3# 65# happyReduction_146 happyReduction_146 (_ `HappyStk` (HappyAbsSyn29 happy_var_2) `HappyStk` _ `HappyStk` happyRest) tk = happyThen (( checkRevDecls happy_var_2) ) (\r -> happyReturn (HappyAbsSyn29 r)) happyReduce_147 = happySpecReduce_1 65# happyReduction_147 happyReduction_147 _ = HappyAbsSyn29 ([] ) happyReduce_148 = happySpecReduce_3 66# happyReduction_148 happyReduction_148 (HappyAbsSyn25 happy_var_3) _ (HappyAbsSyn29 happy_var_1) = HappyAbsSyn29 (happy_var_3 : happy_var_1 ) happyReduction_148 _ _ _ = notHappyAtAll happyReduce_149 = happySpecReduce_1 66# happyReduction_149 happyReduction_149 (HappyAbsSyn25 happy_var_1) = HappyAbsSyn29 ([happy_var_1] ) happyReduction_149 _ = notHappyAtAll happyReduce_150 = happyMonadReduce 4# 67# happyReduction_150 happyReduction_150 ((HappyAbsSyn29 happy_var_4) `HappyStk` (HappyAbsSyn69 happy_var_3) `HappyStk` (HappyAbsSyn72 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) tk = happyThen (( checkValDef happy_var_1 happy_var_2 happy_var_3 happy_var_4) ) (\r -> happyReturn (HappyAbsSyn25 r)) happyReduce_151 = happySpecReduce_2 68# happyReduction_151 happyReduction_151 (HappyAbsSyn29 happy_var_2) _ = HappyAbsSyn29 (happy_var_2 ) happyReduction_151 _ _ = notHappyAtAll happyReduce_152 = happySpecReduce_0 68# happyReduction_152 happyReduction_152 = HappyAbsSyn29 ([] ) happyReduce_153 = happyMonadReduce 2# 69# happyReduction_153 happyReduction_153 ((HappyAbsSyn72 happy_var_2) `HappyStk` _ `HappyStk` happyRest) tk = happyThen (( do { e <- checkExpr happy_var_2; return (HsUnGuardedRhs e) }) ) (\r -> happyReturn (HappyAbsSyn69 r)) happyReduce_154 = happySpecReduce_1 69# happyReduction_154 happyReduction_154 (HappyAbsSyn70 happy_var_1) = HappyAbsSyn69 (HsGuardedRhss (reverse happy_var_1) ) happyReduction_154 _ = notHappyAtAll happyReduce_155 = happySpecReduce_2 70# happyReduction_155 happyReduction_155 (HappyAbsSyn71 happy_var_2) (HappyAbsSyn70 happy_var_1) = HappyAbsSyn70 (happy_var_2 : happy_var_1 ) happyReduction_155 _ _ = notHappyAtAll happyReduce_156 = happySpecReduce_1 70# happyReduction_156 happyReduction_156 (HappyAbsSyn71 happy_var_1) = HappyAbsSyn70 ([happy_var_1] ) happyReduction_156 _ = notHappyAtAll happyReduce_157 = happyMonadReduce 5# 71# happyReduction_157 happyReduction_157 ((HappyAbsSyn72 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { g <- checkExpr happy_var_3; e <- checkExpr happy_var_5; return (HsGuardedRhs happy_var_1 g e) }) ) (\r -> happyReturn (HappyAbsSyn71 r)) happyReduce_158 = happyReduce 4# 72# happyReduction_158 happyReduction_158 ((HappyAbsSyn47 happy_var_4) `HappyStk` (HappyAbsSyn128 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn72 (HsExpTypeSig happy_var_3 happy_var_1 happy_var_4 ) `HappyStk` happyRest happyReduce_159 = happySpecReduce_1 72# happyReduction_159 happyReduction_159 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_159 _ = notHappyAtAll happyReduce_160 = happySpecReduce_1 73# happyReduction_160 happyReduction_160 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_160 _ = notHappyAtAll happyReduce_161 = happySpecReduce_1 73# happyReduction_161 happyReduction_161 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_161 _ = notHappyAtAll happyReduce_162 = happySpecReduce_3 74# happyReduction_162 happyReduction_162 (HappyAbsSyn72 happy_var_3) (HappyAbsSyn113 happy_var_2) (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsInfixApp happy_var_1 happy_var_2 happy_var_3 ) happyReduction_162 _ _ _ = notHappyAtAll happyReduce_163 = happySpecReduce_1 74# happyReduction_163 happyReduction_163 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_163 _ = notHappyAtAll happyReduce_164 = happySpecReduce_3 75# happyReduction_164 happyReduction_164 (HappyAbsSyn72 happy_var_3) (HappyAbsSyn113 happy_var_2) (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsInfixApp happy_var_1 happy_var_2 happy_var_3 ) happyReduction_164 _ _ _ = notHappyAtAll happyReduce_165 = happySpecReduce_1 75# happyReduction_165 happyReduction_165 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_165 _ = notHappyAtAll happyReduce_166 = happyReduce 5# 76# happyReduction_166 happyReduction_166 ((HappyAbsSyn72 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn79 happy_var_3) `HappyStk` (HappyAbsSyn128 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn72 (HsLambda happy_var_2 (reverse happy_var_3) happy_var_5 ) `HappyStk` happyRest happyReduce_167 = happyReduce 4# 76# happyReduction_167 happyReduction_167 ((HappyAbsSyn72 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn29 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn72 (HsLet happy_var_2 happy_var_4 ) `HappyStk` happyRest happyReduce_168 = happyReduce 6# 76# happyReduction_168 happyReduction_168 ((HappyAbsSyn72 happy_var_6) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn72 (HsIf happy_var_2 happy_var_4 happy_var_6 ) `HappyStk` happyRest happyReduce_169 = happyReduce 4# 77# happyReduction_169 happyReduction_169 ((HappyAbsSyn90 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn72 (HsCase happy_var_2 happy_var_4 ) `HappyStk` happyRest happyReduce_170 = happySpecReduce_2 77# happyReduction_170 happyReduction_170 (HappyAbsSyn72 happy_var_2) _ = HappyAbsSyn72 (HsNegApp happy_var_2 ) happyReduction_170 _ _ = notHappyAtAll happyReduce_171 = happySpecReduce_2 77# happyReduction_171 happyReduction_171 (HappyAbsSyn88 happy_var_2) _ = HappyAbsSyn72 (HsDo happy_var_2 ) happyReduction_171 _ _ = notHappyAtAll happyReduce_172 = happySpecReduce_1 77# happyReduction_172 happyReduction_172 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_172 _ = notHappyAtAll happyReduce_173 = happySpecReduce_2 78# happyReduction_173 happyReduction_173 (HappyAbsSyn72 happy_var_2) (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsApp happy_var_1 happy_var_2 ) happyReduction_173 _ _ = notHappyAtAll happyReduce_174 = happySpecReduce_1 78# happyReduction_174 happyReduction_174 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_174 _ = notHappyAtAll happyReduce_175 = happySpecReduce_2 79# happyReduction_175 happyReduction_175 (HappyAbsSyn80 happy_var_2) (HappyAbsSyn79 happy_var_1) = HappyAbsSyn79 (happy_var_2 : happy_var_1 ) happyReduction_175 _ _ = notHappyAtAll happyReduce_176 = happySpecReduce_1 79# happyReduction_176 happyReduction_176 (HappyAbsSyn80 happy_var_1) = HappyAbsSyn79 ([happy_var_1] ) happyReduction_176 _ = notHappyAtAll happyReduce_177 = happyMonadReduce 1# 80# happyReduction_177 happyReduction_177 ((HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) tk = happyThen (( checkPattern happy_var_1) ) (\r -> happyReturn (HappyAbsSyn80 r)) happyReduce_178 = happyMonadReduce 3# 81# happyReduction_178 happyReduction_178 ((HappyAbsSyn72 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn46 happy_var_1) `HappyStk` happyRest) tk = happyThen (( do { n <- checkUnQual happy_var_1; return (HsAsPat n happy_var_3) }) ) (\r -> happyReturn (HappyAbsSyn72 r)) happyReduce_179 = happySpecReduce_2 81# happyReduction_179 happyReduction_179 (HappyAbsSyn72 happy_var_2) _ = HappyAbsSyn72 (HsIrrPat happy_var_2 ) happyReduction_179 _ _ = notHappyAtAll happyReduce_180 = happySpecReduce_1 81# happyReduction_180 happyReduction_180 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_180 _ = notHappyAtAll happyReduce_181 = happyMonadReduce 3# 82# happyReduction_181 happyReduction_181 (_ `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) tk = happyThen (( mkRecConstrOrUpdate happy_var_1 []) ) (\r -> happyReturn (HappyAbsSyn72 r)) happyReduce_182 = happyMonadReduce 4# 82# happyReduction_182 happyReduction_182 (_ `HappyStk` (HappyAbsSyn100 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) tk = happyThen (( mkRecConstrOrUpdate happy_var_1 (reverse happy_var_3)) ) (\r -> happyReturn (HappyAbsSyn72 r)) happyReduce_183 = happySpecReduce_1 82# happyReduction_183 happyReduction_183 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_183 _ = notHappyAtAll happyReduce_184 = happySpecReduce_1 83# happyReduction_184 happyReduction_184 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn72 (HsVar happy_var_1 ) happyReduction_184 _ = notHappyAtAll happyReduce_185 = happySpecReduce_1 83# happyReduction_185 happyReduction_185 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (happy_var_1 ) happyReduction_185 _ = notHappyAtAll happyReduce_186 = happySpecReduce_1 83# happyReduction_186 happyReduction_186 (HappyAbsSyn127 happy_var_1) = HappyAbsSyn72 (HsLit happy_var_1 ) happyReduction_186 _ = notHappyAtAll happyReduce_187 = happySpecReduce_3 83# happyReduction_187 happyReduction_187 _ (HappyAbsSyn72 happy_var_2) _ = HappyAbsSyn72 (HsParen happy_var_2 ) happyReduction_187 _ _ _ = notHappyAtAll happyReduce_188 = happySpecReduce_3 83# happyReduction_188 happyReduction_188 _ (HappyAbsSyn85 happy_var_2) _ = HappyAbsSyn72 (HsTuple (reverse happy_var_2) ) happyReduction_188 _ _ _ = notHappyAtAll happyReduce_189 = happySpecReduce_3 83# happyReduction_189 happyReduction_189 _ (HappyAbsSyn72 happy_var_2) _ = HappyAbsSyn72 (happy_var_2 ) happyReduction_189 _ _ _ = notHappyAtAll happyReduce_190 = happyReduce 4# 83# happyReduction_190 happyReduction_190 (_ `HappyStk` (HappyAbsSyn113 happy_var_3) `HappyStk` (HappyAbsSyn72 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn72 (HsLeftSection happy_var_2 happy_var_3 ) `HappyStk` happyRest happyReduce_191 = happyReduce 4# 83# happyReduction_191 happyReduction_191 (_ `HappyStk` (HappyAbsSyn72 happy_var_3) `HappyStk` (HappyAbsSyn113 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn72 (HsRightSection happy_var_2 happy_var_3 ) `HappyStk` happyRest happyReduce_192 = happySpecReduce_1 83# happyReduction_192 happyReduction_192 _ = HappyAbsSyn72 (HsWildCard ) happyReduce_193 = happySpecReduce_2 84# happyReduction_193 happyReduction_193 _ (HappyAbsSyn26 happy_var_1) = HappyAbsSyn26 (happy_var_1 + 1 ) happyReduction_193 _ _ = notHappyAtAll happyReduce_194 = happySpecReduce_1 84# happyReduction_194 happyReduction_194 _ = HappyAbsSyn26 (1 ) happyReduce_195 = happySpecReduce_3 85# happyReduction_195 happyReduction_195 (HappyAbsSyn72 happy_var_3) _ (HappyAbsSyn85 happy_var_1) = HappyAbsSyn85 (happy_var_3 : happy_var_1 ) happyReduction_195 _ _ _ = notHappyAtAll happyReduce_196 = happySpecReduce_3 85# happyReduction_196 happyReduction_196 (HappyAbsSyn72 happy_var_3) _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn85 ([happy_var_3,happy_var_1] ) happyReduction_196 _ _ _ = notHappyAtAll happyReduce_197 = happySpecReduce_1 86# happyReduction_197 happyReduction_197 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsList [happy_var_1] ) happyReduction_197 _ = notHappyAtAll happyReduce_198 = happySpecReduce_1 86# happyReduction_198 happyReduction_198 (HappyAbsSyn85 happy_var_1) = HappyAbsSyn72 (HsList (reverse happy_var_1) ) happyReduction_198 _ = notHappyAtAll happyReduce_199 = happySpecReduce_2 86# happyReduction_199 happyReduction_199 _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsEnumFrom happy_var_1 ) happyReduction_199 _ _ = notHappyAtAll happyReduce_200 = happyReduce 4# 86# happyReduction_200 happyReduction_200 (_ `HappyStk` (HappyAbsSyn72 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn72 (HsEnumFromThen happy_var_1 happy_var_3 ) `HappyStk` happyRest happyReduce_201 = happySpecReduce_3 86# happyReduction_201 happyReduction_201 (HappyAbsSyn72 happy_var_3) _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsEnumFromTo happy_var_1 happy_var_3 ) happyReduction_201 _ _ _ = notHappyAtAll happyReduce_202 = happyReduce 5# 86# happyReduction_202 happyReduction_202 ((HappyAbsSyn72 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn72 (HsEnumFromThenTo happy_var_1 happy_var_3 happy_var_5 ) `HappyStk` happyRest happyReduce_203 = happySpecReduce_3 86# happyReduction_203 happyReduction_203 (HappyAbsSyn88 happy_var_3) _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn72 (HsListComp happy_var_1 (reverse happy_var_3) ) happyReduction_203 _ _ _ = notHappyAtAll happyReduce_204 = happySpecReduce_3 87# happyReduction_204 happyReduction_204 (HappyAbsSyn72 happy_var_3) _ (HappyAbsSyn85 happy_var_1) = HappyAbsSyn85 (happy_var_3 : happy_var_1 ) happyReduction_204 _ _ _ = notHappyAtAll happyReduce_205 = happySpecReduce_3 87# happyReduction_205 happyReduction_205 (HappyAbsSyn72 happy_var_3) _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn85 ([happy_var_3,happy_var_1] ) happyReduction_205 _ _ _ = notHappyAtAll happyReduce_206 = happySpecReduce_3 88# happyReduction_206 happyReduction_206 (HappyAbsSyn89 happy_var_3) _ (HappyAbsSyn88 happy_var_1) = HappyAbsSyn88 (happy_var_3 : happy_var_1 ) happyReduction_206 _ _ _ = notHappyAtAll happyReduce_207 = happySpecReduce_1 88# happyReduction_207 happyReduction_207 (HappyAbsSyn89 happy_var_1) = HappyAbsSyn88 ([happy_var_1] ) happyReduction_207 _ = notHappyAtAll happyReduce_208 = happyReduce 4# 89# happyReduction_208 happyReduction_208 ((HappyAbsSyn72 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_2) `HappyStk` (HappyAbsSyn80 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn89 (HsGenerator happy_var_2 happy_var_1 happy_var_4 ) `HappyStk` happyRest happyReduce_209 = happySpecReduce_1 89# happyReduction_209 happyReduction_209 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn89 (HsQualifier happy_var_1 ) happyReduction_209 _ = notHappyAtAll happyReduce_210 = happySpecReduce_2 89# happyReduction_210 happyReduction_210 (HappyAbsSyn29 happy_var_2) _ = HappyAbsSyn89 (HsLetStmt happy_var_2 ) happyReduction_210 _ _ = notHappyAtAll happyReduce_211 = happySpecReduce_3 90# happyReduction_211 happyReduction_211 _ (HappyAbsSyn90 happy_var_2) _ = HappyAbsSyn90 (happy_var_2 ) happyReduction_211 _ _ _ = notHappyAtAll happyReduce_212 = happySpecReduce_3 90# happyReduction_212 happyReduction_212 _ (HappyAbsSyn90 happy_var_2) _ = HappyAbsSyn90 (happy_var_2 ) happyReduction_212 _ _ _ = notHappyAtAll happyReduce_213 = happySpecReduce_3 91# happyReduction_213 happyReduction_213 _ (HappyAbsSyn90 happy_var_2) _ = HappyAbsSyn90 (reverse happy_var_2 ) happyReduction_213 _ _ _ = notHappyAtAll happyReduce_214 = happySpecReduce_3 92# happyReduction_214 happyReduction_214 (HappyAbsSyn93 happy_var_3) _ (HappyAbsSyn90 happy_var_1) = HappyAbsSyn90 (happy_var_3 : happy_var_1 ) happyReduction_214 _ _ _ = notHappyAtAll happyReduce_215 = happySpecReduce_1 92# happyReduction_215 happyReduction_215 (HappyAbsSyn93 happy_var_1) = HappyAbsSyn90 ([happy_var_1] ) happyReduction_215 _ = notHappyAtAll happyReduce_216 = happyReduce 4# 93# happyReduction_216 happyReduction_216 ((HappyAbsSyn29 happy_var_4) `HappyStk` (HappyAbsSyn94 happy_var_3) `HappyStk` (HappyAbsSyn80 happy_var_2) `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn93 (HsAlt happy_var_1 happy_var_2 happy_var_3 happy_var_4 ) `HappyStk` happyRest happyReduce_217 = happySpecReduce_2 94# happyReduction_217 happyReduction_217 (HappyAbsSyn72 happy_var_2) _ = HappyAbsSyn94 (HsUnGuardedAlt happy_var_2 ) happyReduction_217 _ _ = notHappyAtAll happyReduce_218 = happySpecReduce_1 94# happyReduction_218 happyReduction_218 (HappyAbsSyn95 happy_var_1) = HappyAbsSyn94 (HsGuardedAlts (reverse happy_var_1) ) happyReduction_218 _ = notHappyAtAll happyReduce_219 = happySpecReduce_2 95# happyReduction_219 happyReduction_219 (HappyAbsSyn96 happy_var_2) (HappyAbsSyn95 happy_var_1) = HappyAbsSyn95 (happy_var_2 : happy_var_1 ) happyReduction_219 _ _ = notHappyAtAll happyReduce_220 = happySpecReduce_1 95# happyReduction_220 happyReduction_220 (HappyAbsSyn96 happy_var_1) = HappyAbsSyn95 ([happy_var_1] ) happyReduction_220 _ = notHappyAtAll happyReduce_221 = happyReduce 5# 96# happyReduction_221 happyReduction_221 ((HappyAbsSyn72 happy_var_5) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_3) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn96 (HsGuardedAlt happy_var_1 happy_var_3 happy_var_5 ) `HappyStk` happyRest happyReduce_222 = happyMonadReduce 1# 97# happyReduction_222 happyReduction_222 ((HappyAbsSyn72 happy_var_1) `HappyStk` happyRest) tk = happyThen (( checkPattern happy_var_1) ) (\r -> happyReturn (HappyAbsSyn80 r)) happyReduce_223 = happySpecReduce_3 98# happyReduction_223 happyReduction_223 _ (HappyAbsSyn88 happy_var_2) _ = HappyAbsSyn88 (happy_var_2 ) happyReduction_223 _ _ _ = notHappyAtAll happyReduce_224 = happySpecReduce_3 98# happyReduction_224 happyReduction_224 _ (HappyAbsSyn88 happy_var_2) _ = HappyAbsSyn88 (happy_var_2 ) happyReduction_224 _ _ _ = notHappyAtAll happyReduce_225 = happyReduce 4# 99# happyReduction_225 happyReduction_225 ((HappyAbsSyn88 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn29 happy_var_2) `HappyStk` _ `HappyStk` happyRest) = HappyAbsSyn88 (HsLetStmt happy_var_2 : happy_var_4 ) `HappyStk` happyRest happyReduce_226 = happyReduce 6# 99# happyReduction_226 happyReduction_226 ((HappyAbsSyn88 happy_var_6) `HappyStk` _ `HappyStk` (HappyAbsSyn72 happy_var_4) `HappyStk` _ `HappyStk` (HappyAbsSyn128 happy_var_2) `HappyStk` (HappyAbsSyn80 happy_var_1) `HappyStk` happyRest) = HappyAbsSyn88 (HsGenerator happy_var_2 happy_var_1 happy_var_4 : happy_var_6 ) `HappyStk` happyRest happyReduce_227 = happySpecReduce_3 99# happyReduction_227 happyReduction_227 (HappyAbsSyn88 happy_var_3) _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn88 (HsQualifier happy_var_1 : happy_var_3 ) happyReduction_227 _ _ _ = notHappyAtAll happyReduce_228 = happySpecReduce_2 99# happyReduction_228 happyReduction_228 (HappyAbsSyn88 happy_var_2) _ = HappyAbsSyn88 (happy_var_2 ) happyReduction_228 _ _ = notHappyAtAll happyReduce_229 = happySpecReduce_2 99# happyReduction_229 happyReduction_229 _ (HappyAbsSyn72 happy_var_1) = HappyAbsSyn88 ([HsQualifier happy_var_1] ) happyReduction_229 _ _ = notHappyAtAll happyReduce_230 = happySpecReduce_1 99# happyReduction_230 happyReduction_230 (HappyAbsSyn72 happy_var_1) = HappyAbsSyn88 ([HsQualifier happy_var_1] ) happyReduction_230 _ = notHappyAtAll happyReduce_231 = happySpecReduce_3 100# happyReduction_231 happyReduction_231 (HappyAbsSyn101 happy_var_3) _ (HappyAbsSyn100 happy_var_1) = HappyAbsSyn100 (happy_var_3 : happy_var_1 ) happyReduction_231 _ _ _ = notHappyAtAll happyReduce_232 = happySpecReduce_1 100# happyReduction_232 happyReduction_232 (HappyAbsSyn101 happy_var_1) = HappyAbsSyn100 ([happy_var_1] ) happyReduction_232 _ = notHappyAtAll happyReduce_233 = happySpecReduce_3 101# happyReduction_233 happyReduction_233 (HappyAbsSyn72 happy_var_3) _ (HappyAbsSyn46 happy_var_1) = HappyAbsSyn101 (HsFieldUpdate happy_var_1 happy_var_3 ) happyReduction_233 _ _ _ = notHappyAtAll happyReduce_234 = happySpecReduce_2 102# happyReduction_234 happyReduction_234 _ _ = HappyAbsSyn72 (unit_con ) happyReduce_235 = happySpecReduce_2 102# happyReduction_235 happyReduction_235 _ _ = HappyAbsSyn72 (HsList [] ) happyReduce_236 = happySpecReduce_3 102# happyReduction_236 happyReduction_236 _ (HappyAbsSyn26 happy_var_2) _ = HappyAbsSyn72 (tuple_con happy_var_2 ) happyReduction_236 _ _ _ = notHappyAtAll happyReduce_237 = happySpecReduce_1 102# happyReduction_237 happyReduction_237 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn72 (HsCon happy_var_1 ) happyReduction_237 _ = notHappyAtAll happyReduce_238 = happySpecReduce_1 103# happyReduction_238 happyReduction_238 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_238 _ = notHappyAtAll happyReduce_239 = happySpecReduce_3 103# happyReduction_239 happyReduction_239 _ (HappyAbsSyn42 happy_var_2) _ = HappyAbsSyn42 (happy_var_2 ) happyReduction_239 _ _ _ = notHappyAtAll happyReduce_240 = happySpecReduce_1 104# happyReduction_240 happyReduction_240 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_240 _ = notHappyAtAll happyReduce_241 = happySpecReduce_3 104# happyReduction_241 happyReduction_241 _ (HappyAbsSyn46 happy_var_2) _ = HappyAbsSyn46 (happy_var_2 ) happyReduction_241 _ _ _ = notHappyAtAll happyReduce_242 = happySpecReduce_1 105# happyReduction_242 happyReduction_242 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_242 _ = notHappyAtAll happyReduce_243 = happySpecReduce_3 105# happyReduction_243 happyReduction_243 _ (HappyAbsSyn42 happy_var_2) _ = HappyAbsSyn42 (happy_var_2 ) happyReduction_243 _ _ _ = notHappyAtAll happyReduce_244 = happySpecReduce_1 106# happyReduction_244 happyReduction_244 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_244 _ = notHappyAtAll happyReduce_245 = happySpecReduce_3 106# happyReduction_245 happyReduction_245 _ (HappyAbsSyn46 happy_var_2) _ = HappyAbsSyn46 (happy_var_2 ) happyReduction_245 _ _ _ = notHappyAtAll happyReduce_246 = happySpecReduce_1 107# happyReduction_246 happyReduction_246 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_246 _ = notHappyAtAll happyReduce_247 = happySpecReduce_3 107# happyReduction_247 happyReduction_247 _ (HappyAbsSyn42 happy_var_2) _ = HappyAbsSyn42 (happy_var_2 ) happyReduction_247 _ _ _ = notHappyAtAll happyReduce_248 = happySpecReduce_1 108# happyReduction_248 happyReduction_248 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_248 _ = notHappyAtAll happyReduce_249 = happySpecReduce_3 108# happyReduction_249 happyReduction_249 _ (HappyAbsSyn46 happy_var_2) _ = HappyAbsSyn46 (happy_var_2 ) happyReduction_249 _ _ _ = notHappyAtAll happyReduce_250 = happySpecReduce_1 109# happyReduction_250 happyReduction_250 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_250 _ = notHappyAtAll happyReduce_251 = happySpecReduce_3 109# happyReduction_251 happyReduction_251 _ (HappyAbsSyn46 happy_var_2) _ = HappyAbsSyn46 (happy_var_2 ) happyReduction_251 _ _ _ = notHappyAtAll happyReduce_252 = happySpecReduce_1 110# happyReduction_252 happyReduction_252 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_252 _ = notHappyAtAll happyReduce_253 = happySpecReduce_3 110# happyReduction_253 happyReduction_253 _ (HappyAbsSyn42 happy_var_2) _ = HappyAbsSyn42 (happy_var_2 ) happyReduction_253 _ _ _ = notHappyAtAll happyReduce_254 = happySpecReduce_1 111# happyReduction_254 happyReduction_254 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_254 _ = notHappyAtAll happyReduce_255 = happySpecReduce_3 111# happyReduction_255 happyReduction_255 _ (HappyAbsSyn46 happy_var_2) _ = HappyAbsSyn46 (happy_var_2 ) happyReduction_255 _ _ _ = notHappyAtAll happyReduce_256 = happySpecReduce_1 112# happyReduction_256 happyReduction_256 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn112 (HsVarOp happy_var_1 ) happyReduction_256 _ = notHappyAtAll happyReduce_257 = happySpecReduce_1 112# happyReduction_257 happyReduction_257 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn112 (HsConOp happy_var_1 ) happyReduction_257 _ = notHappyAtAll happyReduce_258 = happySpecReduce_1 113# happyReduction_258 happyReduction_258 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn113 (HsQVarOp happy_var_1 ) happyReduction_258 _ = notHappyAtAll happyReduce_259 = happySpecReduce_1 113# happyReduction_259 happyReduction_259 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn113 (HsQConOp happy_var_1 ) happyReduction_259 _ = notHappyAtAll happyReduce_260 = happySpecReduce_1 114# happyReduction_260 happyReduction_260 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn113 (HsQVarOp happy_var_1 ) happyReduction_260 _ = notHappyAtAll happyReduce_261 = happySpecReduce_1 114# happyReduction_261 happyReduction_261 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn113 (HsQConOp happy_var_1 ) happyReduction_261 _ = notHappyAtAll happyReduce_262 = happySpecReduce_1 115# happyReduction_262 happyReduction_262 _ = HappyAbsSyn46 (list_cons_name ) happyReduce_263 = happySpecReduce_1 115# happyReduction_263 happyReduction_263 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_263 _ = notHappyAtAll happyReduce_264 = happySpecReduce_1 116# happyReduction_264 happyReduction_264 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn46 (UnQual happy_var_1 ) happyReduction_264 _ = notHappyAtAll happyReduce_265 = happySpecReduce_1 116# happyReduction_265 happyReduction_265 (HappyTerminal (QVarId happy_var_1)) = HappyAbsSyn46 (Qual (Module (fst happy_var_1)) (HsIdent (snd happy_var_1)) ) happyReduction_265 _ = notHappyAtAll happyReduce_266 = happySpecReduce_1 117# happyReduction_266 happyReduction_266 (HappyTerminal (VarId happy_var_1)) = HappyAbsSyn42 (HsIdent happy_var_1 ) happyReduction_266 _ = notHappyAtAll happyReduce_267 = happySpecReduce_1 117# happyReduction_267 happyReduction_267 _ = HappyAbsSyn42 (HsIdent "as" ) happyReduce_268 = happySpecReduce_1 117# happyReduction_268 happyReduction_268 _ = HappyAbsSyn42 (HsIdent "export" ) happyReduce_269 = happySpecReduce_1 117# happyReduction_269 happyReduction_269 _ = HappyAbsSyn42 (HsIdent "hiding" ) happyReduce_270 = happySpecReduce_1 117# happyReduction_270 happyReduction_270 _ = HappyAbsSyn42 (HsIdent "qualified" ) happyReduce_271 = happySpecReduce_1 117# happyReduction_271 happyReduction_271 _ = HappyAbsSyn42 (HsIdent "safe" ) happyReduce_272 = happySpecReduce_1 117# happyReduction_272 happyReduction_272 _ = HappyAbsSyn42 (HsIdent "unsafe" ) happyReduce_273 = happySpecReduce_1 118# happyReduction_273 happyReduction_273 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn46 (UnQual happy_var_1 ) happyReduction_273 _ = notHappyAtAll happyReduce_274 = happySpecReduce_1 118# happyReduction_274 happyReduction_274 (HappyTerminal (QConId happy_var_1)) = HappyAbsSyn46 (Qual (Module (fst happy_var_1)) (HsIdent (snd happy_var_1)) ) happyReduction_274 _ = notHappyAtAll happyReduce_275 = happySpecReduce_1 119# happyReduction_275 happyReduction_275 (HappyTerminal (ConId happy_var_1)) = HappyAbsSyn42 (HsIdent happy_var_1 ) happyReduction_275 _ = notHappyAtAll happyReduce_276 = happySpecReduce_1 120# happyReduction_276 happyReduction_276 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn46 (UnQual happy_var_1 ) happyReduction_276 _ = notHappyAtAll happyReduce_277 = happySpecReduce_1 120# happyReduction_277 happyReduction_277 (HappyTerminal (QConSym happy_var_1)) = HappyAbsSyn46 (Qual (Module (fst happy_var_1)) (HsSymbol (snd happy_var_1)) ) happyReduction_277 _ = notHappyAtAll happyReduce_278 = happySpecReduce_1 121# happyReduction_278 happyReduction_278 (HappyTerminal (ConSym happy_var_1)) = HappyAbsSyn42 (HsSymbol happy_var_1 ) happyReduction_278 _ = notHappyAtAll happyReduce_279 = happySpecReduce_1 122# happyReduction_279 happyReduction_279 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn46 (UnQual happy_var_1 ) happyReduction_279 _ = notHappyAtAll happyReduce_280 = happySpecReduce_1 122# happyReduction_280 happyReduction_280 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_280 _ = notHappyAtAll happyReduce_281 = happySpecReduce_1 123# happyReduction_281 happyReduction_281 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn46 (UnQual happy_var_1 ) happyReduction_281 _ = notHappyAtAll happyReduce_282 = happySpecReduce_1 123# happyReduction_282 happyReduction_282 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_282 _ = notHappyAtAll happyReduce_283 = happySpecReduce_1 124# happyReduction_283 happyReduction_283 (HappyTerminal (VarSym happy_var_1)) = HappyAbsSyn42 (HsSymbol happy_var_1 ) happyReduction_283 _ = notHappyAtAll happyReduce_284 = happySpecReduce_1 124# happyReduction_284 happyReduction_284 _ = HappyAbsSyn42 (HsSymbol "-" ) happyReduce_285 = happySpecReduce_1 124# happyReduction_285 happyReduction_285 _ = HappyAbsSyn42 (HsSymbol "!" ) happyReduce_286 = happySpecReduce_1 125# happyReduction_286 happyReduction_286 (HappyTerminal (VarSym happy_var_1)) = HappyAbsSyn42 (HsSymbol happy_var_1 ) happyReduction_286 _ = notHappyAtAll happyReduce_287 = happySpecReduce_1 125# happyReduction_287 happyReduction_287 _ = HappyAbsSyn42 (HsSymbol "!" ) happyReduce_288 = happySpecReduce_1 126# happyReduction_288 happyReduction_288 (HappyTerminal (QVarSym happy_var_1)) = HappyAbsSyn46 (Qual (Module (fst happy_var_1)) (HsSymbol (snd happy_var_1)) ) happyReduction_288 _ = notHappyAtAll happyReduce_289 = happySpecReduce_1 127# happyReduction_289 happyReduction_289 (HappyTerminal (IntTok happy_var_1)) = HappyAbsSyn127 (HsInt happy_var_1 ) happyReduction_289 _ = notHappyAtAll happyReduce_290 = happySpecReduce_1 127# happyReduction_290 happyReduction_290 (HappyTerminal (Character happy_var_1)) = HappyAbsSyn127 (HsChar happy_var_1 ) happyReduction_290 _ = notHappyAtAll happyReduce_291 = happySpecReduce_1 127# happyReduction_291 happyReduction_291 (HappyTerminal (FloatTok happy_var_1)) = HappyAbsSyn127 (HsFrac happy_var_1 ) happyReduction_291 _ = notHappyAtAll happyReduce_292 = happySpecReduce_1 127# happyReduction_292 happyReduction_292 (HappyTerminal (StringTok happy_var_1)) = HappyAbsSyn127 (HsString happy_var_1 ) happyReduction_292 _ = notHappyAtAll happyReduce_293 = happyMonadReduce 0# 128# happyReduction_293 happyReduction_293 (happyRest) tk = happyThen (( getSrcLoc) ) (\r -> happyReturn (HappyAbsSyn128 r)) happyReduce_294 = happyMonadReduce 0# 129# happyReduction_294 happyReduction_294 (happyRest) tk = happyThen (( pushCurrentContext) ) (\r -> happyReturn (HappyAbsSyn7 r)) happyReduce_295 = happySpecReduce_1 130# happyReduction_295 happyReduction_295 _ = HappyAbsSyn7 (() ) happyReduce_296 = happyMonadReduce 1# 130# happyReduction_296 happyReduction_296 (_ `HappyStk` happyRest) tk = happyThen (( popContext) ) (\r -> happyReturn (HappyAbsSyn7 r)) happyReduce_297 = happySpecReduce_1 131# happyReduction_297 happyReduction_297 (HappyTerminal (ConId happy_var_1)) = HappyAbsSyn131 (Module happy_var_1 ) happyReduction_297 _ = notHappyAtAll happyReduce_298 = happySpecReduce_1 131# happyReduction_298 happyReduction_298 (HappyTerminal (QConId happy_var_1)) = HappyAbsSyn131 (Module (fst happy_var_1 ++ '.':snd happy_var_1) ) happyReduction_298 _ = notHappyAtAll happyReduce_299 = happySpecReduce_1 132# happyReduction_299 happyReduction_299 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_299 _ = notHappyAtAll happyReduce_300 = happySpecReduce_1 133# happyReduction_300 happyReduction_300 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_300 _ = notHappyAtAll happyReduce_301 = happySpecReduce_1 134# happyReduction_301 happyReduction_301 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_301 _ = notHappyAtAll happyReduce_302 = happySpecReduce_1 135# happyReduction_302 happyReduction_302 (HappyAbsSyn46 happy_var_1) = HappyAbsSyn46 (happy_var_1 ) happyReduction_302 _ = notHappyAtAll happyReduce_303 = happySpecReduce_1 136# happyReduction_303 happyReduction_303 (HappyAbsSyn42 happy_var_1) = HappyAbsSyn42 (happy_var_1 ) happyReduction_303 _ = notHappyAtAll happyNewToken action sts stk = lexer(\tk -> let cont i = action i i tk (HappyState action) sts stk in case tk of { EOF -> action 202# 202# tk (HappyState action) sts stk; VarId happy_dollar_dollar -> cont 137#; QVarId happy_dollar_dollar -> cont 138#; ConId happy_dollar_dollar -> cont 139#; QConId happy_dollar_dollar -> cont 140#; VarSym happy_dollar_dollar -> cont 141#; ConSym happy_dollar_dollar -> cont 142#; QVarSym happy_dollar_dollar -> cont 143#; QConSym happy_dollar_dollar -> cont 144#; IntTok happy_dollar_dollar -> cont 145#; FloatTok happy_dollar_dollar -> cont 146#; Character happy_dollar_dollar -> cont 147#; StringTok happy_dollar_dollar -> cont 148#; LeftParen -> cont 149#; RightParen -> cont 150#; SemiColon -> cont 151#; LeftCurly -> cont 152#; RightCurly -> cont 153#; VRightCurly -> cont 154#; LeftSquare -> cont 155#; RightSquare -> cont 156#; Comma -> cont 157#; Underscore -> cont 158#; BackQuote -> cont 159#; DotDot -> cont 160#; Colon -> cont 161#; DoubleColon -> cont 162#; Equals -> cont 163#; Backslash -> cont 164#; Bar -> cont 165#; LeftArrow -> cont 166#; RightArrow -> cont 167#; And -> cont 168#; At -> cont 169#; Tilde -> cont 170#; DoubleArrow -> cont 171#; Minus -> cont 172#; Exclamation -> cont 173#; KW_Case -> cont 174#; KW_Class -> cont 175#; KW_Data -> cont 176#; KW_Default -> cont 177#; KW_Deriving -> cont 178#; KW_Do -> cont 179#; KW_Else -> cont 180#; KW_Foreign -> cont 181#; KW_If -> cont 182#; KW_Import -> cont 183#; KW_In -> cont 184#; KW_Infix -> cont 185#; KW_InfixL -> cont 186#; KW_InfixR -> cont 187#; KW_Instance -> cont 188#; KW_Let -> cont 189#; KW_Module -> cont 190#; KW_NewType -> cont 191#; KW_Of -> cont 192#; KW_Then -> cont 193#; KW_Type -> cont 194#; KW_Where -> cont 195#; KW_As -> cont 196#; KW_Export -> cont 197#; KW_Hiding -> cont 198#; KW_Qualified -> cont 199#; KW_Safe -> cont 200#; KW_Unsafe -> cont 201#; _ -> happyError' tk }) happyError_ tk = happyError' tk happyThen :: () => P a -> (a -> P b) -> P b happyThen = (>>=) happyReturn :: () => a -> P a happyReturn = (return) happyThen1 = happyThen happyReturn1 :: () => a -> P a happyReturn1 = happyReturn happyError' :: () => (Token) -> P a happyError' tk = (\token -> happyError) tk parse = happySomeParser where happySomeParser = happyThen (happyParse action_0) (\x -> case x of {HappyAbsSyn4 z -> happyReturn z; _other -> notHappyAtAll }) happySeq = happyDontSeq happyError :: P a happyError = fail "Parse error" -- | Parse of a string, which should contain a complete Haskell 98 module. parseModule :: String -> ParseResult HsModule parseModule = runParser parse -- | Parse of a string, which should contain a complete Haskell 98 module. parseModuleWithMode :: ParseMode -> String -> ParseResult HsModule parseModuleWithMode mode = runParserWithMode mode parse {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} {-# LINE 1 "<built-in>" #-} {-# LINE 1 "<command-line>" #-} {-# LINE 1 "templates/GenericTemplate.hs" #-} -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp {-# LINE 28 "templates/GenericTemplate.hs" #-} {-# LINE 49 "templates/GenericTemplate.hs" #-} {-# LINE 59 "templates/GenericTemplate.hs" #-} {-# LINE 68 "templates/GenericTemplate.hs" #-} infixr 9 `HappyStk` data HappyStk a = HappyStk a (HappyStk a) ----------------------------------------------------------------------------- -- starting the parse happyParse start_state = happyNewToken start_state notHappyAtAll notHappyAtAll ----------------------------------------------------------------------------- -- Accepting the parse -- If the current token is 1#, it means we've just accepted a partial -- parse (a %partial parser). We must ignore the saved token on the top of -- the stack in this case. happyAccept 1# tk st sts (_ `HappyStk` ans `HappyStk` _) = happyReturn1 ans happyAccept j tk st sts (HappyStk ans _) = (happyTcHack j ) (happyReturn1 ans) ----------------------------------------------------------------------------- -- Arrays only: do the next action {-# LINE 155 "templates/GenericTemplate.hs" #-} ----------------------------------------------------------------------------- -- HappyState data type (not arrays) newtype HappyState b c = HappyState (Happy_GHC_Exts.Int# -> -- token number Happy_GHC_Exts.Int# -> -- token number (yes, again) b -> -- token semantic value HappyState b c -> -- current state [HappyState b c] -> -- state stack c) ----------------------------------------------------------------------------- -- Shifting a token happyShift new_state 1# tk st sts stk@(x `HappyStk` _) = let i = (case x of { HappyErrorToken (Happy_GHC_Exts.I# (i)) -> i }) in -- trace "shifting the error token" $ new_state i i tk (HappyState (new_state)) ((st):(sts)) (stk) happyShift new_state i tk st sts stk = happyNewToken new_state ((st):(sts)) ((HappyTerminal (tk))`HappyStk`stk) -- happyReduce is specialised for the common cases. happySpecReduce_0 i fn 1# tk st sts stk = happyFail 1# tk st sts stk happySpecReduce_0 nt fn j tk st@((HappyState (action))) sts stk = action nt j tk st ((st):(sts)) (fn `HappyStk` stk) happySpecReduce_1 i fn 1# tk st sts stk = happyFail 1# tk st sts stk happySpecReduce_1 nt fn j tk _ sts@(((st@(HappyState (action))):(_))) (v1`HappyStk`stk') = let r = fn v1 in happySeq r (action nt j tk st sts (r `HappyStk` stk')) happySpecReduce_2 i fn 1# tk st sts stk = happyFail 1# tk st sts stk happySpecReduce_2 nt fn j tk _ ((_):(sts@(((st@(HappyState (action))):(_))))) (v1`HappyStk`v2`HappyStk`stk') = let r = fn v1 v2 in happySeq r (action nt j tk st sts (r `HappyStk` stk')) happySpecReduce_3 i fn 1# tk st sts stk = happyFail 1# tk st sts stk happySpecReduce_3 nt fn j tk _ ((_):(((_):(sts@(((st@(HappyState (action))):(_))))))) (v1`HappyStk`v2`HappyStk`v3`HappyStk`stk') = let r = fn v1 v2 v3 in happySeq r (action nt j tk st sts (r `HappyStk` stk')) happyReduce k i fn 1# tk st sts stk = happyFail 1# tk st sts stk happyReduce k nt fn j tk st sts stk = case happyDrop (k Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) sts of sts1@(((st1@(HappyState (action))):(_))) -> let r = fn stk in -- it doesn't hurt to always seq here... happyDoSeq r (action nt j tk st1 sts1 r) happyMonadReduce k nt fn 1# tk st sts stk = happyFail 1# tk st sts stk happyMonadReduce k nt fn j tk st sts stk = happyThen1 (fn stk tk) (\r -> action nt j tk st1 sts1 (r `HappyStk` drop_stk)) where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts)) drop_stk = happyDropStk k stk happyMonad2Reduce k nt fn 1# tk st sts stk = happyFail 1# tk st sts stk happyMonad2Reduce k nt fn j tk st sts stk = happyThen1 (fn stk tk) (\r -> happyNewToken new_state sts1 (r `HappyStk` drop_stk)) where sts1@(((st1@(HappyState (action))):(_))) = happyDrop k ((st):(sts)) drop_stk = happyDropStk k stk new_state = action happyDrop 0# l = l happyDrop n ((_):(t)) = happyDrop (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#)) t happyDropStk 0# l = l happyDropStk n (x `HappyStk` xs) = happyDropStk (n Happy_GHC_Exts.-# (1#::Happy_GHC_Exts.Int#)) xs ----------------------------------------------------------------------------- -- Moving to a new state after a reduction {-# LINE 253 "templates/GenericTemplate.hs" #-} happyGoto action j tk st = action j j tk (HappyState action) ----------------------------------------------------------------------------- -- Error recovery (1# is the error token) -- parse error if we are in recovery and we fail again happyFail 1# tk old_st _ stk = -- trace "failing" $ happyError_ tk {- We don't need state discarding for our restricted implementation of "error". In fact, it can cause some bogus parses, so I've disabled it for now --SDM -- discard a state happyFail 1# tk old_st (((HappyState (action))):(sts)) (saved_tok `HappyStk` _ `HappyStk` stk) = -- trace ("discarding state, depth " ++ show (length stk)) $ action 1# 1# tk (HappyState (action)) sts ((saved_tok`HappyStk`stk)) -} -- Enter error recovery: generate an error token, -- save the old token and carry on. happyFail i tk (HappyState (action)) sts stk = -- trace "entering error recovery" $ action 1# 1# tk (HappyState (action)) sts ( (HappyErrorToken (Happy_GHC_Exts.I# (i))) `HappyStk` stk) -- Internal happy errors: notHappyAtAll = error "Internal Happy error\n" ----------------------------------------------------------------------------- -- Hack to get the typechecker to accept our action functions happyTcHack :: Happy_GHC_Exts.Int# -> a -> a happyTcHack x y = y {-# INLINE happyTcHack #-} ----------------------------------------------------------------------------- -- Seq-ing. If the --strict flag is given, then Happy emits -- happySeq = happyDoSeq -- otherwise it emits -- happySeq = happyDontSeq happyDoSeq, happyDontSeq :: a -> b -> b happyDoSeq a b = a `seq` b happyDontSeq a b = b ----------------------------------------------------------------------------- -- Don't inline any functions from the template. GHC has a nasty habit -- of deciding to inline happyGoto everywhere, which increases the size of -- the generated parser quite a bit. {-# LINE 317 "templates/GenericTemplate.hs" #-} {-# NOINLINE happyShift #-} {-# NOINLINE happySpecReduce_0 #-} {-# NOINLINE happySpecReduce_1 #-} {-# NOINLINE happySpecReduce_2 #-} {-# NOINLINE happySpecReduce_3 #-} {-# NOINLINE happyReduce #-} {-# NOINLINE happyMonadReduce #-} {-# NOINLINE happyGoto #-} {-# NOINLINE happyFail #-} -- end of Happy Template.
emcardoso/CTi
src/Haskell/Parser/Parser.hs
bsd-3-clause
252,819
7,858
72
34,797
74,501
40,538
33,963
-1
-1
module Graphics.Pastel.XPM.Draw ( drawXPM ) where import Graphics.Pastel import Numeric import Data.Maybe import Data.List import Data.Array hexOut :: Int -> Int -> String hexOut l x = (replicate padLen '0') ++ hex where padLen = l - length hex hex = showHex x "" drawXPM :: (Int, Int) -> Drawing -> String drawXPM (width, height) drawing = unlines $ concat [[magic], [header], palette, image] where magic = "! XPM2" header = unwords $ map show [ width, height, pSize, indexSize ] palette = map paletteLine pLookup where paletteLine (i,c) = hexOut indexSize i ++ " c #" ++ hexOut 6 c image = map imageLine pImage where imageLine xs = concat $ map (hexOut indexSize) xs indexSize = ceiling $ log (succ $ fromIntegral pSize) / (4 * log 2) (pImage, pLookup, pSize) = palettize $ intField (width, height) drawing
willdonnelly/pastel
Graphics/Pastel/XPM/Draw.hs
bsd-3-clause
892
0
12
223
333
181
152
20
1
-- E2.hs {-# OPTIONS_GHC -Wall #-} module Euler.E002 ( e002 ) where e002 :: Integer e002 = sum $ filter even (fibsUnder 4000000 []) where fibsUnder :: Integer -> [Integer] -> [Integer] fibsUnder n [] = fibsUnder n [1] fibsUnder n [x] = fibsUnder n (2:[x]) fibsUnder n (x:xs) | x + (head xs) > n = (x:xs) | otherwise = fibsUnder n ((x + (head xs)):(x:xs))
ghorn/euler
Euler/E002.hs
bsd-3-clause
392
0
14
104
196
104
92
10
3
{-# LANGUAGE QuasiQuotes #-} -- | A somewhat fancier example demonstrating the use of Abstract Predicates and exist-types import LiquidHaskell ------------------------------------------------------------------------- -- | Data types --------------------------------------------------------- ------------------------------------------------------------------------- data Vec a = Nil | Cons a (Vec a) [lq| data Vec [llen] a = Nil | Cons (x::a) (xs::(Vec a)) |] -- | We can encode the notion of length as an inductive measure @llen@ [lq| measure llen :: forall a. Vec a -> Int llen (Nil) = 0 llen (Cons x xs) = 1 + llen(xs) |] [lq| invariant {v:Vec a | (llen v) >= 0} |] -- | As a warmup, lets check that a /real/ length function indeed computes -- the length of the list. [lq| sizeOf :: xs:Vec a -> {v: Int | v = llen xs} |] sizeOf :: Vec a -> Int sizeOf Nil = 0 sizeOf (Cons _ xs) = 1 + sizeOf xs ------------------------------------------------------------------------- -- | Higher-order fold -------------------------------------------------- ------------------------------------------------------------------------- -- | Time to roll up the sleeves. Here's a a higher-order @foldr@ function -- for our `Vec` type. Note that the `op` argument takes an extra /ghost/ -- parameter that will let us properly describe the type of `efoldr` [lq| efoldr :: forall a b <p :: x0:Vec a -> x1:b -> Prop>. (xs:Vec a -> x:a -> b <p xs> -> b <p (Ex.Cons x xs)>) -> b <p Ex.Nil> -> ys: Vec a -> b <p ys> |] efoldr :: (Vec a -> a -> b -> b) -> b -> Vec a -> b efoldr op b Nil = b efoldr op b (Cons x xs) = op xs x (efoldr op b xs) ------------------------------------------------------------------------- -- | Clients of `efold` ------------------------------------------------- ------------------------------------------------------------------------- -- | Finally, lets write a few /client/ functions that use `efoldr` to -- operate on the `Vec`s. -- | First: Computing the length using `efoldr` [lq| size :: xs:Vec a -> {v: Int | v = llen xs} |] size :: Vec a -> Int size = efoldr (\_ _ n -> n + 1) 0 -- | The above uses a helper that counts up the size. (Pesky hack to avoid writing qualifier v = ~A + 1) [lq| suc :: x:Int -> {v: Int | v = x + 1} |] suc :: Int -> Int suc x = x + 1 -- | Second: Appending two lists using `efoldr` [lq| app :: xs: Vec Int -> ys: Vec Int -> {v: Vec Int | llen v = llen xs + llen ys } |] app :: Vec Int -> Vec Int -> Vec Int app xs ys = efoldr (\_ z zs -> Cons z zs) ys xs
spinda/liquidhaskell
tests/gsoc15/unknown/pos/ex1.hs
bsd-3-clause
2,623
0
9
576
348
198
150
23
1
module Chess where import Data.List import Data.String.ToString import Data.Sequence hiding (replicate) data ChessmanType = Pawn | Bishop | Knight | Castle | Queen | King data Placeholder = Free | Line data CellPlaceholder = SpecialPlaceholder { placeholder :: Placeholder, symbol :: String} | Chessman { chessmanType :: ChessmanType, symbol :: String } instance ToString CellPlaceholder where toString = symbol type Board = [[CellPlaceholder]] blackPawn = Chessman Pawn "♟ " whitePawn = Chessman Pawn "♙ " blackKnight = Chessman Knight "♞ " whiteKnight = Chessman Knight "♘ " blackBishop = Chessman Bishop "♝ " whiteBishop = Chessman Bishop "♗ " blackCastle = Chessman Castle "♜ " whiteCastle = Chessman Castle "♖ " blackQueen = Chessman Queen "♛ " whiteQueen = Chessman Queen "♕ " blackKing = Chessman King "♚ " whiteKing = Chessman King "♔ " emptyCell = SpecialPlaceholder Free " " linePlaceholder = SpecialPlaceholder Line "--" lineString = replicate 8 $ linePlaceholder butyLines = replicate 7 lineString initialBoard = [[blackCastle, blackKnight, blackBishop, blackQueen, blackKing, blackBishop, blackKnight, blackCastle], replicate 8 blackPawn, replicate 8 emptyCell, replicate 8 emptyCell, replicate 8 whitePawn, [whiteCastle, whiteKnight, whiteBishop, whiteQueen, whiteKing, whiteBishop, whiteKnight, whiteCastle]] printBoard :: Board -> IO () printBoard xxs = mapM_ printLine butyBoard where printLine xs = putStrLn ("|" ++ (intercalate "|" (map toString xs)) ++ "|") zipLists board placeholder = helper board placeholder [] where helper (x:xs) (y:ys) accum = helper xs ys (accum ++ [y] ++ [x]) helper [] (y:[]) accum = accum ++ [y] butyBoard = zipLists xxs butyLines
apischan/hs-chess
src/Chess.hs
bsd-3-clause
2,036
0
14
582
552
303
249
48
2
{-# LANGUAGE TemplateHaskell #-} -- | Code snippets used by the Python backends. module Futhark.CodeGen.RTS.Python ( memoryPy, openclPy, panicPy, scalarPy, serverPy, tuningPy, valuesPy, ) where import Data.FileEmbed import qualified Data.Text as T -- | @rts/python/memory.py@ memoryPy :: T.Text memoryPy = $(embedStringFile "rts/python/memory.py") -- | @rts/python/opencl.py@ openclPy :: T.Text openclPy = $(embedStringFile "rts/python/opencl.py") -- | @rts/python/panic.py@ panicPy :: T.Text panicPy = $(embedStringFile "rts/python/panic.py") -- | @rts/python/scalar.py@ scalarPy :: T.Text scalarPy = $(embedStringFile "rts/python/scalar.py") -- | @rts/python/server.py@ serverPy :: T.Text serverPy = $(embedStringFile "rts/python/server.py") -- | @rts/python/tuning.py@ tuningPy :: T.Text tuningPy = $(embedStringFile "rts/python/tuning.py") -- | @rts/python/values.py@ valuesPy :: T.Text valuesPy = $(embedStringFile "rts/python/values.py")
diku-dk/futhark
src/Futhark/CodeGen/RTS/Python.hs
isc
981
0
7
139
187
110
77
25
1
{-# LANGUAGE DerivingVia #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TupleSections #-} module Database.Persist.Compatible.TH ( makeCompatibleInstances , makeCompatibleKeyInstances ) where import Data.Aeson import Database.Persist.Class import Database.Persist.Sql.Class import Language.Haskell.TH import Database.Persist.Compatible.Types -- | Gives a bunch of useful instance declarations for a backend based on its -- compatibility with another backend, using 'Compatible'. -- -- The argument should be a type of the form @ forall v1 ... vn. Compatible b s @ -- (Quantification is optional, but supported because TH won't let you have -- unbound type variables in a type splice). The instance is produced for @s@ -- based on the instance defined for @b@, which is constrained in the instance -- head to exist. -- -- @v1 ... vn@ are implicitly quantified in the instance, which is derived via -- @'Compatible' b s@. -- -- @since 2.12 makeCompatibleInstances :: Q Type -> Q [Dec] makeCompatibleInstances compatibleType = do (b, s) <- compatibleType >>= \case ForallT _ _ (AppT (AppT (ConT conTName) b) s) -> if conTName == ''Compatible then pure (b, s) else fail $ "Cannot make `deriving via` instances if the argument is " <> "not of the form `forall v1 ... vn. Compatible sub sup`" AppT (AppT (ConT conTName) b) s -> if conTName == ''Compatible then pure (b, s) else fail $ "Cannot make `deriving via` instances if the argument is " <> "not of the form `Compatible sub sup`" _ -> fail $ "Cannot make `deriving via` instances if the argument is " <> "not of the form `Compatible sub sup`" [d| deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b)) => HasPersistBackend $(return s) deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b), PersistStoreRead $(return b)) => PersistStoreRead $(return s) deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b), PersistQueryRead $(return b)) => PersistQueryRead $(return s) deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b), PersistUniqueRead $(return b)) => PersistUniqueRead $(return s) deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b), PersistStoreWrite $(return b)) => PersistStoreWrite $(return s) deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b), PersistQueryWrite $(return b)) => PersistQueryWrite $(return s) deriving via (Compatible $(return b) $(return s)) instance (HasPersistBackend $(return b), PersistUniqueWrite $(return b)) => PersistUniqueWrite $(return s) |] -- | Gives a bunch of useful instance declarations for a backend key based on -- its compatibility with another backend & key, using 'Compatible'. -- -- The argument should be a type of the form @ forall v1 ... vn. Compatible b s @ -- (Quantification is optional, but supported because TH won't let you have -- unbound type variables in a type splice). The instance is produced for -- @'BackendKey' s@ based on the instance defined for @'BackendKey' b@, which -- is constrained in the instance head to exist. -- -- @v1 ... vn@ are implicitly quantified in the instance, which is derived via -- @'BackendKey' ('Compatible' b s)@. -- -- @since 2.12 makeCompatibleKeyInstances :: Q Type -> Q [Dec] makeCompatibleKeyInstances compatibleType = do (b, s) <- compatibleType >>= \case ForallT _ _ (AppT (AppT (ConT conTName) b) s) -> if conTName == ''Compatible then pure (b, s) else fail $ "Cannot make `deriving via` instances if the argument is " <> "not of the form `forall v1 ... vn. Compatible sub sup`" AppT (AppT (ConT conTName) b) s -> if conTName == ''Compatible then pure (b, s) else fail $ "Cannot make `deriving via` instances if the argument is " <> "not of the form `Compatible sub sup`" _ -> fail $ "Cannot make `deriving via` instances if the argument is " <> "not of the form `Compatible sub sup`" [d| deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Show (BackendKey $(return b))) => Show (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Read (BackendKey $(return b))) => Read (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Eq (BackendKey $(return b))) => Eq (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Ord (BackendKey $(return b))) => Ord (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Num (BackendKey $(return b))) => Num (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Integral (BackendKey $(return b))) => Integral (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), PersistField (BackendKey $(return b))) => PersistField (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), PersistFieldSql (BackendKey $(return b))) => PersistFieldSql (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Real (BackendKey $(return b))) => Real (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Enum (BackendKey $(return b))) => Enum (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), Bounded (BackendKey $(return b))) => Bounded (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), ToJSON (BackendKey $(return b))) => ToJSON (BackendKey $(return s)) deriving via (BackendKey (Compatible $(return b) $(return s))) instance (PersistCore $(return b), PersistCore $(return s), FromJSON (BackendKey $(return b))) => FromJSON (BackendKey $(return s)) |]
yesodweb/persistent
persistent/Database/Persist/Compatible/TH.hs
mit
7,439
0
18
1,856
454
259
195
-1
-1
-- Copyright (C) 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/>. module BDCS.DepsolveSpec(spec) where import Control.Monad.Except(runExceptT) import qualified Data.Map as Map import qualified Data.Set as Set import Test.Hspec import BDCS.Depsolve {-# ANN module ("HLint: ignore Reduce duplication" :: String) #-} spec :: Spec spec = do describe "BDCS.Depsolve.formulaToCNF tests" $ do it "atom" $ formulaToCNF (Atom '1') `shouldBe` [[CNFAtom (CNFOriginal '1')]] it "not" $ formulaToCNF (Not '1') `shouldBe` [[CNFNot (CNFOriginal '1')]] it "and" $ formulaToCNF (And [Atom '1', Atom '2', Atom '3', Atom '4']) `shouldBe` [[CNFAtom (CNFOriginal '1')], [CNFAtom (CNFOriginal '2')], [CNFAtom (CNFOriginal '3')], [CNFAtom (CNFOriginal '4')]] it "Or 0 items" $ formulaToCNF (Or [] :: Formula ()) `shouldBe` ([[]] :: CNFFormula ()) it "Or 1 item" $ formulaToCNF (Or [Atom '1']) `shouldBe` [[CNFAtom (CNFOriginal '1')]] -- See the comment in formulaToCNF for more detail. In short, for 1 OR 2 OR 3: -- start with (1) OR (2 OR 3) ==> (sub 0 -> 1) AND (NOT(sub 0) -> (2 OR 3)) -- the left half becomes (NOT(sub0) OR 1), which is the first part of the result -- the right half becomes (sub0 OR (2 OR 3)) -- recurse on (2 OR 3), adding sub0 to the front of each result it "Or 2 items" $ formulaToCNF (Or [Atom '1', Atom '2']) `shouldBe` [[CNFNot (CNFSubstitute 0), CNFAtom (CNFOriginal '1')], [CNFAtom (CNFSubstitute 0), CNFAtom (CNFOriginal '2')]] it "Or 3 items" $ formulaToCNF (Or [Atom '1', Atom '2', Atom '3']) `shouldBe` [[CNFNot (CNFSubstitute 0), CNFAtom (CNFOriginal '1')], [CNFAtom (CNFSubstitute 0), CNFNot (CNFSubstitute 1), CNFAtom (CNFOriginal '2')], [CNFAtom (CNFSubstitute 0), CNFAtom (CNFSubstitute 1), CNFAtom (CNFOriginal '3')]] describe "BDCS.Depsolve.pureLiteralEliminate tests" $ do it "pureLiteralEliminate, empty list" $ pureLiteralEliminate Set.empty Map.empty ([] :: CNFFormula Char) `shouldBe` Map.empty it "already assigned, matches" $ do let assignments = Map.singleton (CNFOriginal '1') True let formula = [[CNFAtom (CNFOriginal '1')]] let solution = assignments pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "already assigned, does not match" $ do let assignments = Map.singleton (CNFOriginal '1') True let formula = [[CNFNot (CNFOriginal '1')]] let solution = Map.empty pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "pureLiteralEliminate, pure, appears once" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')]] let solution = Map.singleton (CNFOriginal '1') True pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "pure, appears once negative" $ do let assignments = Map.empty let formula = [[CNFNot (CNFOriginal '1')]] let solution = Map.singleton (CNFOriginal '1') False pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "pure, appears multiple times" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFAtom (CNFOriginal '1'), CNFAtom (CNFOriginal '2')], [CNFNot (CNFOriginal '2')]] let solution = Map.singleton (CNFOriginal '1') True pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "pure, appears multiple times negative" $ do let assignments = Map.empty let formula = [[CNFNot (CNFOriginal '1')], [CNFNot (CNFOriginal '1'), CNFAtom (CNFOriginal '2')], [CNFNot (CNFOriginal '2')]] let solution = Map.singleton (CNFOriginal '1') False pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "unpure" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFNot (CNFOriginal '1')]] let solution = Map.empty pureLiteralEliminate Set.empty assignments formula `shouldBe` solution it "unpure 2" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1'), CNFNot (CNFOriginal '1')], [CNFNot (CNFOriginal '1')]] let solution = Map.empty pureLiteralEliminate Set.empty assignments formula `shouldBe` solution describe "BDCS.Depsolve.unitPropagate tests" $ do it "empty list" $ runExceptT (unitPropagate Map.empty ([] :: CNFFormula Char)) >>= (`shouldBe` Right (Map.empty, [])) it "one thing" $ runExceptT (unitPropagate Map.empty [[CNFAtom (CNFOriginal '1')]]) >>= (`shouldBe` Right (Map.singleton (CNFOriginal '1') True, [])) it "unit then elimate clause" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFAtom (CNFOriginal '1'), CNFNot (CNFOriginal '2')]] let assignments' = Map.singleton (CNFOriginal '1') True let formula' = [] runExceptT (unitPropagate assignments formula) >>= (`shouldBe` Right (assignments', formula')) it "unit then elimate impossible" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFAtom (CNFOriginal '2'), CNFNot (CNFOriginal '1')]] let assignments' = Map.singleton (CNFOriginal '1') True let formula' = [[CNFAtom (CNFOriginal '2')]] runExceptT (unitPropagate assignments formula) >>= (`shouldBe` Right (assignments', formula')) it "unit then repeated" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFAtom (CNFOriginal '1')]] let assignments' = Map.singleton (CNFOriginal '1') True let formula' = [] runExceptT (unitPropagate assignments formula) >>= (`shouldBe` Right (assignments', formula')) it "unit then unsolvable unit" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFNot (CNFOriginal '1')]] runExceptT (unitPropagate assignments formula) >>= (`shouldBe` Left "Unable to solve expression") it "units then unsolvable clause" $ do let assignments = Map.empty let formula = [[CNFAtom (CNFOriginal '1')], [CNFAtom (CNFOriginal '2')], [CNFNot (CNFOriginal '1'), CNFNot (CNFOriginal '2')]] runExceptT (unitPropagate assignments formula) >>= (`shouldBe` Left "Unable to solve expression") describe "BDCS.Depsolve.solveCNF tests" $ do it "empty formula" $ do let formula = [] :: (CNFFormula Char) let solution = [] :: [DepAssignment Char] runExceptT (solveCNF formula) >>= (`shouldBe` Right solution) it "singleton" $ do let formula = [[CNFAtom (CNFOriginal '1')]] let solution = [('1', True)] runExceptT (solveCNF formula) >>= (`shouldBe` Right solution)
atodorov/bdcs
src/tests/BDCS/DepsolveSpec.hs
lgpl-2.1
9,452
42
41
3,584
2,212
1,159
1,053
140
1
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE CPP #-} module Web.Twitter.Conduit.Cursor ( CursorKey (..) , IdsCursorKey , UsersCursorKey , ListsCursorKey , WithCursor (..) ) where import Control.Applicative import Data.Aeson import Data.Monoid import Data.Text (Text) import Web.Twitter.Types (checkError) -- $setup -- >>> type UserId = Integer class CursorKey a where cursorKey :: a -> Text -- | Phantom type to specify the key which point out the content in the response. data IdsCursorKey instance CursorKey IdsCursorKey where cursorKey = const "ids" -- | Phantom type to specify the key which point out the content in the response. data UsersCursorKey instance CursorKey UsersCursorKey where cursorKey = const "users" -- | Phantom type to specify the key which point out the content in the response. data ListsCursorKey instance CursorKey ListsCursorKey where cursorKey = const "lists" #if __GLASGOW_HASKELL__ >= 706 -- | A wrapper for API responses which have "next_cursor" field. -- -- The first type parameter of 'WithCursor' specifies the field name of contents. -- -- >>> let Just res = decode "{\"previous_cursor\": 0, \"next_cursor\": 1234567890, \"ids\": [1111111111]}" :: Maybe (WithCursor IdsCursorKey UserId) -- >>> nextCursor res -- 1234567890 -- >>> contents res -- [1111111111] -- -- >>> let Just res = decode "{\"previous_cursor\": 0, \"next_cursor\": 0, \"users\": [1000]}" :: Maybe (WithCursor UsersCursorKey UserId) -- >>> nextCursor res -- 0 -- >>> contents res -- [1000] #endif data WithCursor cursorKey wrapped = WithCursor { previousCursor :: Integer , nextCursor :: Integer , contents :: [wrapped] } deriving Show instance (FromJSON wrapped, CursorKey c) => FromJSON (WithCursor c wrapped) where parseJSON (Object o) = checkError o >> WithCursor <$> o .: "previous_cursor" <*> o .: "next_cursor" <*> o .: cursorKey (undefined :: c) parseJSON _ = mempty
johan--/twitter-conduit
Web/Twitter/Conduit/Cursor.hs
bsd-2-clause
2,094
0
13
433
298
180
118
-1
-1
----------------------------------------------------------------------------- -- | -- Module : Language.Python.Common.PrettyToken -- Copyright : (c) 2009 Bernie Pope -- License : BSD-style -- Maintainer : [email protected] -- Stability : experimental -- Portability : ghc -- -- Pretty printing of tokens. Note the output is intended for displaying in -- messages to the user, and may not be valid Python syntax. For instance -- the pretty printing is useful for displaying parser error messages, but -- not useful for producing concrete Python source. ----------------------------------------------------------------------------- module Language.Python.Common.PrettyToken where import Language.Python.Common.Token import Language.Python.Common.Pretty instance Pretty Token where pretty tok = case tok of IndentToken {} -> text "indentation" DedentToken {} -> text "dedentation" NewlineToken {} -> text "end of line" LineJoinToken {} -> text "line join" CommentToken { token_literal = str } -> text "comment:" <+> prettyPrefix 10 str IdentifierToken { token_literal = str } -> text "identifier:" <+> text str StringToken { token_literal = str } -> text "string:" <+> prettyPrefix 10 str ByteStringToken { token_literal = str } -> text "byte string:" <+> prettyPrefix 10 str UnicodeStringToken { token_literal = str } -> text "unicode string:" <+> prettyPrefix 10 str IntegerToken { token_literal = str } -> text "integer:" <+> text str LongIntegerToken { token_literal = str } -> text "long integer:" <+> text str FloatToken { token_literal = str } -> text "floating point number:" <+> text str ImaginaryToken { token_literal = str } -> text "imaginary number:" <+> text str DefToken {} -> text "def" WhileToken {} -> text "while" IfToken {} -> text "if" TrueToken {} -> text "True" FalseToken {} -> text "False" ReturnToken {} -> text "return" TryToken {} -> text "try" ExceptToken {} -> text "except" RaiseToken {} -> text "raise" InToken {} -> text "in" IsToken {} -> text "is" LambdaToken {} -> text "lambda" ClassToken {} -> text "class" FinallyToken {} -> text "finally" NoneToken {} -> text "None" ForToken {} -> text "for" FromToken {} -> text "from" GlobalToken {} -> text "global" WithToken {} -> text "with" AsToken {} -> text "as" ElifToken {} -> text "elif" YieldToken {} -> text "yield" AssertToken {} -> text "assert" ImportToken {} -> text "import" PassToken {} -> text "pass" BreakToken {} -> text "break" ContinueToken {} -> text "continue" DeleteToken {} -> text "delete" ElseToken {} -> text "else" NotToken {} -> text "not" AndToken {} -> text "and" OrToken {} -> text "or" NonLocalToken {} -> text "nonlocal" PrintToken {} -> text "print" ExecToken {} -> text "exec" AtToken {} -> text "at" LeftRoundBracketToken {} -> text "(" RightRoundBracketToken {} -> text ")" LeftSquareBracketToken {} -> text "[" RightSquareBracketToken {} -> text "]" LeftBraceToken {} -> text "{" RightBraceToken {} -> text "}" DotToken {} -> text "." CommaToken {} -> text "," SemiColonToken {} -> text ";" ColonToken {} -> text ":" EllipsisToken {} -> text "..." RightArrowToken {} -> text "->" AssignToken {} -> text "=" PlusAssignToken {} -> text "+=" MinusAssignToken {} -> text "-=" MultAssignToken {} -> text "*=" DivAssignToken {} -> text "/=" ModAssignToken {} -> text "%=" PowAssignToken {} -> text "**=" BinAndAssignToken {} -> text "&=" BinOrAssignToken {} -> text "|=" BinXorAssignToken {} -> text "^=" LeftShiftAssignToken {} -> text "<<=" RightShiftAssignToken {} -> text ">>=" FloorDivAssignToken {} -> text "//=" BackQuoteToken {} -> text "` (back quote)" PlusToken {} -> text "+" MinusToken {} -> text "-" MultToken {} -> text "*" DivToken {} -> text "/" GreaterThanToken {} -> text ">" LessThanToken {} -> text "<" EqualityToken {} -> text "==" GreaterThanEqualsToken {} -> text ">=" LessThanEqualsToken {} -> text "<=" ExponentToken {} -> text "**" BinaryOrToken {} -> text "|" XorToken {} -> text "^" BinaryAndToken {} -> text "&" ShiftLeftToken {} -> text "<<" ShiftRightToken {} -> text ">>" ModuloToken {} -> text "%" FloorDivToken {} -> text "//" TildeToken {} -> text "~" NotEqualsToken {} -> text "!=" NotEqualsV2Token {} -> text "<>" EOFToken {} -> text "end of input"
jml/language-python
src/Language/Python/Common/PrettyToken.hs
bsd-3-clause
5,158
0
11
1,612
1,420
674
746
111
0
{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Distribution.Server.Util.Histogram where import Data.Map (Map) import qualified Data.Map as Map import Data.List (delete, sortBy) import Data.Ord (comparing) import Control.DeepSeq -- | Histograms are intended to keep track of an integer attribute related -- to a collection of objects. data Histogram a = Histogram { histogram :: Map a Int, reverseHistogram :: Map Count [a] } emptyHistogram :: Histogram a emptyHistogram = Histogram Map.empty Map.empty newtype Count = Count Int deriving (Eq, Show, NFData) instance Ord Count where compare (Count a) (Count b) = compare b a instance NFData a => NFData (Histogram a) where rnf (Histogram a b) = rnf a `seq` rnf b topCounts :: Ord a => Histogram a -> [(a, Int)] topCounts = concatMap (\(Count c, es) -> map (flip (,) c) es) . Map.toList . reverseHistogram topEntries :: Ord a => Histogram a -> [a] topEntries = concat . Map.elems . reverseHistogram getCount :: Ord a => Histogram a -> a -> Int getCount (Histogram hist _) entry = Map.findWithDefault 0 entry hist updateHistogram :: Ord a => a -> Int -> Histogram a -> Histogram a updateHistogram entry new (Histogram hist rev) = let old = Map.findWithDefault 0 entry hist in Histogram (Map.insert entry new hist) (Map.alter putInEntry (Count new) . Map.alter takeOutEntry (Count old) $ rev) where takeOutEntry Nothing = Nothing takeOutEntry (Just l) = case delete entry l of [] -> Nothing l' -> Just l' putInEntry Nothing = Just [entry] putInEntry (Just l) = Just (entry:l) constructHistogram :: Ord a => [(a, Int)] -> Histogram a constructHistogram assoc = Histogram (Map.fromList assoc) (Map.fromListWith (++) . map toSingle $ assoc) where toSingle (entry, c) = (Count c, [entry]) sortByCounts :: Ord a => (b -> a) -> Histogram a -> [b] -> [(b, Int)] sortByCounts entryFunc (Histogram hist _) items = let modEntry item = (item, Map.findWithDefault 0 (entryFunc item) hist) in sortBy (comparing snd) $ map modEntry items
isomorphism/hackage2
Distribution/Server/Util/Histogram.hs
bsd-3-clause
2,077
0
13
425
816
422
394
44
4
{-# LANGUAGE TypeFamilies #-} {-# OPTIONS -Wall #-} data Duo a = Duo a a deriving(Eq,Ord,Read,Show) data Trio a = Trio a a a deriving(Eq,Ord,Read,Show) data Index2 = Index2 Int deriving(Eq,Ord,Read,Show) data Index3 = Index3 Int deriving(Eq,Ord,Read,Show) data Axis v = Axis Int deriving(Eq,Ord,Read,Show) class Vector v where getComponent :: Axis v -> v a -> a compose :: (Axis v -> a) -> v a instance Vector Duo where getComponent (Axis i) (Duo a b) | i == 0 = a | i == 1 = b | True = error "index out of bound" compose f = Duo (f (Axis 0)) (f (Axis 1)) instance Vector Trio where getComponent (Axis i) (Trio a b c) | i == 0 = a | i == 1 = b | i == 2 = c | True = error "index out of bound" compose f = Trio (f (Axis 0)) (f (Axis 1)) (f (Axis 2)) ni :: Duo Int ni = Duo 4 2 san :: Trio Int san = Trio 3 9 8 san' = compose (\i -> getComponent i san) kyu = compose (\i -> compose (\j -> getComponent i san * getComponent j san)) roku = compose (\i -> compose (\j -> concat $ replicate (getComponent i ni) $ show $ getComponent j san)) main :: IO () main = do putStrLn "hawawa" print ni print san print san' print kyu print roku
nushio3/Paraiso
attic/Traversable/FootTestFamilyless.hs
bsd-3-clause
1,205
0
16
314
645
318
327
39
1
-- -- Data vault for metrics -- -- Copyright © 2013-2014 Anchor Systems, Pty Ltd and Others -- -- The code in this file, and the program it is a part of, is -- made available to you by its authors as open source software: -- you can redistribute it and/or modify it under the terms of -- the 3-clause BSD licence. -- {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} module Main where import Control.Concurrent.Async import Control.Concurrent.MVar import Control.Monad import qualified Data.ByteString.Char8 as S import Data.Maybe (fromJust) import Data.String import Data.Word (Word64) import Options.Applicative hiding (Parser, option) import qualified Options.Applicative as O import System.Directory import System.Log.Logger import Text.Trifecta import CommandRunners import DaemonRunners (forkThread) import Marquise.Client import Package (package, version) import Vaultaire.Program data Options = Options { pool :: String , user :: String , broker :: String , debug :: Bool , quiet :: Bool , component :: Component } data Component = None | RegisterOrigin { origin :: Origin , buckets :: Word64 , step :: Word64 , start :: TimeStamp , end :: TimeStamp } | Read { origin :: Origin , address :: Address , start :: TimeStamp , end :: TimeStamp } | List { origin :: Origin } | DumpDays { origin :: Origin } -- | Command line option parsing helpfulParser :: Options -> O.ParserInfo Options helpfulParser os = info (helper <*> optionsParser os) fullDesc optionsParser :: Options -> O.Parser Options optionsParser Options{..} = Options <$> parsePool <*> parseUser <*> parseBroker <*> parseDebug <*> parseQuiet <*> parseComponents where parsePool = strOption $ long "pool" <> short 'p' <> metavar "POOL" <> value pool <> showDefault <> help "Ceph pool name for storage" parseUser = strOption $ long "user" <> short 'u' <> metavar "USER" <> value user <> showDefault <> help "Ceph user for access to storage" parseBroker = strOption $ long "broker" <> short 'b' <> metavar "BROKER" <> value broker <> showDefault <> help "Vault broker host name or IP address" parseDebug = switch $ long "debug" <> short 'd' <> help "Output lots of debugging information" parseQuiet = switch $ long "quiet" <> short 'q' <> help "Only emit warnings or fatal messages" parseComponents = subparser ( parseRegisterOriginComponent <> parseReadComponent <> parseListComponent <> parseDumpDaysComponent ) parseRegisterOriginComponent = componentHelper "register" registerOriginParser "Register a new origin" parseReadComponent = componentHelper "read" readOptionsParser "Read points" parseListComponent = componentHelper "list" listOptionsParser "List addresses and metadata in origin" parseDumpDaysComponent = componentHelper "days" dumpDaysParser "Display the current day map contents" componentHelper cmd_name parser desc = command cmd_name (info (helper <*> parser) (progDesc desc)) parseOrigin :: O.Parser Origin parseOrigin = argument (fmap mkOrigin str) (metavar "ORIGIN") where mkOrigin = Origin . S.pack readOptionsParser :: O.Parser Component readOptionsParser = Read <$> parseOrigin <*> parseAddress <*> parseStart <*> parseEnd where parseAddress = argument (fmap fromString str) (metavar "ADDRESS") parseStart = O.option auto $ long "start" <> short 's' <> value 0 <> showDefault <> help "Start time in nanoseconds since epoch" parseEnd = O.option auto $ long "end" <> short 'e' <> value maxBound <> showDefault <> help "End time in nanoseconds since epoch" listOptionsParser :: O.Parser Component listOptionsParser = List <$> parseOrigin dumpDaysParser :: O.Parser Component dumpDaysParser = DumpDays <$> parseOrigin registerOriginParser :: O.Parser Component registerOriginParser = RegisterOrigin <$> parseOrigin <*> parseBuckets <*> parseStep <*> parseBegin <*> parseEnd where parseBuckets = O.option auto $ long "buckets" <> short 'n' <> value 128 <> showDefault <> help "Number of buckets to distribute writes over" parseStep = O.option auto $ long "step" <> short 's' <> value 14400000000000 <> showDefault <> help "Back-dated rollover period (see documentation: TODO)" parseBegin = O.option auto $ long "begin" <> short 'b' <> value 0 <> showDefault <> help "Back-date begin time (default is no backdating)" parseEnd = O.option auto $ long "end" <> short 'e' <> value 0 <> showDefault <> help "Back-date end time" -- | Config file parsing parseConfig :: FilePath -> IO Options parseConfig fp = do exists <- doesFileExist fp if exists then do maybe_ls <- parseFromFile configParser fp case maybe_ls of Just ls -> return $ mergeConfig ls defaultConfig Nothing -> error "Failed to parse config" else return defaultConfig where defaultConfig = Options "vaultaire" "vaultaire" "localhost" False False None mergeConfig ls Options{..} = fromJust $ Options <$> lookup "pool" ls `mplus` pure pool <*> lookup "user" ls `mplus` pure user <*> lookup "broker" ls `mplus` pure broker <*> pure debug <*> pure quiet <*> pure None configParser :: Parser [(String, String)] configParser = some $ liftA2 (,) (spaces *> possibleKeys <* spaces <* char '=') (spaces *> (stringLiteral <|> stringLiteral')) possibleKeys :: Parser String possibleKeys = string "pool" <|> string "user" <|> string "broker" parseArgsWithConfig :: FilePath -> IO Options parseArgsWithConfig = parseConfig >=> execParser . helpfulParser -- -- Main program entry point -- main :: IO () main = do Options{..} <- parseArgsWithConfig "/etc/vaultaire.conf" let level | debug = Debug | quiet = Quiet | otherwise = Normal quit <- initializeProgram (package ++ "-" ++ version) level -- Run selected command. debugM "Main.main" "Starting command" -- Although none of the commands are running in the background, we get off -- of the main thread so that we can block the main thread on the quit -- semaphore, such that a user interrupt will kill the program. a <- forkThread $ do case component of None -> return () RegisterOrigin origin buckets step begin end -> runRegisterOrigin pool user origin buckets step begin end Read{} -> error "Currently unimplemented. Use marquise's `data read` command" List _ -> error "Currently unimplemented. Use marquise's `data list` command" DumpDays origin -> runDumpDayMap pool user origin putMVar quit () wait a debugM "Main.main" "End"
anchor/vaultaire
src/Inspect.hs
bsd-3-clause
8,021
0
16
2,739
1,648
840
808
-1
-1
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd"> <helpset version="2.0" xml:lang="hi-IN"> <title>Advanced SQLInjection Scanner</title> <maps> <homeID>sqliplugin</homeID> <mapref location="map.jhm"/> </maps> <view> <name>TOC</name> <label>Contents</label> <type>org.zaproxy.zap.extension.help.ZapTocView</type> <data>toc.xml</data> </view> <view> <name>Index</name> <label>Index</label> <type>javax.help.IndexView</type> <data>index.xml</data> </view> <view> <name>Search</name> <label>Search</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favorites</label> <type>javax.help.FavoritesView</type> </view> </helpset>
kingthorin/zap-extensions
addOns/sqliplugin/src/main/javahelp/help_hi_IN/helpset_hi_IN.hs
apache-2.0
981
77
66
157
409
207
202
-1
-1
{-# LANGUAGE TransformListComp #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE Rank2Types #-} ----------------------------------------------------------------------------- -- | -- Module : Haddock.Backends.Html.Decl -- Copyright : (c) Simon Marlow 2003-2006, -- David Waern 2006-2009, -- Mark Lentczner 2010 -- License : BSD-like -- -- Maintainer : [email protected] -- Stability : experimental -- Portability : portable ----------------------------------------------------------------------------- module Haddock.Backends.Xhtml.Decl ( ppDecl, ppTyName, ppTyFamHeader, ppTypeApp, ppOrphanInstances, tyvarNames ) where import Haddock.Backends.Xhtml.DocMarkup import Haddock.Backends.Xhtml.Layout import Haddock.Backends.Xhtml.Names import Haddock.Backends.Xhtml.Types import Haddock.Backends.Xhtml.Utils import Haddock.GhcUtils import Haddock.Types import Haddock.Doc (combineDocumentation) import Data.List ( intersperse, sort ) import qualified Data.Map as Map import Data.Maybe import Text.XHtml hiding ( name, title, p, quote ) import GHC import GHC.Exts import Name import BooleanFormula import RdrName ( rdrNameOcc ) ppDecl :: Bool -> LinksInfo -> LHsDecl DocName -> DocForDecl DocName -> [DocInstance DocName] -> [(DocName, Fixity)] -> [(DocName, DocForDecl DocName)] -> Splice -> Unicode -> Qualification -> Html ppDecl summ links (L loc decl) (mbDoc, fnArgsDoc) instances fixities subdocs splice unicode qual = case decl of TyClD (FamDecl d) -> ppTyFam summ False links instances fixities loc mbDoc d splice unicode qual TyClD d@(DataDecl {}) -> ppDataDecl summ links instances fixities subdocs loc mbDoc d splice unicode qual TyClD d@(SynDecl {}) -> ppTySyn summ links fixities loc (mbDoc, fnArgsDoc) d splice unicode qual TyClD d@(ClassDecl {}) -> ppClassDecl summ links instances fixities loc mbDoc subdocs d splice unicode qual SigD (TypeSig lnames lty) -> ppLFunSig summ links loc (mbDoc, fnArgsDoc) lnames (hsSigWcType lty) fixities splice unicode qual SigD (PatSynSig lname ty) -> ppLPatSig summ links loc (mbDoc, fnArgsDoc) lname ty fixities splice unicode qual ForD d -> ppFor summ links loc (mbDoc, fnArgsDoc) d fixities splice unicode qual InstD _ -> noHtml _ -> error "declaration not supported by ppDecl" ppLFunSig :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName -> [Located DocName] -> LHsType DocName -> [(DocName, Fixity)] -> Splice -> Unicode -> Qualification -> Html ppLFunSig summary links loc doc lnames lty fixities splice unicode qual = ppFunSig summary links loc doc (map unLoc lnames) lty fixities splice unicode qual ppFunSig :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName -> [DocName] -> LHsType DocName -> [(DocName, Fixity)] -> Splice -> Unicode -> Qualification -> Html ppFunSig summary links loc doc docnames typ fixities splice unicode qual = ppSigLike summary links loc mempty doc docnames fixities (unLoc typ, pp_typ) splice unicode qual where pp_typ = ppLType unicode qual typ ppLPatSig :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName -> Located DocName -> LHsSigType DocName -> [(DocName, Fixity)] -> Splice -> Unicode -> Qualification -> Html ppLPatSig summary links loc (doc, _argDocs) (L _ name) typ fixities splice unicode qual | summary = pref1 | otherwise = topDeclElem links loc splice [name] (pref1 <+> ppFixities fixities qual) +++ docSection Nothing qual doc where pref1 = hsep [ keyword "pattern" , ppBinder summary occname , dcolon unicode , ppLType unicode qual (hsSigType typ) ] occname = nameOccName . getName $ name ppSigLike :: Bool -> LinksInfo -> SrcSpan -> Html -> DocForDecl DocName -> [DocName] -> [(DocName, Fixity)] -> (HsType DocName, Html) -> Splice -> Unicode -> Qualification -> Html ppSigLike summary links loc leader doc docnames fixities (typ, pp_typ) splice unicode qual = ppTypeOrFunSig summary links loc docnames typ doc ( addFixities $ leader <+> ppTypeSig summary occnames pp_typ unicode , addFixities . concatHtml . punctuate comma $ map (ppBinder False) occnames , dcolon unicode ) splice unicode qual where occnames = map (nameOccName . getName) docnames addFixities html | summary = html | otherwise = html <+> ppFixities fixities qual ppTypeOrFunSig :: Bool -> LinksInfo -> SrcSpan -> [DocName] -> HsType DocName -> DocForDecl DocName -> (Html, Html, Html) -> Splice -> Unicode -> Qualification -> Html ppTypeOrFunSig summary links loc docnames typ (doc, argDocs) (pref1, pref2, sep) splice unicode qual | summary = pref1 | Map.null argDocs = topDeclElem links loc splice docnames pref1 +++ docSection curName qual doc | otherwise = topDeclElem links loc splice docnames pref2 +++ subArguments qual (do_args 0 sep typ) +++ docSection curName qual doc where curName = getName <$> listToMaybe docnames argDoc n = Map.lookup n argDocs do_largs n leader (L _ t) = do_args n leader t do_args :: Int -> Html -> HsType DocName -> [SubDecl] do_args n leader (HsForAllTy tvs ltype) = do_largs n leader' ltype where leader' = leader <+> ppForAll tvs unicode qual do_args n leader (HsQualTy lctxt ltype) | null (unLoc lctxt) = do_largs n leader ltype | otherwise = (leader <+> ppLContextNoArrow lctxt unicode qual, Nothing, []) : do_largs n (darrow unicode) ltype do_args n leader (HsFunTy lt r) = (leader <+> ppLFunLhType unicode qual lt, argDoc n, []) : do_largs (n+1) (arrow unicode) r do_args n leader t = [(leader <+> ppType unicode qual t, argDoc n, [])] ppForAll :: [LHsTyVarBndr DocName] -> Unicode -> Qualification -> Html ppForAll tvs unicode qual = case [ppKTv n k | L _ (KindedTyVar (L _ n) k) <- tvs] of [] -> noHtml ts -> forallSymbol unicode <+> hsep ts +++ dot where ppKTv n k = parens $ ppTyName (getName n) <+> dcolon unicode <+> ppLKind unicode qual k ppFixities :: [(DocName, Fixity)] -> Qualification -> Html ppFixities [] _ = noHtml ppFixities fs qual = foldr1 (+++) (map ppFix uniq_fs) +++ rightEdge where ppFix (ns, p, d) = thespan ! [theclass "fixity"] << (toHtml d <+> toHtml (show p) <+> ppNames ns) ppDir InfixR = "infixr" ppDir InfixL = "infixl" ppDir InfixN = "infix" ppNames = case fs of _:[] -> const noHtml -- Don't display names for fixities on single names _ -> concatHtml . intersperse (stringToHtml ", ") . map (ppDocName qual Infix False) uniq_fs = [ (n, the p, the d') | (n, Fixity _ p d) <- fs , let d' = ppDir d , then group by Down (p,d') using groupWith ] rightEdge = thespan ! [theclass "rightedge"] << noHtml -- | Pretty-print type variables. ppTyVars :: [LHsTyVarBndr DocName] -> [Html] ppTyVars tvs = map (ppTyName . getName . hsLTyVarName) tvs tyvarNames :: LHsQTyVars DocName -> [Name] tyvarNames = map (getName . hsLTyVarName) . hsQTvExplicit ppFor :: Bool -> LinksInfo -> SrcSpan -> DocForDecl DocName -> ForeignDecl DocName -> [(DocName, Fixity)] -> Splice -> Unicode -> Qualification -> Html ppFor summary links loc doc (ForeignImport (L _ name) typ _ _) fixities splice unicode qual = ppFunSig summary links loc doc [name] (hsSigType typ) fixities splice unicode qual ppFor _ _ _ _ _ _ _ _ _ = error "ppFor" -- we skip type patterns for now ppTySyn :: Bool -> LinksInfo -> [(DocName, Fixity)] -> SrcSpan -> DocForDecl DocName -> TyClDecl DocName -> Splice -> Unicode -> Qualification -> Html ppTySyn summary links fixities loc doc (SynDecl { tcdLName = L _ name, tcdTyVars = ltyvars , tcdRhs = ltype }) splice unicode qual = ppTypeOrFunSig summary links loc [name] (unLoc ltype) doc (full <+> fixs, hdr <+> fixs, spaceHtml +++ equals) splice unicode qual where hdr = hsep ([keyword "type", ppBinder summary occ] ++ ppTyVars (hsQTvExplicit ltyvars)) full = hdr <+> equals <+> ppLType unicode qual ltype occ = nameOccName . getName $ name fixs | summary = noHtml | otherwise = ppFixities fixities qual ppTySyn _ _ _ _ _ _ _ _ _ = error "declaration not supported by ppTySyn" ppTypeSig :: Bool -> [OccName] -> Html -> Unicode -> Html ppTypeSig summary nms pp_ty unicode = concatHtml htmlNames <+> dcolon unicode <+> pp_ty where htmlNames = intersperse (stringToHtml ", ") $ map (ppBinder summary) nms ppTyName :: Name -> Html ppTyName = ppName Prefix ppSimpleSig :: LinksInfo -> Splice -> Unicode -> Qualification -> SrcSpan -> [DocName] -> HsType DocName -> Html ppSimpleSig links splice unicode qual loc names typ = topDeclElem' names $ ppTypeSig True occNames ppTyp unicode where topDeclElem' = topDeclElem links loc splice ppTyp = ppType unicode qual typ occNames = map getOccName names -------------------------------------------------------------------------------- -- * Type families -------------------------------------------------------------------------------- ppFamilyInfo :: Bool -> FamilyInfo DocName -> Html ppFamilyInfo assoc OpenTypeFamily | assoc = keyword "type" | otherwise = keyword "type family" ppFamilyInfo assoc DataFamily | assoc = keyword "data" | otherwise = keyword "data family" ppFamilyInfo _ (ClosedTypeFamily _) = keyword "type family" ppTyFamHeader :: Bool -> Bool -> FamilyDecl DocName -> Unicode -> Qualification -> Html ppTyFamHeader summary associated d@(FamilyDecl { fdInfo = info , fdResultSig = L _ result , fdInjectivityAnn = injectivity }) unicode qual = (case info of OpenTypeFamily | associated -> keyword "type" | otherwise -> keyword "type family" DataFamily | associated -> keyword "data" | otherwise -> keyword "data family" ClosedTypeFamily _ -> keyword "type family" ) <+> ppFamDeclBinderWithVars summary unicode qual d <+> ppResultSig result unicode qual <+> (case injectivity of Nothing -> noHtml Just (L _ injectivityAnn) -> ppInjectivityAnn unicode qual injectivityAnn ) <+> (case info of ClosedTypeFamily _ -> keyword "where ..." _ -> mempty ) ppResultSig :: FamilyResultSig DocName -> Unicode -> Qualification -> Html ppResultSig result unicode qual = case result of NoSig -> noHtml KindSig kind -> dcolon unicode <+> ppLKind unicode qual kind TyVarSig (L _ bndr) -> equals <+> ppHsTyVarBndr unicode qual bndr ppPseudoFamilyHeader :: Unicode -> Qualification -> PseudoFamilyDecl DocName -> Html ppPseudoFamilyHeader unicode qual (PseudoFamilyDecl { .. }) = ppFamilyInfo True pfdInfo <+> ppAppNameTypes (unLoc pfdLName) [] (map unLoc pfdTyVars) unicode qual <+> ppResultSig (unLoc pfdKindSig) unicode qual ppInjectivityAnn :: Bool -> Qualification -> InjectivityAnn DocName -> Html ppInjectivityAnn unicode qual (InjectivityAnn lhs rhs) = char '|' <+> ppLDocName qual Raw lhs <+> arrow unicode <+> hsep (map (ppLDocName qual Raw) rhs) ppTyFam :: Bool -> Bool -> LinksInfo -> [DocInstance DocName] -> [(DocName, Fixity)] -> SrcSpan -> Documentation DocName -> FamilyDecl DocName -> Splice -> Unicode -> Qualification -> Html ppTyFam summary associated links instances fixities loc doc decl splice unicode qual | summary = ppTyFamHeader True associated decl unicode qual | otherwise = header_ +++ docSection Nothing qual doc +++ instancesBit where docname = unLoc $ fdLName decl header_ = topDeclElem links loc splice [docname] $ ppTyFamHeader summary associated decl unicode qual <+> ppFixities fixities qual instancesBit | FamilyDecl { fdInfo = ClosedTypeFamily mb_eqns } <- decl , not summary = subEquations qual $ map (ppTyFamEqn . unLoc) $ fromMaybe [] mb_eqns | otherwise = ppInstances links (OriginFamily docname) instances splice unicode qual -- Individual equation of a closed type family ppTyFamEqn TyFamEqn { tfe_tycon = n, tfe_rhs = rhs , tfe_pats = HsIB { hsib_body = ts }} = ( ppAppNameTypes (unLoc n) [] (map unLoc ts) unicode qual <+> equals <+> ppType unicode qual (unLoc rhs) , Nothing, [] ) ppPseudoFamilyDecl :: LinksInfo -> Splice -> Unicode -> Qualification -> PseudoFamilyDecl DocName -> Html ppPseudoFamilyDecl links splice unicode qual decl@(PseudoFamilyDecl { pfdLName = L loc name, .. }) = wrapper $ ppPseudoFamilyHeader unicode qual decl where wrapper = topDeclElem links loc splice [name] -------------------------------------------------------------------------------- -- * Associated Types -------------------------------------------------------------------------------- ppAssocType :: Bool -> LinksInfo -> DocForDecl DocName -> LFamilyDecl DocName -> [(DocName, Fixity)] -> Splice -> Unicode -> Qualification -> Html ppAssocType summ links doc (L loc decl) fixities splice unicode qual = ppTyFam summ True links [] fixities loc (fst doc) decl splice unicode qual -------------------------------------------------------------------------------- -- * TyClDecl helpers -------------------------------------------------------------------------------- -- | Print a type family and its variables ppFamDeclBinderWithVars :: Bool -> Unicode -> Qualification -> FamilyDecl DocName -> Html ppFamDeclBinderWithVars summ unicode qual (FamilyDecl { fdLName = lname, fdTyVars = tvs }) = ppAppDocNameTyVarBndrs summ unicode qual (unLoc lname) (map unLoc $ hsq_explicit tvs) -- | Print a newtype / data binder and its variables ppDataBinderWithVars :: Bool -> TyClDecl DocName -> Html ppDataBinderWithVars summ decl = ppAppDocNameNames summ (tcdName decl) (tyvarNames $ tcdTyVars decl) -------------------------------------------------------------------------------- -- * Type applications -------------------------------------------------------------------------------- ppAppDocNameTyVarBndrs :: Bool -> Unicode -> Qualification -> DocName -> [HsTyVarBndr DocName] -> Html ppAppDocNameTyVarBndrs summ unicode qual n vs = ppTypeApp n [] vs ppDN (ppHsTyVarBndr unicode qual) where ppDN notation = ppBinderFixity notation summ . nameOccName . getName ppBinderFixity Infix = ppBinderInfix ppBinderFixity _ = ppBinder -- | Print an application of a 'DocName' and two lists of 'HsTypes' (kinds, types) ppAppNameTypes :: DocName -> [HsType DocName] -> [HsType DocName] -> Unicode -> Qualification -> Html ppAppNameTypes n ks ts unicode qual = ppTypeApp n ks ts (\p -> ppDocName qual p True) (ppParendType unicode qual) -- | Print an application of a 'DocName' and a list of 'Names' ppAppDocNameNames :: Bool -> DocName -> [Name] -> Html ppAppDocNameNames summ n ns = ppTypeApp n [] ns ppDN ppTyName where ppDN notation = ppBinderFixity notation summ . nameOccName . getName ppBinderFixity Infix = ppBinderInfix ppBinderFixity _ = ppBinder -- | General printing of type applications ppTypeApp :: DocName -> [a] -> [a] -> (Notation -> DocName -> Html) -> (a -> Html) -> Html ppTypeApp n [] (t1:t2:rest) ppDN ppT | operator, not . null $ rest = parens opApp <+> hsep (map ppT rest) | operator = opApp where operator = isNameSym . getName $ n opApp = ppT t1 <+> ppDN Infix n <+> ppT t2 ppTypeApp n ks ts ppDN ppT = ppDN Prefix n <+> hsep (map ppT $ ks ++ ts) ------------------------------------------------------------------------------- -- * Contexts ------------------------------------------------------------------------------- ppLContext, ppLContextNoArrow :: Located (HsContext DocName) -> Unicode -> Qualification -> Html ppLContext = ppContext . unLoc ppLContextNoArrow = ppContextNoArrow . unLoc ppContextNoArrow :: HsContext DocName -> Unicode -> Qualification -> Html ppContextNoArrow cxt unicode qual = fromMaybe noHtml $ ppContextNoLocsMaybe (map unLoc cxt) unicode qual ppContextNoLocs :: [HsType DocName] -> Unicode -> Qualification -> Html ppContextNoLocs cxt unicode qual = maybe noHtml (<+> darrow unicode) $ ppContextNoLocsMaybe cxt unicode qual ppContextNoLocsMaybe :: [HsType DocName] -> Unicode -> Qualification -> Maybe Html ppContextNoLocsMaybe [] _ _ = Nothing ppContextNoLocsMaybe cxt unicode qual = Just $ ppHsContext cxt unicode qual ppContext :: HsContext DocName -> Unicode -> Qualification -> Html ppContext cxt unicode qual = ppContextNoLocs (map unLoc cxt) unicode qual ppHsContext :: [HsType DocName] -> Unicode -> Qualification-> Html ppHsContext [] _ _ = noHtml ppHsContext [p] unicode qual = ppCtxType unicode qual p ppHsContext cxt unicode qual = parenList (map (ppType unicode qual) cxt) ------------------------------------------------------------------------------- -- * Class declarations ------------------------------------------------------------------------------- ppClassHdr :: Bool -> Located [LHsType DocName] -> DocName -> LHsQTyVars DocName -> [Located ([Located DocName], [Located DocName])] -> Unicode -> Qualification -> Html ppClassHdr summ lctxt n tvs fds unicode qual = keyword "class" <+> (if not . null . unLoc $ lctxt then ppLContext lctxt unicode qual else noHtml) <+> ppAppDocNameNames summ n (tyvarNames tvs) <+> ppFds fds unicode qual ppFds :: [Located ([Located DocName], [Located DocName])] -> Unicode -> Qualification -> Html ppFds fds unicode qual = if null fds then noHtml else char '|' <+> hsep (punctuate comma (map (fundep . unLoc) fds)) where fundep (vars1,vars2) = ppVars vars1 <+> arrow unicode <+> ppVars vars2 ppVars = hsep . map ((ppDocName qual Prefix True) . unLoc) ppShortClassDecl :: Bool -> LinksInfo -> TyClDecl DocName -> SrcSpan -> [(DocName, DocForDecl DocName)] -> Splice -> Unicode -> Qualification -> Html ppShortClassDecl summary links (ClassDecl { tcdCtxt = lctxt, tcdLName = lname, tcdTyVars = tvs , tcdFDs = fds, tcdSigs = sigs, tcdATs = ats }) loc subdocs splice unicode qual = if not (any isUserLSig sigs) && null ats then (if summary then id else topDeclElem links loc splice [nm]) hdr else (if summary then id else topDeclElem links loc splice [nm]) (hdr <+> keyword "where") +++ shortSubDecls False ( [ ppAssocType summary links doc at [] splice unicode qual | at <- ats , let doc = lookupAnySubdoc (unL $ fdLName $ unL at) subdocs ] ++ -- ToDo: add associated type defaults [ ppFunSig summary links loc doc names (hsSigWcType typ) [] splice unicode qual | L _ (TypeSig lnames typ) <- sigs , let doc = lookupAnySubdoc (head names) subdocs names = map unLoc lnames ] -- FIXME: is taking just the first name ok? Is it possible that -- there are different subdocs for different names in a single -- type signature? ) where hdr = ppClassHdr summary lctxt (unLoc lname) tvs fds unicode qual nm = unLoc lname ppShortClassDecl _ _ _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl" ppClassDecl :: Bool -> LinksInfo -> [DocInstance DocName] -> [(DocName, Fixity)] -> SrcSpan -> Documentation DocName -> [(DocName, DocForDecl DocName)] -> TyClDecl DocName -> Splice -> Unicode -> Qualification -> Html ppClassDecl summary links instances fixities loc d subdocs decl@(ClassDecl { tcdCtxt = lctxt, tcdLName = lname, tcdTyVars = ltyvars , tcdFDs = lfds, tcdSigs = lsigs, tcdATs = ats }) splice unicode qual | summary = ppShortClassDecl summary links decl loc subdocs splice unicode qual | otherwise = classheader +++ docSection Nothing qual d +++ minimalBit +++ atBit +++ methodBit +++ instancesBit where sigs = map unLoc lsigs classheader | any isUserLSig lsigs = topDeclElem links loc splice [nm] (hdr unicode qual <+> keyword "where" <+> fixs) | otherwise = topDeclElem links loc splice [nm] (hdr unicode qual <+> fixs) -- Only the fixity relevant to the class header fixs = ppFixities [ f | f@(n,_) <- fixities, n == unLoc lname ] qual nm = tcdName decl hdr = ppClassHdr summary lctxt (unLoc lname) ltyvars lfds -- ToDo: add assocatied typ defaults atBit = subAssociatedTypes [ ppAssocType summary links doc at subfixs splice unicode qual | at <- ats , let n = unL . fdLName $ unL at doc = lookupAnySubdoc (unL $ fdLName $ unL at) subdocs subfixs = [ f | f@(n',_) <- fixities, n == n' ] ] methodBit = subMethods [ ppFunSig summary links loc doc names (hsSigType typ) subfixs splice unicode qual | L _ (ClassOpSig _ lnames typ) <- lsigs , let doc = lookupAnySubdoc (head names) subdocs subfixs = [ f | n <- names , f@(n',_) <- fixities , n == n' ] names = map unLoc lnames ] -- FIXME: is taking just the first name ok? Is it possible that -- there are different subdocs for different names in a single -- type signature? minimalBit = case [ s | MinimalSig _ (L _ s) <- sigs ] of -- Miminal complete definition = every shown method And xs : _ | sort [getName n | L _ (Var (L _ n)) <- xs] == sort [getName n | TypeSig ns _ <- sigs, L _ n <- ns] -> noHtml -- Minimal complete definition = the only shown method Var (L _ n) : _ | [getName n] == [getName n' | L _ (TypeSig ns _) <- lsigs, L _ n' <- ns] -> noHtml -- Minimal complete definition = nothing And [] : _ -> subMinimal $ toHtml "Nothing" m : _ -> subMinimal $ ppMinimal False m _ -> noHtml ppMinimal _ (Var (L _ n)) = ppDocName qual Prefix True n ppMinimal _ (And fs) = foldr1 (\a b -> a+++", "+++b) $ map (ppMinimal True . unLoc) fs ppMinimal p (Or fs) = wrap $ foldr1 (\a b -> a+++" | "+++b) $ map (ppMinimal False . unLoc) fs where wrap | p = parens | otherwise = id ppMinimal p (Parens x) = ppMinimal p (unLoc x) instancesBit = ppInstances links (OriginClass nm) instances splice unicode qual ppClassDecl _ _ _ _ _ _ _ _ _ _ _ = error "declaration type not supported by ppShortClassDecl" ppInstances :: LinksInfo -> InstOrigin DocName -> [DocInstance DocName] -> Splice -> Unicode -> Qualification -> Html ppInstances links origin instances splice unicode qual = subInstances qual instName links True (zipWith instDecl [1..] instances) -- force Splice = True to use line URLs where instName = getOccString origin instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName) instDecl no (inst, mdoc, loc) = ((ppInstHead links splice unicode qual mdoc origin False no inst), loc) ppOrphanInstances :: LinksInfo -> [DocInstance DocName] -> Splice -> Unicode -> Qualification -> Html ppOrphanInstances links instances splice unicode qual = subOrphanInstances qual links True (zipWith instDecl [1..] instances) where instOrigin :: InstHead name -> InstOrigin name instOrigin inst = OriginClass (ihdClsName inst) instDecl :: Int -> DocInstance DocName -> (SubDecl,Located DocName) instDecl no (inst, mdoc, loc) = ((ppInstHead links splice unicode qual mdoc (instOrigin inst) True no inst), loc) ppInstHead :: LinksInfo -> Splice -> Unicode -> Qualification -> Maybe (MDoc DocName) -> InstOrigin DocName -> Bool -- ^ Is instance orphan -> Int -- ^ Normal -> InstHead DocName -> SubDecl ppInstHead links splice unicode qual mdoc origin orphan no ihd@(InstHead {..}) = case ihdInstType of ClassInst { .. } -> ( subInstHead iid $ ppContextNoLocs clsiCtx unicode qual <+> typ , mdoc , [subInstDetails iid ats sigs] ) where sigs = ppInstanceSigs links splice unicode qual clsiSigs ats = ppInstanceAssocTys links splice unicode qual clsiAssocTys TypeInst rhs -> ( subInstHead iid ptype , mdoc , [subFamInstDetails iid prhs] ) where ptype = keyword "type" <+> typ prhs = ptype <+> maybe noHtml (\t -> equals <+> ppType unicode qual t) rhs DataInst dd -> ( subInstHead iid pdata , mdoc , [subFamInstDetails iid pdecl]) where pdata = keyword "data" <+> typ pdecl = pdata <+> ppShortDataDecl False True dd unicode qual where iid = instanceId origin no orphan ihd typ = ppAppNameTypes ihdClsName ihdKinds ihdTypes unicode qual ppInstanceAssocTys :: LinksInfo -> Splice -> Unicode -> Qualification -> [PseudoFamilyDecl DocName] -> [Html] ppInstanceAssocTys links splice unicode qual = map ppFamilyDecl' where ppFamilyDecl' = ppPseudoFamilyDecl links splice unicode qual ppInstanceSigs :: LinksInfo -> Splice -> Unicode -> Qualification -> [Sig DocName] -> [Html] ppInstanceSigs links splice unicode qual sigs = do TypeSig lnames typ <- sigs let names = map unLoc lnames L loc rtyp = get_type typ return $ ppSimpleSig links splice unicode qual loc names rtyp where get_type = hswc_body . hsib_body lookupAnySubdoc :: Eq id1 => id1 -> [(id1, DocForDecl id2)] -> DocForDecl id2 lookupAnySubdoc n = fromMaybe noDocForDecl . lookup n instanceId :: InstOrigin DocName -> Int -> Bool -> InstHead DocName -> String instanceId origin no orphan ihd = concat $ [ "o:" | orphan ] ++ [ qual origin , ":" ++ getOccString origin , ":" ++ (occNameString . getOccName . ihdClsName) ihd , ":" ++ show no ] where qual (OriginClass _) = "ic" qual (OriginData _) = "id" qual (OriginFamily _) = "if" ------------------------------------------------------------------------------- -- * Data & newtype declarations ------------------------------------------------------------------------------- -- TODO: print contexts ppShortDataDecl :: Bool -> Bool -> TyClDecl DocName -> Unicode -> Qualification -> Html ppShortDataDecl summary dataInst dataDecl unicode qual | [] <- cons = dataHeader | [lcon] <- cons, isH98, (cHead,cBody,cFoot) <- ppShortConstrParts summary dataInst (unLoc lcon) unicode qual = (dataHeader <+> equals <+> cHead) +++ cBody +++ cFoot | isH98 = dataHeader +++ shortSubDecls dataInst (zipWith doConstr ('=':repeat '|') cons) | otherwise = (dataHeader <+> keyword "where") +++ shortSubDecls dataInst (map doGADTConstr cons) where dataHeader | dataInst = noHtml | otherwise = ppDataHeader summary dataDecl unicode qual doConstr c con = toHtml [c] <+> ppShortConstr summary (unLoc con) unicode qual doGADTConstr con = ppShortConstr summary (unLoc con) unicode qual cons = dd_cons (tcdDataDefn dataDecl) isH98 = case unLoc (head cons) of ConDeclH98 {} -> True ConDeclGADT{} -> False ppDataDecl :: Bool -> LinksInfo -> [DocInstance DocName] -> [(DocName, Fixity)] -> [(DocName, DocForDecl DocName)] -> SrcSpan -> Documentation DocName -> TyClDecl DocName -> Splice -> Unicode -> Qualification -> Html ppDataDecl summary links instances fixities subdocs loc doc dataDecl splice unicode qual | summary = ppShortDataDecl summary False dataDecl unicode qual | otherwise = header_ +++ docSection Nothing qual doc +++ constrBit +++ instancesBit where docname = tcdName dataDecl cons = dd_cons (tcdDataDefn dataDecl) isH98 = case unLoc (head cons) of ConDeclH98 {} -> True ConDeclGADT{} -> False header_ = topDeclElem links loc splice [docname] $ ppDataHeader summary dataDecl unicode qual <+> whereBit <+> fix fix = ppFixities (filter (\(n,_) -> n == docname) fixities) qual whereBit | null cons = noHtml | otherwise = if isH98 then noHtml else keyword "where" constrBit = subConstructors qual [ ppSideBySideConstr subdocs subfixs unicode qual c | c <- cons , let subfixs = filter (\(n,_) -> any (\cn -> cn == n) (map unLoc (getConNames (unLoc c)))) fixities ] instancesBit = ppInstances links (OriginData docname) instances splice unicode qual ppShortConstr :: Bool -> ConDecl DocName -> Unicode -> Qualification -> Html ppShortConstr summary con unicode qual = cHead <+> cBody <+> cFoot where (cHead,cBody,cFoot) = ppShortConstrParts summary False con unicode qual -- returns three pieces: header, body, footer so that header & footer can be -- incorporated into the declaration ppShortConstrParts :: Bool -> Bool -> ConDecl DocName -> Unicode -> Qualification -> (Html, Html, Html) ppShortConstrParts summary dataInst con unicode qual = case con of ConDeclH98{} -> case con_details con of PrefixCon args -> (header_ unicode qual +++ hsep (ppOcc : map (ppLParendType unicode qual) args), noHtml, noHtml) RecCon (L _ fields) -> (header_ unicode qual +++ ppOcc <+> char '{', doRecordFields fields, char '}') InfixCon arg1 arg2 -> (header_ unicode qual +++ hsep [ppLParendType unicode qual arg1, ppOccInfix, ppLParendType unicode qual arg2], noHtml, noHtml) ConDeclGADT {} -> (ppOcc <+> dcolon unicode <+> ppLType unicode qual resTy,noHtml,noHtml) where resTy = hsib_body (con_type con) doRecordFields fields = shortSubDecls dataInst (map (ppShortField summary unicode qual) (map unLoc fields)) header_ = ppConstrHdr forall_ tyVars context occ = map (nameOccName . getName . unLoc) $ getConNames con ppOcc = case occ of [one] -> ppBinder summary one _ -> hsep (punctuate comma (map (ppBinder summary) occ)) ppOccInfix = case occ of [one] -> ppBinderInfix summary one _ -> hsep (punctuate comma (map (ppBinderInfix summary) occ)) ltvs = fromMaybe (HsQTvs PlaceHolder [] PlaceHolder) (con_qvars con) tyVars = tyvarNames ltvs lcontext = fromMaybe (noLoc []) (con_cxt con) context = unLoc lcontext forall_ = False -- ppConstrHdr is for (non-GADT) existentials constructors' syntax ppConstrHdr :: Bool -> [Name] -> HsContext DocName -> Unicode -> Qualification -> Html ppConstrHdr forall_ tvs ctxt unicode qual = (if null tvs then noHtml else ppForall) +++ (if null ctxt then noHtml else ppContextNoArrow ctxt unicode qual <+> darrow unicode +++ toHtml " ") where ppForall | forall_ = forallSymbol unicode <+> hsep (map (ppName Prefix) tvs) <+> toHtml ". " | otherwise = noHtml ppSideBySideConstr :: [(DocName, DocForDecl DocName)] -> [(DocName, Fixity)] -> Unicode -> Qualification -> LConDecl DocName -> SubDecl ppSideBySideConstr subdocs fixities unicode qual (L _ con) = (decl, mbDoc, fieldPart) where decl = case con of ConDeclH98{} -> case con_details con of PrefixCon args -> hsep ((header_ +++ ppOcc) : map (ppLParendType unicode qual) args) <+> fixity RecCon _ -> header_ +++ ppOcc <+> fixity InfixCon arg1 arg2 -> hsep [header_ +++ ppLParendType unicode qual arg1, ppOccInfix, ppLParendType unicode qual arg2] <+> fixity ConDeclGADT{} -> doGADTCon resTy resTy = hsib_body (con_type con) fieldPart = case getConDetails con of RecCon (L _ fields) -> [doRecordFields fields] _ -> [] doRecordFields fields = subFields qual (map (ppSideBySideField subdocs unicode qual) (map unLoc fields)) doGADTCon :: Located (HsType DocName) -> Html doGADTCon ty = ppOcc <+> dcolon unicode -- ++AZ++ make this prepend "{..}" when it is a record style GADT <+> ppLType unicode qual ty <+> fixity fixity = ppFixities fixities qual header_ = ppConstrHdr forall_ tyVars context unicode qual occ = map (nameOccName . getName . unLoc) $ getConNames con ppOcc = case occ of [one] -> ppBinder False one _ -> hsep (punctuate comma (map (ppBinder False) occ)) ppOccInfix = case occ of [one] -> ppBinderInfix False one _ -> hsep (punctuate comma (map (ppBinderInfix False) occ)) tyVars = tyvarNames (fromMaybe (HsQTvs PlaceHolder [] PlaceHolder) (con_qvars con)) context = unLoc (fromMaybe (noLoc []) (con_cxt con)) forall_ = False -- don't use "con_doc con", in case it's reconstructed from a .hi file, -- or also because we want Haddock to do the doc-parsing, not GHC. mbDoc = lookup (unLoc $ head $ getConNames con) subdocs >>= combineDocumentation . fst ppSideBySideField :: [(DocName, DocForDecl DocName)] -> Unicode -> Qualification -> ConDeclField DocName -> SubDecl ppSideBySideField subdocs unicode qual (ConDeclField names ltype _) = (hsep (punctuate comma (map ((ppBinder False) . rdrNameOcc . unLoc . rdrNameFieldOcc . unLoc) names)) <+> dcolon unicode <+> ppLType unicode qual ltype, mbDoc, []) where -- don't use cd_fld_doc for same reason we don't use con_doc above -- Where there is more than one name, they all have the same documentation mbDoc = lookup (selectorFieldOcc $ unLoc $ head names) subdocs >>= combineDocumentation . fst ppShortField :: Bool -> Unicode -> Qualification -> ConDeclField DocName -> Html ppShortField summary unicode qual (ConDeclField names ltype _) = hsep (punctuate comma (map ((ppBinder summary) . rdrNameOcc . unLoc . rdrNameFieldOcc . unLoc) names)) <+> dcolon unicode <+> ppLType unicode qual ltype -- | Print the LHS of a data\/newtype declaration. -- Currently doesn't handle 'data instance' decls or kind signatures ppDataHeader :: Bool -> TyClDecl DocName -> Unicode -> Qualification -> Html ppDataHeader summary decl@(DataDecl { tcdDataDefn = HsDataDefn { dd_ND = nd , dd_ctxt = ctxt , dd_kindSig = ks } }) unicode qual = -- newtype or data (case nd of { NewType -> keyword "newtype"; DataType -> keyword "data" }) <+> -- context ppLContext ctxt unicode qual <+> -- T a b c ..., or a :+: b ppDataBinderWithVars summary decl <+> case ks of Nothing -> mempty Just (L _ x) -> dcolon unicode <+> ppKind unicode qual x ppDataHeader _ _ _ _ = error "ppDataHeader: illegal argument" -------------------------------------------------------------------------------- -- * Types and contexts -------------------------------------------------------------------------------- ppBang :: HsSrcBang -> Html ppBang (HsSrcBang _ _ SrcStrict) = toHtml "!" ppBang (HsSrcBang _ _ SrcLazy) = toHtml "~" ppBang _ = noHtml tupleParens :: HsTupleSort -> [Html] -> Html tupleParens HsUnboxedTuple = ubxParenList tupleParens _ = parenList -------------------------------------------------------------------------------- -- * Rendering of HsType -------------------------------------------------------------------------------- pREC_TOP, pREC_CTX, pREC_FUN, pREC_OP, pREC_CON :: Int pREC_TOP = 0 :: Int -- type in ParseIface.y in GHC pREC_CTX = 1 :: Int -- Used for single contexts, eg. ctx => type -- (as opposed to (ctx1, ctx2) => type) pREC_FUN = 2 :: Int -- btype in ParseIface.y in GHC -- Used for LH arg of (->) pREC_OP = 3 :: Int -- Used for arg of any infix operator -- (we don't keep their fixities around) pREC_CON = 4 :: Int -- Used for arg of type applicn: -- always parenthesise unless atomic maybeParen :: Int -- Precedence of context -> Int -- Precedence of top-level operator -> Html -> Html -- Wrap in parens if (ctxt >= op) maybeParen ctxt_prec op_prec p | ctxt_prec >= op_prec = parens p | otherwise = p ppLType, ppLParendType, ppLFunLhType :: Unicode -> Qualification -> Located (HsType DocName) -> Html ppLType unicode qual y = ppType unicode qual (unLoc y) ppLParendType unicode qual y = ppParendType unicode qual (unLoc y) ppLFunLhType unicode qual y = ppFunLhType unicode qual (unLoc y) ppType, ppCtxType, ppParendType, ppFunLhType :: Unicode -> Qualification -> HsType DocName -> Html ppType unicode qual ty = ppr_mono_ty pREC_TOP ty unicode qual ppCtxType unicode qual ty = ppr_mono_ty pREC_CTX ty unicode qual ppParendType unicode qual ty = ppr_mono_ty pREC_CON ty unicode qual ppFunLhType unicode qual ty = ppr_mono_ty pREC_FUN ty unicode qual ppHsTyVarBndr :: Unicode -> Qualification -> HsTyVarBndr DocName -> Html ppHsTyVarBndr _ qual (UserTyVar (L _ name)) = ppDocName qual Raw False name ppHsTyVarBndr unicode qual (KindedTyVar name kind) = parens (ppDocName qual Raw False (unLoc name) <+> dcolon unicode <+> ppLKind unicode qual kind) ppLKind :: Unicode -> Qualification -> LHsKind DocName -> Html ppLKind unicode qual y = ppKind unicode qual (unLoc y) ppKind :: Unicode -> Qualification -> HsKind DocName -> Html ppKind unicode qual ki = ppr_mono_ty pREC_TOP ki unicode qual ppForAllPart :: [LHsTyVarBndr DocName] -> Unicode -> Html ppForAllPart tvs unicode = hsep (forallSymbol unicode : ppTyVars tvs) +++ dot ppr_mono_lty :: Int -> LHsType DocName -> Unicode -> Qualification -> Html ppr_mono_lty ctxt_prec ty = ppr_mono_ty ctxt_prec (unLoc ty) ppr_mono_ty :: Int -> HsType DocName -> Unicode -> Qualification -> Html ppr_mono_ty ctxt_prec (HsForAllTy tvs ty) unicode qual = maybeParen ctxt_prec pREC_FUN $ ppForAllPart tvs unicode <+> ppr_mono_lty pREC_TOP ty unicode qual ppr_mono_ty ctxt_prec (HsQualTy ctxt ty) unicode qual = maybeParen ctxt_prec pREC_FUN $ ppLContext ctxt unicode qual <+> ppr_mono_lty pREC_TOP ty unicode qual -- UnicodeSyntax alternatives ppr_mono_ty _ (HsTyVar (L _ name)) True _ | getOccString (getName name) == "*" = toHtml "★" | getOccString (getName name) == "(->)" = toHtml "(→)" ppr_mono_ty _ (HsBangTy b ty) u q = ppBang b +++ ppLParendType u q ty ppr_mono_ty _ (HsTyVar (L _ name)) _ q = ppDocName q Prefix True name ppr_mono_ty ctxt_prec (HsFunTy ty1 ty2) u q = ppr_fun_ty ctxt_prec ty1 ty2 u q ppr_mono_ty _ (HsTupleTy con tys) u q = tupleParens con (map (ppLType u q) tys) ppr_mono_ty _ (HsKindSig ty kind) u q = parens (ppr_mono_lty pREC_TOP ty u q <+> dcolon u <+> ppLKind u q kind) ppr_mono_ty _ (HsListTy ty) u q = brackets (ppr_mono_lty pREC_TOP ty u q) ppr_mono_ty _ (HsPArrTy ty) u q = pabrackets (ppr_mono_lty pREC_TOP ty u q) ppr_mono_ty ctxt_prec (HsIParamTy n ty) u q = maybeParen ctxt_prec pREC_CTX $ ppIPName n <+> dcolon u <+> ppr_mono_lty pREC_TOP ty u q ppr_mono_ty _ (HsSpliceTy {}) _ _ = error "ppr_mono_ty HsSpliceTy" ppr_mono_ty _ (HsRecTy {}) _ _ = toHtml "{..}" -- Can now legally occur in ConDeclGADT, the output here is to provide a -- placeholder in the signature, which is followed by the field -- declarations. ppr_mono_ty _ (HsCoreTy {}) _ _ = error "ppr_mono_ty HsCoreTy" ppr_mono_ty _ (HsExplicitListTy _ tys) u q = promoQuote $ brackets $ hsep $ punctuate comma $ map (ppLType u q) tys ppr_mono_ty _ (HsExplicitTupleTy _ tys) u q = promoQuote $ parenList $ map (ppLType u q) tys ppr_mono_ty _ (HsAppsTy {}) _ _ = error "ppr_mono_ty HsAppsTy" ppr_mono_ty ctxt_prec (HsEqTy ty1 ty2) unicode qual = maybeParen ctxt_prec pREC_CTX $ ppr_mono_lty pREC_OP ty1 unicode qual <+> char '~' <+> ppr_mono_lty pREC_OP ty2 unicode qual ppr_mono_ty ctxt_prec (HsAppTy fun_ty arg_ty) unicode qual = maybeParen ctxt_prec pREC_CON $ hsep [ppr_mono_lty pREC_FUN fun_ty unicode qual, ppr_mono_lty pREC_CON arg_ty unicode qual] ppr_mono_ty ctxt_prec (HsOpTy ty1 op ty2) unicode qual = maybeParen ctxt_prec pREC_FUN $ ppr_mono_lty pREC_OP ty1 unicode qual <+> ppr_op <+> ppr_mono_lty pREC_OP ty2 unicode qual where -- `(:)` is valid in type signature only as constructor to promoted list -- and needs to be quoted in code so we explicitly quote it here too. ppr_op | (getOccString . getName . unLoc) op == ":" = promoQuote ppr_op' | otherwise = ppr_op' ppr_op' = ppLDocName qual Infix op ppr_mono_ty ctxt_prec (HsParTy ty) unicode qual -- = parens (ppr_mono_lty pREC_TOP ty) = ppr_mono_lty ctxt_prec ty unicode qual ppr_mono_ty ctxt_prec (HsDocTy ty _) unicode qual = ppr_mono_lty ctxt_prec ty unicode qual ppr_mono_ty _ (HsWildCardTy (AnonWildCard _)) _ _ = char '_' ppr_mono_ty _ (HsTyLit n) _ _ = ppr_tylit n ppr_tylit :: HsTyLit -> Html ppr_tylit (HsNumTy _ n) = toHtml (show n) ppr_tylit (HsStrTy _ s) = toHtml (show s) ppr_fun_ty :: Int -> LHsType DocName -> LHsType DocName -> Unicode -> Qualification -> Html ppr_fun_ty ctxt_prec ty1 ty2 unicode qual = let p1 = ppr_mono_lty pREC_FUN ty1 unicode qual p2 = ppr_mono_lty pREC_TOP ty2 unicode qual in maybeParen ctxt_prec pREC_FUN $ hsep [p1, arrow unicode <+> p2]
niteria/haddock
haddock-api/src/Haddock/Backends/Xhtml/Decl.hs
bsd-2-clause
43,362
0
22
11,553
12,801
6,465
6,336
711
9
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE helpset PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 2.0//EN" "http://java.sun.com/products/javahelp/helpset_2_0.dtd"> <helpset version="2.0" xml:lang="en-GB"> <title>Custom Payloads Add-on</title> <maps> <homeID>custompayloads</homeID> <mapref location="map.jhm"/> </maps> <view> <name>TOC</name> <label>Contents</label> <type>org.zaproxy.zap.extension.help.ZapTocView</type> <data>toc.xml</data> </view> <view> <name>Index</name> <label>Index</label> <type>javax.help.IndexView</type> <data>index.xml</data> </view> <view> <name>Search</name> <label>Search</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favorites</label> <type>javax.help.FavoritesView</type> </view> </helpset>
thc202/zap-extensions
addOns/custompayloads/src/main/javahelp/org/zaproxy/zap/extension/custompayloads/resources/help/helpset.hs
apache-2.0
991
81
68
170
423
216
207
-1
-1
{-# LANGUAGE ForeignFunctionInterface #-} module Static001 where foreign export ccall f :: Int -> Int f :: Int -> Int f n = n + 1
urbanslug/ghc
testsuite/tests/driver/Static001.hs
bsd-3-clause
130
0
6
26
40
23
17
5
1
module Main where import Data.List import Data.Map (Map) import qualified Data.Map as Map import qualified Data.Set as Set data Edge = Edge String String deriving (Eq, Ord) edge :: String -> String -> Edge edge a b | a < b = Edge a b | otherwise = Edge b a edgeToList :: Edge -> [String] edgeToList (Edge a b) = [a,b] main :: IO () main = do input <- loadInput let people1 = uniques (concatMap edgeToList (Map.keys input)) print (maximumHappiness input people1) -- Adding the extra person as the empty string, it's definitely not in the list let people2 = "" : people1 print (maximumHappiness input people2) neighbors :: [String] -> [Edge] neighbors [] = [] neighbors (x:xs) = zipWith edge (x:xs) (xs ++ [x]) maximumHappiness :: Map Edge Int {- ^ Happiness effects of each edge -} -> [String] {- ^ List of all people to be seated -} -> Int {- ^ Maximum happiness effect -} maximumHappiness relationships people = maximum (score <$> permutations people) where score xs = sum [Map.findWithDefault 0 e relationships | e <- neighbors xs] loadInput :: IO (Map Edge Int) loadInput = Map.fromListWith (+) . map parseLine . lines <$> readFile "input13.txt" parseLine :: String -> (Edge, Int) parseLine str = case words (filter (/='.') str) of [a,_,"gain",n,_,_,_,_,_,_,b] -> (edge a b, read n) [a,_,"lose",n,_,_,_,_,_,_,b] -> (edge a b, - read n) _ -> error ("Bad input line: " ++ str) uniques :: Ord a => [a] -> [a] uniques = Set.toList . Set.fromList
glguy/advent2015
Day13.hs
isc
1,541
1
15
349
629
338
291
39
3
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-} module Y2017.M06.D15.Solution where import Data.Monoid ((<>)) {-- Today's Haskell problem comes by way of @aisamanra, Mr. Lists-are-Mu-functions- in-the-function-of-Mus. For, as we all know: 'Mus' is the plural of 'Mu.' Deep thoughts, from geophf, the Muse. geddit? Mu? Mus? Muse? GEDDIT? Anyway. 'getty the sitokouros' defines Lists as follows: (also see hipster-lists.png) --} newtype Mu f = Mu (f (Mu f)) data L t r = Nil | Cons t r type List t = Mu (L t) -- now why @aisamanra didn't have the type be Μ and not Mu ... that is to say: -- Μ, the Greek letter for M, which you often see as μ, is beyond me, but okay. -- So, anyway, today's haskell problem -- Problem 1. -- Scare your friends, and replace all [a] values with List a values, but write -- a show-instance so that they can't tell the difference ... AT ALL! instance Show t => Show (List t) where show = showL showL :: Show t => List t -> String showL (Mu Nil) = "[]" showL (Mu (Cons t r)) = '[' : show t ++ showing r showing :: Show t => List t -> String showing (Mu Nil) = "]" showing (Mu (Cons t r)) = ", " ++ show t ++ showing r -- hint: there may be a trick to this show instance, a setting-up context. {-- >>> Mu Nil [] >>> Mu (Cons 1 (Mu (Cons 2 (Mu (Cons 3 (Mu Nil)))))) [1, 2, 3] --} -- Problem 2. -- write headμ and tailμ functions headμ :: List t -> t headμ (Mu (Cons x _)) = x tailμ :: List t -> List t tailμ (Mu (Cons _ r)) = r -- Of course, like head and tail, these are not total functions. -- Consolation: deal with it. {-- eh, types to hard for my head! -- Problem 3. -- Of course, List t is Foldable and Traversable, right? -- Make it so, Number 1 instance Foldable f => Foldable (L f) where foldMap f Nil = mempty foldMap f (Cons x r) = f x <> foldMap f r instance Traversable (L t) where traverse = undefined -- or you can define sequenceA if you prefer -- which means, OF COURSE, that List t MUST BE a Functor! instance Functor (L t) where fmap = undefined --} -- Problem 4. -- Now that you have all that, define a List Int of 1 .. 10. What is the sum of -- that list's elements's successors? What is the headμ? What is the tailμ? oneToTen :: List Int oneToTen = fromList [1..10] fromList :: [a] -> List a fromList [] = Mu Nil fromList (h:t) = Mu (Cons h (fromList t)) {-- >>> oneToTen [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] I'M TOTALLY FOOLED! --} -- sum is a fold sumSucc10 :: List Int -> Int sumSucc10 = foldµ (+) 0 . mapµ succ foldµ :: (a -> b -> b) -> b -> List a -> b foldµ f z (Mu Nil) = z foldµ f z (Mu (Cons x r)) = foldµ f (f x z) r mapµ :: (a -> b) -> List a -> List b mapµ f (Mu Nil) = Mu Nil mapµ f (Mu (Cons x r)) = Mu (Cons (f x) (mapµ f r)) {-- >>> sumSucc10 oneToTen 65 --} headμ10 :: List Int -> Int headμ10 = headμ {-- >>> headμ10 oneToTen 1 --} tailμ10 :: List Int -> List Int tailμ10 = tailμ {-- >>> tailμ10 oneToTen [2, 3, 4, 5, 6, 7, 8, 9, 10] n.b.: the type of the value returned is List Int, not [Int] --}
geophf/1HaskellADay
exercises/HAD/Y2017/M06/D15/Solution.hs
mit
3,060
15
9
688
705
369
336
35
1
{-#LANGUAGE OverloadedStrings#-} module Yesod.Raml.Routes ( parseRamlRoutes , parseRamlRoutesFile , routesFromRaml , toYesodRoutes ) where import Yesod.Raml.Routes.Internal
junjihashimoto/yesod-raml
yesod-raml/Yesod/Raml/Routes.hs
mit
177
0
4
20
29
20
9
7
0
import Data.List numbers :: [Integer] numbers = [1500, 1765, 2364, 3345, 3700, 5934, 8313] batches :: [Integer] -> [[Integer]] batches xs = filter (not . null) . map (\(x, y) -> filter (\a -> a >= x && a < y) xs) . emptyBuckets $ xs emptyBuckets :: [Integer] -> [(Integer, Integer)] emptyBuckets = map (\x -> (x * 1000, (x + 1) * 1000)) . enumFromTo 0 . (`div` 1000) . maximum
adsmit14/haskell
Sandbox/bucketRanges.hs
mit
484
0
16
180
209
120
89
13
1
module Verifier (Result(..), Type(..), verify) where import Control.Exception.Base (handleJust) import Control.Monad.IO.Class (MonadIO, liftIO) import qualified Data.ByteString as BS (readFile) import Data.Digest.CRC32 (crc32) import Data.Functor ((<$>)) import Data.Word (Word32) import System.IO.Error (isDoesNotExistError) data Result = Result FilePath Type data Type = Ok | Missing | Invalid Word32 Word32 deriving (Eq, Show) calculateChecksum :: FilePath -> IO Word32 calculateChecksum = (crc32 <$>) . BS.readFile verify :: FilePath -> Word32 -> IO Result verify fp expected = liftIO $ Result fp <$> handleJust (\e -> if isDoesNotExistError e then Just Missing else Nothing) return (do actual <- calculateChecksum fp return $ if actual == expected then Ok else Invalid expected actual )
asvanberg/hsfv
Verifier.hs
mit
834
0
12
151
275
158
117
24
3
module Hafer.Export.Common.Dot ( module Hafer.Export.Common.Dot ) where -- ########################################################################## -- # Constants -- ########################################################################## cGRAPH_START = "digraph G {" cGRAPH_END = "}" cGENERAL_CONFIG = "fontname = \"Bitstream Vera Sans\";\ \ rankdir = \"RL\";\ \ fontsize = 8;" -- ########################################################################## -- # Escape functions -- ########################################################################## reservedWords = ["Graph", "Node", "Edge"] escape :: String -> String escape name = escapeReserved $ map escapeChar name escapeChar :: Char -> Char escapeChar c = case c of ' ' -> '_' '<' -> '_' '>' -> '_' ',' -> '_' '.' -> '_' '\\'-> '_' _ -> c escapeReserved :: String -> String escapeReserved word = case (elem word reservedWords) of True -> "_" ++ word False -> word escapeHTML :: String -> String escapeHTML word = concat $ map escapeHTMLChar word escapeHTMLChar :: Char -> String escapeHTMLChar c = case c of '<' -> "&lt;" '>' -> "&gt;" _ -> [c]
ooz/Hafer
src/Hafer/Export/Common/Dot.hs
mit
1,180
0
8
217
255
140
115
28
7
-- Problems/Problem040Spec.hs module Problems.Problem040Spec (main, spec) where import Test.Hspec import Problems.Problem040 main :: IO() main = hspec spec spec :: Spec spec = describe "Problem 40" $ it "Should evaluate to 210" $ p40 `shouldBe` 210
Sgoettschkes/learning
haskell/ProjectEuler/tests/Problems/Problem040Spec.hs
mit
264
0
8
51
73
41
32
9
1
-- Sum of Odd Cubed Numbers -- https://www.codewars.com/kata/580dda86c40fa6c45f00028a module OddCubed.JorgeVS.Kata where oddCubed :: [Int] -> Int oddCubed = sum . map (^3) . filter odd
gafiatulin/codewars
src/7 kyu/OddCubed.hs
mit
187
0
8
27
44
26
18
3
1
module Hickory.Graphics.Debug ( debugShape, debugShapeId, grabDebug, clearDebug, DebugShape(..), module Hickory.Color ) where import System.IO.Unsafe import Data.IORef import Hickory.Math.Vector import Hickory.Color import Linear (V3) data DebugShape = DebugVector (V3 Scalar) | DebugPoint (V3 Scalar) | DebugLine (V3 Scalar) (V3 Scalar) | DebugAngle Scalar {-# NOINLINE lst #-} lst :: IORef [(Color, String, DebugShape)] lst = unsafePerformIO $ newIORef [] colors = [rgb 1 1 0, rgb 0 1 1, rgb 1 0 1, rgb 1 1 1, rgb 1 0.7 0.4, rgb 1 0.4 0.7, rgb 0.7 1 0.4, rgb 0.7 0.4 1, rgb 0.4 1 0.7, rgb 0.4 0.7 1 ] addShape :: (String, DebugShape) -> [(Color, String, DebugShape)] -> [(Color, String, DebugShape)] addShape (label, shape) xs = if not $ any (\(_,l',_) -> label == l') xs then (colors !! length xs, label, shape) : xs else xs debugShape label s a = unsafePerformIO $ do modifyIORef lst (addShape (label, s)) return a debugShapeId label wrapper a = unsafePerformIO $ do modifyIORef lst (addShape (label, wrapper a)) return a grabDebug = readIORef lst clearDebug = writeIORef lst []
asivitz/Hickory
Hickory/Graphics/Debug.hs
mit
1,296
0
12
392
478
262
216
41
2
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeSynonymInstances #-} module IHaskell.Display.Widgets.Output ( -- * The Output Widget OutputWidget, -- * Constructor mkOutputWidget, -- * Using the output widget appendOutput, clearOutput, clearOutput_, replaceOutput, ) where -- To keep `cabal repl` happy when running from the ihaskell repo import Prelude import Data.Aeson import Data.IORef (newIORef) import IHaskell.Display import IHaskell.Eval.Widgets import IHaskell.IPython.Message.UUID as U import IHaskell.Display.Widgets.Types -- | An 'OutputWidget' represents a Output widget from IPython.html.widgets. type OutputWidget = IPythonWidget OutputType -- | Create a new output widget mkOutputWidget :: IO OutputWidget mkOutputWidget = do -- Default properties, with a random uuid uuid <- U.random let widgetState = WidgetState $ defaultDOMWidget "OutputView" "OutputModel" stateIO <- newIORef widgetState let widget = IPythonWidget uuid stateIO -- Open a comm for this widget, and store it in the kernel state widgetSendOpen widget $ toJSON widgetState -- Return the image widget return widget -- | Append to the output widget appendOutput :: IHaskellDisplay a => OutputWidget -> a -> IO () appendOutput widget out = do disp <- display out widgetPublishDisplay widget disp -- | Clear the output widget immediately clearOutput :: OutputWidget -> IO () clearOutput widget = widgetClearOutput widget False -- | Clear the output widget on next append clearOutput_ :: OutputWidget -> IO () clearOutput_ widget = widgetClearOutput widget True -- | Replace the currently displayed output for output widget replaceOutput :: IHaskellDisplay a => OutputWidget -> a -> IO () replaceOutput widget d = do clearOutput_ widget appendOutput widget d instance IHaskellDisplay OutputWidget where display b = do widgetSendView b return $ Display [] instance IHaskellWidget OutputWidget where getCommUUID = uuid
sumitsahrawat/IHaskell
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Output.hs
mit
2,128
0
11
441
386
202
184
45
1
{-# LANGUAGE IncoherentInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TemplateHaskell #-} module Jira.API.Types.Project where import Jira.API.Types.Avatar import Jira.API.Types.Classes import Control.Applicative import Control.Lens (makeLenses) import Data.Aeson type ProjectKey = String data ProjectIdentifier = ProjectId String | ProjectKey String deriving (Show, Eq) instance UrlIdentifier ProjectIdentifier where urlId (ProjectId s) = s urlId (ProjectKey s) = s instance ToJSON ProjectIdentifier where toJSON (ProjectId s) = object [ "id" .= s ] toJSON (ProjectKey s) = object [ "key" .= s ] data Project = Project { _pId :: String , _pKey :: String , _pName :: String , _pAvatars :: AvatarUrls } deriving (Eq, Show) instance FromJSON Project where parseJSON = withObject "Expected Object" $ \o -> Project <$> o .: "id" <*> o .: "key" <*> o .: "name" <*> o .: "avatarUrls" makeLenses ''Project
dsmatter/jira-api
src/Jira/API/Types/Project.hs
mit
1,194
0
15
415
277
154
123
31
0
module MAL.Types ( module MAL.Types.Common , module MAL.Types.Anime , module MAL.Types.Manga ) where import MAL.Types.Common import MAL.Types.Anime import MAL.Types.Manga
nyorem/skemmtun
src/MAL/Types.hs
mit
189
0
5
37
47
32
15
7
0
module Main where import qualified Web.MarkovBot.Main as MarkovBot main :: IO () main = MarkovBot.main
mgaut72/MarkovChain
markov-bot/Main.hs
mit
104
0
6
16
30
19
11
4
1
import Test.QuickCheck ------------------------------------------------------------------------------- -- Ejercicio 2 - intercambia ------------------------------------------------------------------------------- intercambia :: (a,b) -> (b,a) intercambia (a,b) = (b,a) ------------------------------------------------------------------------------- -- Ejercicio 3 - ordena2 y ordena3 ------------------------------------------------------------------------------- -- 3.a ordena2 :: Ord a => (a,a) -> (a,a) ordena2 (x,y) | y < x = (y,x) | otherwise = (x,y) p1_ordena2 x y = enOrden (ordena2 (x,y)) where enOrden (x,y) = x <= y p2_ordena2 x y = mismosElementos (x,y) (ordena2 (x,y)) where mismosElementos (x,y) (x',y') = (x == x' && y == y') || (x == y' && y == x') -- 3.b ordena3 :: Ord a => (a,a,a) -> (a,a,a) ordena3 (x,y,z) | x < y && y < z = (x,y,z) | y < x && x < z = (y,x,z) | z < x && x < y = (z,x,y) | x < z && z < y = (x,z,y) | otherwise = (y,z,x) ------------------------------------------------------------------------------- -- Ejercicio 4 - max2 ------------------------------------------------------------------------------- -- 4.a max2 :: Ord a => a -> a -> a max2 x y | x >= y = x | otherwise = y -- 4.b -- p1_max2: el máximo de dos números x e y coincide o bien con x o bien con y. p1_max2 x y = max2 x y == x || max2 x y == y -- p2_max2: el máximo de x e y es mayor o igual que x y mayor o igual que y. p2_max2 x y = x >= y || y <= x -- p3_max2: si x es mayor o igual que y, entonces el máximo de x e y es x. p3_max2 x y = if(x >= y) then x `max2` y == x else y -- p4_max2: si y es mayor o igual que x, entonces el máximo de x e y es y. p4_max2 x y = if(y >= x) then y `max2` x == y else x ------------------------------------------------------------------------------- -- Ejercicio 5 - entre (resuelto, se usa en el ejercicio 7) ------------------------------------------------------------------------------- entre :: Ord a => a -> (a, a) -> Bool entre x (inf,sup) = inf <= x && x <= sup ------------------------------------------------------------------------------- -- Ejercicio 7 - descomponer ------------------------------------------------------------------------------- -- Para este ejercicio nos interesa utilizar la función predefinida: -- -- divMod :: Integral a => a -> a -> (a, a) -- -- que calcula simultáneamente el cociente y el resto de la división entera: -- -- *Main> divMod 30 7 -- (4,2) -- 7.a type TotalSegundos = Integer type Horas = Integer type Minutos = Integer type Segundos = Integer descomponer :: TotalSegundos -> (Horas,Minutos,Segundos) descomponer x = (horas, minutos, segundos) where horas = x `div` 60 `div` 60 minutos = x `div` 60 `mod` 60 segundos = x `mod` 60 `mod` 60 -- 7.b p_descomponer x = x>=0 ==> h*3600 + m*60 + s == x && m `entre` (0,59) && s `entre` (0,59) where (h,m,s) = descomponer x ------------------------------------------------------------------------------- -- Ejercicio 14 - potencia ------------------------------------------------------------------------------- -- 14.a potencia :: Integer -> Integer -> Integer potencia b n | n == 0 = 1 | n == 1 = b | otherwise = b * potencia b (n-1) -- 14.b potencia' :: Integer -> Integer -> Integer potencia' b n | n == 0 = 1 | otherwise = imp * potencia' b (expo `div` 2) * potencia' b (expo `div` 2) where expo = if even n then n else n-1 imp = if even n then 1 else b -- 14.c p_pot b n = potencia b m == sol && potencia' b m == sol where sol = b^m m = abs n
Nachox07/ED-Haskell-Java
Practicas/QuickCheck/QuickCheck.hs
mit
3,825
0
15
940
1,146
641
505
-1
-1
module Algebraic.Nested.Roll where import Algebraic.Nested.Type import Algebraic.Nested.Op import Autolib.Pick import Autolib.ToDoc import qualified Data.Set as S import System.Random import Control.Applicative ((<$>)) roll :: Ord a => [a] -> Int -> IO (Type a) roll base size = if size < 1 then do action <- pick [ return $ Make $ S.empty , unit <$> pick base ] action else do sl <- randomRIO (0, size-1) let sr = size - 1 - sl l <- roll base sl r <- roll base sr return $ union l $ Make $ S.fromList [ Packed r ]
marcellussiegburg/autotool
collection/src/Algebraic/Nested/Roll.hs
gpl-2.0
567
0
12
148
234
122
112
19
2
{-# LANGUAGE DeriveDataTypeable, TemplateHaskell #-} module Baum.Such.Config where import Autolib.ToDoc import Autolib.Reader import Data.Typeable data Config a = -- use phantom type for baum Config { start_size :: Int , min_key :: a , max_key :: a , fixed_insert_ops :: Int , fixed_delete_ops :: Int , guess_insert_ops :: Int , guess_delete_ops :: Int } deriving ( Typeable ) $(derives [makeReader, makeToDoc] [''Config]) example :: Config Int example = Config { start_size = 10 , min_key = 0 , max_key = 1000 , fixed_insert_ops = 5 , fixed_delete_ops = 0 , guess_insert_ops = 5 , guess_delete_ops = 0 }
Erdwolf/autotool-bonn
src/Baum/Such/Config.hs
gpl-2.0
675
6
9
168
169
105
64
24
1
module InferenceSpec (spec) where import Test.Hspec import Language.Inference.Syntax import Language.Inference.Semantics import Data.Either spec :: Spec spec = do describe "infering types" $ do -- TODO: these tests are brittle due to the explicit numbering it "should infer the identity" $ do infer (TmAbs "x" (TmVar "x")) `shouldBe` Right (TyArr (TyVar 1) (TyVar 1)) it "should infer the church booleans" $ do infer (TmAbs "x" (TmAbs "y" (TmVar "x"))) `shouldBe` Right (TyArr (TyVar 1) (TyArr (TyVar 2) (TyVar 1))) it "should infer true" $ do infer TmTrue `shouldBe` Right TyBool it "should infer false" $ do infer TmFalse `shouldBe` Right TyBool it "should infer zero" $ do infer TmZero `shouldBe` Right TyNat it "should infer one" $ do infer (TmSucc TmZero) `shouldBe` Right TyNat it "should infer recursive function definitions" $ do infer (TmRec TmTrue (TmAbs "y" TmFalse)) `shouldBe` Right (TyArr TyNat TyBool) it "should infer the argument of an if statement" $ do infer (TmAbs "x" (TmIf (TmVar "x") TmZero (TmSucc (TmZero)))) `shouldBe` Right (TyArr TyBool TyNat) it "should infer the result of an if statement" $ do infer (TmAbs "x" (TmIf TmTrue (TmVar "x") TmZero)) `shouldBe` Right (TyArr TyNat TyNat) it "should correctly determine result of application" $ do infer (TmApp (TmAbs "x" (TmVar "x")) TmZero) `shouldBe` Right TyNat it "should correctly determine result of application of plus" $ do infer (TmApp (TmRec (TmAbs "x" (TmVar "x")) (TmAbs "f" (TmAbs "x" (TmSucc (TmApp (TmVar "f") (TmVar "x")))))) (TmSucc TmZero)) `shouldBe` Right (TyArr TyNat TyNat) describe "let" $ do it "should be polymorphic" $ do infer (TmLet "x" (TmAbs "x" (TmVar "x")) (TmIf (TmApp (TmVar "x") TmTrue) (TmApp (TmVar "x") TmZero) (TmApp (TmVar "x") (TmZero)))) `shouldBe` Right TyNat describe "invalid types" $ do it "should error if undefined variable" $ do infer (TmVar "x") `shouldSatisfy` isLeft
robertclancy/tapl
inference/tests/InferenceSpec.hs
gpl-2.0
2,301
0
28
703
780
375
405
36
1
-- Euler discovered the remarkable quadratic formula: -- -- n² + n + 41 -- -- It turns out that the formula will produce 40 primes for the consecutive values n = 0 to 39. However, when n = 40, 402 + 40 + 41 = 40(40 + 1) + 41 is divisible by 41, and certainly when n = 41, 41² + 41 + 41 is clearly divisible by 41. -- -- The incredible formula n² − 79n + 1601 was discovered, which produces 80 primes for the consecutive values n = 0 to 79. The product of the coefficients, −79 and 1601, is −126479. -- -- Considering quadratics of the form: -- -- n² + an + b, where |a| < 1000 and |b| < 1000 -- -- where |n| is the modulus/absolute value of n -- e.g. |11| = 11 and |−4| = 4 -- -- Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n = 0. import Prime import Data.Ord import Data.List main :: IO () main = print answer -- Pull out the third elt of the answer with the longest sequence -- that should -- be the answer answer :: Integer answer = third $ maximumBy (comparing fourth) answers -- Give a list of a,b,product of a & b and length of the longest sequence of primes answers :: [(Integer, Integer, Integer, Integer)] answers = [(a,b,a*b,toInteger $ length ps) | a <- [-1000..1000], b <- primeList, let ps = primesFor a b] where primeList = 0 : 1 : (primesTo 1000) -- Build a list of primes for n² + an + b primesFor :: Integer -> Integer -> [Integer] primesFor a b = takeWhile primeOrZero $ map (\n -> (n^2) + (a*n) + b) [1..max a b] where primeOrZero n = (n==0) || (prime $ abs n) -- Convenience functions for grabbng bits from tuples third :: (b,b,a,b) -> a third (_,_,x,_) = x fourth :: (b,b,b,a) -> a fourth (_,_,_,x) = x
ciderpunx/project_euler_in_haskell
euler027.hs
gpl-2.0
1,806
0
12
400
379
219
160
19
1
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Model.Event ( Event (..) ) where import Data.Aeson import GHC.Generics import Test.QuickCheck import Model.Number data Event = Event { eventType :: Number , activationTime :: Float } deriving (Show, Eq, Generic) instance FromJSON Event instance ToJSON Event instance Arbitrary Event where arbitrary = Event <$> arbitrary <*> arbitrary
massimo-zaniboni/netrobots
robot_examples/haskell-servant/rest_api/lib/Model/Event.hs
gpl-3.0
539
0
8
98
111
65
46
19
0
{-# LANGUAGE Arrows, OverloadedStrings, LambdaCase #-} module Utils.Yukari.Parser (parsePage, parseYenPage) where import Control.Applicative import Control.Lens hiding (deep) import qualified Data.Attoparsec.Text as A import Data.Char import Data.List import Data.Maybe (mapMaybe, fromMaybe) import Data.Text (pack, unpack, split, Text) import qualified Data.Text as T import Data.Tree.NTree.TypeDefs import Text.HandsomeSoup import Text.Read (readMaybe) import Text.XML.HXT.Core import Utils.Yukari.Settings import Utils.Yukari.Types parseAnimeInfo :: String -> Information parseAnimeInfo info = AnimeInformation AnimeInfo { _releaseFormat = parseFormat info , _videoContainer = parseContainer info , _animeCodec = parseCodec info , _subtitles = parseSubs info , _resolution = parseResolution info , _audio = parseAudio info } parseCodec :: String -> Maybe AnimeCodec parseCodec info = let i' = splitInfoS info in if length i' >= 3 then let c = i' !! 2 in case () of _ | "WMV" `isInfixOf` c -> Just WMV_ | "Hi10P" `isInfixOf` c -> Just H264HI10P | "h264" `isInfixOf` c -> Just H264 | "ISO" `isInfixOf` info -> readMaybe $ head i' | otherwise -> readMaybe c else Nothing parseMangaInfo :: String -> Information parseMangaInfo info = MangaInformation MangaInfo { _scanlated = "Scanlated" `isInfixOf` info , _archived = not $ "Unarchived" `isInfixOf` info , _ongoing = "Ongoing" `isInfixOf` info } parseContainer :: String -> Maybe AnimeContainer parseContainer info = let i' = splitInfoS info in if length i' >= 2 then let c = head $ tail i' in case () of _ | "ISO" `isInfixOf` c -> Just ISO | "VOB" `isInfixOf` c -> Just VOB | "M2TS" `isInfixOf` c -> Just M2TS | otherwise -> readMaybe c else Nothing parseAudio :: String -> Audio parseAudio s | "| MP3" `isInfixOf` s = MP3 | "| FLAC" `isInfixOf` s = FLAC | "| AAC" `isInfixOf` s = AAC | "| AC" `isInfixOf` s = AC | "| PCM" `isInfixOf` s = MP3 | otherwise = fromMaybe (OtherAudio s) $ dts s where dts :: String -> Maybe Audio dts [] = Nothing dts s'@(_:xs) | "| DTS " `isPrefixOf` s' = Just . DTS . takeWhile (/= ' ') $ drop (length ("| DTS " :: String)) s' | otherwise = dts xs parseFormat :: String -> Maybe ReleaseFormat parseFormat info = case splitInfoS info of [] -> Nothing x:_ | "DVD" `isInfixOf` x -> Just DVD | otherwise -> readMaybe x parseSubs :: String -> Subtitles parseSubs info | "RAW" `isInfixOf` sub = RAW | "Softsubs" `isInfixOf` sub = Softsub $ extractParens sub | "Hardsubs" `isInfixOf` sub = Hardsub $ extractParens sub | otherwise = UnknownSubs where sub = extractSubs info extractParens x = if '(' `elem` x then init $ tail $ dropWhile (/= '(') x else "" safeApply :: ([t] -> [a]) -> [t] -> [a] safeApply _ [] = [] safeApply f xs = f xs anyInfix :: String -> [String] -> Bool anyInfix x = any (`isInfixOf` x) extractSubs :: String -> String extractSubs x = let xs = filter (`anyInfix` ["Hardsubs", "Softsubs", "RAW"]) $ splitInfoS x in safeApply last xs splitsize :: String -> (Double, String) splitsize s = (read $ head as, head $ tail as) where as = map unpack $ split (== ' ') (pack s) sizeToBytes :: String -> Integer sizeToBytes size = round $ s * 1024 ^ getExp m where (s, m) = splitsize $ delete ',' size getExp :: String -> Int getExp n = fst . head . filter (\(_, u) -> n == u) $ zip [0, 1..] ["B", "KB", "MB" , "GB", "TB", "PB"] stripeg :: Char -> String -> String stripeg t = reverse . takeWhile (/= t) . reverse stripeq :: String -> String stripeq = stripeg '=' stripID :: String -> Integer stripID = read . stripeq parseResolution :: String -> Maybe Resolution parseResolution = either (const Nothing) Just . A.parseOnly r . pack where r :: A.Parser Resolution r = pp <|> reg <|> (A.anyChar *> r) pp = "480p" *> return (Resolution 640 480) <|> "720p" *> return (Resolution 1280 720) <|> "1080p" *> return (Resolution 1920 1080) reg = Resolution <$> A.decimal <* "x" <*> A.decimal splitInfoS :: String -> [String] splitInfoS = map unpack . splitInfo . pack splitInfo :: Text -> [Text] splitInfo = filter (not . T.null) . map dropOuterSpaces . split (== '|') dropOuterSpaces :: Text -> Text dropOuterSpaces = T.dropWhile (== ' ') . T.dropWhileEnd (== ' ') nameAttr :: ArrowXml cat => String -> String -> (t -> String -> Bool) -> t -> cat (NTree XNode) XmlTree nameAttr name attrV p comp = deep (hasName name) >>> hasAttrValue attrV (p comp) nAt :: ArrowXml cat => String -> cat (NTree XNode) XmlTree nAt = nameAttr "span" "class" (==) gTit :: ArrowXml cat => cat (NTree XNode) XmlTree gTit = nAt "group_title" (.<) :: ArrowList a => ([c] -> d) -> a b c -> a b d (.<) = flip (>.) (<\\) :: (ArrowTree a, Tree t) => a (t c) d -> a b (t c) -> a b d (<\\) = flip (//>) getTorrent :: ArrowXml cat => YukariSettings -> cat (NTree XNode) ABTorrent getTorrent ys = nameAttr "tr" "class" isInfixOf "torrent " >>> proc x -> do tID <- getAttrValue "id" -< x tInfSuf <- concat .< (deep getText <<< processTopDown (filterA . neg $ hasName "img") <<< hasAttrValue "href" infixIds <<< tda) -< x tLink <- hasAttrValue "href" infixIds ! "href" <<< tda -< x tDown <- css "a" ! "href" <<< getCssAttr "a" "title" "Download" -< x tstch <- getTorP "torrent_snatched" -< x tlchr <- getTorP "torrent_leechers" -< x tsdr <- getTorP "torrent_seeders" -< x tsize <- getTorP "torrent_size" -< x returnA -< ABTorrent { _torrentID = read $ stripeg '_' tID , _torrentURI = mainpage tLink , _torrentDownloadURI = mainpage tDown , _torrentInfoSuffix = dropWs tInfSuf , _torrentInfo = Nothing , _torrentSnatched = read tstch , _torrentLeechers = read tlchr , _torrentSeeders = read tsdr , _torrentSize = sizeToBytes tsize } where infixIds x = "php?id=" `isInfixOf` x && "torrentid=" `isInfixOf` x mainpage x = ys ^. siteSettings . baseSite ++ "/" ++ x getTorP x = getCssAttr "td" "class" x >>> deep getText getCssAttr t a eq = css t >>> hasAttrValue a (== eq) tda = deep (hasName "td") >>> deep (hasName "a") dropWs ('\t':xs) = dropWs xs dropWs ('\n':xs) = dropWs xs dropWs xs = xs extractTorrentGroups :: ArrowXml cat => cat a (NTree XNode) -> YukariSettings -> cat a ABTorrentGroup extractTorrentGroups doc ys = doc //> css "div" >>> havp "class" "group_cont" >>> proc x -> do cat <- nameAttr "span" "class" (==) "cat" >>> css "a" /> getText -< x img <- css "img" ! "src" <<< nAt "mainimg" -< x serID <- havp "href" "series.php" ! "href" <<< css "a" <<< gTit -< x grID <- havp "href" "torrents.php" ! "href" <<< css "a" <<< gTit -< x title <- havpa "series" /> getText -< x tags <- listA $ css "a" ! "href" <<< hasAttrValue "class" (== "tags_sm") <<< multi (hasName "div") -< x tors <- listA (getTorrent ys) <<< hasAttrValue "class" (== "torrent_group") <<< multi (hasName "table") -< x let cat' = parseCategory cat returnA -< ABTorrentGroup { _torrentName = title , _torrentCategory = cat' , _seriesID = stripID serID , _groupID = stripID grID , _torrentImageURI = img , _torrentTags = map stripeq tags , _torrents = [attachInfo x' . parseInfo cat' $ _torrentInfoSuffix x' | x' <- tors] } where havp atr content = hasAttrValue atr $ isInfixOf content havpa page = havp "href" (page ++ ".php") <<< css "a" <<< gTit attachInfo t i = t & torrentInfo .~ i parseInfo :: Maybe Category -> String -> Maybe Information parseInfo (Just Anime) suf = Just $ parseAnimeInfo suf parseInfo (Just LiveAction) suf = Just $ parseAnimeInfo suf parseInfo (Just LiveActionSeries) suf = Just $ parseAnimeInfo suf parseInfo (Just (Manga _)) suf = Just $ parseMangaInfo suf parseInfo _ _ = Nothing extractNextPage :: (ArrowXml cat, ArrowChoice cat) => cat a (NTree XNode) -> cat a String extractNextPage doc = doc /> css "div" >>> hasAttrValue "class" (== "pages") >>> css "a" >>> proc e -> do t <- deep getText -< e if "Next" `isInfixOf` t then getAttrValue "href" -< e else zeroArrow -< () parsePage :: YukariSettings -> String -> IO (String, [ABTorrentGroup]) parsePage ys html = do let doc = parseHtml html site = ys ^. siteSettings . baseSite n <- runX $ extractNextPage doc gs <- runX $ extractTorrentGroups doc ys let next = safeApply (\x -> site ++ "/" ++ head x) n gs' = filter (ys ^. siteSettings . groupFilterFunc) gs return (next, map (ys ^. siteSettings . groupPreprocessor) gs') parseYenPage :: String -> IO YenPage parseYenPage body = do let doc = parseHtml body yen <- runX $ doc //> hasAttrValue "href" (== "/konbini.php") /> getText links <- runX $ doc //> hasName "a" ! "href" >>. filter isExchange return YenPage { _yenOwned = yenToInt $ head yen , _spendingLinks = mapMaybe linksToCostLinks links } where yenToInt = read . reverse . takeWhile isDigit . reverse . filter (/= ',') isExchange = isInfixOf "action=exchange" linksToCostLinks x | "trade=1" `isInfixOf` x = Just (1000, x) | "trade=2" `isInfixOf` x = Just (10000, x) | "trade=3" `isInfixOf` x = Just (100000, x) | "trade=4" `isInfixOf` x = Just (1000000, x) | otherwise = Nothing parseCategory :: String -> Maybe Category parseCategory cat | cat `elem` [ "Single", "Soundtrack" , "DVD", "Live", "PV" , "Live Album" , "Compilation", "Album" , "Drama CD", "EP"] = Music <$> readMaybe cat | cat == "Remix CD" = Just $ Music RemixCD | cat `elem` [ "Manga", "Oneshot", "Manhua" , "Manhwa", "OEL"] = if cat == "Manga" then Just $ Manga GenericManga else Manga <$> readMaybe cat | cat == "Visual Novel" = Just VisualNovel | cat == "Light Novel" = Just LightNovel | cat == "Live Action Movie" = Just LiveAction | cat == "Live Action TV Series" = Just LiveActionSeries | cat == "Game Guide" = Just GameGuide | otherwise = readMaybe cat
Fuuzetsu/yukari
src/Utils/Yukari/Parser.hs
gpl-3.0
11,360
3
19
3,589
3,880
1,976
1,904
-1
-1
module Sound.Tidal.Config where {- Config.hs - For default Tidal configuration values. Copyright (C) 2020, Alex McLean and contributors This library 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 3 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this library. If not, see <http://www.gnu.org/licenses/>. -} data Config = Config {cCtrlListen :: Bool, cCtrlAddr :: String, cCtrlPort :: Int, cFrameTimespan :: Double, cTempoAddr :: String, cTempoPort :: Int, cTempoClientPort :: Int, cSkipTicks :: Int, cVerbose :: Bool } defaultConfig :: Config defaultConfig = Config {cCtrlListen = True, cCtrlAddr ="127.0.0.1", cCtrlPort = 6010, cFrameTimespan = 1/20, cTempoAddr = "127.0.0.1", cTempoPort = 9160, cTempoClientPort = 0, -- choose at random cSkipTicks = 10, cVerbose = True }
bgold-cosmos/Tidal
src/Sound/Tidal/Config.hs
gpl-3.0
1,682
0
8
655
142
93
49
20
1
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- | -- Module : Network.Google.ServiceNetworking.Types.Product -- 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) -- module Network.Google.ServiceNetworking.Types.Product where import Network.Google.Prelude import Network.Google.ServiceNetworking.Types.Sum -- | Represents a subnet that was created or discovered by a private access -- management service. -- -- /See:/ 'googleCloudServicenetworkingV1betaSubnetwork' smart constructor. data GoogleCloudServicenetworkingV1betaSubnetwork = GoogleCloudServicenetworkingV1betaSubnetwork' { _gcsvsOutsideAllocation :: !(Maybe Bool) , _gcsvsNetwork :: !(Maybe Text) , _gcsvsName :: !(Maybe Text) , _gcsvsIPCIdRRange :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'GoogleCloudServicenetworkingV1betaSubnetwork' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'gcsvsOutsideAllocation' -- -- * 'gcsvsNetwork' -- -- * 'gcsvsName' -- -- * 'gcsvsIPCIdRRange' googleCloudServicenetworkingV1betaSubnetwork :: GoogleCloudServicenetworkingV1betaSubnetwork googleCloudServicenetworkingV1betaSubnetwork = GoogleCloudServicenetworkingV1betaSubnetwork' { _gcsvsOutsideAllocation = Nothing , _gcsvsNetwork = Nothing , _gcsvsName = Nothing , _gcsvsIPCIdRRange = Nothing } -- | This is a discovered subnet that is not within the current consumer -- allocated ranges. gcsvsOutsideAllocation :: Lens' GoogleCloudServicenetworkingV1betaSubnetwork (Maybe Bool) gcsvsOutsideAllocation = lens _gcsvsOutsideAllocation (\ s a -> s{_gcsvsOutsideAllocation = a}) -- | In the Shared VPC host project, the VPC network that\'s peered with the -- consumer network. For example: -- \`projects\/1234321\/global\/networks\/host-network\` gcsvsNetwork :: Lens' GoogleCloudServicenetworkingV1betaSubnetwork (Maybe Text) gcsvsNetwork = lens _gcsvsNetwork (\ s a -> s{_gcsvsNetwork = a}) -- | Subnetwork name. See https:\/\/cloud.google.com\/compute\/docs\/vpc\/ gcsvsName :: Lens' GoogleCloudServicenetworkingV1betaSubnetwork (Maybe Text) gcsvsName = lens _gcsvsName (\ s a -> s{_gcsvsName = a}) -- | Subnetwork CIDR range in \`10.x.x.x\/y\` format. gcsvsIPCIdRRange :: Lens' GoogleCloudServicenetworkingV1betaSubnetwork (Maybe Text) gcsvsIPCIdRRange = lens _gcsvsIPCIdRRange (\ s a -> s{_gcsvsIPCIdRRange = a}) instance FromJSON GoogleCloudServicenetworkingV1betaSubnetwork where parseJSON = withObject "GoogleCloudServicenetworkingV1betaSubnetwork" (\ o -> GoogleCloudServicenetworkingV1betaSubnetwork' <$> (o .:? "outsideAllocation") <*> (o .:? "network") <*> (o .:? "name") <*> (o .:? "ipCidrRange")) instance ToJSON GoogleCloudServicenetworkingV1betaSubnetwork where toJSON GoogleCloudServicenetworkingV1betaSubnetwork'{..} = object (catMaybes [("outsideAllocation" .=) <$> _gcsvsOutsideAllocation, ("network" .=) <$> _gcsvsNetwork, ("name" .=) <$> _gcsvsName, ("ipCidrRange" .=) <$> _gcsvsIPCIdRRange]) -- | Specifies a location to extract JWT from an API request. -- -- /See:/ 'jwtLocation' smart constructor. data JwtLocation = JwtLocation' { _jlValuePrefix :: !(Maybe Text) , _jlHeader :: !(Maybe Text) , _jlQuery :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'JwtLocation' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'jlValuePrefix' -- -- * 'jlHeader' -- -- * 'jlQuery' jwtLocation :: JwtLocation jwtLocation = JwtLocation' {_jlValuePrefix = Nothing, _jlHeader = Nothing, _jlQuery = Nothing} -- | The value prefix. The value format is \"value_prefix{token}\" Only -- applies to \"in\" header type. Must be empty for \"in\" query type. If -- not empty, the header value has to match (case sensitive) this prefix. -- If not matched, JWT will not be extracted. If matched, JWT will be -- extracted after the prefix is removed. For example, for \"Authorization: -- Bearer {JWT}\", value_prefix=\"Bearer \" with a space at the end. jlValuePrefix :: Lens' JwtLocation (Maybe Text) jlValuePrefix = lens _jlValuePrefix (\ s a -> s{_jlValuePrefix = a}) -- | Specifies HTTP header name to extract JWT token. jlHeader :: Lens' JwtLocation (Maybe Text) jlHeader = lens _jlHeader (\ s a -> s{_jlHeader = a}) -- | Specifies URL query parameter name to extract JWT token. jlQuery :: Lens' JwtLocation (Maybe Text) jlQuery = lens _jlQuery (\ s a -> s{_jlQuery = a}) instance FromJSON JwtLocation where parseJSON = withObject "JwtLocation" (\ o -> JwtLocation' <$> (o .:? "valuePrefix") <*> (o .:? "header") <*> (o .:? "query")) instance ToJSON JwtLocation where toJSON JwtLocation'{..} = object (catMaybes [("valuePrefix" .=) <$> _jlValuePrefix, ("header" .=) <$> _jlHeader, ("query" .=) <$> _jlQuery]) -- | Metadata provided through GetOperation request for the LRO generated by -- RemoveDnsZone API -- -- /See:/ 'removeDNSZoneMetadata' smart constructor. data RemoveDNSZoneMetadata = RemoveDNSZoneMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RemoveDNSZoneMetadata' with the minimum fields required to make a request. -- removeDNSZoneMetadata :: RemoveDNSZoneMetadata removeDNSZoneMetadata = RemoveDNSZoneMetadata' instance FromJSON RemoveDNSZoneMetadata where parseJSON = withObject "RemoveDNSZoneMetadata" (\ o -> pure RemoveDNSZoneMetadata') instance ToJSON RemoveDNSZoneMetadata where toJSON = const emptyObject -- | Define a parameter\'s name and location. The parameter may be passed as -- either an HTTP header or a URL query parameter, and if both are passed -- the behavior is implementation-dependent. -- -- /See:/ 'systemParameter' smart constructor. data SystemParameter = SystemParameter' { _spHTTPHeader :: !(Maybe Text) , _spURLQueryParameter :: !(Maybe Text) , _spName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SystemParameter' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'spHTTPHeader' -- -- * 'spURLQueryParameter' -- -- * 'spName' systemParameter :: SystemParameter systemParameter = SystemParameter' {_spHTTPHeader = Nothing, _spURLQueryParameter = Nothing, _spName = Nothing} -- | Define the HTTP header name to use for the parameter. It is case -- insensitive. spHTTPHeader :: Lens' SystemParameter (Maybe Text) spHTTPHeader = lens _spHTTPHeader (\ s a -> s{_spHTTPHeader = a}) -- | Define the URL query parameter name to use for the parameter. It is case -- sensitive. spURLQueryParameter :: Lens' SystemParameter (Maybe Text) spURLQueryParameter = lens _spURLQueryParameter (\ s a -> s{_spURLQueryParameter = a}) -- | Define the name of the parameter, such as \"api_key\" . It is case -- sensitive. spName :: Lens' SystemParameter (Maybe Text) spName = lens _spName (\ s a -> s{_spName = a}) instance FromJSON SystemParameter where parseJSON = withObject "SystemParameter" (\ o -> SystemParameter' <$> (o .:? "httpHeader") <*> (o .:? "urlQueryParameter") <*> (o .:? "name")) instance ToJSON SystemParameter where toJSON SystemParameter'{..} = object (catMaybes [("httpHeader" .=) <$> _spHTTPHeader, ("urlQueryParameter" .=) <$> _spURLQueryParameter, ("name" .=) <$> _spName]) -- | An object that describes the schema of a MonitoredResource object using -- a type name and a set of labels. For example, the monitored resource -- descriptor for Google Compute Engine VM instances has a type of -- \`\"gce_instance\"\` and specifies the use of the labels -- \`\"instance_id\"\` and \`\"zone\"\` to identify particular VM -- instances. Different APIs can support different monitored resource -- types. APIs generally provide a \`list\` method that returns the -- monitored resource descriptors used by the API. -- -- /See:/ 'monitoredResourceDescriptor' smart constructor. data MonitoredResourceDescriptor = MonitoredResourceDescriptor' { _mrdName :: !(Maybe Text) , _mrdDisplayName :: !(Maybe Text) , _mrdLabels :: !(Maybe [LabelDescriptor]) , _mrdType :: !(Maybe Text) , _mrdDescription :: !(Maybe Text) , _mrdLaunchStage :: !(Maybe MonitoredResourceDescriptorLaunchStage) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'MonitoredResourceDescriptor' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mrdName' -- -- * 'mrdDisplayName' -- -- * 'mrdLabels' -- -- * 'mrdType' -- -- * 'mrdDescription' -- -- * 'mrdLaunchStage' monitoredResourceDescriptor :: MonitoredResourceDescriptor monitoredResourceDescriptor = MonitoredResourceDescriptor' { _mrdName = Nothing , _mrdDisplayName = Nothing , _mrdLabels = Nothing , _mrdType = Nothing , _mrdDescription = Nothing , _mrdLaunchStage = Nothing } -- | Optional. The resource name of the monitored resource descriptor: -- \`\"projects\/{project_id}\/monitoredResourceDescriptors\/{type}\"\` -- where {type} is the value of the \`type\` field in this object and -- {project_id} is a project ID that provides API-specific context for -- accessing the type. APIs that do not use project information can use the -- resource name format \`\"monitoredResourceDescriptors\/{type}\"\`. mrdName :: Lens' MonitoredResourceDescriptor (Maybe Text) mrdName = lens _mrdName (\ s a -> s{_mrdName = a}) -- | Optional. A concise name for the monitored resource type that might be -- displayed in user interfaces. It should be a Title Cased Noun Phrase, -- without any article or other determiners. For example, \`\"Google Cloud -- SQL Database\"\`. mrdDisplayName :: Lens' MonitoredResourceDescriptor (Maybe Text) mrdDisplayName = lens _mrdDisplayName (\ s a -> s{_mrdDisplayName = a}) -- | Required. A set of labels used to describe instances of this monitored -- resource type. For example, an individual Google Cloud SQL database is -- identified by values for the labels \`\"database_id\"\` and -- \`\"zone\"\`. mrdLabels :: Lens' MonitoredResourceDescriptor [LabelDescriptor] mrdLabels = lens _mrdLabels (\ s a -> s{_mrdLabels = a}) . _Default . _Coerce -- | Required. The monitored resource type. For example, the type -- \`\"cloudsql_database\"\` represents databases in Google Cloud SQL. mrdType :: Lens' MonitoredResourceDescriptor (Maybe Text) mrdType = lens _mrdType (\ s a -> s{_mrdType = a}) -- | Optional. A detailed description of the monitored resource type that -- might be used in documentation. mrdDescription :: Lens' MonitoredResourceDescriptor (Maybe Text) mrdDescription = lens _mrdDescription (\ s a -> s{_mrdDescription = a}) -- | Optional. The launch stage of the monitored resource definition. mrdLaunchStage :: Lens' MonitoredResourceDescriptor (Maybe MonitoredResourceDescriptorLaunchStage) mrdLaunchStage = lens _mrdLaunchStage (\ s a -> s{_mrdLaunchStage = a}) instance FromJSON MonitoredResourceDescriptor where parseJSON = withObject "MonitoredResourceDescriptor" (\ o -> MonitoredResourceDescriptor' <$> (o .:? "name") <*> (o .:? "displayName") <*> (o .:? "labels" .!= mempty) <*> (o .:? "type") <*> (o .:? "description") <*> (o .:? "launchStage")) instance ToJSON MonitoredResourceDescriptor where toJSON MonitoredResourceDescriptor'{..} = object (catMaybes [("name" .=) <$> _mrdName, ("displayName" .=) <$> _mrdDisplayName, ("labels" .=) <$> _mrdLabels, ("type" .=) <$> _mrdType, ("description" .=) <$> _mrdDescription, ("launchStage" .=) <$> _mrdLaunchStage]) -- -- /See:/ 'secondaryIPRange' smart constructor. data SecondaryIPRange = SecondaryIPRange' { _sirRangeName :: !(Maybe Text) , _sirIPCIdRRange :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SecondaryIPRange' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sirRangeName' -- -- * 'sirIPCIdRRange' secondaryIPRange :: SecondaryIPRange secondaryIPRange = SecondaryIPRange' {_sirRangeName = Nothing, _sirIPCIdRRange = Nothing} -- | Name of the secondary IP range. sirRangeName :: Lens' SecondaryIPRange (Maybe Text) sirRangeName = lens _sirRangeName (\ s a -> s{_sirRangeName = a}) -- | Secondary IP CIDR range in \`x.x.x.x\/y\` format. sirIPCIdRRange :: Lens' SecondaryIPRange (Maybe Text) sirIPCIdRRange = lens _sirIPCIdRRange (\ s a -> s{_sirIPCIdRRange = a}) instance FromJSON SecondaryIPRange where parseJSON = withObject "SecondaryIPRange" (\ o -> SecondaryIPRange' <$> (o .:? "rangeName") <*> (o .:? "ipCidrRange")) instance ToJSON SecondaryIPRange where toJSON SecondaryIPRange'{..} = object (catMaybes [("rangeName" .=) <$> _sirRangeName, ("ipCidrRange" .=) <$> _sirIPCIdRRange]) -- | Request to enable VPC service controls. -- -- /See:/ 'enableVPCServiceControlsRequest' smart constructor. newtype EnableVPCServiceControlsRequest = EnableVPCServiceControlsRequest' { _evscrConsumerNetwork :: Maybe Text } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'EnableVPCServiceControlsRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'evscrConsumerNetwork' enableVPCServiceControlsRequest :: EnableVPCServiceControlsRequest enableVPCServiceControlsRequest = EnableVPCServiceControlsRequest' {_evscrConsumerNetwork = Nothing} -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is a project -- number, as in \'12345\' {network} is network name. evscrConsumerNetwork :: Lens' EnableVPCServiceControlsRequest (Maybe Text) evscrConsumerNetwork = lens _evscrConsumerNetwork (\ s a -> s{_evscrConsumerNetwork = a}) instance FromJSON EnableVPCServiceControlsRequest where parseJSON = withObject "EnableVPCServiceControlsRequest" (\ o -> EnableVPCServiceControlsRequest' <$> (o .:? "consumerNetwork")) instance ToJSON EnableVPCServiceControlsRequest where toJSON EnableVPCServiceControlsRequest'{..} = object (catMaybes [("consumerNetwork" .=) <$> _evscrConsumerNetwork]) -- | ListConnectionsResponse is the response to list peering states for the -- given service and consumer project. -- -- /See:/ 'listConnectionsResponse' smart constructor. newtype ListConnectionsResponse = ListConnectionsResponse' { _lcrConnections :: Maybe [Connection] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ListConnectionsResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lcrConnections' listConnectionsResponse :: ListConnectionsResponse listConnectionsResponse = ListConnectionsResponse' {_lcrConnections = Nothing} -- | The list of Connections. lcrConnections :: Lens' ListConnectionsResponse [Connection] lcrConnections = lens _lcrConnections (\ s a -> s{_lcrConnections = a}) . _Default . _Coerce instance FromJSON ListConnectionsResponse where parseJSON = withObject "ListConnectionsResponse" (\ o -> ListConnectionsResponse' <$> (o .:? "connections" .!= mempty)) instance ToJSON ListConnectionsResponse where toJSON ListConnectionsResponse'{..} = object (catMaybes [("connections" .=) <$> _lcrConnections]) -- | A documentation rule provides information about individual API elements. -- -- /See:/ 'documentationRule' smart constructor. data DocumentationRule = DocumentationRule' { _drSelector :: !(Maybe Text) , _drDeprecationDescription :: !(Maybe Text) , _drDescription :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DocumentationRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'drSelector' -- -- * 'drDeprecationDescription' -- -- * 'drDescription' documentationRule :: DocumentationRule documentationRule = DocumentationRule' { _drSelector = Nothing , _drDeprecationDescription = Nothing , _drDescription = Nothing } -- | The selector is a comma-separated list of patterns for any element such -- as a method, a field, an enum value. Each pattern is a qualified name of -- the element which may end in \"*\", indicating a wildcard. Wildcards are -- only allowed at the end and for a whole component of the qualified name, -- i.e. \"foo.*\" is ok, but not \"foo.b*\" or \"foo.*.bar\". A wildcard -- will match one or more components. To specify a default for all -- applicable elements, the whole pattern \"*\" is used. drSelector :: Lens' DocumentationRule (Maybe Text) drSelector = lens _drSelector (\ s a -> s{_drSelector = a}) -- | Deprecation description of the selected element(s). It can be provided -- if an element is marked as \`deprecated\`. drDeprecationDescription :: Lens' DocumentationRule (Maybe Text) drDeprecationDescription = lens _drDeprecationDescription (\ s a -> s{_drDeprecationDescription = a}) -- | The description is the comment in front of the selected proto element, -- such as a message, a method, a \'service\' definition, or a field. drDescription :: Lens' DocumentationRule (Maybe Text) drDescription = lens _drDescription (\ s a -> s{_drDescription = a}) instance FromJSON DocumentationRule where parseJSON = withObject "DocumentationRule" (\ o -> DocumentationRule' <$> (o .:? "selector") <*> (o .:? "deprecationDescription") <*> (o .:? "description")) instance ToJSON DocumentationRule where toJSON DocumentationRule'{..} = object (catMaybes [("selector" .=) <$> _drSelector, ("deprecationDescription" .=) <$> _drDeprecationDescription, ("description" .=) <$> _drDescription]) -- | The \`Status\` type defines a logical error model that is suitable for -- different programming environments, including REST APIs and RPC APIs. It -- is used by [gRPC](https:\/\/github.com\/grpc). Each \`Status\` message -- contains three pieces of data: error code, error message, and error -- details. You can find out more about this error model and how to work -- with it in the [API Design -- Guide](https:\/\/cloud.google.com\/apis\/design\/errors). -- -- /See:/ 'status' smart constructor. data Status = Status' { _sDetails :: !(Maybe [StatusDetailsItem]) , _sCode :: !(Maybe (Textual Int32)) , _sMessage :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Status' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sDetails' -- -- * 'sCode' -- -- * 'sMessage' status :: Status status = Status' {_sDetails = Nothing, _sCode = Nothing, _sMessage = Nothing} -- | A list of messages that carry the error details. There is a common set -- of message types for APIs to use. sDetails :: Lens' Status [StatusDetailsItem] sDetails = lens _sDetails (\ s a -> s{_sDetails = a}) . _Default . _Coerce -- | The status code, which should be an enum value of google.rpc.Code. sCode :: Lens' Status (Maybe Int32) sCode = lens _sCode (\ s a -> s{_sCode = a}) . mapping _Coerce -- | A developer-facing error message, which should be in English. Any -- user-facing error message should be localized and sent in the -- google.rpc.Status.details field, or localized by the client. sMessage :: Lens' Status (Maybe Text) sMessage = lens _sMessage (\ s a -> s{_sMessage = a}) instance FromJSON Status where parseJSON = withObject "Status" (\ o -> Status' <$> (o .:? "details" .!= mempty) <*> (o .:? "code") <*> (o .:? "message")) instance ToJSON Status where toJSON Status'{..} = object (catMaybes [("details" .=) <$> _sDetails, ("code" .=) <$> _sCode, ("message" .=) <$> _sMessage]) -- | Configuration information for a private service access connection. -- -- /See:/ 'consumerConfig' smart constructor. data ConsumerConfig = ConsumerConfig' { _ccProducerExportCustomRoutes :: !(Maybe Bool) , _ccConsumerImportSubnetRoutesWithPublicIP :: !(Maybe Bool) , _ccReservedRanges :: !(Maybe [GoogleCloudServicenetworkingV1ConsumerConfigReservedRange]) , _ccConsumerExportCustomRoutes :: !(Maybe Bool) , _ccVPCScReferenceArchitectureEnabled :: !(Maybe Bool) , _ccProducerNetwork :: !(Maybe Text) , _ccProducerImportCustomRoutes :: !(Maybe Bool) , _ccProducerExportSubnetRoutesWithPublicIP :: !(Maybe Bool) , _ccConsumerImportCustomRoutes :: !(Maybe Bool) , _ccProducerImportSubnetRoutesWithPublicIP :: !(Maybe Bool) , _ccConsumerExportSubnetRoutesWithPublicIP :: !(Maybe Bool) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ConsumerConfig' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ccProducerExportCustomRoutes' -- -- * 'ccConsumerImportSubnetRoutesWithPublicIP' -- -- * 'ccReservedRanges' -- -- * 'ccConsumerExportCustomRoutes' -- -- * 'ccVPCScReferenceArchitectureEnabled' -- -- * 'ccProducerNetwork' -- -- * 'ccProducerImportCustomRoutes' -- -- * 'ccProducerExportSubnetRoutesWithPublicIP' -- -- * 'ccConsumerImportCustomRoutes' -- -- * 'ccProducerImportSubnetRoutesWithPublicIP' -- -- * 'ccConsumerExportSubnetRoutesWithPublicIP' consumerConfig :: ConsumerConfig consumerConfig = ConsumerConfig' { _ccProducerExportCustomRoutes = Nothing , _ccConsumerImportSubnetRoutesWithPublicIP = Nothing , _ccReservedRanges = Nothing , _ccConsumerExportCustomRoutes = Nothing , _ccVPCScReferenceArchitectureEnabled = Nothing , _ccProducerNetwork = Nothing , _ccProducerImportCustomRoutes = Nothing , _ccProducerExportSubnetRoutesWithPublicIP = Nothing , _ccConsumerImportCustomRoutes = Nothing , _ccProducerImportSubnetRoutesWithPublicIP = Nothing , _ccConsumerExportSubnetRoutesWithPublicIP = Nothing } -- | Export custom routes flag value for peering from producer to consumer. ccProducerExportCustomRoutes :: Lens' ConsumerConfig (Maybe Bool) ccProducerExportCustomRoutes = lens _ccProducerExportCustomRoutes (\ s a -> s{_ccProducerExportCustomRoutes = a}) -- | Import subnet routes with public ip flag value for peering from consumer -- to producer. ccConsumerImportSubnetRoutesWithPublicIP :: Lens' ConsumerConfig (Maybe Bool) ccConsumerImportSubnetRoutesWithPublicIP = lens _ccConsumerImportSubnetRoutesWithPublicIP (\ s a -> s{_ccConsumerImportSubnetRoutesWithPublicIP = a}) -- | Output only. The reserved ranges associated with this private service -- access connection. ccReservedRanges :: Lens' ConsumerConfig [GoogleCloudServicenetworkingV1ConsumerConfigReservedRange] ccReservedRanges = lens _ccReservedRanges (\ s a -> s{_ccReservedRanges = a}) . _Default . _Coerce -- | Export custom routes flag value for peering from consumer to producer. ccConsumerExportCustomRoutes :: Lens' ConsumerConfig (Maybe Bool) ccConsumerExportCustomRoutes = lens _ccConsumerExportCustomRoutes (\ s a -> s{_ccConsumerExportCustomRoutes = a}) -- | Output only. Indicates whether the VPC Service Controls reference -- architecture is configured for the producer VPC host network. ccVPCScReferenceArchitectureEnabled :: Lens' ConsumerConfig (Maybe Bool) ccVPCScReferenceArchitectureEnabled = lens _ccVPCScReferenceArchitectureEnabled (\ s a -> s{_ccVPCScReferenceArchitectureEnabled = a}) -- | Output only. The VPC host network that is used to host managed service -- instances. In the format, -- projects\/{project}\/global\/networks\/{network} where {project} is the -- project number e.g. \'12345\' and {network} is the network name. ccProducerNetwork :: Lens' ConsumerConfig (Maybe Text) ccProducerNetwork = lens _ccProducerNetwork (\ s a -> s{_ccProducerNetwork = a}) -- | Import custom routes flag value for peering from producer to consumer. ccProducerImportCustomRoutes :: Lens' ConsumerConfig (Maybe Bool) ccProducerImportCustomRoutes = lens _ccProducerImportCustomRoutes (\ s a -> s{_ccProducerImportCustomRoutes = a}) -- | Export subnet routes with public ip flag value for peering from producer -- to consumer. ccProducerExportSubnetRoutesWithPublicIP :: Lens' ConsumerConfig (Maybe Bool) ccProducerExportSubnetRoutesWithPublicIP = lens _ccProducerExportSubnetRoutesWithPublicIP (\ s a -> s{_ccProducerExportSubnetRoutesWithPublicIP = a}) -- | Import custom routes flag value for peering from consumer to producer. ccConsumerImportCustomRoutes :: Lens' ConsumerConfig (Maybe Bool) ccConsumerImportCustomRoutes = lens _ccConsumerImportCustomRoutes (\ s a -> s{_ccConsumerImportCustomRoutes = a}) -- | Import subnet routes with public ip flag value for peering from producer -- to consumer. ccProducerImportSubnetRoutesWithPublicIP :: Lens' ConsumerConfig (Maybe Bool) ccProducerImportSubnetRoutesWithPublicIP = lens _ccProducerImportSubnetRoutesWithPublicIP (\ s a -> s{_ccProducerImportSubnetRoutesWithPublicIP = a}) -- | Export subnet routes with public ip flag value for peering from consumer -- to producer. ccConsumerExportSubnetRoutesWithPublicIP :: Lens' ConsumerConfig (Maybe Bool) ccConsumerExportSubnetRoutesWithPublicIP = lens _ccConsumerExportSubnetRoutesWithPublicIP (\ s a -> s{_ccConsumerExportSubnetRoutesWithPublicIP = a}) instance FromJSON ConsumerConfig where parseJSON = withObject "ConsumerConfig" (\ o -> ConsumerConfig' <$> (o .:? "producerExportCustomRoutes") <*> (o .:? "consumerImportSubnetRoutesWithPublicIp") <*> (o .:? "reservedRanges" .!= mempty) <*> (o .:? "consumerExportCustomRoutes") <*> (o .:? "vpcScReferenceArchitectureEnabled") <*> (o .:? "producerNetwork") <*> (o .:? "producerImportCustomRoutes") <*> (o .:? "producerExportSubnetRoutesWithPublicIp") <*> (o .:? "consumerImportCustomRoutes") <*> (o .:? "producerImportSubnetRoutesWithPublicIp") <*> (o .:? "consumerExportSubnetRoutesWithPublicIp")) instance ToJSON ConsumerConfig where toJSON ConsumerConfig'{..} = object (catMaybes [("producerExportCustomRoutes" .=) <$> _ccProducerExportCustomRoutes, ("consumerImportSubnetRoutesWithPublicIp" .=) <$> _ccConsumerImportSubnetRoutesWithPublicIP, ("reservedRanges" .=) <$> _ccReservedRanges, ("consumerExportCustomRoutes" .=) <$> _ccConsumerExportCustomRoutes, ("vpcScReferenceArchitectureEnabled" .=) <$> _ccVPCScReferenceArchitectureEnabled, ("producerNetwork" .=) <$> _ccProducerNetwork, ("producerImportCustomRoutes" .=) <$> _ccProducerImportCustomRoutes, ("producerExportSubnetRoutesWithPublicIp" .=) <$> _ccProducerExportSubnetRoutesWithPublicIP, ("consumerImportCustomRoutes" .=) <$> _ccConsumerImportCustomRoutes, ("producerImportSubnetRoutesWithPublicIp" .=) <$> _ccProducerImportSubnetRoutesWithPublicIP, ("consumerExportSubnetRoutesWithPublicIp" .=) <$> _ccConsumerExportSubnetRoutesWithPublicIP]) -- | Request to add a private managed DNS zone in the shared producer host -- project and a matching DNS peering zone in the consumer project. -- -- /See:/ 'addDNSZoneRequest' smart constructor. data AddDNSZoneRequest = AddDNSZoneRequest' { _adzrDNSSuffix :: !(Maybe Text) , _adzrName :: !(Maybe Text) , _adzrConsumerNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddDNSZoneRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'adzrDNSSuffix' -- -- * 'adzrName' -- -- * 'adzrConsumerNetwork' addDNSZoneRequest :: AddDNSZoneRequest addDNSZoneRequest = AddDNSZoneRequest' { _adzrDNSSuffix = Nothing , _adzrName = Nothing , _adzrConsumerNetwork = Nothing } -- | Required. The DNS name suffix for the zones e.g. \`example.com\`. adzrDNSSuffix :: Lens' AddDNSZoneRequest (Maybe Text) adzrDNSSuffix = lens _adzrDNSSuffix (\ s a -> s{_adzrDNSSuffix = a}) -- | Required. The name for both the private zone in the shared producer host -- project and the peering zone in the consumer project. Must be unique -- within both projects. The name must be 1-63 characters long, must begin -- with a letter, end with a letter or digit, and only contain lowercase -- letters, digits or dashes. adzrName :: Lens' AddDNSZoneRequest (Maybe Text) adzrName = lens _adzrName (\ s a -> s{_adzrName = a}) -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is the -- project number, as in \'12345\' {network} is the network name. adzrConsumerNetwork :: Lens' AddDNSZoneRequest (Maybe Text) adzrConsumerNetwork = lens _adzrConsumerNetwork (\ s a -> s{_adzrConsumerNetwork = a}) instance FromJSON AddDNSZoneRequest where parseJSON = withObject "AddDNSZoneRequest" (\ o -> AddDNSZoneRequest' <$> (o .:? "dnsSuffix") <*> (o .:? "name") <*> (o .:? "consumerNetwork")) instance ToJSON AddDNSZoneRequest where toJSON AddDNSZoneRequest'{..} = object (catMaybes [("dnsSuffix" .=) <$> _adzrDNSSuffix, ("name" .=) <$> _adzrName, ("consumerNetwork" .=) <$> _adzrConsumerNetwork]) -- | Request for AddRoles to allow Service Producers to add roles in the -- shared VPC host project for them to use. -- -- /See:/ 'addRolesRequest' smart constructor. data AddRolesRequest = AddRolesRequest' { _arrPolicyBinding :: !(Maybe [PolicyBinding]) , _arrConsumerNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddRolesRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'arrPolicyBinding' -- -- * 'arrConsumerNetwork' addRolesRequest :: AddRolesRequest addRolesRequest = AddRolesRequest' {_arrPolicyBinding = Nothing, _arrConsumerNetwork = Nothing} -- | Required. List of policy bindings to add to shared VPC host project. arrPolicyBinding :: Lens' AddRolesRequest [PolicyBinding] arrPolicyBinding = lens _arrPolicyBinding (\ s a -> s{_arrPolicyBinding = a}) . _Default . _Coerce -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is a project -- number, as in \'12345\' {network} is a network name. arrConsumerNetwork :: Lens' AddRolesRequest (Maybe Text) arrConsumerNetwork = lens _arrConsumerNetwork (\ s a -> s{_arrConsumerNetwork = a}) instance FromJSON AddRolesRequest where parseJSON = withObject "AddRolesRequest" (\ o -> AddRolesRequest' <$> (o .:? "policyBinding" .!= mempty) <*> (o .:? "consumerNetwork")) instance ToJSON AddRolesRequest where toJSON AddRolesRequest'{..} = object (catMaybes [("policyBinding" .=) <$> _arrPolicyBinding, ("consumerNetwork" .=) <$> _arrConsumerNetwork]) -- | Configuration of a specific billing destination (Currently only support -- bill against consumer project). -- -- /See:/ 'billingDestination' smart constructor. data BillingDestination = BillingDestination' { _bdMetrics :: !(Maybe [Text]) , _bdMonitoredResource :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'BillingDestination' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'bdMetrics' -- -- * 'bdMonitoredResource' billingDestination :: BillingDestination billingDestination = BillingDestination' {_bdMetrics = Nothing, _bdMonitoredResource = Nothing} -- | Names of the metrics to report to this billing destination. Each name -- must be defined in Service.metrics section. bdMetrics :: Lens' BillingDestination [Text] bdMetrics = lens _bdMetrics (\ s a -> s{_bdMetrics = a}) . _Default . _Coerce -- | The monitored resource type. The type must be defined in -- Service.monitored_resources section. bdMonitoredResource :: Lens' BillingDestination (Maybe Text) bdMonitoredResource = lens _bdMonitoredResource (\ s a -> s{_bdMonitoredResource = a}) instance FromJSON BillingDestination where parseJSON = withObject "BillingDestination" (\ o -> BillingDestination' <$> (o .:? "metrics" .!= mempty) <*> (o .:? "monitoredResource")) instance ToJSON BillingDestination where toJSON BillingDestination'{..} = object (catMaybes [("metrics" .=) <$> _bdMetrics, ("monitoredResource" .=) <$> _bdMonitoredResource]) -- | Selects and configures the service controller used by the service. The -- service controller handles features like abuse, quota, billing, logging, -- monitoring, etc. -- -- /See:/ 'control' smart constructor. newtype Control = Control' { _cEnvironment :: Maybe Text } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Control' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'cEnvironment' control :: Control control = Control' {_cEnvironment = Nothing} -- | The service control environment to use. If empty, no control plane -- feature (like quota and billing) will be enabled. cEnvironment :: Lens' Control (Maybe Text) cEnvironment = lens _cEnvironment (\ s a -> s{_cEnvironment = a}) instance FromJSON Control where parseJSON = withObject "Control" (\ o -> Control' <$> (o .:? "environment")) instance ToJSON Control where toJSON Control'{..} = object (catMaybes [("environment" .=) <$> _cEnvironment]) -- | Metadata provided through GetOperation request for the LRO generated by -- CreatePeeredDnsDomain API. -- -- /See:/ 'peeredDNSDomainMetadata' smart constructor. data PeeredDNSDomainMetadata = PeeredDNSDomainMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'PeeredDNSDomainMetadata' with the minimum fields required to make a request. -- peeredDNSDomainMetadata :: PeeredDNSDomainMetadata peeredDNSDomainMetadata = PeeredDNSDomainMetadata' instance FromJSON PeeredDNSDomainMetadata where parseJSON = withObject "PeeredDNSDomainMetadata" (\ o -> pure PeeredDNSDomainMetadata') instance ToJSON PeeredDNSDomainMetadata where toJSON = const emptyObject -- | Represents a range reservation. -- -- /See:/ 'rangeReservation' smart constructor. data RangeReservation = RangeReservation' { _rrIPPrefixLength :: !(Maybe (Textual Int32)) , _rrSecondaryRangeIPPrefixLengths :: !(Maybe [Textual Int32]) , _rrRequestedRanges :: !(Maybe [Text]) , _rrSubnetworkCandidates :: !(Maybe [Subnetwork]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RangeReservation' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'rrIPPrefixLength' -- -- * 'rrSecondaryRangeIPPrefixLengths' -- -- * 'rrRequestedRanges' -- -- * 'rrSubnetworkCandidates' rangeReservation :: RangeReservation rangeReservation = RangeReservation' { _rrIPPrefixLength = Nothing , _rrSecondaryRangeIPPrefixLengths = Nothing , _rrRequestedRanges = Nothing , _rrSubnetworkCandidates = Nothing } -- | Required. The size of the desired subnet. Use usual CIDR range notation. -- For example, \'30\' to find unused x.x.x.x\/30 CIDR range. The goal is -- to determine if one of the allocated ranges has enough free space for a -- subnet of the requested size. rrIPPrefixLength :: Lens' RangeReservation (Maybe Int32) rrIPPrefixLength = lens _rrIPPrefixLength (\ s a -> s{_rrIPPrefixLength = a}) . mapping _Coerce -- | Optional. The size of the desired secondary ranges for the subnet. Use -- usual CIDR range notation. For example, \'30\' to find unused -- x.x.x.x\/30 CIDR range. The goal is to determine that the allocated -- ranges have enough free space for all the requested secondary ranges. rrSecondaryRangeIPPrefixLengths :: Lens' RangeReservation [Int32] rrSecondaryRangeIPPrefixLengths = lens _rrSecondaryRangeIPPrefixLengths (\ s a -> s{_rrSecondaryRangeIPPrefixLengths = a}) . _Default . _Coerce -- | Optional. The name of one or more allocated IP address ranges associated -- with this private service access connection. If no range names are -- provided all ranges associated with this connection will be considered. -- If a CIDR range with the specified IP prefix length is not available -- within these ranges the validation fails. rrRequestedRanges :: Lens' RangeReservation [Text] rrRequestedRanges = lens _rrRequestedRanges (\ s a -> s{_rrRequestedRanges = a}) . _Default . _Coerce -- | Optional. List of subnetwork candidates to validate. The required input -- fields are \`name\`, \`network\`, and \`region\`. Subnetworks from this -- list which exist will be returned in the response with the -- \`ip_cidr_range\`, \`secondary_ip_cider_ranges\`, and -- \`outside_allocation\` fields set. rrSubnetworkCandidates :: Lens' RangeReservation [Subnetwork] rrSubnetworkCandidates = lens _rrSubnetworkCandidates (\ s a -> s{_rrSubnetworkCandidates = a}) . _Default . _Coerce instance FromJSON RangeReservation where parseJSON = withObject "RangeReservation" (\ o -> RangeReservation' <$> (o .:? "ipPrefixLength") <*> (o .:? "secondaryRangeIpPrefixLengths" .!= mempty) <*> (o .:? "requestedRanges" .!= mempty) <*> (o .:? "subnetworkCandidates" .!= mempty)) instance ToJSON RangeReservation where toJSON RangeReservation'{..} = object (catMaybes [("ipPrefixLength" .=) <$> _rrIPPrefixLength, ("secondaryRangeIpPrefixLengths" .=) <$> _rrSecondaryRangeIPPrefixLengths, ("requestedRanges" .=) <$> _rrRequestedRanges, ("subnetworkCandidates" .=) <$> _rrSubnetworkCandidates]) -- | User-defined authentication requirements, including support for [JSON -- Web Token -- (JWT)](https:\/\/tools.ietf.org\/html\/draft-ietf-oauth-json-web-token-32). -- -- /See:/ 'authRequirement' smart constructor. data AuthRequirement = AuthRequirement' { _arProviderId :: !(Maybe Text) , _arAudiences :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AuthRequirement' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'arProviderId' -- -- * 'arAudiences' authRequirement :: AuthRequirement authRequirement = AuthRequirement' {_arProviderId = Nothing, _arAudiences = Nothing} -- | id from authentication provider. Example: provider_id: bookstore_auth arProviderId :: Lens' AuthRequirement (Maybe Text) arProviderId = lens _arProviderId (\ s a -> s{_arProviderId = a}) -- | NOTE: This will be deprecated soon, once AuthProvider.audiences is -- implemented and accepted in all the runtime components. The list of JWT -- [audiences](https:\/\/tools.ietf.org\/html\/draft-ietf-oauth-json-web-token-32#section-4.1.3). -- that are allowed to access. A JWT containing any of these audiences will -- be accepted. When this setting is absent, only JWTs with audience -- \"https:\/\/Service_name\/API_name\" will be accepted. For example, if -- no audiences are in the setting, LibraryService API will only accept -- JWTs with the following audience -- \"https:\/\/library-example.googleapis.com\/google.example.library.v1.LibraryService\". -- Example: audiences: bookstore_android.apps.googleusercontent.com, -- bookstore_web.apps.googleusercontent.com arAudiences :: Lens' AuthRequirement (Maybe Text) arAudiences = lens _arAudiences (\ s a -> s{_arAudiences = a}) instance FromJSON AuthRequirement where parseJSON = withObject "AuthRequirement" (\ o -> AuthRequirement' <$> (o .:? "providerId") <*> (o .:? "audiences")) instance ToJSON AuthRequirement where toJSON AuthRequirement'{..} = object (catMaybes [("providerId" .=) <$> _arProviderId, ("audiences" .=) <$> _arAudiences]) -- | \`Context\` defines which contexts an API requests. Example: context: -- rules: - selector: \"*\" requested: - google.rpc.context.ProjectContext -- - google.rpc.context.OriginContext The above specifies that all methods -- in the API request \`google.rpc.context.ProjectContext\` and -- \`google.rpc.context.OriginContext\`. Available context types are -- defined in package \`google.rpc.context\`. This also provides mechanism -- to allowlist any protobuf message extension that can be sent in grpc -- metadata using “x-goog-ext--bin” and “x-goog-ext--jspb” format. For -- example, list any service specific protobuf types that can appear in -- grpc metadata as follows in your yaml file: Example: context: rules: - -- selector: \"google.example.library.v1.LibraryService.CreateBook\" -- allowed_request_extensions: - google.foo.v1.NewExtension -- allowed_response_extensions: - google.foo.v1.NewExtension You can also -- specify extension ID instead of fully qualified extension name here. -- -- /See:/ 'context' smart constructor. newtype Context = Context' { _cRules :: Maybe [ContextRule] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Context' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'cRules' context :: Context context = Context' {_cRules = Nothing} -- | A list of RPC context rules that apply to individual API methods. -- **NOTE:** All service configuration rules follow \"last one wins\" -- order. cRules :: Lens' Context [ContextRule] cRules = lens _cRules (\ s a -> s{_cRules = a}) . _Default . _Coerce instance FromJSON Context where parseJSON = withObject "Context" (\ o -> Context' <$> (o .:? "rules" .!= mempty)) instance ToJSON Context where toJSON Context'{..} = object (catMaybes [("rules" .=) <$> _cRules]) -- | Configuration of a specific logging destination (the producer project or -- the consumer project). -- -- /See:/ 'loggingDestination' smart constructor. data LoggingDestination = LoggingDestination' { _ldMonitoredResource :: !(Maybe Text) , _ldLogs :: !(Maybe [Text]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'LoggingDestination' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ldMonitoredResource' -- -- * 'ldLogs' loggingDestination :: LoggingDestination loggingDestination = LoggingDestination' {_ldMonitoredResource = Nothing, _ldLogs = Nothing} -- | The monitored resource type. The type must be defined in the -- Service.monitored_resources section. ldMonitoredResource :: Lens' LoggingDestination (Maybe Text) ldMonitoredResource = lens _ldMonitoredResource (\ s a -> s{_ldMonitoredResource = a}) -- | Names of the logs to be sent to this destination. Each name must be -- defined in the Service.logs section. If the log name is not a domain -- scoped name, it will be automatically prefixed with the service name -- followed by \"\/\". ldLogs :: Lens' LoggingDestination [Text] ldLogs = lens _ldLogs (\ s a -> s{_ldLogs = a}) . _Default . _Coerce instance FromJSON LoggingDestination where parseJSON = withObject "LoggingDestination" (\ o -> LoggingDestination' <$> (o .:? "monitoredResource") <*> (o .:? "logs" .!= mempty)) instance ToJSON LoggingDestination where toJSON LoggingDestination'{..} = object (catMaybes [("monitoredResource" .=) <$> _ldMonitoredResource, ("logs" .=) <$> _ldLogs]) -- | Defines a metric type and its schema. Once a metric descriptor is -- created, deleting or altering it stops data collection and makes the -- metric type\'s existing data unusable. -- -- /See:/ 'metricDescriptor' smart constructor. data MetricDescriptor = MetricDescriptor' { _mdMonitoredResourceTypes :: !(Maybe [Text]) , _mdMetricKind :: !(Maybe MetricDescriptorMetricKind) , _mdName :: !(Maybe Text) , _mdMetadata :: !(Maybe MetricDescriptorMetadata) , _mdDisplayName :: !(Maybe Text) , _mdLabels :: !(Maybe [LabelDescriptor]) , _mdType :: !(Maybe Text) , _mdValueType :: !(Maybe MetricDescriptorValueType) , _mdDescription :: !(Maybe Text) , _mdUnit :: !(Maybe Text) , _mdLaunchStage :: !(Maybe MetricDescriptorLaunchStage) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'MetricDescriptor' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mdMonitoredResourceTypes' -- -- * 'mdMetricKind' -- -- * 'mdName' -- -- * 'mdMetadata' -- -- * 'mdDisplayName' -- -- * 'mdLabels' -- -- * 'mdType' -- -- * 'mdValueType' -- -- * 'mdDescription' -- -- * 'mdUnit' -- -- * 'mdLaunchStage' metricDescriptor :: MetricDescriptor metricDescriptor = MetricDescriptor' { _mdMonitoredResourceTypes = Nothing , _mdMetricKind = Nothing , _mdName = Nothing , _mdMetadata = Nothing , _mdDisplayName = Nothing , _mdLabels = Nothing , _mdType = Nothing , _mdValueType = Nothing , _mdDescription = Nothing , _mdUnit = Nothing , _mdLaunchStage = Nothing } -- | Read-only. If present, then a time series, which is identified partially -- by a metric type and a MonitoredResourceDescriptor, that is associated -- with this metric type can only be associated with one of the monitored -- resource types listed here. mdMonitoredResourceTypes :: Lens' MetricDescriptor [Text] mdMonitoredResourceTypes = lens _mdMonitoredResourceTypes (\ s a -> s{_mdMonitoredResourceTypes = a}) . _Default . _Coerce -- | Whether the metric records instantaneous values, changes to a value, -- etc. Some combinations of \`metric_kind\` and \`value_type\` might not -- be supported. mdMetricKind :: Lens' MetricDescriptor (Maybe MetricDescriptorMetricKind) mdMetricKind = lens _mdMetricKind (\ s a -> s{_mdMetricKind = a}) -- | The resource name of the metric descriptor. mdName :: Lens' MetricDescriptor (Maybe Text) mdName = lens _mdName (\ s a -> s{_mdName = a}) -- | Optional. Metadata which can be used to guide usage of the metric. mdMetadata :: Lens' MetricDescriptor (Maybe MetricDescriptorMetadata) mdMetadata = lens _mdMetadata (\ s a -> s{_mdMetadata = a}) -- | A concise name for the metric, which can be displayed in user -- interfaces. Use sentence case without an ending period, for example -- \"Request count\". This field is optional but it is recommended to be -- set for any metrics associated with user-visible concepts, such as -- Quota. mdDisplayName :: Lens' MetricDescriptor (Maybe Text) mdDisplayName = lens _mdDisplayName (\ s a -> s{_mdDisplayName = a}) -- | The set of labels that can be used to describe a specific instance of -- this metric type. For example, the -- \`appengine.googleapis.com\/http\/server\/response_latencies\` metric -- type has a label for the HTTP response code, \`response_code\`, so you -- can look at latencies for successful responses or just for responses -- that failed. mdLabels :: Lens' MetricDescriptor [LabelDescriptor] mdLabels = lens _mdLabels (\ s a -> s{_mdLabels = a}) . _Default . _Coerce -- | The metric type, including its DNS name prefix. The type is not -- URL-encoded. All user-defined metric types have the DNS name -- \`custom.googleapis.com\` or \`external.googleapis.com\`. Metric types -- should use a natural hierarchical grouping. For example: -- \"custom.googleapis.com\/invoice\/paid\/amount\" -- \"external.googleapis.com\/prometheus\/up\" -- \"appengine.googleapis.com\/http\/server\/response_latencies\" mdType :: Lens' MetricDescriptor (Maybe Text) mdType = lens _mdType (\ s a -> s{_mdType = a}) -- | Whether the measurement is an integer, a floating-point number, etc. -- Some combinations of \`metric_kind\` and \`value_type\` might not be -- supported. mdValueType :: Lens' MetricDescriptor (Maybe MetricDescriptorValueType) mdValueType = lens _mdValueType (\ s a -> s{_mdValueType = a}) -- | A detailed description of the metric, which can be used in -- documentation. mdDescription :: Lens' MetricDescriptor (Maybe Text) mdDescription = lens _mdDescription (\ s a -> s{_mdDescription = a}) -- | The units in which the metric value is reported. It is only applicable -- if the \`value_type\` is \`INT64\`, \`DOUBLE\`, or \`DISTRIBUTION\`. The -- \`unit\` defines the representation of the stored metric values. -- Different systems might scale the values to be more easily displayed (so -- a value of \`0.02kBy\` _might_ be displayed as \`20By\`, and a value of -- \`3523kBy\` _might_ be displayed as \`3.5MBy\`). However, if the -- \`unit\` is \`kBy\`, then the value of the metric is always in thousands -- of bytes, no matter how it might be displayed. If you want a custom -- metric to record the exact number of CPU-seconds used by a job, you can -- create an \`INT64 CUMULATIVE\` metric whose \`unit\` is \`s{CPU}\` (or -- equivalently \`1s{CPU}\` or just \`s\`). If the job uses 12,005 -- CPU-seconds, then the value is written as \`12005\`. Alternatively, if -- you want a custom metric to record data in a more granular way, you can -- create a \`DOUBLE CUMULATIVE\` metric whose \`unit\` is \`ks{CPU}\`, and -- then write the value \`12.005\` (which is \`12005\/1000\`), or use -- \`Kis{CPU}\` and write \`11.723\` (which is \`12005\/1024\`). The -- supported units are a subset of [The Unified Code for Units of -- Measure](https:\/\/unitsofmeasure.org\/ucum.html) standard: **Basic -- units (UNIT)** * \`bit\` bit * \`By\` byte * \`s\` second * \`min\` -- minute * \`h\` hour * \`d\` day * \`1\` dimensionless **Prefixes -- (PREFIX)** * \`k\` kilo (10^3) * \`M\` mega (10^6) * \`G\` giga (10^9) * -- \`T\` tera (10^12) * \`P\` peta (10^15) * \`E\` exa (10^18) * \`Z\` -- zetta (10^21) * \`Y\` yotta (10^24) * \`m\` milli (10^-3) * \`u\` micro -- (10^-6) * \`n\` nano (10^-9) * \`p\` pico (10^-12) * \`f\` femto -- (10^-15) * \`a\` atto (10^-18) * \`z\` zepto (10^-21) * \`y\` yocto -- (10^-24) * \`Ki\` kibi (2^10) * \`Mi\` mebi (2^20) * \`Gi\` gibi (2^30) -- * \`Ti\` tebi (2^40) * \`Pi\` pebi (2^50) **Grammar** The grammar also -- includes these connectors: * \`\/\` division or ratio (as an infix -- operator). For examples, \`kBy\/{email}\` or \`MiBy\/10ms\` (although -- you should almost never have \`\/s\` in a metric \`unit\`; rates should -- always be computed at query time from the underlying cumulative or delta -- value). * \`.\` multiplication or composition (as an infix operator). -- For examples, \`GBy.d\` or \`k{watt}.h\`. The grammar for a unit is as -- follows: Expression = Component { \".\" Component } { \"\/\" Component } -- ; Component = ( [ PREFIX ] UNIT | \"%\" ) [ Annotation ] | Annotation | -- \"1\" ; Annotation = \"{\" NAME \"}\" ; Notes: * \`Annotation\` is just -- a comment if it follows a \`UNIT\`. If the annotation is used alone, -- then the unit is equivalent to \`1\`. For examples, \`{request}\/s == -- 1\/s\`, \`By{transmitted}\/s == By\/s\`. * \`NAME\` is a sequence of -- non-blank printable ASCII characters not containing \`{\` or \`}\`. * -- \`1\` represents a unitary [dimensionless -- unit](https:\/\/en.wikipedia.org\/wiki\/Dimensionless_quantity) of 1, -- such as in \`1\/s\`. It is typically used when none of the basic units -- are appropriate. For example, \"new users per day\" can be represented -- as \`1\/d\` or \`{new-users}\/d\` (and a metric value \`5\` would mean -- \"5 new users). Alternatively, \"thousands of page views per day\" would -- be represented as \`1000\/d\` or \`k1\/d\` or \`k{page_views}\/d\` (and -- a metric value of \`5.3\` would mean \"5300 page views per day\"). * -- \`%\` represents dimensionless value of 1\/100, and annotates values -- giving a percentage (so the metric values are typically in the range of -- 0..100, and a metric value \`3\` means \"3 percent\"). * \`10^2.%\` -- indicates a metric contains a ratio, typically in the range 0..1, that -- will be multiplied by 100 and displayed as a percentage (so a metric -- value \`0.03\` means \"3 percent\"). mdUnit :: Lens' MetricDescriptor (Maybe Text) mdUnit = lens _mdUnit (\ s a -> s{_mdUnit = a}) -- | Optional. The launch stage of the metric definition. mdLaunchStage :: Lens' MetricDescriptor (Maybe MetricDescriptorLaunchStage) mdLaunchStage = lens _mdLaunchStage (\ s a -> s{_mdLaunchStage = a}) instance FromJSON MetricDescriptor where parseJSON = withObject "MetricDescriptor" (\ o -> MetricDescriptor' <$> (o .:? "monitoredResourceTypes" .!= mempty) <*> (o .:? "metricKind") <*> (o .:? "name") <*> (o .:? "metadata") <*> (o .:? "displayName") <*> (o .:? "labels" .!= mempty) <*> (o .:? "type") <*> (o .:? "valueType") <*> (o .:? "description") <*> (o .:? "unit") <*> (o .:? "launchStage")) instance ToJSON MetricDescriptor where toJSON MetricDescriptor'{..} = object (catMaybes [("monitoredResourceTypes" .=) <$> _mdMonitoredResourceTypes, ("metricKind" .=) <$> _mdMetricKind, ("name" .=) <$> _mdName, ("metadata" .=) <$> _mdMetadata, ("displayName" .=) <$> _mdDisplayName, ("labels" .=) <$> _mdLabels, ("type" .=) <$> _mdType, ("valueType" .=) <$> _mdValueType, ("description" .=) <$> _mdDescription, ("unit" .=) <$> _mdUnit, ("launchStage" .=) <$> _mdLaunchStage]) -- | The response message for Operations.ListOperations. -- -- /See:/ 'listOperationsResponse' smart constructor. data ListOperationsResponse = ListOperationsResponse' { _lorNextPageToken :: !(Maybe Text) , _lorOperations :: !(Maybe [Operation]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ListOperationsResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lorNextPageToken' -- -- * 'lorOperations' listOperationsResponse :: ListOperationsResponse listOperationsResponse = ListOperationsResponse' {_lorNextPageToken = Nothing, _lorOperations = Nothing} -- | The standard List next-page token. lorNextPageToken :: Lens' ListOperationsResponse (Maybe Text) lorNextPageToken = lens _lorNextPageToken (\ s a -> s{_lorNextPageToken = a}) -- | A list of operations that matches the specified filter in the request. lorOperations :: Lens' ListOperationsResponse [Operation] lorOperations = lens _lorOperations (\ s a -> s{_lorOperations = a}) . _Default . _Coerce instance FromJSON ListOperationsResponse where parseJSON = withObject "ListOperationsResponse" (\ o -> ListOperationsResponse' <$> (o .:? "nextPageToken") <*> (o .:? "operations" .!= mempty)) instance ToJSON ListOperationsResponse where toJSON ListOperationsResponse'{..} = object (catMaybes [("nextPageToken" .=) <$> _lorNextPageToken, ("operations" .=) <$> _lorOperations]) -- | Represents a DNS zone resource. -- -- /See:/ 'dnsZone' smart constructor. data DNSZone = DNSZone' { _dzDNSSuffix :: !(Maybe Text) , _dzName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DNSZone' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'dzDNSSuffix' -- -- * 'dzName' dnsZone :: DNSZone dnsZone = DNSZone' {_dzDNSSuffix = Nothing, _dzName = Nothing} -- | The DNS name suffix of this zone e.g. \`example.com.\`. dzDNSSuffix :: Lens' DNSZone (Maybe Text) dzDNSSuffix = lens _dzDNSSuffix (\ s a -> s{_dzDNSSuffix = a}) -- | User assigned name for this resource. Must be unique within the project. -- The name must be 1-63 characters long, must begin with a letter, end -- with a letter or digit, and only contain lowercase letters, digits or -- dashes. dzName :: Lens' DNSZone (Maybe Text) dzName = lens _dzName (\ s a -> s{_dzName = a}) instance FromJSON DNSZone where parseJSON = withObject "DNSZone" (\ o -> DNSZone' <$> (o .:? "dnsSuffix") <*> (o .:? "name")) instance ToJSON DNSZone where toJSON DNSZone'{..} = object (catMaybes [("dnsSuffix" .=) <$> _dzDNSSuffix, ("name" .=) <$> _dzName]) -- | The request message for Operations.CancelOperation. -- -- /See:/ 'cancelOperationRequest' smart constructor. data CancelOperationRequest = CancelOperationRequest' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'CancelOperationRequest' with the minimum fields required to make a request. -- cancelOperationRequest :: CancelOperationRequest cancelOperationRequest = CancelOperationRequest' instance FromJSON CancelOperationRequest where parseJSON = withObject "CancelOperationRequest" (\ o -> pure CancelOperationRequest') instance ToJSON CancelOperationRequest where toJSON = const emptyObject -- | A backend rule provides configuration for an individual API element. -- -- /See:/ 'backendRule' smart constructor. data BackendRule = BackendRule' { _brJwtAudience :: !(Maybe Text) , _brSelector :: !(Maybe Text) , _brAddress :: !(Maybe Text) , _brProtocol :: !(Maybe Text) , _brDisableAuth :: !(Maybe Bool) , _brOperationDeadline :: !(Maybe (Textual Double)) , _brDeadline :: !(Maybe (Textual Double)) , _brPathTranslation :: !(Maybe BackendRulePathTranslation) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'BackendRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'brJwtAudience' -- -- * 'brSelector' -- -- * 'brAddress' -- -- * 'brProtocol' -- -- * 'brDisableAuth' -- -- * 'brOperationDeadline' -- -- * 'brDeadline' -- -- * 'brPathTranslation' backendRule :: BackendRule backendRule = BackendRule' { _brJwtAudience = Nothing , _brSelector = Nothing , _brAddress = Nothing , _brProtocol = Nothing , _brDisableAuth = Nothing , _brOperationDeadline = Nothing , _brDeadline = Nothing , _brPathTranslation = Nothing } -- | The JWT audience is used when generating a JWT ID token for the backend. -- This ID token will be added in the HTTP \"authorization\" header, and -- sent to the backend. brJwtAudience :: Lens' BackendRule (Maybe Text) brJwtAudience = lens _brJwtAudience (\ s a -> s{_brJwtAudience = a}) -- | Selects the methods to which this rule applies. Refer to selector for -- syntax details. brSelector :: Lens' BackendRule (Maybe Text) brSelector = lens _brSelector (\ s a -> s{_brSelector = a}) -- | The address of the API backend. The scheme is used to determine the -- backend protocol and security. The following schemes are accepted: -- SCHEME PROTOCOL SECURITY http:\/\/ HTTP None https:\/\/ HTTP TLS -- grpc:\/\/ gRPC None grpcs:\/\/ gRPC TLS It is recommended to explicitly -- include a scheme. Leaving out the scheme may cause constrasting -- behaviors across platforms. If the port is unspecified, the default is: -- - 80 for schemes without TLS - 443 for schemes with TLS For HTTP -- backends, use protocol to specify the protocol version. brAddress :: Lens' BackendRule (Maybe Text) brAddress = lens _brAddress (\ s a -> s{_brAddress = a}) -- | The protocol used for sending a request to the backend. The supported -- values are \"http\/1.1\" and \"h2\". The default value is inferred from -- the scheme in the address field: SCHEME PROTOCOL http:\/\/ http\/1.1 -- https:\/\/ http\/1.1 grpc:\/\/ h2 grpcs:\/\/ h2 For secure HTTP backends -- (https:\/\/) that support HTTP\/2, set this field to \"h2\" for improved -- performance. Configuring this field to non-default values is only -- supported for secure HTTP backends. This field will be ignored for all -- other backends. See -- https:\/\/www.iana.org\/assignments\/tls-extensiontype-values\/tls-extensiontype-values.xhtml#alpn-protocol-ids -- for more details on the supported values. brProtocol :: Lens' BackendRule (Maybe Text) brProtocol = lens _brProtocol (\ s a -> s{_brProtocol = a}) -- | When disable_auth is true, a JWT ID token won\'t be generated and the -- original \"Authorization\" HTTP header will be preserved. If the header -- is used to carry the original token and is expected by the backend, this -- field must be set to true to preserve the header. brDisableAuth :: Lens' BackendRule (Maybe Bool) brDisableAuth = lens _brDisableAuth (\ s a -> s{_brDisableAuth = a}) -- | The number of seconds to wait for the completion of a long running -- operation. The default is no deadline. brOperationDeadline :: Lens' BackendRule (Maybe Double) brOperationDeadline = lens _brOperationDeadline (\ s a -> s{_brOperationDeadline = a}) . mapping _Coerce -- | The number of seconds to wait for a response from a request. The default -- varies based on the request protocol and deployment environment. brDeadline :: Lens' BackendRule (Maybe Double) brDeadline = lens _brDeadline (\ s a -> s{_brDeadline = a}) . mapping _Coerce brPathTranslation :: Lens' BackendRule (Maybe BackendRulePathTranslation) brPathTranslation = lens _brPathTranslation (\ s a -> s{_brPathTranslation = a}) instance FromJSON BackendRule where parseJSON = withObject "BackendRule" (\ o -> BackendRule' <$> (o .:? "jwtAudience") <*> (o .:? "selector") <*> (o .:? "address") <*> (o .:? "protocol") <*> (o .:? "disableAuth") <*> (o .:? "operationDeadline") <*> (o .:? "deadline") <*> (o .:? "pathTranslation")) instance ToJSON BackendRule where toJSON BackendRule'{..} = object (catMaybes [("jwtAudience" .=) <$> _brJwtAudience, ("selector" .=) <$> _brSelector, ("address" .=) <$> _brAddress, ("protocol" .=) <$> _brProtocol, ("disableAuth" .=) <$> _brDisableAuth, ("operationDeadline" .=) <$> _brOperationDeadline, ("deadline" .=) <$> _brDeadline, ("pathTranslation" .=) <$> _brPathTranslation]) -- | Metadata provided through GetOperation request for the LRO generated by -- UpdateDnsRecordSet API -- -- /See:/ 'updateDNSRecordSetMetadata' smart constructor. data UpdateDNSRecordSetMetadata = UpdateDNSRecordSetMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'UpdateDNSRecordSetMetadata' with the minimum fields required to make a request. -- updateDNSRecordSetMetadata :: UpdateDNSRecordSetMetadata updateDNSRecordSetMetadata = UpdateDNSRecordSetMetadata' instance FromJSON UpdateDNSRecordSetMetadata where parseJSON = withObject "UpdateDNSRecordSetMetadata" (\ o -> pure UpdateDNSRecordSetMetadata') instance ToJSON UpdateDNSRecordSetMetadata where toJSON = const emptyObject -- | \`SourceContext\` represents information about the source of a protobuf -- element, like the file in which it is defined. -- -- /See:/ 'sourceContext' smart constructor. newtype SourceContext = SourceContext' { _scFileName :: Maybe Text } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SourceContext' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'scFileName' sourceContext :: SourceContext sourceContext = SourceContext' {_scFileName = Nothing} -- | The path-qualified name of the .proto file that contained the associated -- protobuf element. For example: -- \`\"google\/protobuf\/source_context.proto\"\`. scFileName :: Lens' SourceContext (Maybe Text) scFileName = lens _scFileName (\ s a -> s{_scFileName = a}) instance FromJSON SourceContext where parseJSON = withObject "SourceContext" (\ o -> SourceContext' <$> (o .:? "fileName")) instance ToJSON SourceContext where toJSON SourceContext'{..} = object (catMaybes [("fileName" .=) <$> _scFileName]) -- | A single field of a message type. -- -- /See:/ 'field' smart constructor. data Field = Field' { _fKind :: !(Maybe FieldKind) , _fOneofIndex :: !(Maybe (Textual Int32)) , _fName :: !(Maybe Text) , _fJSONName :: !(Maybe Text) , _fCardinality :: !(Maybe FieldCardinality) , _fOptions :: !(Maybe [Option]) , _fPacked :: !(Maybe Bool) , _fDefaultValue :: !(Maybe Text) , _fNumber :: !(Maybe (Textual Int32)) , _fTypeURL :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Field' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'fKind' -- -- * 'fOneofIndex' -- -- * 'fName' -- -- * 'fJSONName' -- -- * 'fCardinality' -- -- * 'fOptions' -- -- * 'fPacked' -- -- * 'fDefaultValue' -- -- * 'fNumber' -- -- * 'fTypeURL' field :: Field field = Field' { _fKind = Nothing , _fOneofIndex = Nothing , _fName = Nothing , _fJSONName = Nothing , _fCardinality = Nothing , _fOptions = Nothing , _fPacked = Nothing , _fDefaultValue = Nothing , _fNumber = Nothing , _fTypeURL = Nothing } -- | The field type. fKind :: Lens' Field (Maybe FieldKind) fKind = lens _fKind (\ s a -> s{_fKind = a}) -- | The index of the field type in \`Type.oneofs\`, for message or -- enumeration types. The first type has index 1; zero means the type is -- not in the list. fOneofIndex :: Lens' Field (Maybe Int32) fOneofIndex = lens _fOneofIndex (\ s a -> s{_fOneofIndex = a}) . mapping _Coerce -- | The field name. fName :: Lens' Field (Maybe Text) fName = lens _fName (\ s a -> s{_fName = a}) -- | The field JSON name. fJSONName :: Lens' Field (Maybe Text) fJSONName = lens _fJSONName (\ s a -> s{_fJSONName = a}) -- | The field cardinality. fCardinality :: Lens' Field (Maybe FieldCardinality) fCardinality = lens _fCardinality (\ s a -> s{_fCardinality = a}) -- | The protocol buffer options. fOptions :: Lens' Field [Option] fOptions = lens _fOptions (\ s a -> s{_fOptions = a}) . _Default . _Coerce -- | Whether to use alternative packed wire representation. fPacked :: Lens' Field (Maybe Bool) fPacked = lens _fPacked (\ s a -> s{_fPacked = a}) -- | The string value of the default value of this field. Proto2 syntax only. fDefaultValue :: Lens' Field (Maybe Text) fDefaultValue = lens _fDefaultValue (\ s a -> s{_fDefaultValue = a}) -- | The field number. fNumber :: Lens' Field (Maybe Int32) fNumber = lens _fNumber (\ s a -> s{_fNumber = a}) . mapping _Coerce -- | The field type URL, without the scheme, for message or enumeration -- types. Example: \`\"type.googleapis.com\/google.protobuf.Timestamp\"\`. fTypeURL :: Lens' Field (Maybe Text) fTypeURL = lens _fTypeURL (\ s a -> s{_fTypeURL = a}) instance FromJSON Field where parseJSON = withObject "Field" (\ o -> Field' <$> (o .:? "kind") <*> (o .:? "oneofIndex") <*> (o .:? "name") <*> (o .:? "jsonName") <*> (o .:? "cardinality") <*> (o .:? "options" .!= mempty) <*> (o .:? "packed") <*> (o .:? "defaultValue") <*> (o .:? "number") <*> (o .:? "typeUrl")) instance ToJSON Field where toJSON Field'{..} = object (catMaybes [("kind" .=) <$> _fKind, ("oneofIndex" .=) <$> _fOneofIndex, ("name" .=) <$> _fName, ("jsonName" .=) <$> _fJSONName, ("cardinality" .=) <$> _fCardinality, ("options" .=) <$> _fOptions, ("packed" .=) <$> _fPacked, ("defaultValue" .=) <$> _fDefaultValue, ("number" .=) <$> _fNumber, ("typeUrl" .=) <$> _fTypeURL]) -- | Bind API methods to metrics. Binding a method to a metric causes that -- metric\'s configured quota behaviors to apply to the method call. -- -- /See:/ 'metricRule' smart constructor. data MetricRule = MetricRule' { _mrSelector :: !(Maybe Text) , _mrMetricCosts :: !(Maybe MetricRuleMetricCosts) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'MetricRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mrSelector' -- -- * 'mrMetricCosts' metricRule :: MetricRule metricRule = MetricRule' {_mrSelector = Nothing, _mrMetricCosts = Nothing} -- | Selects the methods to which this rule applies. Refer to selector for -- syntax details. mrSelector :: Lens' MetricRule (Maybe Text) mrSelector = lens _mrSelector (\ s a -> s{_mrSelector = a}) -- | Metrics to update when the selected methods are called, and the -- associated cost applied to each metric. The key of the map is the metric -- name, and the values are the amount increased for the metric against -- which the quota limits are defined. The value must not be negative. mrMetricCosts :: Lens' MetricRule (Maybe MetricRuleMetricCosts) mrMetricCosts = lens _mrMetricCosts (\ s a -> s{_mrMetricCosts = a}) instance FromJSON MetricRule where parseJSON = withObject "MetricRule" (\ o -> MetricRule' <$> (o .:? "selector") <*> (o .:? "metricCosts")) instance ToJSON MetricRule where toJSON MetricRule'{..} = object (catMaybes [("selector" .=) <$> _mrSelector, ("metricCosts" .=) <$> _mrMetricCosts]) -- | \`Service\` is the root object of Google API service configuration -- (service config). It describes the basic information about a logical -- service, such as the service name and the user-facing title, and -- delegates other aspects to sub-sections. Each sub-section is either a -- proto message or a repeated proto message that configures a specific -- aspect, such as auth. For more information, see each proto message -- definition. Example: type: google.api.Service name: -- calendar.googleapis.com title: Google Calendar API apis: - name: -- google.calendar.v3.Calendar visibility: rules: - selector: -- \"google.calendar.v3.*\" restriction: PREVIEW backend: rules: - -- selector: \"google.calendar.v3.*\" address: calendar.example.com -- authentication: providers: - id: google_calendar_auth jwks_uri: -- https:\/\/www.googleapis.com\/oauth2\/v1\/certs issuer: -- https:\/\/securetoken.google.com rules: - selector: \"*\" requirements: -- provider_id: google_calendar_auth -- -- /See:/ 'service' smart constructor. data Service = Service' { _sControl :: !(Maybe Control) , _sMetrics :: !(Maybe [MetricDescriptor]) , _sContext :: !(Maybe Context) , _sAuthentication :: !(Maybe Authentication) , _sAPIs :: !(Maybe [API]) , _sTypes :: !(Maybe [Type]) , _sSystemTypes :: !(Maybe [Type]) , _sMonitoredResources :: !(Maybe [MonitoredResourceDescriptor]) , _sBackend :: !(Maybe Backend) , _sMonitoring :: !(Maybe Monitoring) , _sName :: !(Maybe Text) , _sSystemParameters :: !(Maybe SystemParameters) , _sLogs :: !(Maybe [LogDescriptor]) , _sDocumentation :: !(Maybe Documentation) , _sId :: !(Maybe Text) , _sUsage :: !(Maybe Usage) , _sEndpoints :: !(Maybe [Endpoint]) , _sEnums :: !(Maybe [Enum']) , _sConfigVersion :: !(Maybe (Textual Word32)) , _sHTTP :: !(Maybe HTTP) , _sTitle :: !(Maybe Text) , _sProducerProjectId :: !(Maybe Text) , _sSourceInfo :: !(Maybe SourceInfo) , _sBilling :: !(Maybe Billing) , _sCustomError :: !(Maybe CustomError) , _sLogging :: !(Maybe Logging) , _sQuota :: !(Maybe Quota) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Service' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sControl' -- -- * 'sMetrics' -- -- * 'sContext' -- -- * 'sAuthentication' -- -- * 'sAPIs' -- -- * 'sTypes' -- -- * 'sSystemTypes' -- -- * 'sMonitoredResources' -- -- * 'sBackend' -- -- * 'sMonitoring' -- -- * 'sName' -- -- * 'sSystemParameters' -- -- * 'sLogs' -- -- * 'sDocumentation' -- -- * 'sId' -- -- * 'sUsage' -- -- * 'sEndpoints' -- -- * 'sEnums' -- -- * 'sConfigVersion' -- -- * 'sHTTP' -- -- * 'sTitle' -- -- * 'sProducerProjectId' -- -- * 'sSourceInfo' -- -- * 'sBilling' -- -- * 'sCustomError' -- -- * 'sLogging' -- -- * 'sQuota' service :: Service service = Service' { _sControl = Nothing , _sMetrics = Nothing , _sContext = Nothing , _sAuthentication = Nothing , _sAPIs = Nothing , _sTypes = Nothing , _sSystemTypes = Nothing , _sMonitoredResources = Nothing , _sBackend = Nothing , _sMonitoring = Nothing , _sName = Nothing , _sSystemParameters = Nothing , _sLogs = Nothing , _sDocumentation = Nothing , _sId = Nothing , _sUsage = Nothing , _sEndpoints = Nothing , _sEnums = Nothing , _sConfigVersion = Nothing , _sHTTP = Nothing , _sTitle = Nothing , _sProducerProjectId = Nothing , _sSourceInfo = Nothing , _sBilling = Nothing , _sCustomError = Nothing , _sLogging = Nothing , _sQuota = Nothing } -- | Configuration for the service control plane. sControl :: Lens' Service (Maybe Control) sControl = lens _sControl (\ s a -> s{_sControl = a}) -- | Defines the metrics used by this service. sMetrics :: Lens' Service [MetricDescriptor] sMetrics = lens _sMetrics (\ s a -> s{_sMetrics = a}) . _Default . _Coerce -- | Context configuration. sContext :: Lens' Service (Maybe Context) sContext = lens _sContext (\ s a -> s{_sContext = a}) -- | Auth configuration. sAuthentication :: Lens' Service (Maybe Authentication) sAuthentication = lens _sAuthentication (\ s a -> s{_sAuthentication = a}) -- | A list of API interfaces exported by this service. Only the \`name\` -- field of the google.protobuf.Api needs to be provided by the -- configuration author, as the remaining fields will be derived from the -- IDL during the normalization process. It is an error to specify an API -- interface here which cannot be resolved against the associated IDL -- files. sAPIs :: Lens' Service [API] sAPIs = lens _sAPIs (\ s a -> s{_sAPIs = a}) . _Default . _Coerce -- | A list of all proto message types included in this API service. Types -- referenced directly or indirectly by the \`apis\` are automatically -- included. Messages which are not referenced but shall be included, such -- as types used by the \`google.protobuf.Any\` type, should be listed here -- by name by the configuration author. Example: types: - name: -- google.protobuf.Int32 sTypes :: Lens' Service [Type] sTypes = lens _sTypes (\ s a -> s{_sTypes = a}) . _Default . _Coerce -- | A list of all proto message types included in this API service. It -- serves similar purpose as [google.api.Service.types], except that these -- types are not needed by user-defined APIs. Therefore, they will not show -- up in the generated discovery doc. This field should only be used to -- define system APIs in ESF. sSystemTypes :: Lens' Service [Type] sSystemTypes = lens _sSystemTypes (\ s a -> s{_sSystemTypes = a}) . _Default . _Coerce -- | Defines the monitored resources used by this service. This is required -- by the Service.monitoring and Service.logging configurations. sMonitoredResources :: Lens' Service [MonitoredResourceDescriptor] sMonitoredResources = lens _sMonitoredResources (\ s a -> s{_sMonitoredResources = a}) . _Default . _Coerce -- | API backend configuration. sBackend :: Lens' Service (Maybe Backend) sBackend = lens _sBackend (\ s a -> s{_sBackend = a}) -- | Monitoring configuration. sMonitoring :: Lens' Service (Maybe Monitoring) sMonitoring = lens _sMonitoring (\ s a -> s{_sMonitoring = a}) -- | The service name, which is a DNS-like logical identifier for the -- service, such as \`calendar.googleapis.com\`. The service name typically -- goes through DNS verification to make sure the owner of the service also -- owns the DNS name. sName :: Lens' Service (Maybe Text) sName = lens _sName (\ s a -> s{_sName = a}) -- | System parameter configuration. sSystemParameters :: Lens' Service (Maybe SystemParameters) sSystemParameters = lens _sSystemParameters (\ s a -> s{_sSystemParameters = a}) -- | Defines the logs used by this service. sLogs :: Lens' Service [LogDescriptor] sLogs = lens _sLogs (\ s a -> s{_sLogs = a}) . _Default . _Coerce -- | Additional API documentation. sDocumentation :: Lens' Service (Maybe Documentation) sDocumentation = lens _sDocumentation (\ s a -> s{_sDocumentation = a}) -- | A unique ID for a specific instance of this message, typically assigned -- by the client for tracking purpose. Must be no longer than 63 characters -- and only lower case letters, digits, \'.\', \'_\' and \'-\' are allowed. -- If empty, the server may choose to generate one instead. sId :: Lens' Service (Maybe Text) sId = lens _sId (\ s a -> s{_sId = a}) -- | Configuration controlling usage of this service. sUsage :: Lens' Service (Maybe Usage) sUsage = lens _sUsage (\ s a -> s{_sUsage = a}) -- | Configuration for network endpoints. If this is empty, then an endpoint -- with the same name as the service is automatically generated to service -- all defined APIs. sEndpoints :: Lens' Service [Endpoint] sEndpoints = lens _sEndpoints (\ s a -> s{_sEndpoints = a}) . _Default . _Coerce -- | A list of all enum types included in this API service. Enums referenced -- directly or indirectly by the \`apis\` are automatically included. Enums -- which are not referenced but shall be included should be listed here by -- name by the configuration author. Example: enums: - name: -- google.someapi.v1.SomeEnum sEnums :: Lens' Service [Enum'] sEnums = lens _sEnums (\ s a -> s{_sEnums = a}) . _Default . _Coerce -- | Obsolete. Do not use. This field has no semantic meaning. The service -- config compiler always sets this field to \`3\`. sConfigVersion :: Lens' Service (Maybe Word32) sConfigVersion = lens _sConfigVersion (\ s a -> s{_sConfigVersion = a}) . mapping _Coerce -- | HTTP configuration. sHTTP :: Lens' Service (Maybe HTTP) sHTTP = lens _sHTTP (\ s a -> s{_sHTTP = a}) -- | The product title for this service, it is the name displayed in Google -- Cloud Console. sTitle :: Lens' Service (Maybe Text) sTitle = lens _sTitle (\ s a -> s{_sTitle = a}) -- | The Google project that owns this service. sProducerProjectId :: Lens' Service (Maybe Text) sProducerProjectId = lens _sProducerProjectId (\ s a -> s{_sProducerProjectId = a}) -- | Output only. The source information for this configuration if available. sSourceInfo :: Lens' Service (Maybe SourceInfo) sSourceInfo = lens _sSourceInfo (\ s a -> s{_sSourceInfo = a}) -- | Billing configuration. sBilling :: Lens' Service (Maybe Billing) sBilling = lens _sBilling (\ s a -> s{_sBilling = a}) -- | Custom error configuration. sCustomError :: Lens' Service (Maybe CustomError) sCustomError = lens _sCustomError (\ s a -> s{_sCustomError = a}) -- | Logging configuration. sLogging :: Lens' Service (Maybe Logging) sLogging = lens _sLogging (\ s a -> s{_sLogging = a}) -- | Quota configuration. sQuota :: Lens' Service (Maybe Quota) sQuota = lens _sQuota (\ s a -> s{_sQuota = a}) instance FromJSON Service where parseJSON = withObject "Service" (\ o -> Service' <$> (o .:? "control") <*> (o .:? "metrics" .!= mempty) <*> (o .:? "context") <*> (o .:? "authentication") <*> (o .:? "apis" .!= mempty) <*> (o .:? "types" .!= mempty) <*> (o .:? "systemTypes" .!= mempty) <*> (o .:? "monitoredResources" .!= mempty) <*> (o .:? "backend") <*> (o .:? "monitoring") <*> (o .:? "name") <*> (o .:? "systemParameters") <*> (o .:? "logs" .!= mempty) <*> (o .:? "documentation") <*> (o .:? "id") <*> (o .:? "usage") <*> (o .:? "endpoints" .!= mempty) <*> (o .:? "enums" .!= mempty) <*> (o .:? "configVersion") <*> (o .:? "http") <*> (o .:? "title") <*> (o .:? "producerProjectId") <*> (o .:? "sourceInfo") <*> (o .:? "billing") <*> (o .:? "customError") <*> (o .:? "logging") <*> (o .:? "quota")) instance ToJSON Service where toJSON Service'{..} = object (catMaybes [("control" .=) <$> _sControl, ("metrics" .=) <$> _sMetrics, ("context" .=) <$> _sContext, ("authentication" .=) <$> _sAuthentication, ("apis" .=) <$> _sAPIs, ("types" .=) <$> _sTypes, ("systemTypes" .=) <$> _sSystemTypes, ("monitoredResources" .=) <$> _sMonitoredResources, ("backend" .=) <$> _sBackend, ("monitoring" .=) <$> _sMonitoring, ("name" .=) <$> _sName, ("systemParameters" .=) <$> _sSystemParameters, ("logs" .=) <$> _sLogs, ("documentation" .=) <$> _sDocumentation, ("id" .=) <$> _sId, ("usage" .=) <$> _sUsage, ("endpoints" .=) <$> _sEndpoints, ("enums" .=) <$> _sEnums, ("configVersion" .=) <$> _sConfigVersion, ("http" .=) <$> _sHTTP, ("title" .=) <$> _sTitle, ("producerProjectId" .=) <$> _sProducerProjectId, ("sourceInfo" .=) <$> _sSourceInfo, ("billing" .=) <$> _sBilling, ("customError" .=) <$> _sCustomError, ("logging" .=) <$> _sLogging, ("quota" .=) <$> _sQuota]) -- | This resource represents a long-running operation that is the result of -- a network API call. -- -- /See:/ 'operation' smart constructor. data Operation = Operation' { _oDone :: !(Maybe Bool) , _oError :: !(Maybe Status) , _oResponse :: !(Maybe OperationResponse) , _oName :: !(Maybe Text) , _oMetadata :: !(Maybe OperationMetadata) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Operation' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'oDone' -- -- * 'oError' -- -- * 'oResponse' -- -- * 'oName' -- -- * 'oMetadata' operation :: Operation operation = Operation' { _oDone = Nothing , _oError = Nothing , _oResponse = Nothing , _oName = Nothing , _oMetadata = Nothing } -- | If the value is \`false\`, it means the operation is still in progress. -- If \`true\`, the operation is completed, and either \`error\` or -- \`response\` is available. oDone :: Lens' Operation (Maybe Bool) oDone = lens _oDone (\ s a -> s{_oDone = a}) -- | The error result of the operation in case of failure or cancellation. oError :: Lens' Operation (Maybe Status) oError = lens _oError (\ s a -> s{_oError = a}) -- | The normal response of the operation in case of success. If the original -- method returns no data on success, such as \`Delete\`, the response is -- \`google.protobuf.Empty\`. If the original method is standard -- \`Get\`\/\`Create\`\/\`Update\`, the response should be the resource. -- For other methods, the response should have the type \`XxxResponse\`, -- where \`Xxx\` is the original method name. For example, if the original -- method name is \`TakeSnapshot()\`, the inferred response type is -- \`TakeSnapshotResponse\`. oResponse :: Lens' Operation (Maybe OperationResponse) oResponse = lens _oResponse (\ s a -> s{_oResponse = a}) -- | The server-assigned name, which is only unique within the same service -- that originally returns it. If you use the default HTTP mapping, the -- \`name\` should be a resource name ending with -- \`operations\/{unique_id}\`. oName :: Lens' Operation (Maybe Text) oName = lens _oName (\ s a -> s{_oName = a}) -- | Service-specific metadata associated with the operation. It typically -- contains progress information and common metadata such as create time. -- Some services might not provide such metadata. Any method that returns a -- long-running operation should document the metadata type, if any. oMetadata :: Lens' Operation (Maybe OperationMetadata) oMetadata = lens _oMetadata (\ s a -> s{_oMetadata = a}) instance FromJSON Operation where parseJSON = withObject "Operation" (\ o -> Operation' <$> (o .:? "done") <*> (o .:? "error") <*> (o .:? "response") <*> (o .:? "name") <*> (o .:? "metadata")) instance ToJSON Operation where toJSON Operation'{..} = object (catMaybes [("done" .=) <$> _oDone, ("error" .=) <$> _oError, ("response" .=) <$> _oResponse, ("name" .=) <$> _oName, ("metadata" .=) <$> _oMetadata]) -- | A generic empty message that you can re-use to avoid defining duplicated -- empty messages in your APIs. A typical example is to use it as the -- request or the response type of an API method. For instance: service Foo -- { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } The -- JSON representation for \`Empty\` is empty JSON object \`{}\`. -- -- /See:/ 'empty' smart constructor. data Empty = Empty' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Empty' with the minimum fields required to make a request. -- empty :: Empty empty = Empty' instance FromJSON Empty where parseJSON = withObject "Empty" (\ o -> pure Empty') instance ToJSON Empty where toJSON = const emptyObject -- | Metadata provided through GetOperation request for the LRO generated by -- RemoveDnsRecordSet API -- -- /See:/ 'removeDNSRecordSetMetadata' smart constructor. data RemoveDNSRecordSetMetadata = RemoveDNSRecordSetMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RemoveDNSRecordSetMetadata' with the minimum fields required to make a request. -- removeDNSRecordSetMetadata :: RemoveDNSRecordSetMetadata removeDNSRecordSetMetadata = RemoveDNSRecordSetMetadata' instance FromJSON RemoveDNSRecordSetMetadata where parseJSON = withObject "RemoveDNSRecordSetMetadata" (\ o -> pure RemoveDNSRecordSetMetadata') instance ToJSON RemoveDNSRecordSetMetadata where toJSON = const emptyObject -- | A custom error rule. -- -- /See:/ 'customErrorRule' smart constructor. data CustomErrorRule = CustomErrorRule' { _cerIsErrorType :: !(Maybe Bool) , _cerSelector :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'CustomErrorRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'cerIsErrorType' -- -- * 'cerSelector' customErrorRule :: CustomErrorRule customErrorRule = CustomErrorRule' {_cerIsErrorType = Nothing, _cerSelector = Nothing} -- | Mark this message as possible payload in error response. Otherwise, -- objects of this type will be filtered when they appear in error payload. cerIsErrorType :: Lens' CustomErrorRule (Maybe Bool) cerIsErrorType = lens _cerIsErrorType (\ s a -> s{_cerIsErrorType = a}) -- | Selects messages to which this rule applies. Refer to selector for -- syntax details. cerSelector :: Lens' CustomErrorRule (Maybe Text) cerSelector = lens _cerSelector (\ s a -> s{_cerSelector = a}) instance FromJSON CustomErrorRule where parseJSON = withObject "CustomErrorRule" (\ o -> CustomErrorRule' <$> (o .:? "isErrorType") <*> (o .:? "selector")) instance ToJSON CustomErrorRule where toJSON CustomErrorRule'{..} = object (catMaybes [("isErrorType" .=) <$> _cerIsErrorType, ("selector" .=) <$> _cerSelector]) -- | Response to list peered DNS domains for a given connection. -- -- /See:/ 'listPeeredDNSDomainsResponse' smart constructor. newtype ListPeeredDNSDomainsResponse = ListPeeredDNSDomainsResponse' { _lpddrPeeredDNSDomains :: Maybe [PeeredDNSDomain] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ListPeeredDNSDomainsResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lpddrPeeredDNSDomains' listPeeredDNSDomainsResponse :: ListPeeredDNSDomainsResponse listPeeredDNSDomainsResponse = ListPeeredDNSDomainsResponse' {_lpddrPeeredDNSDomains = Nothing} -- | The list of peered DNS domains. lpddrPeeredDNSDomains :: Lens' ListPeeredDNSDomainsResponse [PeeredDNSDomain] lpddrPeeredDNSDomains = lens _lpddrPeeredDNSDomains (\ s a -> s{_lpddrPeeredDNSDomains = a}) . _Default . _Coerce instance FromJSON ListPeeredDNSDomainsResponse where parseJSON = withObject "ListPeeredDNSDomainsResponse" (\ o -> ListPeeredDNSDomainsResponse' <$> (o .:? "peeredDnsDomains" .!= mempty)) instance ToJSON ListPeeredDNSDomainsResponse where toJSON ListPeeredDNSDomainsResponse'{..} = object (catMaybes [("peeredDnsDomains" .=) <$> _lpddrPeeredDNSDomains]) -- | Represents a private connection resource. A private connection is -- implemented as a VPC Network Peering connection between a service -- producer\'s VPC network and a service consumer\'s VPC network. -- -- /See:/ 'googleCloudServicenetworkingV1betaConnection' smart constructor. data GoogleCloudServicenetworkingV1betaConnection = GoogleCloudServicenetworkingV1betaConnection' { _gcsvcPeering :: !(Maybe Text) , _gcsvcReservedPeeringRanges :: !(Maybe [Text]) , _gcsvcService :: !(Maybe Text) , _gcsvcNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'GoogleCloudServicenetworkingV1betaConnection' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'gcsvcPeering' -- -- * 'gcsvcReservedPeeringRanges' -- -- * 'gcsvcService' -- -- * 'gcsvcNetwork' googleCloudServicenetworkingV1betaConnection :: GoogleCloudServicenetworkingV1betaConnection googleCloudServicenetworkingV1betaConnection = GoogleCloudServicenetworkingV1betaConnection' { _gcsvcPeering = Nothing , _gcsvcReservedPeeringRanges = Nothing , _gcsvcService = Nothing , _gcsvcNetwork = Nothing } -- | Output only. The name of the VPC Network Peering connection that was -- created by the service producer. gcsvcPeering :: Lens' GoogleCloudServicenetworkingV1betaConnection (Maybe Text) gcsvcPeering = lens _gcsvcPeering (\ s a -> s{_gcsvcPeering = a}) -- | The name of one or more allocated IP address ranges for this service -- producer of type \`PEERING\`. Note that invoking this method with a -- different range when connection is already established will not modify -- already provisioned service producer subnetworks. gcsvcReservedPeeringRanges :: Lens' GoogleCloudServicenetworkingV1betaConnection [Text] gcsvcReservedPeeringRanges = lens _gcsvcReservedPeeringRanges (\ s a -> s{_gcsvcReservedPeeringRanges = a}) . _Default . _Coerce -- | Output only. The name of the peering service that\'s associated with -- this connection, in the following format: \`services\/{service name}\`. gcsvcService :: Lens' GoogleCloudServicenetworkingV1betaConnection (Maybe Text) gcsvcService = lens _gcsvcService (\ s a -> s{_gcsvcService = a}) -- | The name of service consumer\'s VPC network that\'s connected with -- service producer network, in the following format: -- \`projects\/{project}\/global\/networks\/{network}\`. \`{project}\` is a -- project number, such as in \`12345\` that includes the VPC service -- consumer\'s VPC network. \`{network}\` is the name of the service -- consumer\'s VPC network. gcsvcNetwork :: Lens' GoogleCloudServicenetworkingV1betaConnection (Maybe Text) gcsvcNetwork = lens _gcsvcNetwork (\ s a -> s{_gcsvcNetwork = a}) instance FromJSON GoogleCloudServicenetworkingV1betaConnection where parseJSON = withObject "GoogleCloudServicenetworkingV1betaConnection" (\ o -> GoogleCloudServicenetworkingV1betaConnection' <$> (o .:? "peering") <*> (o .:? "reservedPeeringRanges" .!= mempty) <*> (o .:? "service") <*> (o .:? "network")) instance ToJSON GoogleCloudServicenetworkingV1betaConnection where toJSON GoogleCloudServicenetworkingV1betaConnection'{..} = object (catMaybes [("peering" .=) <$> _gcsvcPeering, ("reservedPeeringRanges" .=) <$> _gcsvcReservedPeeringRanges, ("service" .=) <$> _gcsvcService, ("network" .=) <$> _gcsvcNetwork]) -- | The option\'s value packed in an Any message. If the value is a -- primitive, the corresponding wrapper type defined in -- google\/protobuf\/wrappers.proto should be used. If the value is an -- enum, it should be stored as an int32 value using the -- google.protobuf.Int32Value type. -- -- /See:/ 'optionValue' smart constructor. newtype OptionValue = OptionValue' { _ovAddtional :: HashMap Text JSONValue } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'OptionValue' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ovAddtional' optionValue :: HashMap Text JSONValue -- ^ 'ovAddtional' -> OptionValue optionValue pOvAddtional_ = OptionValue' {_ovAddtional = _Coerce # pOvAddtional_} -- | Properties of the object. Contains field \'type with type URL. ovAddtional :: Lens' OptionValue (HashMap Text JSONValue) ovAddtional = lens _ovAddtional (\ s a -> s{_ovAddtional = a}) . _Coerce instance FromJSON OptionValue where parseJSON = withObject "OptionValue" (\ o -> OptionValue' <$> (parseJSONObject o)) instance ToJSON OptionValue where toJSON = toJSON . _ovAddtional -- | Enum value definition. -- -- /See:/ 'enumValue' smart constructor. data EnumValue = EnumValue' { _evName :: !(Maybe Text) , _evOptions :: !(Maybe [Option]) , _evNumber :: !(Maybe (Textual Int32)) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'EnumValue' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'evName' -- -- * 'evOptions' -- -- * 'evNumber' enumValue :: EnumValue enumValue = EnumValue' {_evName = Nothing, _evOptions = Nothing, _evNumber = Nothing} -- | Enum value name. evName :: Lens' EnumValue (Maybe Text) evName = lens _evName (\ s a -> s{_evName = a}) -- | Protocol buffer options. evOptions :: Lens' EnumValue [Option] evOptions = lens _evOptions (\ s a -> s{_evOptions = a}) . _Default . _Coerce -- | Enum value number. evNumber :: Lens' EnumValue (Maybe Int32) evNumber = lens _evNumber (\ s a -> s{_evNumber = a}) . mapping _Coerce instance FromJSON EnumValue where parseJSON = withObject "EnumValue" (\ o -> EnumValue' <$> (o .:? "name") <*> (o .:? "options" .!= mempty) <*> (o .:? "number")) instance ToJSON EnumValue where toJSON EnumValue'{..} = object (catMaybes [("name" .=) <$> _evName, ("options" .=) <$> _evOptions, ("number" .=) <$> _evNumber]) -- | \`Authentication\` defines the authentication configuration for API -- methods provided by an API service. Example: name: -- calendar.googleapis.com authentication: providers: - id: -- google_calendar_auth jwks_uri: -- https:\/\/www.googleapis.com\/oauth2\/v1\/certs issuer: -- https:\/\/securetoken.google.com rules: - selector: \"*\" requirements: -- provider_id: google_calendar_auth - selector: google.calendar.Delegate -- oauth: canonical_scopes: -- https:\/\/www.googleapis.com\/auth\/calendar.read -- -- /See:/ 'authentication' smart constructor. data Authentication = Authentication' { _aRules :: !(Maybe [AuthenticationRule]) , _aProviders :: !(Maybe [AuthProvider]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Authentication' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'aRules' -- -- * 'aProviders' authentication :: Authentication authentication = Authentication' {_aRules = Nothing, _aProviders = Nothing} -- | A list of authentication rules that apply to individual API methods. -- **NOTE:** All service configuration rules follow \"last one wins\" -- order. aRules :: Lens' Authentication [AuthenticationRule] aRules = lens _aRules (\ s a -> s{_aRules = a}) . _Default . _Coerce -- | Defines a set of authentication providers that a service supports. aProviders :: Lens' Authentication [AuthProvider] aProviders = lens _aProviders (\ s a -> s{_aProviders = a}) . _Default . _Coerce instance FromJSON Authentication where parseJSON = withObject "Authentication" (\ o -> Authentication' <$> (o .:? "rules" .!= mempty) <*> (o .:? "providers" .!= mempty)) instance ToJSON Authentication where toJSON Authentication'{..} = object (catMaybes [("rules" .=) <$> _aRules, ("providers" .=) <$> _aProviders]) -- | Metadata provided through GetOperation request for the LRO generated by -- AddRoles API -- -- /See:/ 'addRolesMetadata' smart constructor. data AddRolesMetadata = AddRolesMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddRolesMetadata' with the minimum fields required to make a request. -- addRolesMetadata :: AddRolesMetadata addRolesMetadata = AddRolesMetadata' instance FromJSON AddRolesMetadata where parseJSON = withObject "AddRolesMetadata" (\ o -> pure AddRolesMetadata') instance ToJSON AddRolesMetadata where toJSON = const emptyObject -- | Declares an API Interface to be included in this interface. The -- including interface must redeclare all the methods from the included -- interface, but documentation and options are inherited as follows: - If -- after comment and whitespace stripping, the documentation string of the -- redeclared method is empty, it will be inherited from the original -- method. - Each annotation belonging to the service config (http, -- visibility) which is not set in the redeclared method will be inherited. -- - If an http annotation is inherited, the path pattern will be modified -- as follows. Any version prefix will be replaced by the version of the -- including interface plus the root path if specified. Example of a simple -- mixin: package google.acl.v1; service AccessControl { \/\/ Get the -- underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option -- (google.api.http).get = \"\/v1\/{resource=**}:getAcl\"; } } package -- google.storage.v2; service Storage { \/\/ rpc GetAcl(GetAclRequest) -- returns (Acl); \/\/ Get a data record. rpc GetData(GetDataRequest) -- returns (Data) { option (google.api.http).get = \"\/v2\/{resource=**}\"; -- } } Example of a mixin configuration: apis: - name: -- google.storage.v2.Storage mixins: - name: google.acl.v1.AccessControl -- The mixin construct implies that all methods in \`AccessControl\` are -- also declared with same name and request\/response types in \`Storage\`. -- A documentation generator or annotation processor will see the effective -- \`Storage.GetAcl\` method after inheriting documentation and annotations -- as follows: service Storage { \/\/ Get the underlying ACL object. rpc -- GetAcl(GetAclRequest) returns (Acl) { option (google.api.http).get = -- \"\/v2\/{resource=**}:getAcl\"; } ... } Note how the version in the path -- pattern changed from \`v1\` to \`v2\`. If the \`root\` field in the -- mixin is specified, it should be a relative path under which inherited -- HTTP paths are placed. Example: apis: - name: google.storage.v2.Storage -- mixins: - name: google.acl.v1.AccessControl root: acls This implies the -- following inherited HTTP annotation: service Storage { \/\/ Get the -- underlying ACL object. rpc GetAcl(GetAclRequest) returns (Acl) { option -- (google.api.http).get = \"\/v2\/acls\/{resource=**}:getAcl\"; } ... } -- -- /See:/ 'mixin' smart constructor. data Mixin = Mixin' { _mRoot :: !(Maybe Text) , _mName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Mixin' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mRoot' -- -- * 'mName' mixin :: Mixin mixin = Mixin' {_mRoot = Nothing, _mName = Nothing} -- | If non-empty specifies a path under which inherited HTTP paths are -- rooted. mRoot :: Lens' Mixin (Maybe Text) mRoot = lens _mRoot (\ s a -> s{_mRoot = a}) -- | The fully qualified name of the interface which is included. mName :: Lens' Mixin (Maybe Text) mName = lens _mName (\ s a -> s{_mName = a}) instance FromJSON Mixin where parseJSON = withObject "Mixin" (\ o -> Mixin' <$> (o .:? "root") <*> (o .:? "name")) instance ToJSON Mixin where toJSON Mixin'{..} = object (catMaybes [("root" .=) <$> _mRoot, ("name" .=) <$> _mName]) -- | A custom pattern is used for defining custom HTTP verb. -- -- /See:/ 'customHTTPPattern' smart constructor. data CustomHTTPPattern = CustomHTTPPattern' { _chttppPath :: !(Maybe Text) , _chttppKind :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'CustomHTTPPattern' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'chttppPath' -- -- * 'chttppKind' customHTTPPattern :: CustomHTTPPattern customHTTPPattern = CustomHTTPPattern' {_chttppPath = Nothing, _chttppKind = Nothing} -- | The path matched by this custom verb. chttppPath :: Lens' CustomHTTPPattern (Maybe Text) chttppPath = lens _chttppPath (\ s a -> s{_chttppPath = a}) -- | The name of this custom HTTP verb. chttppKind :: Lens' CustomHTTPPattern (Maybe Text) chttppKind = lens _chttppKind (\ s a -> s{_chttppKind = a}) instance FromJSON CustomHTTPPattern where parseJSON = withObject "CustomHTTPPattern" (\ o -> CustomHTTPPattern' <$> (o .:? "path") <*> (o .:? "kind")) instance ToJSON CustomHTTPPattern where toJSON CustomHTTPPattern'{..} = object (catMaybes [("path" .=) <$> _chttppPath, ("kind" .=) <$> _chttppKind]) -- | Represents a consumer project. -- -- /See:/ 'consumerProject' smart constructor. newtype ConsumerProject = ConsumerProject' { _cpProjectNum :: Maybe (Textual Int64) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ConsumerProject' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'cpProjectNum' consumerProject :: ConsumerProject consumerProject = ConsumerProject' {_cpProjectNum = Nothing} -- | Required. Project number of the consumer that is launching the service -- instance. It can own the network that is peered with Google or, be a -- service project in an XPN where the host project has the network. cpProjectNum :: Lens' ConsumerProject (Maybe Int64) cpProjectNum = lens _cpProjectNum (\ s a -> s{_cpProjectNum = a}) . mapping _Coerce instance FromJSON ConsumerProject where parseJSON = withObject "ConsumerProject" (\ o -> ConsumerProject' <$> (o .:? "projectNum")) instance ToJSON ConsumerProject where toJSON ConsumerProject'{..} = object (catMaybes [("projectNum" .=) <$> _cpProjectNum]) -- | Usage configuration rules for the service. NOTE: Under development. Use -- this rule to configure unregistered calls for the service. Unregistered -- calls are calls that do not contain consumer project identity. (Example: -- calls that do not contain an API key). By default, API methods do not -- allow unregistered calls, and each method call must be identified by a -- consumer project identity. Use this rule to allow\/disallow unregistered -- calls. Example of an API that wants to allow unregistered calls for -- entire service. usage: rules: - selector: \"*\" -- allow_unregistered_calls: true Example of a method that wants to allow -- unregistered calls. usage: rules: - selector: -- \"google.example.library.v1.LibraryService.CreateBook\" -- allow_unregistered_calls: true -- -- /See:/ 'usageRule' smart constructor. data UsageRule = UsageRule' { _urSelector :: !(Maybe Text) , _urAllowUnregisteredCalls :: !(Maybe Bool) , _urSkipServiceControl :: !(Maybe Bool) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'UsageRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'urSelector' -- -- * 'urAllowUnregisteredCalls' -- -- * 'urSkipServiceControl' usageRule :: UsageRule usageRule = UsageRule' { _urSelector = Nothing , _urAllowUnregisteredCalls = Nothing , _urSkipServiceControl = Nothing } -- | Selects the methods to which this rule applies. Use \'*\' to indicate -- all methods in all APIs. Refer to selector for syntax details. urSelector :: Lens' UsageRule (Maybe Text) urSelector = lens _urSelector (\ s a -> s{_urSelector = a}) -- | If true, the selected method allows unregistered calls, e.g. calls that -- don\'t identify any user or application. urAllowUnregisteredCalls :: Lens' UsageRule (Maybe Bool) urAllowUnregisteredCalls = lens _urAllowUnregisteredCalls (\ s a -> s{_urAllowUnregisteredCalls = a}) -- | If true, the selected method should skip service control and the control -- plane features, such as quota and billing, will not be available. This -- flag is used by Google Cloud Endpoints to bypass checks for internal -- methods, such as service health check methods. urSkipServiceControl :: Lens' UsageRule (Maybe Bool) urSkipServiceControl = lens _urSkipServiceControl (\ s a -> s{_urSkipServiceControl = a}) instance FromJSON UsageRule where parseJSON = withObject "UsageRule" (\ o -> UsageRule' <$> (o .:? "selector") <*> (o .:? "allowUnregisteredCalls") <*> (o .:? "skipServiceControl")) instance ToJSON UsageRule where toJSON UsageRule'{..} = object (catMaybes [("selector" .=) <$> _urSelector, ("allowUnregisteredCalls" .=) <$> _urAllowUnregisteredCalls, ("skipServiceControl" .=) <$> _urSkipServiceControl]) -- -- /See:/ 'statusDetailsItem' smart constructor. newtype StatusDetailsItem = StatusDetailsItem' { _sdiAddtional :: HashMap Text JSONValue } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'StatusDetailsItem' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sdiAddtional' statusDetailsItem :: HashMap Text JSONValue -- ^ 'sdiAddtional' -> StatusDetailsItem statusDetailsItem pSdiAddtional_ = StatusDetailsItem' {_sdiAddtional = _Coerce # pSdiAddtional_} -- | Properties of the object. Contains field \'type with type URL. sdiAddtional :: Lens' StatusDetailsItem (HashMap Text JSONValue) sdiAddtional = lens _sdiAddtional (\ s a -> s{_sdiAddtional = a}) . _Coerce instance FromJSON StatusDetailsItem where parseJSON = withObject "StatusDetailsItem" (\ o -> StatusDetailsItem' <$> (parseJSONObject o)) instance ToJSON StatusDetailsItem where toJSON = toJSON . _sdiAddtional -- | Represents a documentation page. A page can contain subpages to -- represent nested documentation set structure. -- -- /See:/ 'page' smart constructor. data Page = Page' { _pSubpages :: !(Maybe [Page]) , _pContent :: !(Maybe Text) , _pName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Page' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'pSubpages' -- -- * 'pContent' -- -- * 'pName' page :: Page page = Page' {_pSubpages = Nothing, _pContent = Nothing, _pName = Nothing} -- | Subpages of this page. The order of subpages specified here will be -- honored in the generated docset. pSubpages :: Lens' Page [Page] pSubpages = lens _pSubpages (\ s a -> s{_pSubpages = a}) . _Default . _Coerce -- | The Markdown content of the page. You can use (== include {path} ==) to -- include content from a Markdown file. The content can be used to produce -- the documentation page such as HTML format page. pContent :: Lens' Page (Maybe Text) pContent = lens _pContent (\ s a -> s{_pContent = a}) -- | The name of the page. It will be used as an identity of the page to -- generate URI of the page, text of the link to this page in navigation, -- etc. The full page name (start from the root page name to this page -- concatenated with \`.\`) can be used as reference to the page in your -- documentation. For example: pages: - name: Tutorial content: (== include -- tutorial.md ==) subpages: - name: Java content: (== include -- tutorial_java.md ==) You can reference \`Java\` page using Markdown -- reference link syntax: \`Java\`. pName :: Lens' Page (Maybe Text) pName = lens _pName (\ s a -> s{_pName = a}) instance FromJSON Page where parseJSON = withObject "Page" (\ o -> Page' <$> (o .:? "subpages" .!= mempty) <*> (o .:? "content") <*> (o .:? "name")) instance ToJSON Page where toJSON Page'{..} = object (catMaybes [("subpages" .=) <$> _pSubpages, ("content" .=) <$> _pContent, ("name" .=) <$> _pName]) -- | Allocated IP address ranges for this private service access connection. -- -- /See:/ 'googleCloudServicenetworkingV1ConsumerConfigReservedRange' smart constructor. data GoogleCloudServicenetworkingV1ConsumerConfigReservedRange = GoogleCloudServicenetworkingV1ConsumerConfigReservedRange' { _gcsvccrrIPPrefixLength :: !(Maybe (Textual Int32)) , _gcsvccrrAddress :: !(Maybe Text) , _gcsvccrrName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'GoogleCloudServicenetworkingV1ConsumerConfigReservedRange' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'gcsvccrrIPPrefixLength' -- -- * 'gcsvccrrAddress' -- -- * 'gcsvccrrName' googleCloudServicenetworkingV1ConsumerConfigReservedRange :: GoogleCloudServicenetworkingV1ConsumerConfigReservedRange googleCloudServicenetworkingV1ConsumerConfigReservedRange = GoogleCloudServicenetworkingV1ConsumerConfigReservedRange' { _gcsvccrrIPPrefixLength = Nothing , _gcsvccrrAddress = Nothing , _gcsvccrrName = Nothing } -- | The prefix length of the reserved range. gcsvccrrIPPrefixLength :: Lens' GoogleCloudServicenetworkingV1ConsumerConfigReservedRange (Maybe Int32) gcsvccrrIPPrefixLength = lens _gcsvccrrIPPrefixLength (\ s a -> s{_gcsvccrrIPPrefixLength = a}) . mapping _Coerce -- | The starting address of the reserved range. The address must be a valid -- IPv4 address in the x.x.x.x format. This value combined with the IP -- prefix length is the CIDR range for the reserved range. gcsvccrrAddress :: Lens' GoogleCloudServicenetworkingV1ConsumerConfigReservedRange (Maybe Text) gcsvccrrAddress = lens _gcsvccrrAddress (\ s a -> s{_gcsvccrrAddress = a}) -- | The name of the reserved range. gcsvccrrName :: Lens' GoogleCloudServicenetworkingV1ConsumerConfigReservedRange (Maybe Text) gcsvccrrName = lens _gcsvccrrName (\ s a -> s{_gcsvccrrName = a}) instance FromJSON GoogleCloudServicenetworkingV1ConsumerConfigReservedRange where parseJSON = withObject "GoogleCloudServicenetworkingV1ConsumerConfigReservedRange" (\ o -> GoogleCloudServicenetworkingV1ConsumerConfigReservedRange' <$> (o .:? "ipPrefixLength") <*> (o .:? "address") <*> (o .:? "name")) instance ToJSON GoogleCloudServicenetworkingV1ConsumerConfigReservedRange where toJSON GoogleCloudServicenetworkingV1ConsumerConfigReservedRange'{..} = object (catMaybes [("ipPrefixLength" .=) <$> _gcsvccrrIPPrefixLength, ("address" .=) <$> _gcsvccrrAddress, ("name" .=) <$> _gcsvccrrName]) -- | Metadata provided through GetOperation request for the LRO generated by -- AddDnsZone API -- -- /See:/ 'addDNSZoneMetadata' smart constructor. data AddDNSZoneMetadata = AddDNSZoneMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddDNSZoneMetadata' with the minimum fields required to make a request. -- addDNSZoneMetadata :: AddDNSZoneMetadata addDNSZoneMetadata = AddDNSZoneMetadata' instance FromJSON AddDNSZoneMetadata where parseJSON = withObject "AddDNSZoneMetadata" (\ o -> pure AddDNSZoneMetadata') instance ToJSON AddDNSZoneMetadata where toJSON = const emptyObject -- | Authentication rules for the service. By default, if a method has any -- authentication requirements, every request must include a valid -- credential matching one of the requirements. It\'s an error to include -- more than one kind of credential in a single request. If a method -- doesn\'t have any auth requirements, request credentials will be -- ignored. -- -- /See:/ 'authenticationRule' smart constructor. data AuthenticationRule = AuthenticationRule' { _arRequirements :: !(Maybe [AuthRequirement]) , _arSelector :: !(Maybe Text) , _arAllowWithoutCredential :: !(Maybe Bool) , _arOAuth :: !(Maybe OAuthRequirements) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AuthenticationRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'arRequirements' -- -- * 'arSelector' -- -- * 'arAllowWithoutCredential' -- -- * 'arOAuth' authenticationRule :: AuthenticationRule authenticationRule = AuthenticationRule' { _arRequirements = Nothing , _arSelector = Nothing , _arAllowWithoutCredential = Nothing , _arOAuth = Nothing } -- | Requirements for additional authentication providers. arRequirements :: Lens' AuthenticationRule [AuthRequirement] arRequirements = lens _arRequirements (\ s a -> s{_arRequirements = a}) . _Default . _Coerce -- | Selects the methods to which this rule applies. Refer to selector for -- syntax details. arSelector :: Lens' AuthenticationRule (Maybe Text) arSelector = lens _arSelector (\ s a -> s{_arSelector = a}) -- | If true, the service accepts API keys without any other credential. This -- flag only applies to HTTP and gRPC requests. arAllowWithoutCredential :: Lens' AuthenticationRule (Maybe Bool) arAllowWithoutCredential = lens _arAllowWithoutCredential (\ s a -> s{_arAllowWithoutCredential = a}) -- | The requirements for OAuth credentials. arOAuth :: Lens' AuthenticationRule (Maybe OAuthRequirements) arOAuth = lens _arOAuth (\ s a -> s{_arOAuth = a}) instance FromJSON AuthenticationRule where parseJSON = withObject "AuthenticationRule" (\ o -> AuthenticationRule' <$> (o .:? "requirements" .!= mempty) <*> (o .:? "selector") <*> (o .:? "allowWithoutCredential") <*> (o .:? "oauth")) instance ToJSON AuthenticationRule where toJSON AuthenticationRule'{..} = object (catMaybes [("requirements" .=) <$> _arRequirements, ("selector" .=) <$> _arSelector, ("allowWithoutCredential" .=) <$> _arAllowWithoutCredential, ("oauth" .=) <$> _arOAuth]) -- | Represents a private connection resource. A private connection is -- implemented as a VPC Network Peering connection between a service -- producer\'s VPC network and a service consumer\'s VPC network. -- -- /See:/ 'connection' smart constructor. data Connection = Connection' { _cPeering :: !(Maybe Text) , _cReservedPeeringRanges :: !(Maybe [Text]) , _cService :: !(Maybe Text) , _cNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Connection' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'cPeering' -- -- * 'cReservedPeeringRanges' -- -- * 'cService' -- -- * 'cNetwork' connection :: Connection connection = Connection' { _cPeering = Nothing , _cReservedPeeringRanges = Nothing , _cService = Nothing , _cNetwork = Nothing } -- | Output only. The name of the VPC Network Peering connection that was -- created by the service producer. cPeering :: Lens' Connection (Maybe Text) cPeering = lens _cPeering (\ s a -> s{_cPeering = a}) -- | The name of one or more allocated IP address ranges for this service -- producer of type \`PEERING\`. Note that invoking CreateConnection method -- with a different range when connection is already established will not -- modify already provisioned service producer subnetworks. If -- CreateConnection method is invoked repeatedly to reconnect when peering -- connection had been disconnected on the consumer side, leaving this -- field empty will restore previously allocated IP ranges. cReservedPeeringRanges :: Lens' Connection [Text] cReservedPeeringRanges = lens _cReservedPeeringRanges (\ s a -> s{_cReservedPeeringRanges = a}) . _Default . _Coerce -- | Output only. The name of the peering service that\'s associated with -- this connection, in the following format: \`services\/{service name}\`. cService :: Lens' Connection (Maybe Text) cService = lens _cService (\ s a -> s{_cService = a}) -- | The name of service consumer\'s VPC network that\'s connected with -- service producer network, in the following format: -- \`projects\/{project}\/global\/networks\/{network}\`. \`{project}\` is a -- project number, such as in \`12345\` that includes the VPC service -- consumer\'s VPC network. \`{network}\` is the name of the service -- consumer\'s VPC network. cNetwork :: Lens' Connection (Maybe Text) cNetwork = lens _cNetwork (\ s a -> s{_cNetwork = a}) instance FromJSON Connection where parseJSON = withObject "Connection" (\ o -> Connection' <$> (o .:? "peering") <*> (o .:? "reservedPeeringRanges" .!= mempty) <*> (o .:? "service") <*> (o .:? "network")) instance ToJSON Connection where toJSON Connection'{..} = object (catMaybes [("peering" .=) <$> _cPeering, ("reservedPeeringRanges" .=) <$> _cReservedPeeringRanges, ("service" .=) <$> _cService, ("network" .=) <$> _cNetwork]) -- | Request to update a record set from a private managed DNS zone in the -- shared producer host project. The name, type, ttl, and data values of -- the existing record set must all exactly match an existing record set in -- the specified zone. -- -- /See:/ 'updateDNSRecordSetRequest' smart constructor. data UpdateDNSRecordSetRequest = UpdateDNSRecordSetRequest' { _udrsrZone :: !(Maybe Text) , _udrsrNewDNSRecordSet :: !(Maybe DNSRecordSet) , _udrsrExistingDNSRecordSet :: !(Maybe DNSRecordSet) , _udrsrConsumerNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'UpdateDNSRecordSetRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'udrsrZone' -- -- * 'udrsrNewDNSRecordSet' -- -- * 'udrsrExistingDNSRecordSet' -- -- * 'udrsrConsumerNetwork' updateDNSRecordSetRequest :: UpdateDNSRecordSetRequest updateDNSRecordSetRequest = UpdateDNSRecordSetRequest' { _udrsrZone = Nothing , _udrsrNewDNSRecordSet = Nothing , _udrsrExistingDNSRecordSet = Nothing , _udrsrConsumerNetwork = Nothing } -- | Required. The name of the private DNS zone in the shared producer host -- project from which the record set will be removed. udrsrZone :: Lens' UpdateDNSRecordSetRequest (Maybe Text) udrsrZone = lens _udrsrZone (\ s a -> s{_udrsrZone = a}) -- | Required. The new values that the DNS record set should be updated to -- hold. udrsrNewDNSRecordSet :: Lens' UpdateDNSRecordSetRequest (Maybe DNSRecordSet) udrsrNewDNSRecordSet = lens _udrsrNewDNSRecordSet (\ s a -> s{_udrsrNewDNSRecordSet = a}) -- | Required. The existing DNS record set to update. udrsrExistingDNSRecordSet :: Lens' UpdateDNSRecordSetRequest (Maybe DNSRecordSet) udrsrExistingDNSRecordSet = lens _udrsrExistingDNSRecordSet (\ s a -> s{_udrsrExistingDNSRecordSet = a}) -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is the -- project number, as in \'12345\' {network} is the network name. udrsrConsumerNetwork :: Lens' UpdateDNSRecordSetRequest (Maybe Text) udrsrConsumerNetwork = lens _udrsrConsumerNetwork (\ s a -> s{_udrsrConsumerNetwork = a}) instance FromJSON UpdateDNSRecordSetRequest where parseJSON = withObject "UpdateDNSRecordSetRequest" (\ o -> UpdateDNSRecordSetRequest' <$> (o .:? "zone") <*> (o .:? "newDnsRecordSet") <*> (o .:? "existingDnsRecordSet") <*> (o .:? "consumerNetwork")) instance ToJSON UpdateDNSRecordSetRequest where toJSON UpdateDNSRecordSetRequest'{..} = object (catMaybes [("zone" .=) <$> _udrsrZone, ("newDnsRecordSet" .=) <$> _udrsrNewDNSRecordSet, ("existingDnsRecordSet" .=) <$> _udrsrExistingDNSRecordSet, ("consumerNetwork" .=) <$> _udrsrConsumerNetwork]) -- | Metrics to update when the selected methods are called, and the -- associated cost applied to each metric. The key of the map is the metric -- name, and the values are the amount increased for the metric against -- which the quota limits are defined. The value must not be negative. -- -- /See:/ 'metricRuleMetricCosts' smart constructor. newtype MetricRuleMetricCosts = MetricRuleMetricCosts' { _mrmcAddtional :: HashMap Text (Textual Int64) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'MetricRuleMetricCosts' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mrmcAddtional' metricRuleMetricCosts :: HashMap Text Int64 -- ^ 'mrmcAddtional' -> MetricRuleMetricCosts metricRuleMetricCosts pMrmcAddtional_ = MetricRuleMetricCosts' {_mrmcAddtional = _Coerce # pMrmcAddtional_} mrmcAddtional :: Lens' MetricRuleMetricCosts (HashMap Text Int64) mrmcAddtional = lens _mrmcAddtional (\ s a -> s{_mrmcAddtional = a}) . _Coerce instance FromJSON MetricRuleMetricCosts where parseJSON = withObject "MetricRuleMetricCosts" (\ o -> MetricRuleMetricCosts' <$> (parseJSONObject o)) instance ToJSON MetricRuleMetricCosts where toJSON = toJSON . _mrmcAddtional -- | Represents a route that was created or discovered by a private access -- management service. -- -- /See:/ 'route' smart constructor. data Route = Route' { _rNextHopGateway :: !(Maybe Text) , _rNetwork :: !(Maybe Text) , _rDestRange :: !(Maybe Text) , _rName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Route' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'rNextHopGateway' -- -- * 'rNetwork' -- -- * 'rDestRange' -- -- * 'rName' route :: Route route = Route' { _rNextHopGateway = Nothing , _rNetwork = Nothing , _rDestRange = Nothing , _rName = Nothing } -- | Fully-qualified URL of the gateway that should handle matching packets -- that this route applies to. For example: -- \`projects\/123456\/global\/gateways\/default-internet-gateway\` rNextHopGateway :: Lens' Route (Maybe Text) rNextHopGateway = lens _rNextHopGateway (\ s a -> s{_rNextHopGateway = a}) -- | Fully-qualified URL of the VPC network in the producer host tenant -- project that this route applies to. For example: -- \`projects\/123456\/global\/networks\/host-network\` rNetwork :: Lens' Route (Maybe Text) rNetwork = lens _rNetwork (\ s a -> s{_rNetwork = a}) -- | Destination CIDR range that this route applies to. rDestRange :: Lens' Route (Maybe Text) rDestRange = lens _rDestRange (\ s a -> s{_rDestRange = a}) -- | Route name. See https:\/\/cloud.google.com\/vpc\/docs\/routes rName :: Lens' Route (Maybe Text) rName = lens _rName (\ s a -> s{_rName = a}) instance FromJSON Route where parseJSON = withObject "Route" (\ o -> Route' <$> (o .:? "nextHopGateway") <*> (o .:? "network") <*> (o .:? "destRange") <*> (o .:? "name")) instance ToJSON Route where toJSON Route'{..} = object (catMaybes [("nextHopGateway" .=) <$> _rNextHopGateway, ("network" .=) <$> _rNetwork, ("destRange" .=) <$> _rDestRange, ("name" .=) <$> _rName]) -- | Request to disable VPC service controls. -- -- /See:/ 'disableVPCServiceControlsRequest' smart constructor. newtype DisableVPCServiceControlsRequest = DisableVPCServiceControlsRequest' { _dvscrConsumerNetwork :: Maybe Text } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DisableVPCServiceControlsRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'dvscrConsumerNetwork' disableVPCServiceControlsRequest :: DisableVPCServiceControlsRequest disableVPCServiceControlsRequest = DisableVPCServiceControlsRequest' {_dvscrConsumerNetwork = Nothing} -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is a project -- number, as in \'12345\' {network} is network name. dvscrConsumerNetwork :: Lens' DisableVPCServiceControlsRequest (Maybe Text) dvscrConsumerNetwork = lens _dvscrConsumerNetwork (\ s a -> s{_dvscrConsumerNetwork = a}) instance FromJSON DisableVPCServiceControlsRequest where parseJSON = withObject "DisableVPCServiceControlsRequest" (\ o -> DisableVPCServiceControlsRequest' <$> (o .:? "consumerNetwork")) instance ToJSON DisableVPCServiceControlsRequest where toJSON DisableVPCServiceControlsRequest'{..} = object (catMaybes [("consumerNetwork" .=) <$> _dvscrConsumerNetwork]) -- | Metadata provided through GetOperation request for the LRO generated by -- Partial Delete Connection API -- -- /See:/ 'partialDeleteConnectionMetadata' smart constructor. data PartialDeleteConnectionMetadata = PartialDeleteConnectionMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'PartialDeleteConnectionMetadata' with the minimum fields required to make a request. -- partialDeleteConnectionMetadata :: PartialDeleteConnectionMetadata partialDeleteConnectionMetadata = PartialDeleteConnectionMetadata' instance FromJSON PartialDeleteConnectionMetadata where parseJSON = withObject "PartialDeleteConnectionMetadata" (\ o -> pure PartialDeleteConnectionMetadata') instance ToJSON PartialDeleteConnectionMetadata where toJSON = const emptyObject -- | Request to remove a record set from a private managed DNS zone in the -- shared producer host project. The name, type, ttl, and data values must -- all exactly match an existing record set in the specified zone. -- -- /See:/ 'removeDNSRecordSetRequest' smart constructor. data RemoveDNSRecordSetRequest = RemoveDNSRecordSetRequest' { _rdrsrZone :: !(Maybe Text) , _rdrsrConsumerNetwork :: !(Maybe Text) , _rdrsrDNSRecordSet :: !(Maybe DNSRecordSet) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RemoveDNSRecordSetRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'rdrsrZone' -- -- * 'rdrsrConsumerNetwork' -- -- * 'rdrsrDNSRecordSet' removeDNSRecordSetRequest :: RemoveDNSRecordSetRequest removeDNSRecordSetRequest = RemoveDNSRecordSetRequest' { _rdrsrZone = Nothing , _rdrsrConsumerNetwork = Nothing , _rdrsrDNSRecordSet = Nothing } -- | Required. The name of the private DNS zone in the shared producer host -- project from which the record set will be removed. rdrsrZone :: Lens' RemoveDNSRecordSetRequest (Maybe Text) rdrsrZone = lens _rdrsrZone (\ s a -> s{_rdrsrZone = a}) -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is the -- project number, as in \'12345\' {network} is the network name. rdrsrConsumerNetwork :: Lens' RemoveDNSRecordSetRequest (Maybe Text) rdrsrConsumerNetwork = lens _rdrsrConsumerNetwork (\ s a -> s{_rdrsrConsumerNetwork = a}) -- | Required. The DNS record set to remove. rdrsrDNSRecordSet :: Lens' RemoveDNSRecordSetRequest (Maybe DNSRecordSet) rdrsrDNSRecordSet = lens _rdrsrDNSRecordSet (\ s a -> s{_rdrsrDNSRecordSet = a}) instance FromJSON RemoveDNSRecordSetRequest where parseJSON = withObject "RemoveDNSRecordSetRequest" (\ o -> RemoveDNSRecordSetRequest' <$> (o .:? "zone") <*> (o .:? "consumerNetwork") <*> (o .:? "dnsRecordSet")) instance ToJSON RemoveDNSRecordSetRequest where toJSON RemoveDNSRecordSetRequest'{..} = object (catMaybes [("zone" .=) <$> _rdrsrZone, ("consumerNetwork" .=) <$> _rdrsrConsumerNetwork, ("dnsRecordSet" .=) <$> _rdrsrDNSRecordSet]) -- | Grouping of IAM role and IAM member. -- -- /See:/ 'policyBinding' smart constructor. data PolicyBinding = PolicyBinding' { _pbRole :: !(Maybe Text) , _pbMember :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'PolicyBinding' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'pbRole' -- -- * 'pbMember' policyBinding :: PolicyBinding policyBinding = PolicyBinding' {_pbRole = Nothing, _pbMember = Nothing} -- | Required. Role to apply. Only allowlisted roles can be used at the -- specified granularity. The role must be one of the following: - -- \'roles\/container.hostServiceAgentUser\' applied on the shared VPC host -- project - \'roles\/compute.securityAdmin\' applied on the shared VPC -- host project pbRole :: Lens' PolicyBinding (Maybe Text) pbRole = lens _pbRole (\ s a -> s{_pbRole = a}) -- | Required. Member to bind the role with. See -- \/iam\/docs\/reference\/rest\/v1\/Policy#Binding for how to format each -- member. Eg. - user:myuser\'mydomain.com - -- serviceAccount:my-service-account\'app.gserviceaccount.com pbMember :: Lens' PolicyBinding (Maybe Text) pbMember = lens _pbMember (\ s a -> s{_pbMember = a}) instance FromJSON PolicyBinding where parseJSON = withObject "PolicyBinding" (\ o -> PolicyBinding' <$> (o .:? "role") <*> (o .:? "member")) instance ToJSON PolicyBinding where toJSON PolicyBinding'{..} = object (catMaybes [("role" .=) <$> _pbRole, ("member" .=) <$> _pbMember]) -- -- /See:/ 'validateConsumerConfigResponse' smart constructor. data ValidateConsumerConfigResponse = ValidateConsumerConfigResponse' { _vccrExistingSubnetworkCandidates :: !(Maybe [Subnetwork]) , _vccrValidationError :: !(Maybe ValidateConsumerConfigResponseValidationError) , _vccrIsValid :: !(Maybe Bool) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ValidateConsumerConfigResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'vccrExistingSubnetworkCandidates' -- -- * 'vccrValidationError' -- -- * 'vccrIsValid' validateConsumerConfigResponse :: ValidateConsumerConfigResponse validateConsumerConfigResponse = ValidateConsumerConfigResponse' { _vccrExistingSubnetworkCandidates = Nothing , _vccrValidationError = Nothing , _vccrIsValid = Nothing } -- | List of subnetwork candidates from the request which exist with the -- \`ip_cidr_range\`, \`secondary_ip_cider_ranges\`, and -- \`outside_allocation\` fields set. vccrExistingSubnetworkCandidates :: Lens' ValidateConsumerConfigResponse [Subnetwork] vccrExistingSubnetworkCandidates = lens _vccrExistingSubnetworkCandidates (\ s a -> s{_vccrExistingSubnetworkCandidates = a}) . _Default . _Coerce -- | The first validation which failed. vccrValidationError :: Lens' ValidateConsumerConfigResponse (Maybe ValidateConsumerConfigResponseValidationError) vccrValidationError = lens _vccrValidationError (\ s a -> s{_vccrValidationError = a}) -- | Indicates whether all the requested validations passed. vccrIsValid :: Lens' ValidateConsumerConfigResponse (Maybe Bool) vccrIsValid = lens _vccrIsValid (\ s a -> s{_vccrIsValid = a}) instance FromJSON ValidateConsumerConfigResponse where parseJSON = withObject "ValidateConsumerConfigResponse" (\ o -> ValidateConsumerConfigResponse' <$> (o .:? "existingSubnetworkCandidates" .!= mempty) <*> (o .:? "validationError") <*> (o .:? "isValid")) instance ToJSON ValidateConsumerConfigResponse where toJSON ValidateConsumerConfigResponse'{..} = object (catMaybes [("existingSubnetworkCandidates" .=) <$> _vccrExistingSubnetworkCandidates, ("validationError" .=) <$> _vccrValidationError, ("isValid" .=) <$> _vccrIsValid]) -- | \`Backend\` defines the backend configuration for a service. -- -- /See:/ 'backend' smart constructor. newtype Backend = Backend' { _bRules :: Maybe [BackendRule] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Backend' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'bRules' backend :: Backend backend = Backend' {_bRules = Nothing} -- | A list of API backend rules that apply to individual API methods. -- **NOTE:** All service configuration rules follow \"last one wins\" -- order. bRules :: Lens' Backend [BackendRule] bRules = lens _bRules (\ s a -> s{_bRules = a}) . _Default . _Coerce instance FromJSON Backend where parseJSON = withObject "Backend" (\ o -> Backend' <$> (o .:? "rules" .!= mempty)) instance ToJSON Backend where toJSON Backend'{..} = object (catMaybes [("rules" .=) <$> _bRules]) -- | Request to update the configuration of a service networking connection -- including the import\/export of custom routes and subnetwork routes with -- public IP. -- -- /See:/ 'updateConsumerConfigRequest' smart constructor. newtype UpdateConsumerConfigRequest = UpdateConsumerConfigRequest' { _uccrConsumerConfig :: Maybe ConsumerConfig } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'UpdateConsumerConfigRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'uccrConsumerConfig' updateConsumerConfigRequest :: UpdateConsumerConfigRequest updateConsumerConfigRequest = UpdateConsumerConfigRequest' {_uccrConsumerConfig = Nothing} -- | Required. The updated peering config. uccrConsumerConfig :: Lens' UpdateConsumerConfigRequest (Maybe ConsumerConfig) uccrConsumerConfig = lens _uccrConsumerConfig (\ s a -> s{_uccrConsumerConfig = a}) instance FromJSON UpdateConsumerConfigRequest where parseJSON = withObject "UpdateConsumerConfigRequest" (\ o -> UpdateConsumerConfigRequest' <$> (o .:? "consumerConfig")) instance ToJSON UpdateConsumerConfigRequest where toJSON UpdateConsumerConfigRequest'{..} = object (catMaybes [("consumerConfig" .=) <$> _uccrConsumerConfig]) -- | Monitoring configuration of the service. The example below shows how to -- configure monitored resources and metrics for monitoring. In the -- example, a monitored resource and two metrics are defined. The -- \`library.googleapis.com\/book\/returned_count\` metric is sent to both -- producer and consumer projects, whereas the -- \`library.googleapis.com\/book\/num_overdue\` metric is only sent to the -- consumer project. monitored_resources: - type: -- library.googleapis.com\/Branch display_name: \"Library Branch\" -- description: \"A branch of a library.\" launch_stage: GA labels: - key: -- resource_container description: \"The Cloud container (ie. project id) -- for the Branch.\" - key: location description: \"The location of the -- library branch.\" - key: branch_id description: \"The id of the -- branch.\" metrics: - name: library.googleapis.com\/book\/returned_count -- display_name: \"Books Returned\" description: \"The count of books that -- have been returned.\" launch_stage: GA metric_kind: DELTA value_type: -- INT64 unit: \"1\" labels: - key: customer_id description: \"The id of -- the customer.\" - name: library.googleapis.com\/book\/num_overdue -- display_name: \"Books Overdue\" description: \"The current number of -- overdue books.\" launch_stage: GA metric_kind: GAUGE value_type: INT64 -- unit: \"1\" labels: - key: customer_id description: \"The id of the -- customer.\" monitoring: producer_destinations: - monitored_resource: -- library.googleapis.com\/Branch metrics: - -- library.googleapis.com\/book\/returned_count consumer_destinations: - -- monitored_resource: library.googleapis.com\/Branch metrics: - -- library.googleapis.com\/book\/returned_count - -- library.googleapis.com\/book\/num_overdue -- -- /See:/ 'monitoring' smart constructor. data Monitoring = Monitoring' { _mProducerDestinations :: !(Maybe [MonitoringDestination]) , _mConsumerDestinations :: !(Maybe [MonitoringDestination]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Monitoring' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mProducerDestinations' -- -- * 'mConsumerDestinations' monitoring :: Monitoring monitoring = Monitoring' {_mProducerDestinations = Nothing, _mConsumerDestinations = Nothing} -- | Monitoring configurations for sending metrics to the producer project. -- There can be multiple producer destinations. A monitored resource type -- may appear in multiple monitoring destinations if different aggregations -- are needed for different sets of metrics associated with that monitored -- resource type. A monitored resource and metric pair may only be used -- once in the Monitoring configuration. mProducerDestinations :: Lens' Monitoring [MonitoringDestination] mProducerDestinations = lens _mProducerDestinations (\ s a -> s{_mProducerDestinations = a}) . _Default . _Coerce -- | Monitoring configurations for sending metrics to the consumer project. -- There can be multiple consumer destinations. A monitored resource type -- may appear in multiple monitoring destinations if different aggregations -- are needed for different sets of metrics associated with that monitored -- resource type. A monitored resource and metric pair may only be used -- once in the Monitoring configuration. mConsumerDestinations :: Lens' Monitoring [MonitoringDestination] mConsumerDestinations = lens _mConsumerDestinations (\ s a -> s{_mConsumerDestinations = a}) . _Default . _Coerce instance FromJSON Monitoring where parseJSON = withObject "Monitoring" (\ o -> Monitoring' <$> (o .:? "producerDestinations" .!= mempty) <*> (o .:? "consumerDestinations" .!= mempty)) instance ToJSON Monitoring where toJSON Monitoring'{..} = object (catMaybes [("producerDestinations" .=) <$> _mProducerDestinations, ("consumerDestinations" .=) <$> _mConsumerDestinations]) -- | A description of a log type. Example in YAML format: - name: -- library.googleapis.com\/activity_history description: The history of -- borrowing and returning library items. display_name: Activity labels: - -- key: \/customer_id description: Identifier of a library customer -- -- /See:/ 'logDescriptor' smart constructor. data LogDescriptor = LogDescriptor' { _ldName :: !(Maybe Text) , _ldDisplayName :: !(Maybe Text) , _ldLabels :: !(Maybe [LabelDescriptor]) , _ldDescription :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'LogDescriptor' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ldName' -- -- * 'ldDisplayName' -- -- * 'ldLabels' -- -- * 'ldDescription' logDescriptor :: LogDescriptor logDescriptor = LogDescriptor' { _ldName = Nothing , _ldDisplayName = Nothing , _ldLabels = Nothing , _ldDescription = Nothing } -- | The name of the log. It must be less than 512 characters long and can -- include the following characters: upper- and lower-case alphanumeric -- characters [A-Za-z0-9], and punctuation characters including slash, -- underscore, hyphen, period [\/_-.]. ldName :: Lens' LogDescriptor (Maybe Text) ldName = lens _ldName (\ s a -> s{_ldName = a}) -- | The human-readable name for this log. This information appears on the -- user interface and should be concise. ldDisplayName :: Lens' LogDescriptor (Maybe Text) ldDisplayName = lens _ldDisplayName (\ s a -> s{_ldDisplayName = a}) -- | The set of labels that are available to describe a specific log entry. -- Runtime requests that contain labels not specified here are considered -- invalid. ldLabels :: Lens' LogDescriptor [LabelDescriptor] ldLabels = lens _ldLabels (\ s a -> s{_ldLabels = a}) . _Default . _Coerce -- | A human-readable description of this log. This information appears in -- the documentation and can contain details. ldDescription :: Lens' LogDescriptor (Maybe Text) ldDescription = lens _ldDescription (\ s a -> s{_ldDescription = a}) instance FromJSON LogDescriptor where parseJSON = withObject "LogDescriptor" (\ o -> LogDescriptor' <$> (o .:? "name") <*> (o .:? "displayName") <*> (o .:? "labels" .!= mempty) <*> (o .:? "description")) instance ToJSON LogDescriptor where toJSON LogDescriptor'{..} = object (catMaybes [("name" .=) <$> _ldName, ("displayName" .=) <$> _ldDisplayName, ("labels" .=) <$> _ldLabels, ("description" .=) <$> _ldDescription]) -- | Method represents a method of an API interface. -- -- /See:/ 'method' smart constructor. data Method = Method' { _metRequestStreaming :: !(Maybe Bool) , _metResponseTypeURL :: !(Maybe Text) , _metName :: !(Maybe Text) , _metResponseStreaming :: !(Maybe Bool) , _metRequestTypeURL :: !(Maybe Text) , _metOptions :: !(Maybe [Option]) , _metSyntax :: !(Maybe MethodSyntax) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Method' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'metRequestStreaming' -- -- * 'metResponseTypeURL' -- -- * 'metName' -- -- * 'metResponseStreaming' -- -- * 'metRequestTypeURL' -- -- * 'metOptions' -- -- * 'metSyntax' method :: Method method = Method' { _metRequestStreaming = Nothing , _metResponseTypeURL = Nothing , _metName = Nothing , _metResponseStreaming = Nothing , _metRequestTypeURL = Nothing , _metOptions = Nothing , _metSyntax = Nothing } -- | If true, the request is streamed. metRequestStreaming :: Lens' Method (Maybe Bool) metRequestStreaming = lens _metRequestStreaming (\ s a -> s{_metRequestStreaming = a}) -- | The URL of the output message type. metResponseTypeURL :: Lens' Method (Maybe Text) metResponseTypeURL = lens _metResponseTypeURL (\ s a -> s{_metResponseTypeURL = a}) -- | The simple name of this method. metName :: Lens' Method (Maybe Text) metName = lens _metName (\ s a -> s{_metName = a}) -- | If true, the response is streamed. metResponseStreaming :: Lens' Method (Maybe Bool) metResponseStreaming = lens _metResponseStreaming (\ s a -> s{_metResponseStreaming = a}) -- | A URL of the input message type. metRequestTypeURL :: Lens' Method (Maybe Text) metRequestTypeURL = lens _metRequestTypeURL (\ s a -> s{_metRequestTypeURL = a}) -- | Any metadata attached to the method. metOptions :: Lens' Method [Option] metOptions = lens _metOptions (\ s a -> s{_metOptions = a}) . _Default . _Coerce -- | The source syntax of this method. metSyntax :: Lens' Method (Maybe MethodSyntax) metSyntax = lens _metSyntax (\ s a -> s{_metSyntax = a}) instance FromJSON Method where parseJSON = withObject "Method" (\ o -> Method' <$> (o .:? "requestStreaming") <*> (o .:? "responseTypeUrl") <*> (o .:? "name") <*> (o .:? "responseStreaming") <*> (o .:? "requestTypeUrl") <*> (o .:? "options" .!= mempty) <*> (o .:? "syntax")) instance ToJSON Method where toJSON Method'{..} = object (catMaybes [("requestStreaming" .=) <$> _metRequestStreaming, ("responseTypeUrl" .=) <$> _metResponseTypeURL, ("name" .=) <$> _metName, ("responseStreaming" .=) <$> _metResponseStreaming, ("requestTypeUrl" .=) <$> _metRequestTypeURL, ("options" .=) <$> _metOptions, ("syntax" .=) <$> _metSyntax]) -- | Represents a found unused range. -- -- /See:/ 'range' smart constructor. data Range = Range' { _ranNetwork :: !(Maybe Text) , _ranIPCIdRRange :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Range' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ranNetwork' -- -- * 'ranIPCIdRRange' range :: Range range = Range' {_ranNetwork = Nothing, _ranIPCIdRRange = Nothing} -- | In the Shared VPC host project, the VPC network that\'s peered with the -- consumer network. For example: -- \`projects\/1234321\/global\/networks\/host-network\` ranNetwork :: Lens' Range (Maybe Text) ranNetwork = lens _ranNetwork (\ s a -> s{_ranNetwork = a}) -- | CIDR range in \"10.x.x.x\/y\" format that is within the allocated ranges -- and currently unused. ranIPCIdRRange :: Lens' Range (Maybe Text) ranIPCIdRRange = lens _ranIPCIdRRange (\ s a -> s{_ranIPCIdRRange = a}) instance FromJSON Range where parseJSON = withObject "Range" (\ o -> Range' <$> (o .:? "network") <*> (o .:? "ipCidrRange")) instance ToJSON Range where toJSON Range'{..} = object (catMaybes [("network" .=) <$> _ranNetwork, ("ipCidrRange" .=) <$> _ranIPCIdRRange]) -- | ### System parameter configuration A system parameter is a special kind -- of parameter defined by the API system, not by an individual API. It is -- typically mapped to an HTTP header and\/or a URL query parameter. This -- configuration specifies which methods change the names of the system -- parameters. -- -- /See:/ 'systemParameters' smart constructor. newtype SystemParameters = SystemParameters' { _spRules :: Maybe [SystemParameterRule] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SystemParameters' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'spRules' systemParameters :: SystemParameters systemParameters = SystemParameters' {_spRules = Nothing} -- | Define system parameters. The parameters defined here will override the -- default parameters implemented by the system. If this field is missing -- from the service config, default system parameters will be used. Default -- system parameters and names is implementation-dependent. Example: define -- api key for all methods system_parameters rules: - selector: \"*\" -- parameters: - name: api_key url_query_parameter: api_key Example: define -- 2 api key names for a specific method. system_parameters rules: - -- selector: \"\/ListShelves\" parameters: - name: api_key http_header: -- Api-Key1 - name: api_key http_header: Api-Key2 **NOTE:** All service -- configuration rules follow \"last one wins\" order. spRules :: Lens' SystemParameters [SystemParameterRule] spRules = lens _spRules (\ s a -> s{_spRules = a}) . _Default . _Coerce instance FromJSON SystemParameters where parseJSON = withObject "SystemParameters" (\ o -> SystemParameters' <$> (o .:? "rules" .!= mempty)) instance ToJSON SystemParameters where toJSON SystemParameters'{..} = object (catMaybes [("rules" .=) <$> _spRules]) -- | Metadata provided through GetOperation request for the LRO generated by -- Delete Connection API -- -- /See:/ 'deleteConnectionMetadata' smart constructor. data DeleteConnectionMetadata = DeleteConnectionMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DeleteConnectionMetadata' with the minimum fields required to make a request. -- deleteConnectionMetadata :: DeleteConnectionMetadata deleteConnectionMetadata = DeleteConnectionMetadata' instance FromJSON DeleteConnectionMetadata where parseJSON = withObject "DeleteConnectionMetadata" (\ o -> pure DeleteConnectionMetadata') instance ToJSON DeleteConnectionMetadata where toJSON = const emptyObject -- | Blank message response type for RemoveDnsZone API -- -- /See:/ 'removeDNSZoneResponse' smart constructor. data RemoveDNSZoneResponse = RemoveDNSZoneResponse' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RemoveDNSZoneResponse' with the minimum fields required to make a request. -- removeDNSZoneResponse :: RemoveDNSZoneResponse removeDNSZoneResponse = RemoveDNSZoneResponse' instance FromJSON RemoveDNSZoneResponse where parseJSON = withObject "RemoveDNSZoneResponse" (\ o -> pure RemoveDNSZoneResponse') instance ToJSON RemoveDNSZoneResponse where toJSON = const emptyObject -- | \`Documentation\` provides the information for describing a service. -- Example: documentation: summary: > The Google Calendar API gives access -- to most calendar features. pages: - name: Overview content: (== include -- google\/foo\/overview.md ==) - name: Tutorial content: (== include -- google\/foo\/tutorial.md ==) subpages; - name: Java content: (== include -- google\/foo\/tutorial_java.md ==) rules: - selector: -- google.calendar.Calendar.Get description: > ... - selector: -- google.calendar.Calendar.Put description: > ... Documentation is -- provided in markdown syntax. In addition to standard markdown features, -- definition lists, tables and fenced code blocks are supported. Section -- headers can be provided and are interpreted relative to the section -- nesting of the context where a documentation fragment is embedded. -- Documentation from the IDL is merged with documentation defined via the -- config at normalization time, where documentation provided by config -- rules overrides IDL provided. A number of constructs specific to the API -- platform are supported in documentation text. In order to reference a -- proto element, the following notation can be used: -- [fully.qualified.proto.name][] To override the display text used for the -- link, this can be used: [display text][fully.qualified.proto.name] Text -- can be excluded from doc using the following notation: (-- internal -- comment --) A few directives are available in documentation. Note that -- directives must appear on a single line to be properly identified. The -- \`include\` directive includes a markdown file from an external source: -- (== include path\/to\/file ==) The \`resource_for\` directive marks a -- message to be the resource of a collection in REST view. If it is not -- specified, tools attempt to infer the resource from the operations in a -- collection: (== resource_for v1.shelves.books ==) The directive -- \`suppress_warning\` does not directly affect documentation and is -- documented together with service config validation. -- -- /See:/ 'documentation' smart constructor. data Documentation = Documentation' { _dSummary :: !(Maybe Text) , _dDocumentationRootURL :: !(Maybe Text) , _dRules :: !(Maybe [DocumentationRule]) , _dPages :: !(Maybe [Page]) , _dServiceRootURL :: !(Maybe Text) , _dOverview :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Documentation' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'dSummary' -- -- * 'dDocumentationRootURL' -- -- * 'dRules' -- -- * 'dPages' -- -- * 'dServiceRootURL' -- -- * 'dOverview' documentation :: Documentation documentation = Documentation' { _dSummary = Nothing , _dDocumentationRootURL = Nothing , _dRules = Nothing , _dPages = Nothing , _dServiceRootURL = Nothing , _dOverview = Nothing } -- | A short description of what the service does. The summary must be plain -- text. It becomes the overview of the service displayed in Google Cloud -- Console. NOTE: This field is equivalent to the standard field -- \`description\`. dSummary :: Lens' Documentation (Maybe Text) dSummary = lens _dSummary (\ s a -> s{_dSummary = a}) -- | The URL to the root of documentation. dDocumentationRootURL :: Lens' Documentation (Maybe Text) dDocumentationRootURL = lens _dDocumentationRootURL (\ s a -> s{_dDocumentationRootURL = a}) -- | A list of documentation rules that apply to individual API elements. -- **NOTE:** All service configuration rules follow \"last one wins\" -- order. dRules :: Lens' Documentation [DocumentationRule] dRules = lens _dRules (\ s a -> s{_dRules = a}) . _Default . _Coerce -- | The top level pages for the documentation set. dPages :: Lens' Documentation [Page] dPages = lens _dPages (\ s a -> s{_dPages = a}) . _Default . _Coerce -- | Specifies the service root url if the default one (the service name from -- the yaml file) is not suitable. This can be seen in any fully specified -- service urls as well as sections that show a base that other urls are -- relative to. dServiceRootURL :: Lens' Documentation (Maybe Text) dServiceRootURL = lens _dServiceRootURL (\ s a -> s{_dServiceRootURL = a}) -- | Declares a single overview page. For example: documentation: summary: -- ... overview: (== include overview.md ==) This is a shortcut for the -- following declaration (using pages style): documentation: summary: ... -- pages: - name: Overview content: (== include overview.md ==) Note: you -- cannot specify both \`overview\` field and \`pages\` field. dOverview :: Lens' Documentation (Maybe Text) dOverview = lens _dOverview (\ s a -> s{_dOverview = a}) instance FromJSON Documentation where parseJSON = withObject "Documentation" (\ o -> Documentation' <$> (o .:? "summary") <*> (o .:? "documentationRootUrl") <*> (o .:? "rules" .!= mempty) <*> (o .:? "pages" .!= mempty) <*> (o .:? "serviceRootUrl") <*> (o .:? "overview")) instance ToJSON Documentation where toJSON Documentation'{..} = object (catMaybes [("summary" .=) <$> _dSummary, ("documentationRootUrl" .=) <$> _dDocumentationRootURL, ("rules" .=) <$> _dRules, ("pages" .=) <$> _dPages, ("serviceRootUrl" .=) <$> _dServiceRootURL, ("overview" .=) <$> _dOverview]) -- | Metadata provided through GetOperation request for the LRO generated by -- AddDnsRecordSet API -- -- /See:/ 'addDNSRecordSetMetadata' smart constructor. data AddDNSRecordSetMetadata = AddDNSRecordSetMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddDNSRecordSetMetadata' with the minimum fields required to make a request. -- addDNSRecordSetMetadata :: AddDNSRecordSetMetadata addDNSRecordSetMetadata = AddDNSRecordSetMetadata' instance FromJSON AddDNSRecordSetMetadata where parseJSON = withObject "AddDNSRecordSetMetadata" (\ o -> pure AddDNSRecordSetMetadata') instance ToJSON AddDNSRecordSetMetadata where toJSON = const emptyObject -- | Additional annotations that can be used to guide the usage of a metric. -- -- /See:/ 'metricDescriptorMetadata' smart constructor. data MetricDescriptorMetadata = MetricDescriptorMetadata' { _mdmSamplePeriod :: !(Maybe GDuration) , _mdmIngestDelay :: !(Maybe GDuration) , _mdmLaunchStage :: !(Maybe MetricDescriptorMetadataLaunchStage) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'MetricDescriptorMetadata' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mdmSamplePeriod' -- -- * 'mdmIngestDelay' -- -- * 'mdmLaunchStage' metricDescriptorMetadata :: MetricDescriptorMetadata metricDescriptorMetadata = MetricDescriptorMetadata' { _mdmSamplePeriod = Nothing , _mdmIngestDelay = Nothing , _mdmLaunchStage = Nothing } -- | The sampling period of metric data points. For metrics which are written -- periodically, consecutive data points are stored at this time interval, -- excluding data loss due to errors. Metrics with a higher granularity -- have a smaller sampling period. mdmSamplePeriod :: Lens' MetricDescriptorMetadata (Maybe Scientific) mdmSamplePeriod = lens _mdmSamplePeriod (\ s a -> s{_mdmSamplePeriod = a}) . mapping _GDuration -- | The delay of data points caused by ingestion. Data points older than -- this age are guaranteed to be ingested and available to be read, -- excluding data loss due to errors. mdmIngestDelay :: Lens' MetricDescriptorMetadata (Maybe Scientific) mdmIngestDelay = lens _mdmIngestDelay (\ s a -> s{_mdmIngestDelay = a}) . mapping _GDuration -- | Deprecated. Must use the MetricDescriptor.launch_stage instead. mdmLaunchStage :: Lens' MetricDescriptorMetadata (Maybe MetricDescriptorMetadataLaunchStage) mdmLaunchStage = lens _mdmLaunchStage (\ s a -> s{_mdmLaunchStage = a}) instance FromJSON MetricDescriptorMetadata where parseJSON = withObject "MetricDescriptorMetadata" (\ o -> MetricDescriptorMetadata' <$> (o .:? "samplePeriod") <*> (o .:? "ingestDelay") <*> (o .:? "launchStage")) instance ToJSON MetricDescriptorMetadata where toJSON MetricDescriptorMetadata'{..} = object (catMaybes [("samplePeriod" .=) <$> _mdmSamplePeriod, ("ingestDelay" .=) <$> _mdmIngestDelay, ("launchStage" .=) <$> _mdmLaunchStage]) -- | DNS domain suffix for which requests originating in the producer VPC -- network are resolved in the associated consumer VPC network. -- -- /See:/ 'peeredDNSDomain' smart constructor. data PeeredDNSDomain = PeeredDNSDomain' { _pddDNSSuffix :: !(Maybe Text) , _pddName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'PeeredDNSDomain' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'pddDNSSuffix' -- -- * 'pddName' peeredDNSDomain :: PeeredDNSDomain peeredDNSDomain = PeeredDNSDomain' {_pddDNSSuffix = Nothing, _pddName = Nothing} -- | The DNS domain name suffix e.g. \`example.com.\`. pddDNSSuffix :: Lens' PeeredDNSDomain (Maybe Text) pddDNSSuffix = lens _pddDNSSuffix (\ s a -> s{_pddDNSSuffix = a}) -- | User assigned name for this resource. Must be unique within the consumer -- network. The name must be 1-63 characters long, must begin with a -- letter, end with a letter or digit, and only contain lowercase letters, -- digits or dashes. pddName :: Lens' PeeredDNSDomain (Maybe Text) pddName = lens _pddName (\ s a -> s{_pddName = a}) instance FromJSON PeeredDNSDomain where parseJSON = withObject "PeeredDNSDomain" (\ o -> PeeredDNSDomain' <$> (o .:? "dnsSuffix") <*> (o .:? "name")) instance ToJSON PeeredDNSDomain where toJSON PeeredDNSDomain'{..} = object (catMaybes [("dnsSuffix" .=) <$> _pddDNSSuffix, ("name" .=) <$> _pddName]) -- | Represents a subnet that was created or discovered by a private access -- management service. -- -- /See:/ 'subnetwork' smart constructor. data Subnetwork = Subnetwork' { _subOutsideAllocation :: !(Maybe Bool) , _subNetwork :: !(Maybe Text) , _subName :: !(Maybe Text) , _subSecondaryIPRanges :: !(Maybe [SecondaryIPRange]) , _subIPCIdRRange :: !(Maybe Text) , _subRegion :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Subnetwork' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'subOutsideAllocation' -- -- * 'subNetwork' -- -- * 'subName' -- -- * 'subSecondaryIPRanges' -- -- * 'subIPCIdRRange' -- -- * 'subRegion' subnetwork :: Subnetwork subnetwork = Subnetwork' { _subOutsideAllocation = Nothing , _subNetwork = Nothing , _subName = Nothing , _subSecondaryIPRanges = Nothing , _subIPCIdRRange = Nothing , _subRegion = Nothing } -- | This is a discovered subnet that is not within the current consumer -- allocated ranges. subOutsideAllocation :: Lens' Subnetwork (Maybe Bool) subOutsideAllocation = lens _subOutsideAllocation (\ s a -> s{_subOutsideAllocation = a}) -- | In the Shared VPC host project, the VPC network that\'s peered with the -- consumer network. For example: -- \`projects\/1234321\/global\/networks\/host-network\` subNetwork :: Lens' Subnetwork (Maybe Text) subNetwork = lens _subNetwork (\ s a -> s{_subNetwork = a}) -- | Subnetwork name. See https:\/\/cloud.google.com\/compute\/docs\/vpc\/ subName :: Lens' Subnetwork (Maybe Text) subName = lens _subName (\ s a -> s{_subName = a}) -- | List of secondary IP ranges in this subnetwork. subSecondaryIPRanges :: Lens' Subnetwork [SecondaryIPRange] subSecondaryIPRanges = lens _subSecondaryIPRanges (\ s a -> s{_subSecondaryIPRanges = a}) . _Default . _Coerce -- | Subnetwork CIDR range in \`10.x.x.x\/y\` format. subIPCIdRRange :: Lens' Subnetwork (Maybe Text) subIPCIdRRange = lens _subIPCIdRRange (\ s a -> s{_subIPCIdRRange = a}) -- | GCP region where the subnetwork is located. subRegion :: Lens' Subnetwork (Maybe Text) subRegion = lens _subRegion (\ s a -> s{_subRegion = a}) instance FromJSON Subnetwork where parseJSON = withObject "Subnetwork" (\ o -> Subnetwork' <$> (o .:? "outsideAllocation") <*> (o .:? "network") <*> (o .:? "name") <*> (o .:? "secondaryIpRanges" .!= mempty) <*> (o .:? "ipCidrRange") <*> (o .:? "region")) instance ToJSON Subnetwork where toJSON Subnetwork'{..} = object (catMaybes [("outsideAllocation" .=) <$> _subOutsideAllocation, ("network" .=) <$> _subNetwork, ("name" .=) <$> _subName, ("secondaryIpRanges" .=) <$> _subSecondaryIPRanges, ("ipCidrRange" .=) <$> _subIPCIdRRange, ("region" .=) <$> _subRegion]) -- | Request to create a subnetwork in a previously peered service network. -- -- /See:/ 'addSubnetworkRequest' smart constructor. data AddSubnetworkRequest = AddSubnetworkRequest' { _asrIPPrefixLength :: !(Maybe (Textual Int32)) , _asrRequestedAddress :: !(Maybe Text) , _asrRequestedRanges :: !(Maybe [Text]) , _asrSecondaryIPRangeSpecs :: !(Maybe [SecondaryIPRangeSpec]) , _asrSubnetwork :: !(Maybe Text) , _asrRegion :: !(Maybe Text) , _asrSubnetworkUsers :: !(Maybe [Text]) , _asrConsumerNetwork :: !(Maybe Text) , _asrConsumer :: !(Maybe Text) , _asrDescription :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddSubnetworkRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'asrIPPrefixLength' -- -- * 'asrRequestedAddress' -- -- * 'asrRequestedRanges' -- -- * 'asrSecondaryIPRangeSpecs' -- -- * 'asrSubnetwork' -- -- * 'asrRegion' -- -- * 'asrSubnetworkUsers' -- -- * 'asrConsumerNetwork' -- -- * 'asrConsumer' -- -- * 'asrDescription' addSubnetworkRequest :: AddSubnetworkRequest addSubnetworkRequest = AddSubnetworkRequest' { _asrIPPrefixLength = Nothing , _asrRequestedAddress = Nothing , _asrRequestedRanges = Nothing , _asrSecondaryIPRangeSpecs = Nothing , _asrSubnetwork = Nothing , _asrRegion = Nothing , _asrSubnetworkUsers = Nothing , _asrConsumerNetwork = Nothing , _asrConsumer = Nothing , _asrDescription = Nothing } -- | Required. The prefix length of the subnet\'s IP address range. Use CIDR -- range notation, such as \`30\` to provision a subnet with an -- \`x.x.x.x\/30\` CIDR range. The IP address range is drawn from a pool of -- available ranges in the service consumer\'s allocated range. asrIPPrefixLength :: Lens' AddSubnetworkRequest (Maybe Int32) asrIPPrefixLength = lens _asrIPPrefixLength (\ s a -> s{_asrIPPrefixLength = a}) . mapping _Coerce -- | Optional. The starting address of a range. The address must be a valid -- IPv4 address in the x.x.x.x format. This value combined with the IP -- prefix range is the CIDR range for the subnet. The range must be within -- the allocated range that is assigned to the private connection. If the -- CIDR range isn\'t available, the call fails. asrRequestedAddress :: Lens' AddSubnetworkRequest (Maybe Text) asrRequestedAddress = lens _asrRequestedAddress (\ s a -> s{_asrRequestedAddress = a}) -- | Optional. The name of one or more allocated IP address ranges associated -- with this private service access connection. If no range names are -- provided all ranges associated with this connection will be considered. -- If a CIDR range with the specified IP prefix length is not available -- within these ranges, the call fails. asrRequestedRanges :: Lens' AddSubnetworkRequest [Text] asrRequestedRanges = lens _asrRequestedRanges (\ s a -> s{_asrRequestedRanges = a}) . _Default . _Coerce -- | Optional. A list of secondary IP ranges to be created within the new -- subnetwork. asrSecondaryIPRangeSpecs :: Lens' AddSubnetworkRequest [SecondaryIPRangeSpec] asrSecondaryIPRangeSpecs = lens _asrSecondaryIPRangeSpecs (\ s a -> s{_asrSecondaryIPRangeSpecs = a}) . _Default . _Coerce -- | Required. A name for the new subnet. For information about the naming -- requirements, see -- [subnetwork](\/compute\/docs\/reference\/rest\/v1\/subnetworks) in the -- Compute API documentation. asrSubnetwork :: Lens' AddSubnetworkRequest (Maybe Text) asrSubnetwork = lens _asrSubnetwork (\ s a -> s{_asrSubnetwork = a}) -- | Required. The name of a [region](\/compute\/docs\/regions-zones) for the -- subnet, such \`europe-west1\`. asrRegion :: Lens' AddSubnetworkRequest (Maybe Text) asrRegion = lens _asrRegion (\ s a -> s{_asrRegion = a}) -- | A list of members that are granted the \`compute.networkUser\` role on -- the subnet. asrSubnetworkUsers :: Lens' AddSubnetworkRequest [Text] asrSubnetworkUsers = lens _asrSubnetworkUsers (\ s a -> s{_asrSubnetworkUsers = a}) . _Default . _Coerce -- | Required. The name of the service consumer\'s VPC network. The network -- must have an existing private connection that was provisioned through -- the connections.create method. The name must be in the following format: -- \`projects\/{project}\/global\/networks\/{network}\`, where {project} is -- a project number, such as \`12345\`. {network} is the name of a VPC -- network in the project. asrConsumerNetwork :: Lens' AddSubnetworkRequest (Maybe Text) asrConsumerNetwork = lens _asrConsumerNetwork (\ s a -> s{_asrConsumerNetwork = a}) -- | Required. A resource that represents the service consumer, such as -- \`projects\/123456\`. The project number can be different from the value -- in the consumer network parameter. For example, the network might be -- part of a Shared VPC network. In those cases, Service Networking -- validates that this resource belongs to that Shared VPC. asrConsumer :: Lens' AddSubnetworkRequest (Maybe Text) asrConsumer = lens _asrConsumer (\ s a -> s{_asrConsumer = a}) -- | Optional. Description of the subnet. asrDescription :: Lens' AddSubnetworkRequest (Maybe Text) asrDescription = lens _asrDescription (\ s a -> s{_asrDescription = a}) instance FromJSON AddSubnetworkRequest where parseJSON = withObject "AddSubnetworkRequest" (\ o -> AddSubnetworkRequest' <$> (o .:? "ipPrefixLength") <*> (o .:? "requestedAddress") <*> (o .:? "requestedRanges" .!= mempty) <*> (o .:? "secondaryIpRangeSpecs" .!= mempty) <*> (o .:? "subnetwork") <*> (o .:? "region") <*> (o .:? "subnetworkUsers" .!= mempty) <*> (o .:? "consumerNetwork") <*> (o .:? "consumer") <*> (o .:? "description")) instance ToJSON AddSubnetworkRequest where toJSON AddSubnetworkRequest'{..} = object (catMaybes [("ipPrefixLength" .=) <$> _asrIPPrefixLength, ("requestedAddress" .=) <$> _asrRequestedAddress, ("requestedRanges" .=) <$> _asrRequestedRanges, ("secondaryIpRangeSpecs" .=) <$> _asrSecondaryIPRangeSpecs, ("subnetwork" .=) <$> _asrSubnetwork, ("region" .=) <$> _asrRegion, ("subnetworkUsers" .=) <$> _asrSubnetworkUsers, ("consumerNetwork" .=) <$> _asrConsumerNetwork, ("consumer" .=) <$> _asrConsumer, ("description" .=) <$> _asrDescription]) -- | Define a system parameter rule mapping system parameter definitions to -- methods. -- -- /See:/ 'systemParameterRule' smart constructor. data SystemParameterRule = SystemParameterRule' { _sprSelector :: !(Maybe Text) , _sprParameters :: !(Maybe [SystemParameter]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SystemParameterRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sprSelector' -- -- * 'sprParameters' systemParameterRule :: SystemParameterRule systemParameterRule = SystemParameterRule' {_sprSelector = Nothing, _sprParameters = Nothing} -- | Selects the methods to which this rule applies. Use \'*\' to indicate -- all methods in all APIs. Refer to selector for syntax details. sprSelector :: Lens' SystemParameterRule (Maybe Text) sprSelector = lens _sprSelector (\ s a -> s{_sprSelector = a}) -- | Define parameters. Multiple names may be defined for a parameter. For a -- given method call, only one of them should be used. If multiple names -- are used the behavior is implementation-dependent. If none of the -- specified names are present the behavior is parameter-dependent. sprParameters :: Lens' SystemParameterRule [SystemParameter] sprParameters = lens _sprParameters (\ s a -> s{_sprParameters = a}) . _Default . _Coerce instance FromJSON SystemParameterRule where parseJSON = withObject "SystemParameterRule" (\ o -> SystemParameterRule' <$> (o .:? "selector") <*> (o .:? "parameters" .!= mempty)) instance ToJSON SystemParameterRule where toJSON SystemParameterRule'{..} = object (catMaybes [("selector" .=) <$> _sprSelector, ("parameters" .=) <$> _sprParameters]) -- | A description of a label. -- -- /See:/ 'labelDescriptor' smart constructor. data LabelDescriptor = LabelDescriptor' { _lKey :: !(Maybe Text) , _lValueType :: !(Maybe LabelDescriptorValueType) , _lDescription :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'LabelDescriptor' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lKey' -- -- * 'lValueType' -- -- * 'lDescription' labelDescriptor :: LabelDescriptor labelDescriptor = LabelDescriptor' {_lKey = Nothing, _lValueType = Nothing, _lDescription = Nothing} -- | The label key. lKey :: Lens' LabelDescriptor (Maybe Text) lKey = lens _lKey (\ s a -> s{_lKey = a}) -- | The type of data that can be assigned to the label. lValueType :: Lens' LabelDescriptor (Maybe LabelDescriptorValueType) lValueType = lens _lValueType (\ s a -> s{_lValueType = a}) -- | A human-readable description for the label. lDescription :: Lens' LabelDescriptor (Maybe Text) lDescription = lens _lDescription (\ s a -> s{_lDescription = a}) instance FromJSON LabelDescriptor where parseJSON = withObject "LabelDescriptor" (\ o -> LabelDescriptor' <$> (o .:? "key") <*> (o .:? "valueType") <*> (o .:? "description")) instance ToJSON LabelDescriptor where toJSON LabelDescriptor'{..} = object (catMaybes [("key" .=) <$> _lKey, ("valueType" .=) <$> _lValueType, ("description" .=) <$> _lDescription]) -- | Represents IAM roles added to the shared VPC host project. -- -- /See:/ 'addRolesResponse' smart constructor. newtype AddRolesResponse = AddRolesResponse' { _aPolicyBinding :: Maybe [PolicyBinding] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddRolesResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'aPolicyBinding' addRolesResponse :: AddRolesResponse addRolesResponse = AddRolesResponse' {_aPolicyBinding = Nothing} -- | Required. List of policy bindings that were added to the shared VPC host -- project. aPolicyBinding :: Lens' AddRolesResponse [PolicyBinding] aPolicyBinding = lens _aPolicyBinding (\ s a -> s{_aPolicyBinding = a}) . _Default . _Coerce instance FromJSON AddRolesResponse where parseJSON = withObject "AddRolesResponse" (\ o -> AddRolesResponse' <$> (o .:? "policyBinding" .!= mempty)) instance ToJSON AddRolesResponse where toJSON AddRolesResponse'{..} = object (catMaybes [("policyBinding" .=) <$> _aPolicyBinding]) -- | Configuration controlling usage of a service. -- -- /See:/ 'usage' smart constructor. data Usage = Usage' { _uRequirements :: !(Maybe [Text]) , _uRules :: !(Maybe [UsageRule]) , _uProducerNotificationChannel :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Usage' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'uRequirements' -- -- * 'uRules' -- -- * 'uProducerNotificationChannel' usage :: Usage usage = Usage' { _uRequirements = Nothing , _uRules = Nothing , _uProducerNotificationChannel = Nothing } -- | Requirements that must be satisfied before a consumer project can use -- the service. Each requirement is of the form \/; for example -- \'serviceusage.googleapis.com\/billing-enabled\'. For Google APIs, a -- Terms of Service requirement must be included here. Google Cloud APIs -- must include \"serviceusage.googleapis.com\/tos\/cloud\". Other Google -- APIs should include \"serviceusage.googleapis.com\/tos\/universal\". -- Additional ToS can be included based on the business needs. uRequirements :: Lens' Usage [Text] uRequirements = lens _uRequirements (\ s a -> s{_uRequirements = a}) . _Default . _Coerce -- | A list of usage rules that apply to individual API methods. **NOTE:** -- All service configuration rules follow \"last one wins\" order. uRules :: Lens' Usage [UsageRule] uRules = lens _uRules (\ s a -> s{_uRules = a}) . _Default . _Coerce -- | The full resource name of a channel used for sending notifications to -- the service producer. Google Service Management currently only supports -- [Google Cloud Pub\/Sub](https:\/\/cloud.google.com\/pubsub) as a -- notification channel. To use Google Cloud Pub\/Sub as the channel, this -- must be the name of a Cloud Pub\/Sub topic that uses the Cloud Pub\/Sub -- topic name format documented in -- https:\/\/cloud.google.com\/pubsub\/docs\/overview. uProducerNotificationChannel :: Lens' Usage (Maybe Text) uProducerNotificationChannel = lens _uProducerNotificationChannel (\ s a -> s{_uProducerNotificationChannel = a}) instance FromJSON Usage where parseJSON = withObject "Usage" (\ o -> Usage' <$> (o .:? "requirements" .!= mempty) <*> (o .:? "rules" .!= mempty) <*> (o .:? "producerNotificationChannel")) instance ToJSON Usage where toJSON Usage'{..} = object (catMaybes [("requirements" .=) <$> _uRequirements, ("rules" .=) <$> _uRules, ("producerNotificationChannel" .=) <$> _uProducerNotificationChannel]) -- | Represents managed DNS zones created in the shared producer host and -- consumer projects. -- -- /See:/ 'addDNSZoneResponse' smart constructor. data AddDNSZoneResponse = AddDNSZoneResponse' { _adzrConsumerPeeringZone :: !(Maybe DNSZone) , _adzrProducerPrivateZone :: !(Maybe DNSZone) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddDNSZoneResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'adzrConsumerPeeringZone' -- -- * 'adzrProducerPrivateZone' addDNSZoneResponse :: AddDNSZoneResponse addDNSZoneResponse = AddDNSZoneResponse' {_adzrConsumerPeeringZone = Nothing, _adzrProducerPrivateZone = Nothing} -- | The DNS peering zone created in the consumer project. adzrConsumerPeeringZone :: Lens' AddDNSZoneResponse (Maybe DNSZone) adzrConsumerPeeringZone = lens _adzrConsumerPeeringZone (\ s a -> s{_adzrConsumerPeeringZone = a}) -- | The private DNS zone created in the shared producer host project. adzrProducerPrivateZone :: Lens' AddDNSZoneResponse (Maybe DNSZone) adzrProducerPrivateZone = lens _adzrProducerPrivateZone (\ s a -> s{_adzrProducerPrivateZone = a}) instance FromJSON AddDNSZoneResponse where parseJSON = withObject "AddDNSZoneResponse" (\ o -> AddDNSZoneResponse' <$> (o .:? "consumerPeeringZone") <*> (o .:? "producerPrivateZone")) instance ToJSON AddDNSZoneResponse where toJSON AddDNSZoneResponse'{..} = object (catMaybes [("consumerPeeringZone" .=) <$> _adzrConsumerPeeringZone, ("producerPrivateZone" .=) <$> _adzrProducerPrivateZone]) -- | Request to remove a private managed DNS zone in the shared producer host -- project and a matching DNS peering zone in the consumer project. -- -- /See:/ 'removeDNSZoneRequest' smart constructor. data RemoveDNSZoneRequest = RemoveDNSZoneRequest' { _rdzrName :: !(Maybe Text) , _rdzrConsumerNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RemoveDNSZoneRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'rdzrName' -- -- * 'rdzrConsumerNetwork' removeDNSZoneRequest :: RemoveDNSZoneRequest removeDNSZoneRequest = RemoveDNSZoneRequest' {_rdzrName = Nothing, _rdzrConsumerNetwork = Nothing} -- | Required. The name for both the private zone in the shared producer host -- project and the peering zone in the consumer project. rdzrName :: Lens' RemoveDNSZoneRequest (Maybe Text) rdzrName = lens _rdzrName (\ s a -> s{_rdzrName = a}) -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is the -- project number, as in \'12345\' {network} is the network name. rdzrConsumerNetwork :: Lens' RemoveDNSZoneRequest (Maybe Text) rdzrConsumerNetwork = lens _rdzrConsumerNetwork (\ s a -> s{_rdzrConsumerNetwork = a}) instance FromJSON RemoveDNSZoneRequest where parseJSON = withObject "RemoveDNSZoneRequest" (\ o -> RemoveDNSZoneRequest' <$> (o .:? "name") <*> (o .:? "consumerNetwork")) instance ToJSON RemoveDNSZoneRequest where toJSON RemoveDNSZoneRequest'{..} = object (catMaybes [("name" .=) <$> _rdzrName, ("consumerNetwork" .=) <$> _rdzrConsumerNetwork]) -- | Request to search for an unused range within allocated ranges. -- -- /See:/ 'searchRangeRequest' smart constructor. data SearchRangeRequest = SearchRangeRequest' { _srrIPPrefixLength :: !(Maybe (Textual Int32)) , _srrNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SearchRangeRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'srrIPPrefixLength' -- -- * 'srrNetwork' searchRangeRequest :: SearchRangeRequest searchRangeRequest = SearchRangeRequest' {_srrIPPrefixLength = Nothing, _srrNetwork = Nothing} -- | Required. The prefix length of the IP range. Use usual CIDR range -- notation. For example, \'30\' to find unused x.x.x.x\/30 CIDR range. -- Actual range will be determined using allocated range for the consumer -- peered network and returned in the result. srrIPPrefixLength :: Lens' SearchRangeRequest (Maybe Int32) srrIPPrefixLength = lens _srrIPPrefixLength (\ s a -> s{_srrIPPrefixLength = a}) . mapping _Coerce -- | Network name in the consumer project. This network must have been -- already peered with a shared VPC network using CreateConnection method. -- Must be in a form \'projects\/{project}\/global\/networks\/{network}\'. -- {project} is a project number, as in \'12345\' {network} is network -- name. srrNetwork :: Lens' SearchRangeRequest (Maybe Text) srrNetwork = lens _srrNetwork (\ s a -> s{_srrNetwork = a}) instance FromJSON SearchRangeRequest where parseJSON = withObject "SearchRangeRequest" (\ o -> SearchRangeRequest' <$> (o .:? "ipPrefixLength") <*> (o .:? "network")) instance ToJSON SearchRangeRequest where toJSON SearchRangeRequest'{..} = object (catMaybes [("ipPrefixLength" .=) <$> _srrIPPrefixLength, ("network" .=) <$> _srrNetwork]) -- | Defines the HTTP configuration for an API service. It contains a list of -- HttpRule, each specifying the mapping of an RPC method to one or more -- HTTP REST API methods. -- -- /See:/ 'hTTP' smart constructor. data HTTP = HTTP' { _hRules :: !(Maybe [HTTPRule]) , _hFullyDecodeReservedExpansion :: !(Maybe Bool) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'HTTP' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'hRules' -- -- * 'hFullyDecodeReservedExpansion' hTTP :: HTTP hTTP = HTTP' {_hRules = Nothing, _hFullyDecodeReservedExpansion = Nothing} -- | A list of HTTP configuration rules that apply to individual API methods. -- **NOTE:** All service configuration rules follow \"last one wins\" -- order. hRules :: Lens' HTTP [HTTPRule] hRules = lens _hRules (\ s a -> s{_hRules = a}) . _Default . _Coerce -- | When set to true, URL path parameters will be fully URI-decoded except -- in cases of single segment matches in reserved expansion, where \"%2F\" -- will be left encoded. The default behavior is to not decode RFC 6570 -- reserved characters in multi segment matches. hFullyDecodeReservedExpansion :: Lens' HTTP (Maybe Bool) hFullyDecodeReservedExpansion = lens _hFullyDecodeReservedExpansion (\ s a -> s{_hFullyDecodeReservedExpansion = a}) instance FromJSON HTTP where parseJSON = withObject "HTTP" (\ o -> HTTP' <$> (o .:? "rules" .!= mempty) <*> (o .:? "fullyDecodeReservedExpansion")) instance ToJSON HTTP where toJSON HTTP'{..} = object (catMaybes [("rules" .=) <$> _hRules, ("fullyDecodeReservedExpansion" .=) <$> _hFullyDecodeReservedExpansion]) -- | A protocol buffer message type. -- -- /See:/ 'type'' smart constructor. data Type = Type' { _tSourceContext :: !(Maybe SourceContext) , _tOneofs :: !(Maybe [Text]) , _tName :: !(Maybe Text) , _tOptions :: !(Maybe [Option]) , _tFields :: !(Maybe [Field]) , _tSyntax :: !(Maybe TypeSyntax) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Type' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'tSourceContext' -- -- * 'tOneofs' -- -- * 'tName' -- -- * 'tOptions' -- -- * 'tFields' -- -- * 'tSyntax' type' :: Type type' = Type' { _tSourceContext = Nothing , _tOneofs = Nothing , _tName = Nothing , _tOptions = Nothing , _tFields = Nothing , _tSyntax = Nothing } -- | The source context. tSourceContext :: Lens' Type (Maybe SourceContext) tSourceContext = lens _tSourceContext (\ s a -> s{_tSourceContext = a}) -- | The list of types appearing in \`oneof\` definitions in this type. tOneofs :: Lens' Type [Text] tOneofs = lens _tOneofs (\ s a -> s{_tOneofs = a}) . _Default . _Coerce -- | The fully qualified message name. tName :: Lens' Type (Maybe Text) tName = lens _tName (\ s a -> s{_tName = a}) -- | The protocol buffer options. tOptions :: Lens' Type [Option] tOptions = lens _tOptions (\ s a -> s{_tOptions = a}) . _Default . _Coerce -- | The list of fields. tFields :: Lens' Type [Field] tFields = lens _tFields (\ s a -> s{_tFields = a}) . _Default . _Coerce -- | The source syntax. tSyntax :: Lens' Type (Maybe TypeSyntax) tSyntax = lens _tSyntax (\ s a -> s{_tSyntax = a}) instance FromJSON Type where parseJSON = withObject "Type" (\ o -> Type' <$> (o .:? "sourceContext") <*> (o .:? "oneofs" .!= mempty) <*> (o .:? "name") <*> (o .:? "options" .!= mempty) <*> (o .:? "fields" .!= mempty) <*> (o .:? "syntax")) instance ToJSON Type where toJSON Type'{..} = object (catMaybes [("sourceContext" .=) <$> _tSourceContext, ("oneofs" .=) <$> _tOneofs, ("name" .=) <$> _tName, ("options" .=) <$> _tOptions, ("fields" .=) <$> _tFields, ("syntax" .=) <$> _tSyntax]) -- | Api is a light-weight descriptor for an API Interface. Interfaces are -- also described as \"protocol buffer services\" in some contexts, such as -- by the \"service\" keyword in a .proto file, but they are different from -- API Services, which represent a concrete implementation of an interface -- as opposed to simply a description of methods and bindings. They are -- also sometimes simply referred to as \"APIs\" in other contexts, such as -- the name of this message itself. See -- https:\/\/cloud.google.com\/apis\/design\/glossary for detailed -- terminology. -- -- /See:/ 'api' smart constructor. data API = API' { _aSourceContext :: !(Maybe SourceContext) , _aMixins :: !(Maybe [Mixin]) , _aMethods :: !(Maybe [Method]) , _aName :: !(Maybe Text) , _aVersion :: !(Maybe Text) , _aOptions :: !(Maybe [Option]) , _aSyntax :: !(Maybe APISyntax) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'API' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'aSourceContext' -- -- * 'aMixins' -- -- * 'aMethods' -- -- * 'aName' -- -- * 'aVersion' -- -- * 'aOptions' -- -- * 'aSyntax' api :: API api = API' { _aSourceContext = Nothing , _aMixins = Nothing , _aMethods = Nothing , _aName = Nothing , _aVersion = Nothing , _aOptions = Nothing , _aSyntax = Nothing } -- | Source context for the protocol buffer service represented by this -- message. aSourceContext :: Lens' API (Maybe SourceContext) aSourceContext = lens _aSourceContext (\ s a -> s{_aSourceContext = a}) -- | Included interfaces. See Mixin. aMixins :: Lens' API [Mixin] aMixins = lens _aMixins (\ s a -> s{_aMixins = a}) . _Default . _Coerce -- | The methods of this interface, in unspecified order. aMethods :: Lens' API [Method] aMethods = lens _aMethods (\ s a -> s{_aMethods = a}) . _Default . _Coerce -- | The fully qualified name of this interface, including package name -- followed by the interface\'s simple name. aName :: Lens' API (Maybe Text) aName = lens _aName (\ s a -> s{_aName = a}) -- | A version string for this interface. If specified, must have the form -- \`major-version.minor-version\`, as in \`1.10\`. If the minor version is -- omitted, it defaults to zero. If the entire version field is empty, the -- major version is derived from the package name, as outlined below. If -- the field is not empty, the version in the package name will be verified -- to be consistent with what is provided here. The versioning schema uses -- [semantic versioning](http:\/\/semver.org) where the major version -- number indicates a breaking change and the minor version an additive, -- non-breaking change. Both version numbers are signals to users what to -- expect from different versions, and should be carefully chosen based on -- the product plan. The major version is also reflected in the package -- name of the interface, which must end in \`v\`, as in -- \`google.feature.v1\`. For major versions 0 and 1, the suffix can be -- omitted. Zero major versions must only be used for experimental, non-GA -- interfaces. aVersion :: Lens' API (Maybe Text) aVersion = lens _aVersion (\ s a -> s{_aVersion = a}) -- | Any metadata attached to the interface. aOptions :: Lens' API [Option] aOptions = lens _aOptions (\ s a -> s{_aOptions = a}) . _Default . _Coerce -- | The source syntax of the service. aSyntax :: Lens' API (Maybe APISyntax) aSyntax = lens _aSyntax (\ s a -> s{_aSyntax = a}) instance FromJSON API where parseJSON = withObject "API" (\ o -> API' <$> (o .:? "sourceContext") <*> (o .:? "mixins" .!= mempty) <*> (o .:? "methods" .!= mempty) <*> (o .:? "name") <*> (o .:? "version") <*> (o .:? "options" .!= mempty) <*> (o .:? "syntax")) instance ToJSON API where toJSON API'{..} = object (catMaybes [("sourceContext" .=) <$> _aSourceContext, ("mixins" .=) <$> _aMixins, ("methods" .=) <$> _aMethods, ("name" .=) <$> _aName, ("version" .=) <$> _aVersion, ("options" .=) <$> _aOptions, ("syntax" .=) <$> _aSyntax]) -- | Configuration of a specific monitoring destination (the producer project -- or the consumer project). -- -- /See:/ 'monitoringDestination' smart constructor. data MonitoringDestination = MonitoringDestination' { _mdMetrics :: !(Maybe [Text]) , _mdMonitoredResource :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'MonitoringDestination' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'mdMetrics' -- -- * 'mdMonitoredResource' monitoringDestination :: MonitoringDestination monitoringDestination = MonitoringDestination' {_mdMetrics = Nothing, _mdMonitoredResource = Nothing} -- | Types of the metrics to report to this monitoring destination. Each type -- must be defined in Service.metrics section. mdMetrics :: Lens' MonitoringDestination [Text] mdMetrics = lens _mdMetrics (\ s a -> s{_mdMetrics = a}) . _Default . _Coerce -- | The monitored resource type. The type must be defined in -- Service.monitored_resources section. mdMonitoredResource :: Lens' MonitoringDestination (Maybe Text) mdMonitoredResource = lens _mdMonitoredResource (\ s a -> s{_mdMonitoredResource = a}) instance FromJSON MonitoringDestination where parseJSON = withObject "MonitoringDestination" (\ o -> MonitoringDestination' <$> (o .:? "metrics" .!= mempty) <*> (o .:? "monitoredResource")) instance ToJSON MonitoringDestination where toJSON MonitoringDestination'{..} = object (catMaybes [("metrics" .=) <$> _mdMetrics, ("monitoredResource" .=) <$> _mdMonitoredResource]) -- | Service-specific metadata associated with the operation. It typically -- contains progress information and common metadata such as create time. -- Some services might not provide such metadata. Any method that returns a -- long-running operation should document the metadata type, if any. -- -- /See:/ 'operationMetadata' smart constructor. newtype OperationMetadata = OperationMetadata' { _omAddtional :: HashMap Text JSONValue } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'OperationMetadata' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'omAddtional' operationMetadata :: HashMap Text JSONValue -- ^ 'omAddtional' -> OperationMetadata operationMetadata pOmAddtional_ = OperationMetadata' {_omAddtional = _Coerce # pOmAddtional_} -- | Properties of the object. Contains field \'type with type URL. omAddtional :: Lens' OperationMetadata (HashMap Text JSONValue) omAddtional = lens _omAddtional (\ s a -> s{_omAddtional = a}) . _Coerce instance FromJSON OperationMetadata where parseJSON = withObject "OperationMetadata" (\ o -> OperationMetadata' <$> (parseJSONObject o)) instance ToJSON OperationMetadata where toJSON = toJSON . _omAddtional -- | \`Endpoint\` describes a network address of a service that serves a set -- of APIs. It is commonly known as a service endpoint. A service may -- expose any number of service endpoints, and all service endpoints share -- the same service definition, such as quota limits and monitoring -- metrics. Example: type: google.api.Service name: -- library-example.googleapis.com endpoints: # Declares network address -- \`https:\/\/library-example.googleapis.com\` # for service -- \`library-example.googleapis.com\`. The \`https\` scheme # is implicit -- for all service endpoints. Other schemes may be # supported in the -- future. - name: library-example.googleapis.com allow_cors: false - name: -- content-staging-library-example.googleapis.com # Allows HTTP OPTIONS -- calls to be passed to the API frontend, for it # to decide whether the -- subsequent cross-origin request is allowed # to proceed. allow_cors: -- true -- -- /See:/ 'endpoint' smart constructor. data Endpoint = Endpoint' { _eAllowCORS :: !(Maybe Bool) , _eName :: !(Maybe Text) , _eTarget :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Endpoint' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'eAllowCORS' -- -- * 'eName' -- -- * 'eTarget' endpoint :: Endpoint endpoint = Endpoint' {_eAllowCORS = Nothing, _eName = Nothing, _eTarget = Nothing} -- | Allowing -- [CORS](https:\/\/en.wikipedia.org\/wiki\/Cross-origin_resource_sharing), -- aka cross-domain traffic, would allow the backends served from this -- endpoint to receive and respond to HTTP OPTIONS requests. The response -- will be used by the browser to determine whether the subsequent -- cross-origin request is allowed to proceed. eAllowCORS :: Lens' Endpoint (Maybe Bool) eAllowCORS = lens _eAllowCORS (\ s a -> s{_eAllowCORS = a}) -- | The canonical name of this endpoint. eName :: Lens' Endpoint (Maybe Text) eName = lens _eName (\ s a -> s{_eName = a}) -- | The specification of an Internet routable address of API frontend that -- will handle requests to this [API -- Endpoint](https:\/\/cloud.google.com\/apis\/design\/glossary). It should -- be either a valid IPv4 address or a fully-qualified domain name. For -- example, \"8.8.8.8\" or \"myservice.appspot.com\". eTarget :: Lens' Endpoint (Maybe Text) eTarget = lens _eTarget (\ s a -> s{_eTarget = a}) instance FromJSON Endpoint where parseJSON = withObject "Endpoint" (\ o -> Endpoint' <$> (o .:? "allowCors") <*> (o .:? "name") <*> (o .:? "target")) instance ToJSON Endpoint where toJSON Endpoint'{..} = object (catMaybes [("allowCors" .=) <$> _eAllowCORS, ("name" .=) <$> _eName, ("target" .=) <$> _eTarget]) -- | OAuth scopes are a way to define data and permissions on data. For -- example, there are scopes defined for \"Read-only access to Google -- Calendar\" and \"Access to Cloud Platform\". Users can consent to a -- scope for an application, giving it permission to access that data on -- their behalf. OAuth scope specifications should be fairly coarse -- grained; a user will need to see and understand the text description of -- what your scope means. In most cases: use one or at most two OAuth -- scopes for an entire family of products. If your product has multiple -- APIs, you should probably be sharing the OAuth scope across all of those -- APIs. When you need finer grained OAuth consent screens: talk with your -- product management about how developers will use them in practice. -- Please note that even though each of the canonical scopes is enough for -- a request to be accepted and passed to the backend, a request can still -- fail due to the backend requiring additional scopes or permissions. -- -- /See:/ 'oAuthRequirements' smart constructor. newtype OAuthRequirements = OAuthRequirements' { _oarCanonicalScopes :: Maybe Text } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'OAuthRequirements' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'oarCanonicalScopes' oAuthRequirements :: OAuthRequirements oAuthRequirements = OAuthRequirements' {_oarCanonicalScopes = Nothing} -- | The list of publicly documented OAuth scopes that are allowed access. An -- OAuth token containing any of these scopes will be accepted. Example: -- canonical_scopes: https:\/\/www.googleapis.com\/auth\/calendar, -- https:\/\/www.googleapis.com\/auth\/calendar.read oarCanonicalScopes :: Lens' OAuthRequirements (Maybe Text) oarCanonicalScopes = lens _oarCanonicalScopes (\ s a -> s{_oarCanonicalScopes = a}) instance FromJSON OAuthRequirements where parseJSON = withObject "OAuthRequirements" (\ o -> OAuthRequirements' <$> (o .:? "canonicalScopes")) instance ToJSON OAuthRequirements where toJSON OAuthRequirements'{..} = object (catMaybes [("canonicalScopes" .=) <$> _oarCanonicalScopes]) -- | Customize service error responses. For example, list any service -- specific protobuf types that can appear in error detail lists of error -- responses. Example: custom_error: types: - google.foo.v1.CustomError - -- google.foo.v1.AnotherError -- -- /See:/ 'customError' smart constructor. data CustomError = CustomError' { _ceRules :: !(Maybe [CustomErrorRule]) , _ceTypes :: !(Maybe [Text]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'CustomError' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'ceRules' -- -- * 'ceTypes' customError :: CustomError customError = CustomError' {_ceRules = Nothing, _ceTypes = Nothing} -- | The list of custom error rules that apply to individual API messages. -- **NOTE:** All service configuration rules follow \"last one wins\" -- order. ceRules :: Lens' CustomError [CustomErrorRule] ceRules = lens _ceRules (\ s a -> s{_ceRules = a}) . _Default . _Coerce -- | The list of custom error detail types, e.g. -- \'google.foo.v1.CustomError\'. ceTypes :: Lens' CustomError [Text] ceTypes = lens _ceTypes (\ s a -> s{_ceTypes = a}) . _Default . _Coerce instance FromJSON CustomError where parseJSON = withObject "CustomError" (\ o -> CustomError' <$> (o .:? "rules" .!= mempty) <*> (o .:? "types" .!= mempty)) instance ToJSON CustomError where toJSON CustomError'{..} = object (catMaybes [("rules" .=) <$> _ceRules, ("types" .=) <$> _ceTypes]) -- | \`QuotaLimit\` defines a specific limit that applies over a specified -- duration for a limit type. There can be at most one limit for a duration -- and limit type combination defined within a \`QuotaGroup\`. -- -- /See:/ 'quotaLimit' smart constructor. data QuotaLimit = QuotaLimit' { _qlValues :: !(Maybe QuotaLimitValues) , _qlFreeTier :: !(Maybe (Textual Int64)) , _qlMetric :: !(Maybe Text) , _qlName :: !(Maybe Text) , _qlDisplayName :: !(Maybe Text) , _qlDuration :: !(Maybe Text) , _qlDefaultLimit :: !(Maybe (Textual Int64)) , _qlDescription :: !(Maybe Text) , _qlUnit :: !(Maybe Text) , _qlMaxLimit :: !(Maybe (Textual Int64)) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'QuotaLimit' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'qlValues' -- -- * 'qlFreeTier' -- -- * 'qlMetric' -- -- * 'qlName' -- -- * 'qlDisplayName' -- -- * 'qlDuration' -- -- * 'qlDefaultLimit' -- -- * 'qlDescription' -- -- * 'qlUnit' -- -- * 'qlMaxLimit' quotaLimit :: QuotaLimit quotaLimit = QuotaLimit' { _qlValues = Nothing , _qlFreeTier = Nothing , _qlMetric = Nothing , _qlName = Nothing , _qlDisplayName = Nothing , _qlDuration = Nothing , _qlDefaultLimit = Nothing , _qlDescription = Nothing , _qlUnit = Nothing , _qlMaxLimit = Nothing } -- | Tiered limit values. You must specify this as a key:value pair, with an -- integer value that is the maximum number of requests allowed for the -- specified unit. Currently only STANDARD is supported. qlValues :: Lens' QuotaLimit (Maybe QuotaLimitValues) qlValues = lens _qlValues (\ s a -> s{_qlValues = a}) -- | Free tier value displayed in the Developers Console for this limit. The -- free tier is the number of tokens that will be subtracted from the -- billed amount when billing is enabled. This field can only be set on a -- limit with duration \"1d\", in a billable group; it is invalid on any -- other limit. If this field is not set, it defaults to 0, indicating that -- there is no free tier for this service. Used by group-based quotas only. qlFreeTier :: Lens' QuotaLimit (Maybe Int64) qlFreeTier = lens _qlFreeTier (\ s a -> s{_qlFreeTier = a}) . mapping _Coerce -- | The name of the metric this quota limit applies to. The quota limits -- with the same metric will be checked together during runtime. The metric -- must be defined within the service config. qlMetric :: Lens' QuotaLimit (Maybe Text) qlMetric = lens _qlMetric (\ s a -> s{_qlMetric = a}) -- | Name of the quota limit. The name must be provided, and it must be -- unique within the service. The name can only include alphanumeric -- characters as well as \'-\'. The maximum length of the limit name is 64 -- characters. qlName :: Lens' QuotaLimit (Maybe Text) qlName = lens _qlName (\ s a -> s{_qlName = a}) -- | User-visible display name for this limit. Optional. If not set, the UI -- will provide a default display name based on the quota configuration. -- This field can be used to override the default display name generated -- from the configuration. qlDisplayName :: Lens' QuotaLimit (Maybe Text) qlDisplayName = lens _qlDisplayName (\ s a -> s{_qlDisplayName = a}) -- | Duration of this limit in textual notation. Must be \"100s\" or \"1d\". -- Used by group-based quotas only. qlDuration :: Lens' QuotaLimit (Maybe Text) qlDuration = lens _qlDuration (\ s a -> s{_qlDuration = a}) -- | Default number of tokens that can be consumed during the specified -- duration. This is the number of tokens assigned when a client -- application developer activates the service for his\/her project. -- Specifying a value of 0 will block all requests. This can be used if you -- are provisioning quota to selected consumers and blocking others. -- Similarly, a value of -1 will indicate an unlimited quota. No other -- negative values are allowed. Used by group-based quotas only. qlDefaultLimit :: Lens' QuotaLimit (Maybe Int64) qlDefaultLimit = lens _qlDefaultLimit (\ s a -> s{_qlDefaultLimit = a}) . mapping _Coerce -- | Optional. User-visible, extended description for this quota limit. -- Should be used only when more context is needed to understand this limit -- than provided by the limit\'s display name (see: \`display_name\`). qlDescription :: Lens' QuotaLimit (Maybe Text) qlDescription = lens _qlDescription (\ s a -> s{_qlDescription = a}) -- | Specify the unit of the quota limit. It uses the same syntax as -- Metric.unit. The supported unit kinds are determined by the quota -- backend system. Here are some examples: * \"1\/min\/{project}\" for -- quota per minute per project. Note: the order of unit components is -- insignificant. The \"1\" at the beginning is required to follow the -- metric unit syntax. qlUnit :: Lens' QuotaLimit (Maybe Text) qlUnit = lens _qlUnit (\ s a -> s{_qlUnit = a}) -- | Maximum number of tokens that can be consumed during the specified -- duration. Client application developers can override the default limit -- up to this maximum. If specified, this value cannot be set to a value -- less than the default limit. If not specified, it is set to the default -- limit. To allow clients to apply overrides with no upper bound, set this -- to -1, indicating unlimited maximum quota. Used by group-based quotas -- only. qlMaxLimit :: Lens' QuotaLimit (Maybe Int64) qlMaxLimit = lens _qlMaxLimit (\ s a -> s{_qlMaxLimit = a}) . mapping _Coerce instance FromJSON QuotaLimit where parseJSON = withObject "QuotaLimit" (\ o -> QuotaLimit' <$> (o .:? "values") <*> (o .:? "freeTier") <*> (o .:? "metric") <*> (o .:? "name") <*> (o .:? "displayName") <*> (o .:? "duration") <*> (o .:? "defaultLimit") <*> (o .:? "description") <*> (o .:? "unit") <*> (o .:? "maxLimit")) instance ToJSON QuotaLimit where toJSON QuotaLimit'{..} = object (catMaybes [("values" .=) <$> _qlValues, ("freeTier" .=) <$> _qlFreeTier, ("metric" .=) <$> _qlMetric, ("name" .=) <$> _qlName, ("displayName" .=) <$> _qlDisplayName, ("duration" .=) <$> _qlDuration, ("defaultLimit" .=) <$> _qlDefaultLimit, ("description" .=) <$> _qlDescription, ("unit" .=) <$> _qlUnit, ("maxLimit" .=) <$> _qlMaxLimit]) -- | Blank message response type for RemoveDnsRecordSet API -- -- /See:/ 'removeDNSRecordSetResponse' smart constructor. data RemoveDNSRecordSetResponse = RemoveDNSRecordSetResponse' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'RemoveDNSRecordSetResponse' with the minimum fields required to make a request. -- removeDNSRecordSetResponse :: RemoveDNSRecordSetResponse removeDNSRecordSetResponse = RemoveDNSRecordSetResponse' instance FromJSON RemoveDNSRecordSetResponse where parseJSON = withObject "RemoveDNSRecordSetResponse" (\ o -> pure RemoveDNSRecordSetResponse') instance ToJSON RemoveDNSRecordSetResponse where toJSON = const emptyObject -- | A protocol buffer option, which can be attached to a message, field, -- enumeration, etc. -- -- /See:/ 'option' smart constructor. data Option = Option' { _optValue :: !(Maybe OptionValue) , _optName :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Option' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'optValue' -- -- * 'optName' option :: Option option = Option' {_optValue = Nothing, _optName = Nothing} -- | The option\'s value packed in an Any message. If the value is a -- primitive, the corresponding wrapper type defined in -- google\/protobuf\/wrappers.proto should be used. If the value is an -- enum, it should be stored as an int32 value using the -- google.protobuf.Int32Value type. optValue :: Lens' Option (Maybe OptionValue) optValue = lens _optValue (\ s a -> s{_optValue = a}) -- | The option\'s name. For protobuf built-in options (options defined in -- descriptor.proto), this is the short name. For example, -- \`\"map_entry\"\`. For custom options, it should be the fully-qualified -- name. For example, \`\"google.api.http\"\`. optName :: Lens' Option (Maybe Text) optName = lens _optName (\ s a -> s{_optName = a}) instance FromJSON Option where parseJSON = withObject "Option" (\ o -> Option' <$> (o .:? "value") <*> (o .:? "name")) instance ToJSON Option where toJSON Option'{..} = object (catMaybes [("value" .=) <$> _optValue, ("name" .=) <$> _optName]) -- | Billing related configuration of the service. The following example -- shows how to configure monitored resources and metrics for billing, -- \`consumer_destinations\` is the only supported destination and the -- monitored resources need at least one label key -- \`cloud.googleapis.com\/location\` to indicate the location of the -- billing usage, using different monitored resources between monitoring -- and billing is recommended so they can be evolved independently: -- monitored_resources: - type: library.googleapis.com\/billing_branch -- labels: - key: cloud.googleapis.com\/location description: | Predefined -- label to support billing location restriction. - key: city description: -- | Custom label to define the city where the library branch is located -- in. - key: name description: Custom label to define the name of the -- library branch. metrics: - name: -- library.googleapis.com\/book\/borrowed_count metric_kind: DELTA -- value_type: INT64 unit: \"1\" billing: consumer_destinations: - -- monitored_resource: library.googleapis.com\/billing_branch metrics: - -- library.googleapis.com\/book\/borrowed_count -- -- /See:/ 'billing' smart constructor. newtype Billing = Billing' { _bConsumerDestinations :: Maybe [BillingDestination] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Billing' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'bConsumerDestinations' billing :: Billing billing = Billing' {_bConsumerDestinations = Nothing} -- | Billing configurations for sending metrics to the consumer project. -- There can be multiple consumer destinations per service, each one must -- have a different monitored resource type. A metric can be used in at -- most one consumer destination. bConsumerDestinations :: Lens' Billing [BillingDestination] bConsumerDestinations = lens _bConsumerDestinations (\ s a -> s{_bConsumerDestinations = a}) . _Default . _Coerce instance FromJSON Billing where parseJSON = withObject "Billing" (\ o -> Billing' <$> (o .:? "consumerDestinations" .!= mempty)) instance ToJSON Billing where toJSON Billing'{..} = object (catMaybes [("consumerDestinations" .=) <$> _bConsumerDestinations]) -- | Source information used to create a Service Config -- -- /See:/ 'sourceInfo' smart constructor. newtype SourceInfo = SourceInfo' { _siSourceFiles :: Maybe [SourceInfoSourceFilesItem] } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SourceInfo' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'siSourceFiles' sourceInfo :: SourceInfo sourceInfo = SourceInfo' {_siSourceFiles = Nothing} -- | All files used during config generation. siSourceFiles :: Lens' SourceInfo [SourceInfoSourceFilesItem] siSourceFiles = lens _siSourceFiles (\ s a -> s{_siSourceFiles = a}) . _Default . _Coerce instance FromJSON SourceInfo where parseJSON = withObject "SourceInfo" (\ o -> SourceInfo' <$> (o .:? "sourceFiles" .!= mempty)) instance ToJSON SourceInfo where toJSON SourceInfo'{..} = object (catMaybes [("sourceFiles" .=) <$> _siSourceFiles]) -- | Tiered limit values. You must specify this as a key:value pair, with an -- integer value that is the maximum number of requests allowed for the -- specified unit. Currently only STANDARD is supported. -- -- /See:/ 'quotaLimitValues' smart constructor. newtype QuotaLimitValues = QuotaLimitValues' { _qlvAddtional :: HashMap Text (Textual Int64) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'QuotaLimitValues' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'qlvAddtional' quotaLimitValues :: HashMap Text Int64 -- ^ 'qlvAddtional' -> QuotaLimitValues quotaLimitValues pQlvAddtional_ = QuotaLimitValues' {_qlvAddtional = _Coerce # pQlvAddtional_} qlvAddtional :: Lens' QuotaLimitValues (HashMap Text Int64) qlvAddtional = lens _qlvAddtional (\ s a -> s{_qlvAddtional = a}) . _Coerce instance FromJSON QuotaLimitValues where parseJSON = withObject "QuotaLimitValues" (\ o -> QuotaLimitValues' <$> (parseJSONObject o)) instance ToJSON QuotaLimitValues where toJSON = toJSON . _qlvAddtional -- -- /See:/ 'validateConsumerConfigRequest' smart constructor. data ValidateConsumerConfigRequest = ValidateConsumerConfigRequest' { _vccrRangeReservation :: !(Maybe RangeReservation) , _vccrConsumerProject :: !(Maybe ConsumerProject) , _vccrValidateNetwork :: !(Maybe Bool) , _vccrConsumerNetwork :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ValidateConsumerConfigRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'vccrRangeReservation' -- -- * 'vccrConsumerProject' -- -- * 'vccrValidateNetwork' -- -- * 'vccrConsumerNetwork' validateConsumerConfigRequest :: ValidateConsumerConfigRequest validateConsumerConfigRequest = ValidateConsumerConfigRequest' { _vccrRangeReservation = Nothing , _vccrConsumerProject = Nothing , _vccrValidateNetwork = Nothing , _vccrConsumerNetwork = Nothing } -- | RANGES_EXHAUSTED, RANGES_EXHAUSTED, and RANGES_DELETED_LATER are done -- when range_reservation is provided. vccrRangeReservation :: Lens' ValidateConsumerConfigRequest (Maybe RangeReservation) vccrRangeReservation = lens _vccrRangeReservation (\ s a -> s{_vccrRangeReservation = a}) -- | NETWORK_NOT_IN_CONSUMERS_PROJECT, NETWORK_NOT_IN_CONSUMERS_HOST_PROJECT, -- and HOST_PROJECT_NOT_FOUND are done when consumer_project is provided. vccrConsumerProject :: Lens' ValidateConsumerConfigRequest (Maybe ConsumerProject) vccrConsumerProject = lens _vccrConsumerProject (\ s a -> s{_vccrConsumerProject = a}) -- | The validations will be performed in the order listed in the -- ValidationError enum. The first failure will return. If a validation is -- not requested, then the next one will be performed. -- SERVICE_NETWORKING_NOT_ENABLED and NETWORK_NOT_PEERED checks are -- performed for all requests where validation is requested. -- NETWORK_NOT_FOUND and NETWORK_DISCONNECTED checks are done for requests -- that have validate_network set to true. vccrValidateNetwork :: Lens' ValidateConsumerConfigRequest (Maybe Bool) vccrValidateNetwork = lens _vccrValidateNetwork (\ s a -> s{_vccrValidateNetwork = a}) -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is a project -- number, as in \'12345\' {network} is network name. vccrConsumerNetwork :: Lens' ValidateConsumerConfigRequest (Maybe Text) vccrConsumerNetwork = lens _vccrConsumerNetwork (\ s a -> s{_vccrConsumerNetwork = a}) instance FromJSON ValidateConsumerConfigRequest where parseJSON = withObject "ValidateConsumerConfigRequest" (\ o -> ValidateConsumerConfigRequest' <$> (o .:? "rangeReservation") <*> (o .:? "consumerProject") <*> (o .:? "validateNetwork") <*> (o .:? "consumerNetwork")) instance ToJSON ValidateConsumerConfigRequest where toJSON ValidateConsumerConfigRequest'{..} = object (catMaybes [("rangeReservation" .=) <$> _vccrRangeReservation, ("consumerProject" .=) <$> _vccrConsumerProject, ("validateNetwork" .=) <$> _vccrValidateNetwork, ("consumerNetwork" .=) <$> _vccrConsumerNetwork]) -- | Enum type definition. -- -- /See:/ 'enum' smart constructor. data Enum' = Enum'' { _enuSourceContext :: !(Maybe SourceContext) , _enuEnumvalue :: !(Maybe [EnumValue]) , _enuName :: !(Maybe Text) , _enuOptions :: !(Maybe [Option]) , _enuSyntax :: !(Maybe EnumSyntax) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Enum' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'enuSourceContext' -- -- * 'enuEnumvalue' -- -- * 'enuName' -- -- * 'enuOptions' -- -- * 'enuSyntax' enum :: Enum' enum = Enum'' { _enuSourceContext = Nothing , _enuEnumvalue = Nothing , _enuName = Nothing , _enuOptions = Nothing , _enuSyntax = Nothing } -- | The source context. enuSourceContext :: Lens' Enum' (Maybe SourceContext) enuSourceContext = lens _enuSourceContext (\ s a -> s{_enuSourceContext = a}) -- | Enum value definitions. enuEnumvalue :: Lens' Enum' [EnumValue] enuEnumvalue = lens _enuEnumvalue (\ s a -> s{_enuEnumvalue = a}) . _Default . _Coerce -- | Enum type name. enuName :: Lens' Enum' (Maybe Text) enuName = lens _enuName (\ s a -> s{_enuName = a}) -- | Protocol buffer options. enuOptions :: Lens' Enum' [Option] enuOptions = lens _enuOptions (\ s a -> s{_enuOptions = a}) . _Default . _Coerce -- | The source syntax. enuSyntax :: Lens' Enum' (Maybe EnumSyntax) enuSyntax = lens _enuSyntax (\ s a -> s{_enuSyntax = a}) instance FromJSON Enum' where parseJSON = withObject "Enum" (\ o -> Enum'' <$> (o .:? "sourceContext") <*> (o .:? "enumvalue" .!= mempty) <*> (o .:? "name") <*> (o .:? "options" .!= mempty) <*> (o .:? "syntax")) instance ToJSON Enum' where toJSON Enum''{..} = object (catMaybes [("sourceContext" .=) <$> _enuSourceContext, ("enumvalue" .=) <$> _enuEnumvalue, ("name" .=) <$> _enuName, ("options" .=) <$> _enuOptions, ("syntax" .=) <$> _enuSyntax]) -- | Logging configuration of the service. The following example shows how to -- configure logs to be sent to the producer and consumer projects. In the -- example, the \`activity_history\` log is sent to both the producer and -- consumer projects, whereas the \`purchase_history\` log is only sent to -- the producer project. monitored_resources: - type: -- library.googleapis.com\/branch labels: - key: \/city description: The -- city where the library branch is located in. - key: \/name description: -- The name of the branch. logs: - name: activity_history labels: - key: -- \/customer_id - name: purchase_history logging: producer_destinations: - -- monitored_resource: library.googleapis.com\/branch logs: - -- activity_history - purchase_history consumer_destinations: - -- monitored_resource: library.googleapis.com\/branch logs: - -- activity_history -- -- /See:/ 'logging' smart constructor. data Logging = Logging' { _lProducerDestinations :: !(Maybe [LoggingDestination]) , _lConsumerDestinations :: !(Maybe [LoggingDestination]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Logging' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'lProducerDestinations' -- -- * 'lConsumerDestinations' logging :: Logging logging = Logging' {_lProducerDestinations = Nothing, _lConsumerDestinations = Nothing} -- | Logging configurations for sending logs to the producer project. There -- can be multiple producer destinations, each one must have a different -- monitored resource type. A log can be used in at most one producer -- destination. lProducerDestinations :: Lens' Logging [LoggingDestination] lProducerDestinations = lens _lProducerDestinations (\ s a -> s{_lProducerDestinations = a}) . _Default . _Coerce -- | Logging configurations for sending logs to the consumer project. There -- can be multiple consumer destinations, each one must have a different -- monitored resource type. A log can be used in at most one consumer -- destination. lConsumerDestinations :: Lens' Logging [LoggingDestination] lConsumerDestinations = lens _lConsumerDestinations (\ s a -> s{_lConsumerDestinations = a}) . _Default . _Coerce instance FromJSON Logging where parseJSON = withObject "Logging" (\ o -> Logging' <$> (o .:? "producerDestinations" .!= mempty) <*> (o .:? "consumerDestinations" .!= mempty)) instance ToJSON Logging where toJSON Logging'{..} = object (catMaybes [("producerDestinations" .=) <$> _lProducerDestinations, ("consumerDestinations" .=) <$> _lConsumerDestinations]) -- | Request to delete a private service access connection. The call will -- fail if there are any managed service instances using this connection. -- -- /See:/ 'deleteConnectionRequest' smart constructor. newtype DeleteConnectionRequest = DeleteConnectionRequest' { _dcrConsumerNetwork :: Maybe Text } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DeleteConnectionRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'dcrConsumerNetwork' deleteConnectionRequest :: DeleteConnectionRequest deleteConnectionRequest = DeleteConnectionRequest' {_dcrConsumerNetwork = Nothing} -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is a project -- number, as in \'12345\' {network} is a network name. dcrConsumerNetwork :: Lens' DeleteConnectionRequest (Maybe Text) dcrConsumerNetwork = lens _dcrConsumerNetwork (\ s a -> s{_dcrConsumerNetwork = a}) instance FromJSON DeleteConnectionRequest where parseJSON = withObject "DeleteConnectionRequest" (\ o -> DeleteConnectionRequest' <$> (o .:? "consumerNetwork")) instance ToJSON DeleteConnectionRequest where toJSON DeleteConnectionRequest'{..} = object (catMaybes [("consumerNetwork" .=) <$> _dcrConsumerNetwork]) -- -- /See:/ 'sourceInfoSourceFilesItem' smart constructor. newtype SourceInfoSourceFilesItem = SourceInfoSourceFilesItem' { _sisfiAddtional :: HashMap Text JSONValue } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SourceInfoSourceFilesItem' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sisfiAddtional' sourceInfoSourceFilesItem :: HashMap Text JSONValue -- ^ 'sisfiAddtional' -> SourceInfoSourceFilesItem sourceInfoSourceFilesItem pSisfiAddtional_ = SourceInfoSourceFilesItem' {_sisfiAddtional = _Coerce # pSisfiAddtional_} -- | Properties of the object. Contains field \'type with type URL. sisfiAddtional :: Lens' SourceInfoSourceFilesItem (HashMap Text JSONValue) sisfiAddtional = lens _sisfiAddtional (\ s a -> s{_sisfiAddtional = a}) . _Coerce instance FromJSON SourceInfoSourceFilesItem where parseJSON = withObject "SourceInfoSourceFilesItem" (\ o -> SourceInfoSourceFilesItem' <$> (parseJSONObject o)) instance ToJSON SourceInfoSourceFilesItem where toJSON = toJSON . _sisfiAddtional -- | Quota configuration helps to achieve fairness and budgeting in service -- usage. The metric based quota configuration works this way: - The -- service configuration defines a set of metrics. - For API calls, the -- quota.metric_rules maps methods to metrics with corresponding costs. - -- The quota.limits defines limits on the metrics, which will be used for -- quota checks at runtime. An example quota configuration in yaml format: -- quota: limits: - name: apiWriteQpsPerProject metric: -- library.googleapis.com\/write_calls unit: \"1\/min\/{project}\" # rate -- limit for consumer projects values: STANDARD: 10000 # The metric rules -- bind all methods to the read_calls metric, # except for the UpdateBook -- and DeleteBook methods. These two methods # are mapped to the -- write_calls metric, with the UpdateBook method # consuming at twice rate -- as the DeleteBook method. metric_rules: - selector: \"*\" metric_costs: -- library.googleapis.com\/read_calls: 1 - selector: -- google.example.library.v1.LibraryService.UpdateBook metric_costs: -- library.googleapis.com\/write_calls: 2 - selector: -- google.example.library.v1.LibraryService.DeleteBook metric_costs: -- library.googleapis.com\/write_calls: 1 Corresponding Metric definition: -- metrics: - name: library.googleapis.com\/read_calls display_name: Read -- requests metric_kind: DELTA value_type: INT64 - name: -- library.googleapis.com\/write_calls display_name: Write requests -- metric_kind: DELTA value_type: INT64 -- -- /See:/ 'quota' smart constructor. data Quota = Quota' { _qLimits :: !(Maybe [QuotaLimit]) , _qMetricRules :: !(Maybe [MetricRule]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'Quota' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'qLimits' -- -- * 'qMetricRules' quota :: Quota quota = Quota' {_qLimits = Nothing, _qMetricRules = Nothing} -- | List of \`QuotaLimit\` definitions for the service. qLimits :: Lens' Quota [QuotaLimit] qLimits = lens _qLimits (\ s a -> s{_qLimits = a}) . _Default . _Coerce -- | List of \`MetricRule\` definitions, each one mapping a selected method -- to one or more metrics. qMetricRules :: Lens' Quota [MetricRule] qMetricRules = lens _qMetricRules (\ s a -> s{_qMetricRules = a}) . _Default . _Coerce instance FromJSON Quota where parseJSON = withObject "Quota" (\ o -> Quota' <$> (o .:? "limits" .!= mempty) <*> (o .:? "metricRules" .!= mempty)) instance ToJSON Quota where toJSON Quota'{..} = object (catMaybes [("limits" .=) <$> _qLimits, ("metricRules" .=) <$> _qMetricRules]) -- | Metadata provided through GetOperation request for the LRO generated by -- DeletePeeredDnsDomain API. -- -- /See:/ 'deletePeeredDNSDomainMetadata' smart constructor. data DeletePeeredDNSDomainMetadata = DeletePeeredDNSDomainMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DeletePeeredDNSDomainMetadata' with the minimum fields required to make a request. -- deletePeeredDNSDomainMetadata :: DeletePeeredDNSDomainMetadata deletePeeredDNSDomainMetadata = DeletePeeredDNSDomainMetadata' instance FromJSON DeletePeeredDNSDomainMetadata where parseJSON = withObject "DeletePeeredDNSDomainMetadata" (\ o -> pure DeletePeeredDNSDomainMetadata') instance ToJSON DeletePeeredDNSDomainMetadata where toJSON = const emptyObject -- | # gRPC Transcoding gRPC Transcoding is a feature for mapping between a -- gRPC method and one or more HTTP REST endpoints. It allows developers to -- build a single API service that supports both gRPC APIs and REST APIs. -- Many systems, including [Google -- APIs](https:\/\/github.com\/googleapis\/googleapis), [Cloud -- Endpoints](https:\/\/cloud.google.com\/endpoints), [gRPC -- Gateway](https:\/\/github.com\/grpc-ecosystem\/grpc-gateway), and -- [Envoy](https:\/\/github.com\/envoyproxy\/envoy) proxy support this -- feature and use it for large scale production services. \`HttpRule\` -- defines the schema of the gRPC\/REST mapping. The mapping specifies how -- different portions of the gRPC request message are mapped to the URL -- path, URL query parameters, and HTTP request body. It also controls how -- the gRPC response message is mapped to the HTTP response body. -- \`HttpRule\` is typically specified as an \`google.api.http\` annotation -- on the gRPC method. Each mapping specifies a URL path template and an -- HTTP method. The path template may refer to one or more fields in the -- gRPC request message, as long as each field is a non-repeated field with -- a primitive (non-message) type. The path template controls how fields of -- the request message are mapped to the URL path. Example: service -- Messaging { rpc GetMessage(GetMessageRequest) returns (Message) { option -- (google.api.http) = { get: \"\/v1\/{name=messages\/*}\" }; } } message -- GetMessageRequest { string name = 1; \/\/ Mapped to URL path. } message -- Message { string text = 1; \/\/ The resource content. } This enables an -- HTTP REST to gRPC mapping as below: HTTP | gRPC -----|----- \`GET -- \/v1\/messages\/123456\` | \`GetMessage(name: \"messages\/123456\")\` -- Any fields in the request message which are not bound by the path -- template automatically become HTTP query parameters if there is no HTTP -- request body. For example: service Messaging { rpc -- GetMessage(GetMessageRequest) returns (Message) { option -- (google.api.http) = { get:\"\/v1\/messages\/{message_id}\" }; } } -- message GetMessageRequest { message SubMessage { string subfield = 1; } -- string message_id = 1; \/\/ Mapped to URL path. int64 revision = 2; \/\/ -- Mapped to URL query parameter \`revision\`. SubMessage sub = 3; \/\/ -- Mapped to URL query parameter \`sub.subfield\`. } This enables a HTTP -- JSON to RPC mapping as below: HTTP | gRPC -----|----- \`GET -- \/v1\/messages\/123456?revision=2&sub.subfield=foo\` | -- \`GetMessage(message_id: \"123456\" revision: 2 sub: -- SubMessage(subfield: \"foo\"))\` Note that fields which are mapped to -- URL query parameters must have a primitive type or a repeated primitive -- type or a non-repeated message type. In the case of a repeated type, the -- parameter can be repeated in the URL as \`...?param=A&param=B\`. In the -- case of a message type, each field of the message is mapped to a -- separate parameter, such as \`...?foo.a=A&foo.b=B&foo.c=C\`. For HTTP -- methods that allow a request body, the \`body\` field specifies the -- mapping. Consider a REST update method on the message resource -- collection: service Messaging { rpc UpdateMessage(UpdateMessageRequest) -- returns (Message) { option (google.api.http) = { patch: -- \"\/v1\/messages\/{message_id}\" body: \"message\" }; } } message -- UpdateMessageRequest { string message_id = 1; \/\/ mapped to the URL -- Message message = 2; \/\/ mapped to the body } The following HTTP JSON -- to RPC mapping is enabled, where the representation of the JSON in the -- request body is determined by protos JSON encoding: HTTP | gRPC -- -----|----- \`PATCH \/v1\/messages\/123456 { \"text\": \"Hi!\" }\` | -- \`UpdateMessage(message_id: \"123456\" message { text: \"Hi!\" })\` The -- special name \`*\` can be used in the body mapping to define that every -- field not bound by the path template should be mapped to the request -- body. This enables the following alternative definition of the update -- method: service Messaging { rpc UpdateMessage(Message) returns (Message) -- { option (google.api.http) = { patch: \"\/v1\/messages\/{message_id}\" -- body: \"*\" }; } } message Message { string message_id = 1; string text -- = 2; } The following HTTP JSON to RPC mapping is enabled: HTTP | gRPC -- -----|----- \`PATCH \/v1\/messages\/123456 { \"text\": \"Hi!\" }\` | -- \`UpdateMessage(message_id: \"123456\" text: \"Hi!\")\` Note that when -- using \`*\` in the body mapping, it is not possible to have HTTP -- parameters, as all fields not bound by the path end in the body. This -- makes this option more rarely used in practice when defining REST APIs. -- The common usage of \`*\` is in custom methods which don\'t use the URL -- at all for transferring data. It is possible to define multiple HTTP -- methods for one RPC by using the \`additional_bindings\` option. -- Example: service Messaging { rpc GetMessage(GetMessageRequest) returns -- (Message) { option (google.api.http) = { get: -- \"\/v1\/messages\/{message_id}\" additional_bindings { get: -- \"\/v1\/users\/{user_id}\/messages\/{message_id}\" } }; } } message -- GetMessageRequest { string message_id = 1; string user_id = 2; } This -- enables the following two alternative HTTP JSON to RPC mappings: HTTP | -- gRPC -----|----- \`GET \/v1\/messages\/123456\` | -- \`GetMessage(message_id: \"123456\")\` \`GET -- \/v1\/users\/me\/messages\/123456\` | \`GetMessage(user_id: \"me\" -- message_id: \"123456\")\` ## Rules for HTTP mapping 1. Leaf request -- fields (recursive expansion nested messages in the request message) are -- classified into three categories: - Fields referred by the path -- template. They are passed via the URL path. - Fields referred by the -- HttpRule.body. They are passed via the HTTP request body. - All other -- fields are passed via the URL query parameters, and the parameter name -- is the field path in the request message. A repeated field can be -- represented as multiple query parameters under the same name. 2. If -- HttpRule.body is \"*\", there is no URL query parameter, all fields are -- passed via URL path and HTTP request body. 3. If HttpRule.body is -- omitted, there is no HTTP request body, all fields are passed via URL -- path and URL query parameters. ### Path template syntax Template = -- \"\/\" Segments [ Verb ] ; Segments = Segment { \"\/\" Segment } ; -- Segment = \"*\" | \"**\" | LITERAL | Variable ; Variable = \"{\" -- FieldPath [ \"=\" Segments ] \"}\" ; FieldPath = IDENT { \".\" IDENT } ; -- Verb = \":\" LITERAL ; The syntax \`*\` matches a single URL path -- segment. The syntax \`**\` matches zero or more URL path segments, which -- must be the last part of the URL path except the \`Verb\`. The syntax -- \`Variable\` matches part of the URL path as specified by its template. -- A variable template must not contain other variables. If a variable -- matches a single path segment, its template may be omitted, e.g. -- \`{var}\` is equivalent to \`{var=*}\`. The syntax \`LITERAL\` matches -- literal text in the URL path. If the \`LITERAL\` contains any reserved -- character, such characters should be percent-encoded before the -- matching. If a variable contains exactly one path segment, such as -- \`\"{var}\"\` or \`\"{var=*}\"\`, when such a variable is expanded into -- a URL path on the client side, all characters except \`[-_.~0-9a-zA-Z]\` -- are percent-encoded. The server side does the reverse decoding. Such -- variables show up in the [Discovery -- Document](https:\/\/developers.google.com\/discovery\/v1\/reference\/apis) -- as \`{var}\`. If a variable contains multiple path segments, such as -- \`\"{var=foo\/*}\"\` or \`\"{var=**}\"\`, when such a variable is -- expanded into a URL path on the client side, all characters except -- \`[-_.~\/0-9a-zA-Z]\` are percent-encoded. The server side does the -- reverse decoding, except \"%2F\" and \"%2f\" are left unchanged. Such -- variables show up in the [Discovery -- Document](https:\/\/developers.google.com\/discovery\/v1\/reference\/apis) -- as \`{+var}\`. ## Using gRPC API Service Configuration gRPC API Service -- Configuration (service config) is a configuration language for -- configuring a gRPC service to become a user-facing product. The service -- config is simply the YAML representation of the \`google.api.Service\` -- proto message. As an alternative to annotating your proto file, you can -- configure gRPC transcoding in your service config YAML files. You do -- this by specifying a \`HttpRule\` that maps the gRPC method to a REST -- endpoint, achieving the same effect as the proto annotation. This can be -- particularly useful if you have a proto that is reused in multiple -- services. Note that any transcoding specified in the service config will -- override any matching transcoding configuration in the proto. Example: -- http: rules: # Selects a gRPC method and applies HttpRule to it. - -- selector: example.v1.Messaging.GetMessage get: -- \/v1\/messages\/{message_id}\/{sub.subfield} ## Special notes When gRPC -- Transcoding is used to map a gRPC to JSON REST endpoints, the proto to -- JSON conversion must follow the [proto3 -- specification](https:\/\/developers.google.com\/protocol-buffers\/docs\/proto3#json). -- While the single segment variable follows the semantics of [RFC -- 6570](https:\/\/tools.ietf.org\/html\/rfc6570) Section 3.2.2 Simple -- String Expansion, the multi segment variable **does not** follow RFC -- 6570 Section 3.2.3 Reserved Expansion. The reason is that the Reserved -- Expansion does not expand special characters like \`?\` and \`#\`, which -- would lead to invalid URLs. As the result, gRPC Transcoding uses a -- custom encoding for multi segment variables. The path variables **must -- not** refer to any repeated or mapped field, because client libraries -- are not capable of handling such variable expansion. The path variables -- **must not** capture the leading \"\/\" character. The reason is that -- the most common use case \"{var}\" does not capture the leading \"\/\" -- character. For consistency, all path variables must share the same -- behavior. Repeated message fields must not be mapped to URL query -- parameters, because no client library can support such complicated -- mapping. If an API needs to use a JSON array for request or response -- body, it can map the request or response body to a repeated field. -- However, some gRPC Transcoding implementations may not support this -- feature. -- -- /See:/ 'hTTPRule' smart constructor. data HTTPRule = HTTPRule' { _httprSelector :: !(Maybe Text) , _httprPost :: !(Maybe Text) , _httprBody :: !(Maybe Text) , _httprCustom :: !(Maybe CustomHTTPPattern) , _httprResponseBody :: !(Maybe Text) , _httprPatch :: !(Maybe Text) , _httprGet :: !(Maybe Text) , _httprAdditionalBindings :: !(Maybe [HTTPRule]) , _httprDelete :: !(Maybe Text) , _httprPut :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'HTTPRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'httprSelector' -- -- * 'httprPost' -- -- * 'httprBody' -- -- * 'httprCustom' -- -- * 'httprResponseBody' -- -- * 'httprPatch' -- -- * 'httprGet' -- -- * 'httprAdditionalBindings' -- -- * 'httprDelete' -- -- * 'httprPut' hTTPRule :: HTTPRule hTTPRule = HTTPRule' { _httprSelector = Nothing , _httprPost = Nothing , _httprBody = Nothing , _httprCustom = Nothing , _httprResponseBody = Nothing , _httprPatch = Nothing , _httprGet = Nothing , _httprAdditionalBindings = Nothing , _httprDelete = Nothing , _httprPut = Nothing } -- | Selects a method to which this rule applies. Refer to selector for -- syntax details. httprSelector :: Lens' HTTPRule (Maybe Text) httprSelector = lens _httprSelector (\ s a -> s{_httprSelector = a}) -- | Maps to HTTP POST. Used for creating a resource or performing an action. httprPost :: Lens' HTTPRule (Maybe Text) httprPost = lens _httprPost (\ s a -> s{_httprPost = a}) -- | The name of the request field whose value is mapped to the HTTP request -- body, or \`*\` for mapping all request fields not captured by the path -- pattern to the HTTP body, or omitted for not having any HTTP request -- body. NOTE: the referred field must be present at the top-level of the -- request message type. httprBody :: Lens' HTTPRule (Maybe Text) httprBody = lens _httprBody (\ s a -> s{_httprBody = a}) -- | The custom pattern is used for specifying an HTTP method that is not -- included in the \`pattern\` field, such as HEAD, or \"*\" to leave the -- HTTP method unspecified for this rule. The wild-card rule is useful for -- services that provide content to Web (HTML) clients. httprCustom :: Lens' HTTPRule (Maybe CustomHTTPPattern) httprCustom = lens _httprCustom (\ s a -> s{_httprCustom = a}) -- | Optional. The name of the response field whose value is mapped to the -- HTTP response body. When omitted, the entire response message will be -- used as the HTTP response body. NOTE: The referred field must be present -- at the top-level of the response message type. httprResponseBody :: Lens' HTTPRule (Maybe Text) httprResponseBody = lens _httprResponseBody (\ s a -> s{_httprResponseBody = a}) -- | Maps to HTTP PATCH. Used for updating a resource. httprPatch :: Lens' HTTPRule (Maybe Text) httprPatch = lens _httprPatch (\ s a -> s{_httprPatch = a}) -- | Maps to HTTP GET. Used for listing and getting information about -- resources. httprGet :: Lens' HTTPRule (Maybe Text) httprGet = lens _httprGet (\ s a -> s{_httprGet = a}) -- | Additional HTTP bindings for the selector. Nested bindings must not -- contain an \`additional_bindings\` field themselves (that is, the -- nesting may only be one level deep). httprAdditionalBindings :: Lens' HTTPRule [HTTPRule] httprAdditionalBindings = lens _httprAdditionalBindings (\ s a -> s{_httprAdditionalBindings = a}) . _Default . _Coerce -- | Maps to HTTP DELETE. Used for deleting a resource. httprDelete :: Lens' HTTPRule (Maybe Text) httprDelete = lens _httprDelete (\ s a -> s{_httprDelete = a}) -- | Maps to HTTP PUT. Used for replacing a resource. httprPut :: Lens' HTTPRule (Maybe Text) httprPut = lens _httprPut (\ s a -> s{_httprPut = a}) instance FromJSON HTTPRule where parseJSON = withObject "HTTPRule" (\ o -> HTTPRule' <$> (o .:? "selector") <*> (o .:? "post") <*> (o .:? "body") <*> (o .:? "custom") <*> (o .:? "responseBody") <*> (o .:? "patch") <*> (o .:? "get") <*> (o .:? "additionalBindings" .!= mempty) <*> (o .:? "delete") <*> (o .:? "put")) instance ToJSON HTTPRule where toJSON HTTPRule'{..} = object (catMaybes [("selector" .=) <$> _httprSelector, ("post" .=) <$> _httprPost, ("body" .=) <$> _httprBody, ("custom" .=) <$> _httprCustom, ("responseBody" .=) <$> _httprResponseBody, ("patch" .=) <$> _httprPatch, ("get" .=) <$> _httprGet, ("additionalBindings" .=) <$> _httprAdditionalBindings, ("delete" .=) <$> _httprDelete, ("put" .=) <$> _httprPut]) -- | Represents a DNS record set resource. -- -- /See:/ 'dnsRecordSet' smart constructor. data DNSRecordSet = DNSRecordSet' { _drsTtl :: !(Maybe GDuration) , _drsData :: !(Maybe [Text]) , _drsDomain :: !(Maybe Text) , _drsType :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'DNSRecordSet' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'drsTtl' -- -- * 'drsData' -- -- * 'drsDomain' -- -- * 'drsType' dnsRecordSet :: DNSRecordSet dnsRecordSet = DNSRecordSet' { _drsTtl = Nothing , _drsData = Nothing , _drsDomain = Nothing , _drsType = Nothing } -- | Required. The period of time for which this RecordSet can be cached by -- resolvers. drsTtl :: Lens' DNSRecordSet (Maybe Scientific) drsTtl = lens _drsTtl (\ s a -> s{_drsTtl = a}) . mapping _GDuration -- | Required. As defined in RFC 1035 (section 5) and RFC 1034 (section -- 3.6.1) for examples see -- https:\/\/cloud.google.com\/dns\/records\/json-record. drsData :: Lens' DNSRecordSet [Text] drsData = lens _drsData (\ s a -> s{_drsData = a}) . _Default . _Coerce -- | Required. The DNS or domain name of the record set, e.g. -- \`test.example.com\`. drsDomain :: Lens' DNSRecordSet (Maybe Text) drsDomain = lens _drsDomain (\ s a -> s{_drsDomain = a}) -- | Required. The identifier of a supported record type. drsType :: Lens' DNSRecordSet (Maybe Text) drsType = lens _drsType (\ s a -> s{_drsType = a}) instance FromJSON DNSRecordSet where parseJSON = withObject "DNSRecordSet" (\ o -> DNSRecordSet' <$> (o .:? "ttl") <*> (o .:? "data" .!= mempty) <*> (o .:? "domain") <*> (o .:? "type")) instance ToJSON DNSRecordSet where toJSON DNSRecordSet'{..} = object (catMaybes [("ttl" .=) <$> _drsTtl, ("data" .=) <$> _drsData, ("domain" .=) <$> _drsDomain, ("type" .=) <$> _drsType]) -- | The normal response of the operation in case of success. If the original -- method returns no data on success, such as \`Delete\`, the response is -- \`google.protobuf.Empty\`. If the original method is standard -- \`Get\`\/\`Create\`\/\`Update\`, the response should be the resource. -- For other methods, the response should have the type \`XxxResponse\`, -- where \`Xxx\` is the original method name. For example, if the original -- method name is \`TakeSnapshot()\`, the inferred response type is -- \`TakeSnapshotResponse\`. -- -- /See:/ 'operationResponse' smart constructor. newtype OperationResponse = OperationResponse' { _orAddtional :: HashMap Text JSONValue } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'OperationResponse' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'orAddtional' operationResponse :: HashMap Text JSONValue -- ^ 'orAddtional' -> OperationResponse operationResponse pOrAddtional_ = OperationResponse' {_orAddtional = _Coerce # pOrAddtional_} -- | Properties of the object. Contains field \'type with type URL. orAddtional :: Lens' OperationResponse (HashMap Text JSONValue) orAddtional = lens _orAddtional (\ s a -> s{_orAddtional = a}) . _Coerce instance FromJSON OperationResponse where parseJSON = withObject "OperationResponse" (\ o -> OperationResponse' <$> (parseJSONObject o)) instance ToJSON OperationResponse where toJSON = toJSON . _orAddtional -- | Request to add a record set to a private managed DNS zone in the shared -- producer host project. -- -- /See:/ 'addDNSRecordSetRequest' smart constructor. data AddDNSRecordSetRequest = AddDNSRecordSetRequest' { _adrsrZone :: !(Maybe Text) , _adrsrConsumerNetwork :: !(Maybe Text) , _adrsrDNSRecordSet :: !(Maybe DNSRecordSet) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AddDNSRecordSetRequest' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'adrsrZone' -- -- * 'adrsrConsumerNetwork' -- -- * 'adrsrDNSRecordSet' addDNSRecordSetRequest :: AddDNSRecordSetRequest addDNSRecordSetRequest = AddDNSRecordSetRequest' { _adrsrZone = Nothing , _adrsrConsumerNetwork = Nothing , _adrsrDNSRecordSet = Nothing } -- | Required. The name of the private DNS zone in the shared producer host -- project to which the record set will be added. adrsrZone :: Lens' AddDNSRecordSetRequest (Maybe Text) adrsrZone = lens _adrsrZone (\ s a -> s{_adrsrZone = a}) -- | Required. The network that the consumer is using to connect with -- services. Must be in the form of -- projects\/{project}\/global\/networks\/{network} {project} is the -- project number, as in \'12345\' {network} is the network name. adrsrConsumerNetwork :: Lens' AddDNSRecordSetRequest (Maybe Text) adrsrConsumerNetwork = lens _adrsrConsumerNetwork (\ s a -> s{_adrsrConsumerNetwork = a}) -- | Required. The DNS record set to add. adrsrDNSRecordSet :: Lens' AddDNSRecordSetRequest (Maybe DNSRecordSet) adrsrDNSRecordSet = lens _adrsrDNSRecordSet (\ s a -> s{_adrsrDNSRecordSet = a}) instance FromJSON AddDNSRecordSetRequest where parseJSON = withObject "AddDNSRecordSetRequest" (\ o -> AddDNSRecordSetRequest' <$> (o .:? "zone") <*> (o .:? "consumerNetwork") <*> (o .:? "dnsRecordSet")) instance ToJSON AddDNSRecordSetRequest where toJSON AddDNSRecordSetRequest'{..} = object (catMaybes [("zone" .=) <$> _adrsrZone, ("consumerNetwork" .=) <$> _adrsrConsumerNetwork, ("dnsRecordSet" .=) <$> _adrsrDNSRecordSet]) -- | Metadata provided through GetOperation request for the LRO generated by -- UpdateConsumerConfig API. -- -- /See:/ 'consumerConfigMetadata' smart constructor. data ConsumerConfigMetadata = ConsumerConfigMetadata' deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ConsumerConfigMetadata' with the minimum fields required to make a request. -- consumerConfigMetadata :: ConsumerConfigMetadata consumerConfigMetadata = ConsumerConfigMetadata' instance FromJSON ConsumerConfigMetadata where parseJSON = withObject "ConsumerConfigMetadata" (\ o -> pure ConsumerConfigMetadata') instance ToJSON ConsumerConfigMetadata where toJSON = const emptyObject -- | Configuration for an authentication provider, including support for -- [JSON Web Token -- (JWT)](https:\/\/tools.ietf.org\/html\/draft-ietf-oauth-json-web-token-32). -- -- /See:/ 'authProvider' smart constructor. data AuthProvider = AuthProvider' { _apJWKsURI :: !(Maybe Text) , _apAudiences :: !(Maybe Text) , _apJwtLocations :: !(Maybe [JwtLocation]) , _apId :: !(Maybe Text) , _apAuthorizationURL :: !(Maybe Text) , _apIssuer :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'AuthProvider' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'apJWKsURI' -- -- * 'apAudiences' -- -- * 'apJwtLocations' -- -- * 'apId' -- -- * 'apAuthorizationURL' -- -- * 'apIssuer' authProvider :: AuthProvider authProvider = AuthProvider' { _apJWKsURI = Nothing , _apAudiences = Nothing , _apJwtLocations = Nothing , _apId = Nothing , _apAuthorizationURL = Nothing , _apIssuer = Nothing } -- | URL of the provider\'s public key set to validate signature of the JWT. -- See [OpenID -- Discovery](https:\/\/openid.net\/specs\/openid-connect-discovery-1_0.html#ProviderMetadata). -- Optional if the key set document: - can be retrieved from [OpenID -- Discovery](https:\/\/openid.net\/specs\/openid-connect-discovery-1_0.html) -- of the issuer. - can be inferred from the email domain of the issuer -- (e.g. a Google service account). Example: -- https:\/\/www.googleapis.com\/oauth2\/v1\/certs apJWKsURI :: Lens' AuthProvider (Maybe Text) apJWKsURI = lens _apJWKsURI (\ s a -> s{_apJWKsURI = a}) -- | The list of JWT -- [audiences](https:\/\/tools.ietf.org\/html\/draft-ietf-oauth-json-web-token-32#section-4.1.3). -- that are allowed to access. A JWT containing any of these audiences will -- be accepted. When this setting is absent, JWTs with audiences: - -- \"https:\/\/[service.name]\/[google.protobuf.Api.name]\" - -- \"https:\/\/[service.name]\/\" will be accepted. For example, if no -- audiences are in the setting, LibraryService API will accept JWTs with -- the following audiences: - -- https:\/\/library-example.googleapis.com\/google.example.library.v1.LibraryService -- - https:\/\/library-example.googleapis.com\/ Example: audiences: -- bookstore_android.apps.googleusercontent.com, -- bookstore_web.apps.googleusercontent.com apAudiences :: Lens' AuthProvider (Maybe Text) apAudiences = lens _apAudiences (\ s a -> s{_apAudiences = a}) -- | Defines the locations to extract the JWT. JWT locations can be either -- from HTTP headers or URL query parameters. The rule is that the first -- match wins. The checking order is: checking all headers first, then URL -- query parameters. If not specified, default to use following 3 -- locations: 1) Authorization: Bearer 2) x-goog-iap-jwt-assertion 3) -- access_token query parameter Default locations can be specified as -- followings: jwt_locations: - header: Authorization value_prefix: -- \"Bearer \" - header: x-goog-iap-jwt-assertion - query: access_token apJwtLocations :: Lens' AuthProvider [JwtLocation] apJwtLocations = lens _apJwtLocations (\ s a -> s{_apJwtLocations = a}) . _Default . _Coerce -- | The unique identifier of the auth provider. It will be referred to by -- \`AuthRequirement.provider_id\`. Example: \"bookstore_auth\". apId :: Lens' AuthProvider (Maybe Text) apId = lens _apId (\ s a -> s{_apId = a}) -- | Redirect URL if JWT token is required but not present or is expired. -- Implement authorizationUrl of securityDefinitions in OpenAPI spec. apAuthorizationURL :: Lens' AuthProvider (Maybe Text) apAuthorizationURL = lens _apAuthorizationURL (\ s a -> s{_apAuthorizationURL = a}) -- | Identifies the principal that issued the JWT. See -- https:\/\/tools.ietf.org\/html\/draft-ietf-oauth-json-web-token-32#section-4.1.1 -- Usually a URL or an email address. Example: -- https:\/\/securetoken.google.com Example: -- 1234567-compute\'developer.gserviceaccount.com apIssuer :: Lens' AuthProvider (Maybe Text) apIssuer = lens _apIssuer (\ s a -> s{_apIssuer = a}) instance FromJSON AuthProvider where parseJSON = withObject "AuthProvider" (\ o -> AuthProvider' <$> (o .:? "jwksUri") <*> (o .:? "audiences") <*> (o .:? "jwtLocations" .!= mempty) <*> (o .:? "id") <*> (o .:? "authorizationUrl") <*> (o .:? "issuer")) instance ToJSON AuthProvider where toJSON AuthProvider'{..} = object (catMaybes [("jwksUri" .=) <$> _apJWKsURI, ("audiences" .=) <$> _apAudiences, ("jwtLocations" .=) <$> _apJwtLocations, ("id" .=) <$> _apId, ("authorizationUrl" .=) <$> _apAuthorizationURL, ("issuer" .=) <$> _apIssuer]) -- | A context rule provides information about the context for an individual -- API element. -- -- /See:/ 'contextRule' smart constructor. data ContextRule = ContextRule' { _crSelector :: !(Maybe Text) , _crRequested :: !(Maybe [Text]) , _crAllowedRequestExtensions :: !(Maybe [Text]) , _crProvided :: !(Maybe [Text]) , _crAllowedResponseExtensions :: !(Maybe [Text]) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ContextRule' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'crSelector' -- -- * 'crRequested' -- -- * 'crAllowedRequestExtensions' -- -- * 'crProvided' -- -- * 'crAllowedResponseExtensions' contextRule :: ContextRule contextRule = ContextRule' { _crSelector = Nothing , _crRequested = Nothing , _crAllowedRequestExtensions = Nothing , _crProvided = Nothing , _crAllowedResponseExtensions = Nothing } -- | Selects the methods to which this rule applies. Refer to selector for -- syntax details. crSelector :: Lens' ContextRule (Maybe Text) crSelector = lens _crSelector (\ s a -> s{_crSelector = a}) -- | A list of full type names of requested contexts. crRequested :: Lens' ContextRule [Text] crRequested = lens _crRequested (\ s a -> s{_crRequested = a}) . _Default . _Coerce -- | A list of full type names or extension IDs of extensions allowed in grpc -- side channel from client to backend. crAllowedRequestExtensions :: Lens' ContextRule [Text] crAllowedRequestExtensions = lens _crAllowedRequestExtensions (\ s a -> s{_crAllowedRequestExtensions = a}) . _Default . _Coerce -- | A list of full type names of provided contexts. crProvided :: Lens' ContextRule [Text] crProvided = lens _crProvided (\ s a -> s{_crProvided = a}) . _Default . _Coerce -- | A list of full type names or extension IDs of extensions allowed in grpc -- side channel from backend to client. crAllowedResponseExtensions :: Lens' ContextRule [Text] crAllowedResponseExtensions = lens _crAllowedResponseExtensions (\ s a -> s{_crAllowedResponseExtensions = a}) . _Default . _Coerce instance FromJSON ContextRule where parseJSON = withObject "ContextRule" (\ o -> ContextRule' <$> (o .:? "selector") <*> (o .:? "requested" .!= mempty) <*> (o .:? "allowedRequestExtensions" .!= mempty) <*> (o .:? "provided" .!= mempty) <*> (o .:? "allowedResponseExtensions" .!= mempty)) instance ToJSON ContextRule where toJSON ContextRule'{..} = object (catMaybes [("selector" .=) <$> _crSelector, ("requested" .=) <$> _crRequested, ("allowedRequestExtensions" .=) <$> _crAllowedRequestExtensions, ("provided" .=) <$> _crProvided, ("allowedResponseExtensions" .=) <$> _crAllowedResponseExtensions]) -- -- /See:/ 'secondaryIPRangeSpec' smart constructor. data SecondaryIPRangeSpec = SecondaryIPRangeSpec' { _sirsIPPrefixLength :: !(Maybe (Textual Int32)) , _sirsRangeName :: !(Maybe Text) , _sirsRequestedAddress :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'SecondaryIPRangeSpec' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'sirsIPPrefixLength' -- -- * 'sirsRangeName' -- -- * 'sirsRequestedAddress' secondaryIPRangeSpec :: SecondaryIPRangeSpec secondaryIPRangeSpec = SecondaryIPRangeSpec' { _sirsIPPrefixLength = Nothing , _sirsRangeName = Nothing , _sirsRequestedAddress = Nothing } -- | Required. The prefix length of the secondary IP range. Use CIDR range -- notation, such as \`30\` to provision a secondary IP range with an -- \`x.x.x.x\/30\` CIDR range. The IP address range is drawn from a pool of -- available ranges in the service consumer\'s allocated range. sirsIPPrefixLength :: Lens' SecondaryIPRangeSpec (Maybe Int32) sirsIPPrefixLength = lens _sirsIPPrefixLength (\ s a -> s{_sirsIPPrefixLength = a}) . mapping _Coerce -- | Required. A name for the secondary IP range. The name must be 1-63 -- characters long, and comply with RFC1035. The name must be unique within -- the subnetwork. sirsRangeName :: Lens' SecondaryIPRangeSpec (Maybe Text) sirsRangeName = lens _sirsRangeName (\ s a -> s{_sirsRangeName = a}) -- | Optional. The starting address of a range. The address must be a valid -- IPv4 address in the x.x.x.x format. This value combined with the IP -- prefix range is the CIDR range for the secondary IP range. The range -- must be within the allocated range that is assigned to the private -- connection. If the CIDR range isn\'t available, the call fails. sirsRequestedAddress :: Lens' SecondaryIPRangeSpec (Maybe Text) sirsRequestedAddress = lens _sirsRequestedAddress (\ s a -> s{_sirsRequestedAddress = a}) instance FromJSON SecondaryIPRangeSpec where parseJSON = withObject "SecondaryIPRangeSpec" (\ o -> SecondaryIPRangeSpec' <$> (o .:? "ipPrefixLength") <*> (o .:? "rangeName") <*> (o .:? "requestedAddress")) instance ToJSON SecondaryIPRangeSpec where toJSON SecondaryIPRangeSpec'{..} = object (catMaybes [("ipPrefixLength" .=) <$> _sirsIPPrefixLength, ("rangeName" .=) <$> _sirsRangeName, ("requestedAddress" .=) <$> _sirsRequestedAddress])
brendanhay/gogol
gogol-servicenetworking/gen/Network/Google/ServiceNetworking/Types/Product.hs
mpl-2.0
274,459
0
37
61,773
41,816
24,372
17,444
4,594
1
{-# LANGUAGE TupleSections #-} -- | create handlers for menu actions. module Jaek.UI.MenuActionHandlers ( createHandlers ,newHandler ,openHandler ,saveHandler ,importHandler ,renderHandler ,zoomInHandler ,zoomOutHandler ,copyHandler ,deleteHandler ,insertHandler ,muteHandler ,module Jaek.UI.FrpHandlers ) where import Graphics.UI.Gtk import Jaek.Base import Jaek.IO import Jaek.StreamExpr import Jaek.Tree import Jaek.UI.Actions import Jaek.UI.Dialogs import Jaek.UI.FrpHandlers import Jaek.UI.Views (Zoom (..)) import Reactive.Banana import Control.Monad.Trans.Maybe createHandlers :: ActionGroup -> Window -> IO () createHandlers actGrp win = mapM_ (\(act,fn,accel) -> do z <- act fn win z actionGroupAddActionWithAccel actGrp z accel ) [(quitAction, quitHandler, Just "<Control>q")] defaultMkAction :: IO Action -> Maybe String -> ActionGroup -> Window -> NetworkDescription (Event ()) defaultMkAction ioact accel actGrp _win = do act <- liftIO ioact liftIO $ actionGroupAddActionWithAccel actGrp act accel maybeEvent0 act $ return $ Just () -- ------------------------------------ -- imperative-style handlers quitHandler :: Window -> Action -> IO (ConnectId Action) quitHandler win act = on act actionActivated $ widgetDestroy win -- ------------------------------------ -- FRP handlers -- these create FRP Events rather than doing basic stuff. maybeEvent0 :: Typeable a => Action -> IO (Maybe a) -> NetworkDescription (Event a) maybeEvent0 act ops = do (addHandler, runHandlers) <- liftIO newAddHandler liftIO $ on act actionActivated $ ops >>= maybe (return ()) runHandlers fromAddHandler addHandler -- |create a new document newHandler :: ActionGroup -> Window -> NetworkDescription (Event (String, HTree)) newHandler actGrp _win = do act <- liftIO newAction liftIO $ actionGroupAddActionWithAccel actGrp act (Just "<Control>N") maybeEvent0 act newProjectDialog -- | Load a saved project file openHandler :: ActionGroup -> Window -> NetworkDescription (Event (String, HTree)) openHandler actGrp _win = do act <- liftIO openAction liftIO $ actionGroupAddActionWithAccel actGrp act (Just "<Control>O") maybeEvent0 act openProjectDialog -- | Save the current project file saveHandler :: ActionGroup -> Window -> NetworkDescription (Event ()) saveHandler actGrp _win = do act <- liftIO saveAction liftIO $ actionGroupAddActionWithAccel actGrp act (Just "<Control>S") maybeEvent0 act $ return $ Just () -- |import a new audio source importHandler :: ActionGroup -> Window -> NetworkDescription (Event (String, [StreamExpr])) importHandler actGrp _win = do act <- liftIO importAction liftIO $ actionGroupAddActionWithAccel actGrp act (Just "<Control>I") maybeEvent0 act $ do fc <- fileChooserDialogNew (Just "Select an audio file to import") Nothing FileChooserActionOpen [] fileChooserSetSelectMultiple fc True dialogAddButton fc stockCancel ResponseCancel dialogAddButton fc stockOk ResponseOk widgetShowAll fc resp <- dialogRun fc case resp of ResponseOk -> do mfp <- fileChooserGetFilename fc widgetDestroy fc case mfp of Nothing -> return Nothing Just fp -> do eExprs <- newFileExpr fp case eExprs of Left err -> print err >> return Nothing Right exprs -> return $ Just (fp, exprs) _ -> widgetDestroy fc >> return Nothing renderHandler :: ActionGroup -> Window -> NetworkDescription (Event WriteInfo) renderHandler actGrp _win = do act <- liftIO renderAction liftIO $ actionGroupAddActionWithAccel actGrp act (Just "<Control>R") maybeEvent0 act $ runMaybeT $ do params <- MaybeT renderAudioDialog when debug . lift . putStrLn $ "got: " ++ show params return params -- ----------------------------------------- -- view sources -- | zoom in action zoomInHandler :: ActionGroup -> Window -> NetworkDescription (Event Zoom) zoomInHandler a w = (Zoom 0.5 <$) <$> defaultMkAction zoomInAction (Just "<Control>+") a w -- | zoom out action zoomOutHandler :: ActionGroup -> Window -> NetworkDescription (Event Zoom) zoomOutHandler a w = (Zoom 2 <$) <$> defaultMkAction zoomOutAction (Just "<Control>-") a w -- ----------------------------------------- -- edit event sources -- | copy action copyHandler :: ActionGroup -> Window -> NetworkDescription (Event ()) copyHandler = defaultMkAction copyAction $ Just "C" -- | delete action deleteHandler :: ActionGroup -> Window -> NetworkDescription (Event ()) deleteHandler = defaultMkAction deleteAction $ Just "D" -- | insert action insertHandler :: ActionGroup -> Window -> NetworkDescription (Event ()) insertHandler = defaultMkAction insertAction $ Just "I" -- | mute action muteHandler :: ActionGroup -> Window -> NetworkDescription (Event ()) muteHandler = defaultMkAction muteAction $ Just "M"
JohnLato/jaek
src/Jaek/UI/MenuActionHandlers.hs
lgpl-3.0
4,997
0
25
977
1,377
679
698
119
4