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
-- hello.hs my hola mundo main = do --let é necesario para declarar variables en ambitos locais pertencentes a funcions let x = "adios mundo" print ("hola mundo " ++ x)
jmlb23/haskell
ch00/hello.hs
gpl-3.0
174
0
9
35
30
15
15
3
1
{-# LANGUAGE FlexibleInstances #-} module Model where import ClassyPrelude.Yesod import Database.Persist.Quasi import Text.Markdown (Markdown) import Yesod.Text.Markdown() -- You can define all of your database entities in the entities file. -- You can find more information on persistent and how to declare entities -- at: -- http://www.yesodweb.com/book/persistent/ share [mkPersist sqlSettings, mkMigrate "migrateAll"] $(persistFileWith lowerCaseSettings "config/models") data SiteAdmin = SiteAdmin { adminUsername :: Text , adminPassword :: Text } deriving Show
garry-cairns/ILikeWhenItWorks
ILikeWhenItWorks/Model.hs
gpl-3.0
581
0
8
84
92
55
37
-1
-1
import XMonad import Data.Monoid import System.Exit import XMonad.Config.Azerty import XMonad.Hooks.DynamicLog import XMonad.Layout.Grid import XMonad.Layout.Roledex import qualified XMonad.StackSet as W import qualified Data.Map as M myTerminal = "urxvt" myFocusFollowsMouse :: Bool myFocusFollowsMouse = False myBorderWidth = 0 myModMask = mod4Mask myWorkspaces = ["1","2","3","4","5","6","7","8","9"] myNormalBorderColor = "#002b36" myFocusedBorderColor = "#839496" myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ [ ((modm .|. shiftMask, xK_c ), kill) , ((modm, xK_space ), sendMessage NextLayout) , ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) , ((modm, xK_n ), refresh) , ((modm, xK_Tab ), windows W.focusDown) , ((modm, xK_j ), windows W.focusDown) , ((modm, xK_k ), windows W.focusUp ) , ((modm, xK_m ), windows W.focusMaster ) , ((modm, xK_Return), windows W.swapMaster) , ((modm .|. shiftMask, xK_j ), windows W.swapDown ) , ((modm .|. shiftMask, xK_k ), windows W.swapUp ) , ((modm, xK_h ), sendMessage Shrink) , ((modm, xK_l ), sendMessage Expand) , ((modm, xK_t ), withFocused $ windows . W.sink) , ((modm , xK_comma ), sendMessage (IncMasterN 1)) , ((modm , xK_period), sendMessage (IncMasterN (-1))) , ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) , ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart") ] ++ [((m .|. modm, k), windows $ f i) | (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] , (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] ++ [((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f)) | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $ [ ((modm, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) , ((modm, button2), (\w -> focus w >> windows W.shiftMaster)) , ((modm, button3), (\w -> focus w >> mouseResizeWindow w >> windows W.shiftMaster)) ] myLayout = tiled ||| Mirror tiled ||| Full ||| Grid ||| Roledex where tiled = Tall nmaster delta ratio nmaster = 1 ratio = 1/2 delta = 3/100 myManageHook = composeAll [ className =? "MPlayer" --> doFloat , className =? "Plugin-container" --> doFloat] myEventHook = mempty myLogHook = return () myStartupHook = return () main = xmonad =<< statusBar myBar myPP toggleStrutsKey defaults { keys = \c -> azertyKeys c `M.union` keys defaults c } myBar = "xmobar" myPP = xmobarPP { ppCurrent = xmobarColor "#ffffff,#93a1a1" "" . wrap " " "" , ppTitle = const "" , ppLayout = xmobarColor "#ffffff,#93a1a1" "" . (\ x -> pad $ case x of "Tall" -> ": t" "Mirror Tall" -> ": m" "Full" -> ": f" "Grid" -> ": g" "Roledex" -> ": r" _ -> x ) , ppHidden = const "" , ppSep = "" } toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask, xK_b) defaults = defaultConfig { terminal = myTerminal, focusFollowsMouse = myFocusFollowsMouse, borderWidth = myBorderWidth, modMask = myModMask, workspaces = myWorkspaces, normalBorderColor = myNormalBorderColor, focusedBorderColor = myFocusedBorderColor, keys = myKeys, mouseBindings = myMouseBindings, layoutHook = myLayout, manageHook = myManageHook, handleEventHook = myEventHook, logHook = myLogHook, startupHook = myStartupHook }
wlaaraki/dotfiles
xmonad/xmonad.hs
gpl-3.0
4,357
2
14
1,594
1,299
755
544
91
6
-- grid is a game written in Haskell -- Copyright (C) 2018 karamellpelle@hotmail.com -- -- This file is part of grid. -- -- grid 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. -- -- grid 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 grid. If not, see <http://www.gnu.org/licenses/>. -- module MEnv.IOS.Init ( Init (..), ScreenOrientation (..), ) where import MyPrelude import Foreign.Storable import Foreign.Marshal.Alloc import Foreign.Ptr import Foreign.C.Types import Data.Bits import Data.List data Init = Init { initScreenMultisample :: !UInt, -- ^ number of multisamples initScreenOrientations :: [ScreenOrientation], -- ^ orientations initScreenRate :: !UInt, -- ^ skip frames initSoundSampleRate :: !UInt, -- ^ sound rate per second initKeysAcclGyroRate :: !Float -- ^ update interval in seconds. -- 0.0 disables } data ScreenOrientation = OrientationPortrait | OrientationPortraitFlipped | OrientationLandscapeLeft | OrientationLandscapeRight instance Storable Init where sizeOf _ = 4 + 4 + 4 + 4 + 4 alignment _ = 4 poke ptr init = do pokeByteOff ptr 0 (fI $ initScreenMultisample init :: CUInt) pokeByteOff ptr 4 (pokeOrientations $ initScreenOrientations init) pokeByteOff ptr 8 (fI$ initScreenRate init :: CUInt) pokeByteOff ptr 12 (fI $ initSoundSampleRate init :: CUInt) pokeByteOff ptr 16 (rTF $ initKeysAcclGyroRate init :: CFloat) peek ptr = do mult <- peekByteOff ptr 0 :: IO CUInt orin <- peekByteOff ptr 4 :: IO CUInt rateScreen <- peekByteOff ptr 8 :: IO CUInt rateSound <- peekByteOff ptr 12 :: IO CUInt rateKeys <- peekByteOff ptr 16 :: IO CFloat return Init { initScreenMultisample = fI mult, initScreenOrientations = peekOrientations orin, initScreenRate = fI rateScreen, initSoundSampleRate = fI rateSound, initKeysAcclGyroRate = rTF rateKeys } pokeOrientations :: [ScreenOrientation] -> CUInt pokeOrientations os = foldl' step 0x00000000 os where step a o = case o of OrientationPortrait -> a .|. 0x01 OrientationPortraitFlipped -> a .|. 0x02 OrientationLandscapeLeft -> a .|. 0x04 OrientationLandscapeRight -> a .|. 0x08 peekOrientations :: CUInt -> [ScreenOrientation] peekOrientations a = testA ++ testB ++ testC ++ testD where testA = if testBit a 0 then [OrientationPortrait] else [] testB = if testBit a 1 then [OrientationPortraitFlipped] else [] testC = if testBit a 2 then [OrientationLandscapeLeft] else [] testD = if testBit a 3 then [OrientationLandscapeRight] else []
karamellpelle/grid
source/MEnv/IOS/Init.hs
gpl-3.0
3,466
0
11
1,042
667
362
305
67
5
module Main where import Parser main :: IO () main = do seminar <- leseSeminar "jena/" print seminar
turion/hasched
Main.hs
gpl-3.0
108
0
8
25
38
19
19
6
1
{-# LANGUAGE Safe, NoMonomorphismRestriction #-} module Text.ParserCombinators.MyParser.Exercises.N0.Lexer where import MonadLib import Control.Applicative import Data.Functor.Identity import Data.Char import Data.Maybe import Data.Either import Text.ParserCombinators.MyParser data N0 = VAR String | NUM Integer | TRUE | FALSE | EQUALS | LESS | PLUS | MINUS | TIMES | ASSIGN | SEQ | SKIP | IF | THEN | ELSE | WHILE | LEFT | RIGHT | NOT | AND | PRINT | SPACE deriving (Show, Eq) word = foldl (<|>) empty [ TRUE <$ ones "true", FALSE <$ ones "false", SKIP <$ ones "skip", IF <$ ones "if", THEN <$ ones "then", ELSE <$ ones "else", WHILE <$ ones "while", PRINT <$ ones "print", NUM . foldl (\x y -> x * 10 + y) 0 <$> some (toInteger . digitToInt <$> satisfies isDigit), VAR <$> some (satisfies isLower) ] symbol = foldl (<|>) empty [ EQUALS <$ ones "=", LESS <$ ones "<", PLUS <$ ones "+", MINUS <$ ones "-", TIMES <$ ones "*", ASSIGN <$ ones ":=", SEQ <$ ones ";", LEFT <$ ones "(", RIGHT <$ ones ")", AND <$ ones "&&", NOT <$ ones "!!", SPACE <$ space ] parseWord = do x <- some symbol y <- word return $ x ++ [y] space = some (satisfies isSpace) lexer :: ParserT Char String Identity [N0] lexer = do x <- optional word y <- many parseWord z <- many symbol return $ filter (SPACE /=) $ maybeToList x ++ join y ++ z lexn0 str = take 1 $ run' (lexer <* end) str isVar (VAR a) = Just a isVar _ = Nothing isNum (NUM a) = Just a isNum _ = Nothing t1 = "while skipy < 100 (skipy := skipy + 10; skip)" t2 = "while:=\nif bif skipy=" t3 = "abc::==def:=:=" t4 = "if % = $ then 0 else 1"
tapuu/MyParser
Text/ParserCombinators/MyParser/Exercises/N0/Lexer.hs
gpl-3.0
1,702
52
13
432
706
372
334
56
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.Mirror.Timeline.Attachments.Insert -- Copyright : (c) 2015-2016 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Adds a new attachment to a timeline item. -- -- /See:/ <https://developers.google.com/glass Google Mirror API Reference> for @mirror.timeline.attachments.insert@. module Network.Google.Resource.Mirror.Timeline.Attachments.Insert ( -- * REST Resource TimelineAttachmentsInsertResource -- * Creating a Request , timelineAttachmentsInsert , TimelineAttachmentsInsert -- * Request Lenses , taiItemId ) where import Network.Google.Mirror.Types import Network.Google.Prelude -- | A resource alias for @mirror.timeline.attachments.insert@ method which the -- 'TimelineAttachmentsInsert' request conforms to. type TimelineAttachmentsInsertResource = "mirror" :> "v1" :> "timeline" :> Capture "itemId" Text :> "attachments" :> QueryParam "alt" AltJSON :> Post '[JSON] Attachment :<|> "upload" :> "mirror" :> "v1" :> "timeline" :> Capture "itemId" Text :> "attachments" :> QueryParam "alt" AltJSON :> QueryParam "uploadType" AltMedia :> AltMedia :> Post '[JSON] Attachment -- | Adds a new attachment to a timeline item. -- -- /See:/ 'timelineAttachmentsInsert' smart constructor. newtype TimelineAttachmentsInsert = TimelineAttachmentsInsert' { _taiItemId :: Text } deriving (Eq,Show,Data,Typeable,Generic) -- | Creates a value of 'TimelineAttachmentsInsert' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'taiItemId' timelineAttachmentsInsert :: Text -- ^ 'taiItemId' -> TimelineAttachmentsInsert timelineAttachmentsInsert pTaiItemId_ = TimelineAttachmentsInsert' { _taiItemId = pTaiItemId_ } -- | The ID of the timeline item the attachment belongs to. taiItemId :: Lens' TimelineAttachmentsInsert Text taiItemId = lens _taiItemId (\ s a -> s{_taiItemId = a}) instance GoogleRequest TimelineAttachmentsInsert where type Rs TimelineAttachmentsInsert = Attachment type Scopes TimelineAttachmentsInsert = '["https://www.googleapis.com/auth/glass.timeline"] requestClient TimelineAttachmentsInsert'{..} = go _taiItemId (Just AltJSON) mirrorService where go :<|> _ = buildClient (Proxy :: Proxy TimelineAttachmentsInsertResource) mempty instance GoogleRequest (MediaUpload TimelineAttachmentsInsert) where type Rs (MediaUpload TimelineAttachmentsInsert) = Attachment type Scopes (MediaUpload TimelineAttachmentsInsert) = Scopes TimelineAttachmentsInsert requestClient (MediaUpload TimelineAttachmentsInsert'{..} body) = go _taiItemId (Just AltJSON) (Just AltMedia) body mirrorService where _ :<|> go = buildClient (Proxy :: Proxy TimelineAttachmentsInsertResource) mempty
rueshyna/gogol
gogol-mirror/gen/Network/Google/Resource/Mirror/Timeline/Attachments/Insert.hs
mpl-2.0
3,919
0
23
1,027
492
279
213
73
1
{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- | -- Module : Network.Google.BigQueryDataTransfer.Types.Sum -- Copyright : (c) 2015-2016 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- module Network.Google.BigQueryDataTransfer.Types.Sum where import Network.Google.Prelude hiding (Bytes) -- | Parameter type. data DataSourceParameterType = TypeUnspecified -- ^ @TYPE_UNSPECIFIED@ -- Type unspecified. | String -- ^ @STRING@ -- String parameter. | Integer -- ^ @INTEGER@ -- Integer parameter (64-bits). Will be serialized to json as string. | Double -- ^ @DOUBLE@ -- Double precision floating point parameter. | Boolean -- ^ @BOOLEAN@ -- Boolean parameter. | Record -- ^ @RECORD@ -- Deprecated. This field has no effect. | PlusPage -- ^ @PLUS_PAGE@ -- Page ID for a Google+ Page. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable DataSourceParameterType instance FromHttpApiData DataSourceParameterType where parseQueryParam = \case "TYPE_UNSPECIFIED" -> Right TypeUnspecified "STRING" -> Right String "INTEGER" -> Right Integer "DOUBLE" -> Right Double "BOOLEAN" -> Right Boolean "RECORD" -> Right Record "PLUS_PAGE" -> Right PlusPage x -> Left ("Unable to parse DataSourceParameterType from: " <> x) instance ToHttpApiData DataSourceParameterType where toQueryParam = \case TypeUnspecified -> "TYPE_UNSPECIFIED" String -> "STRING" Integer -> "INTEGER" Double -> "DOUBLE" Boolean -> "BOOLEAN" Record -> "RECORD" PlusPage -> "PLUS_PAGE" instance FromJSON DataSourceParameterType where parseJSON = parseJSONText "DataSourceParameterType" instance ToJSON DataSourceParameterType where toJSON = toJSONText -- | Data transfer run state. Ignored for input requests. data TransferRunState = TransferStateUnspecified -- ^ @TRANSFER_STATE_UNSPECIFIED@ -- State placeholder (0). | Pending -- ^ @PENDING@ -- Data transfer is scheduled and is waiting to be picked up by data -- transfer backend (2). | Running -- ^ @RUNNING@ -- Data transfer is in progress (3). | Succeeded -- ^ @SUCCEEDED@ -- Data transfer completed successfully (4). | Failed -- ^ @FAILED@ -- Data transfer failed (5). | Cancelled -- ^ @CANCELLED@ -- Data transfer is cancelled (6). deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable TransferRunState instance FromHttpApiData TransferRunState where parseQueryParam = \case "TRANSFER_STATE_UNSPECIFIED" -> Right TransferStateUnspecified "PENDING" -> Right Pending "RUNNING" -> Right Running "SUCCEEDED" -> Right Succeeded "FAILED" -> Right Failed "CANCELLED" -> Right Cancelled x -> Left ("Unable to parse TransferRunState from: " <> x) instance ToHttpApiData TransferRunState where toQueryParam = \case TransferStateUnspecified -> "TRANSFER_STATE_UNSPECIFIED" Pending -> "PENDING" Running -> "RUNNING" Succeeded -> "SUCCEEDED" Failed -> "FAILED" Cancelled -> "CANCELLED" instance FromJSON TransferRunState where parseJSON = parseJSONText "TransferRunState" instance ToJSON TransferRunState where toJSON = toJSONText -- | Deprecated. This field has no effect. data DataSourceTransferType = TransferTypeUnspecified -- ^ @TRANSFER_TYPE_UNSPECIFIED@ -- Invalid or Unknown transfer type placeholder. | Batch -- ^ @BATCH@ -- Batch data transfer. | Streaming -- ^ @STREAMING@ -- Streaming data transfer. Streaming data source currently doesn\'t -- support multiple transfer configs per project. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable DataSourceTransferType instance FromHttpApiData DataSourceTransferType where parseQueryParam = \case "TRANSFER_TYPE_UNSPECIFIED" -> Right TransferTypeUnspecified "BATCH" -> Right Batch "STREAMING" -> Right Streaming x -> Left ("Unable to parse DataSourceTransferType from: " <> x) instance ToHttpApiData DataSourceTransferType where toQueryParam = \case TransferTypeUnspecified -> "TRANSFER_TYPE_UNSPECIFIED" Batch -> "BATCH" Streaming -> "STREAMING" instance FromJSON DataSourceTransferType where parseJSON = parseJSONText "DataSourceTransferType" instance ToJSON DataSourceTransferType where toJSON = toJSONText -- | When specified, only transfer runs with requested states are returned. data ProjectsLocationsTransferConfigsRunsListStates = PLTCRLSTransferStateUnspecified -- ^ @TRANSFER_STATE_UNSPECIFIED@ -- State placeholder (0). | PLTCRLSPending -- ^ @PENDING@ -- Data transfer is scheduled and is waiting to be picked up by data -- transfer backend (2). | PLTCRLSRunning -- ^ @RUNNING@ -- Data transfer is in progress (3). | PLTCRLSSucceeded -- ^ @SUCCEEDED@ -- Data transfer completed successfully (4). | PLTCRLSFailed -- ^ @FAILED@ -- Data transfer failed (5). | PLTCRLSCancelled -- ^ @CANCELLED@ -- Data transfer is cancelled (6). deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable ProjectsLocationsTransferConfigsRunsListStates instance FromHttpApiData ProjectsLocationsTransferConfigsRunsListStates where parseQueryParam = \case "TRANSFER_STATE_UNSPECIFIED" -> Right PLTCRLSTransferStateUnspecified "PENDING" -> Right PLTCRLSPending "RUNNING" -> Right PLTCRLSRunning "SUCCEEDED" -> Right PLTCRLSSucceeded "FAILED" -> Right PLTCRLSFailed "CANCELLED" -> Right PLTCRLSCancelled x -> Left ("Unable to parse ProjectsLocationsTransferConfigsRunsListStates from: " <> x) instance ToHttpApiData ProjectsLocationsTransferConfigsRunsListStates where toQueryParam = \case PLTCRLSTransferStateUnspecified -> "TRANSFER_STATE_UNSPECIFIED" PLTCRLSPending -> "PENDING" PLTCRLSRunning -> "RUNNING" PLTCRLSSucceeded -> "SUCCEEDED" PLTCRLSFailed -> "FAILED" PLTCRLSCancelled -> "CANCELLED" instance FromJSON ProjectsLocationsTransferConfigsRunsListStates where parseJSON = parseJSONText "ProjectsLocationsTransferConfigsRunsListStates" instance ToJSON ProjectsLocationsTransferConfigsRunsListStates where toJSON = toJSONText -- | Message types to return. If not populated - INFO, WARNING and ERROR -- messages are returned. data ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes = MessageSeverityUnspecified -- ^ @MESSAGE_SEVERITY_UNSPECIFIED@ -- No severity specified. | Info -- ^ @INFO@ -- Informational message. | Warning -- ^ @WARNING@ -- Warning message. | Error' -- ^ @ERROR@ -- Error message. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes instance FromHttpApiData ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes where parseQueryParam = \case "MESSAGE_SEVERITY_UNSPECIFIED" -> Right MessageSeverityUnspecified "INFO" -> Right Info "WARNING" -> Right Warning "ERROR" -> Right Error' x -> Left ("Unable to parse ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes from: " <> x) instance ToHttpApiData ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes where toQueryParam = \case MessageSeverityUnspecified -> "MESSAGE_SEVERITY_UNSPECIFIED" Info -> "INFO" Warning -> "WARNING" Error' -> "ERROR" instance FromJSON ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes where parseJSON = parseJSONText "ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes" instance ToJSON ProjectsLocationsTransferConfigsRunsTransferLogsListMessageTypes where toJSON = toJSONText -- | Indicates the type of authorization. data DataSourceAuthorizationType = AuthorizationTypeUnspecified -- ^ @AUTHORIZATION_TYPE_UNSPECIFIED@ -- Type unspecified. | AuthorizationCode -- ^ @AUTHORIZATION_CODE@ -- Use OAuth 2 authorization codes that can be exchanged for a refresh -- token on the backend. | GooglePlusAuthorizationCode -- ^ @GOOGLE_PLUS_AUTHORIZATION_CODE@ -- Return an authorization code for a given Google+ page that can then be -- exchanged for a refresh token on the backend. | FirstPartyOAuth -- ^ @FIRST_PARTY_OAUTH@ -- Use First Party OAuth based on Loas Owned Clients. First Party OAuth -- doesn\'t require a refresh token to get an offline access token. -- Instead, it uses a client-signed JWT assertion to retrieve an access -- token. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable DataSourceAuthorizationType instance FromHttpApiData DataSourceAuthorizationType where parseQueryParam = \case "AUTHORIZATION_TYPE_UNSPECIFIED" -> Right AuthorizationTypeUnspecified "AUTHORIZATION_CODE" -> Right AuthorizationCode "GOOGLE_PLUS_AUTHORIZATION_CODE" -> Right GooglePlusAuthorizationCode "FIRST_PARTY_OAUTH" -> Right FirstPartyOAuth x -> Left ("Unable to parse DataSourceAuthorizationType from: " <> x) instance ToHttpApiData DataSourceAuthorizationType where toQueryParam = \case AuthorizationTypeUnspecified -> "AUTHORIZATION_TYPE_UNSPECIFIED" AuthorizationCode -> "AUTHORIZATION_CODE" GooglePlusAuthorizationCode -> "GOOGLE_PLUS_AUTHORIZATION_CODE" FirstPartyOAuth -> "FIRST_PARTY_OAUTH" instance FromJSON DataSourceAuthorizationType where parseJSON = parseJSONText "DataSourceAuthorizationType" instance ToJSON DataSourceAuthorizationType where toJSON = toJSONText -- | Indicates how run attempts are to be pulled. data ProjectsLocationsTransferConfigsRunsListRunAttempt = RunAttemptUnspecified -- ^ @RUN_ATTEMPT_UNSPECIFIED@ -- All runs should be returned. | Latest -- ^ @LATEST@ -- Only latest run per day should be returned. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable ProjectsLocationsTransferConfigsRunsListRunAttempt instance FromHttpApiData ProjectsLocationsTransferConfigsRunsListRunAttempt where parseQueryParam = \case "RUN_ATTEMPT_UNSPECIFIED" -> Right RunAttemptUnspecified "LATEST" -> Right Latest x -> Left ("Unable to parse ProjectsLocationsTransferConfigsRunsListRunAttempt from: " <> x) instance ToHttpApiData ProjectsLocationsTransferConfigsRunsListRunAttempt where toQueryParam = \case RunAttemptUnspecified -> "RUN_ATTEMPT_UNSPECIFIED" Latest -> "LATEST" instance FromJSON ProjectsLocationsTransferConfigsRunsListRunAttempt where parseJSON = parseJSONText "ProjectsLocationsTransferConfigsRunsListRunAttempt" instance ToJSON ProjectsLocationsTransferConfigsRunsListRunAttempt where toJSON = toJSONText -- | V1 error format. data Xgafv = X1 -- ^ @1@ -- v1 error format | X2 -- ^ @2@ -- v2 error format deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable Xgafv instance FromHttpApiData Xgafv where parseQueryParam = \case "1" -> Right X1 "2" -> Right X2 x -> Left ("Unable to parse Xgafv from: " <> x) instance ToHttpApiData Xgafv where toQueryParam = \case X1 -> "1" X2 -> "2" instance FromJSON Xgafv where parseJSON = parseJSONText "Xgafv" instance ToJSON Xgafv where toJSON = toJSONText -- | Specifies whether the data source supports automatic data refresh for -- the past few days, and how it\'s supported. For some data sources, data -- might not be complete until a few days later, so it\'s useful to refresh -- data automatically. data DataSourceDataRefreshType = DataRefreshTypeUnspecified -- ^ @DATA_REFRESH_TYPE_UNSPECIFIED@ -- The data source won\'t support data auto refresh, which is default -- value. | SlidingWindow -- ^ @SLIDING_WINDOW@ -- The data source supports data auto refresh, and runs will be scheduled -- for the past few days. Does not allow custom values to be set for each -- transfer config. | CustomSlidingWindow -- ^ @CUSTOM_SLIDING_WINDOW@ -- The data source supports data auto refresh, and runs will be scheduled -- for the past few days. Allows custom values to be set for each transfer -- config. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable DataSourceDataRefreshType instance FromHttpApiData DataSourceDataRefreshType where parseQueryParam = \case "DATA_REFRESH_TYPE_UNSPECIFIED" -> Right DataRefreshTypeUnspecified "SLIDING_WINDOW" -> Right SlidingWindow "CUSTOM_SLIDING_WINDOW" -> Right CustomSlidingWindow x -> Left ("Unable to parse DataSourceDataRefreshType from: " <> x) instance ToHttpApiData DataSourceDataRefreshType where toQueryParam = \case DataRefreshTypeUnspecified -> "DATA_REFRESH_TYPE_UNSPECIFIED" SlidingWindow -> "SLIDING_WINDOW" CustomSlidingWindow -> "CUSTOM_SLIDING_WINDOW" instance FromJSON DataSourceDataRefreshType where parseJSON = parseJSONText "DataSourceDataRefreshType" instance ToJSON DataSourceDataRefreshType where toJSON = toJSONText -- | Message types to return. If not populated - INFO, WARNING and ERROR -- messages are returned. data ProjectsTransferConfigsRunsTransferLogsListMessageTypes = PTCRTLLMTMessageSeverityUnspecified -- ^ @MESSAGE_SEVERITY_UNSPECIFIED@ -- No severity specified. | PTCRTLLMTInfo -- ^ @INFO@ -- Informational message. | PTCRTLLMTWarning -- ^ @WARNING@ -- Warning message. | PTCRTLLMTError' -- ^ @ERROR@ -- Error message. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable ProjectsTransferConfigsRunsTransferLogsListMessageTypes instance FromHttpApiData ProjectsTransferConfigsRunsTransferLogsListMessageTypes where parseQueryParam = \case "MESSAGE_SEVERITY_UNSPECIFIED" -> Right PTCRTLLMTMessageSeverityUnspecified "INFO" -> Right PTCRTLLMTInfo "WARNING" -> Right PTCRTLLMTWarning "ERROR" -> Right PTCRTLLMTError' x -> Left ("Unable to parse ProjectsTransferConfigsRunsTransferLogsListMessageTypes from: " <> x) instance ToHttpApiData ProjectsTransferConfigsRunsTransferLogsListMessageTypes where toQueryParam = \case PTCRTLLMTMessageSeverityUnspecified -> "MESSAGE_SEVERITY_UNSPECIFIED" PTCRTLLMTInfo -> "INFO" PTCRTLLMTWarning -> "WARNING" PTCRTLLMTError' -> "ERROR" instance FromJSON ProjectsTransferConfigsRunsTransferLogsListMessageTypes where parseJSON = parseJSONText "ProjectsTransferConfigsRunsTransferLogsListMessageTypes" instance ToJSON ProjectsTransferConfigsRunsTransferLogsListMessageTypes where toJSON = toJSONText -- | When specified, only transfer runs with requested states are returned. data ProjectsTransferConfigsRunsListStates = PTCRLSTransferStateUnspecified -- ^ @TRANSFER_STATE_UNSPECIFIED@ -- State placeholder (0). | PTCRLSPending -- ^ @PENDING@ -- Data transfer is scheduled and is waiting to be picked up by data -- transfer backend (2). | PTCRLSRunning -- ^ @RUNNING@ -- Data transfer is in progress (3). | PTCRLSSucceeded -- ^ @SUCCEEDED@ -- Data transfer completed successfully (4). | PTCRLSFailed -- ^ @FAILED@ -- Data transfer failed (5). | PTCRLSCancelled -- ^ @CANCELLED@ -- Data transfer is cancelled (6). deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable ProjectsTransferConfigsRunsListStates instance FromHttpApiData ProjectsTransferConfigsRunsListStates where parseQueryParam = \case "TRANSFER_STATE_UNSPECIFIED" -> Right PTCRLSTransferStateUnspecified "PENDING" -> Right PTCRLSPending "RUNNING" -> Right PTCRLSRunning "SUCCEEDED" -> Right PTCRLSSucceeded "FAILED" -> Right PTCRLSFailed "CANCELLED" -> Right PTCRLSCancelled x -> Left ("Unable to parse ProjectsTransferConfigsRunsListStates from: " <> x) instance ToHttpApiData ProjectsTransferConfigsRunsListStates where toQueryParam = \case PTCRLSTransferStateUnspecified -> "TRANSFER_STATE_UNSPECIFIED" PTCRLSPending -> "PENDING" PTCRLSRunning -> "RUNNING" PTCRLSSucceeded -> "SUCCEEDED" PTCRLSFailed -> "FAILED" PTCRLSCancelled -> "CANCELLED" instance FromJSON ProjectsTransferConfigsRunsListStates where parseJSON = parseJSONText "ProjectsTransferConfigsRunsListStates" instance ToJSON ProjectsTransferConfigsRunsListStates where toJSON = toJSONText -- | Indicates how run attempts are to be pulled. data ProjectsTransferConfigsRunsListRunAttempt = PTCRLRARunAttemptUnspecified -- ^ @RUN_ATTEMPT_UNSPECIFIED@ -- All runs should be returned. | PTCRLRALatest -- ^ @LATEST@ -- Only latest run per day should be returned. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable ProjectsTransferConfigsRunsListRunAttempt instance FromHttpApiData ProjectsTransferConfigsRunsListRunAttempt where parseQueryParam = \case "RUN_ATTEMPT_UNSPECIFIED" -> Right PTCRLRARunAttemptUnspecified "LATEST" -> Right PTCRLRALatest x -> Left ("Unable to parse ProjectsTransferConfigsRunsListRunAttempt from: " <> x) instance ToHttpApiData ProjectsTransferConfigsRunsListRunAttempt where toQueryParam = \case PTCRLRARunAttemptUnspecified -> "RUN_ATTEMPT_UNSPECIFIED" PTCRLRALatest -> "LATEST" instance FromJSON ProjectsTransferConfigsRunsListRunAttempt where parseJSON = parseJSONText "ProjectsTransferConfigsRunsListRunAttempt" instance ToJSON ProjectsTransferConfigsRunsListRunAttempt where toJSON = toJSONText -- | Message severity. data TransferMessageSeverity = TMSMessageSeverityUnspecified -- ^ @MESSAGE_SEVERITY_UNSPECIFIED@ -- No severity specified. | TMSInfo -- ^ @INFO@ -- Informational message. | TMSWarning -- ^ @WARNING@ -- Warning message. | TMSError' -- ^ @ERROR@ -- Error message. deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable TransferMessageSeverity instance FromHttpApiData TransferMessageSeverity where parseQueryParam = \case "MESSAGE_SEVERITY_UNSPECIFIED" -> Right TMSMessageSeverityUnspecified "INFO" -> Right TMSInfo "WARNING" -> Right TMSWarning "ERROR" -> Right TMSError' x -> Left ("Unable to parse TransferMessageSeverity from: " <> x) instance ToHttpApiData TransferMessageSeverity where toQueryParam = \case TMSMessageSeverityUnspecified -> "MESSAGE_SEVERITY_UNSPECIFIED" TMSInfo -> "INFO" TMSWarning -> "WARNING" TMSError' -> "ERROR" instance FromJSON TransferMessageSeverity where parseJSON = parseJSONText "TransferMessageSeverity" instance ToJSON TransferMessageSeverity where toJSON = toJSONText -- | Output only. State of the most recently updated transfer run. data TransferConfigState = TCSTransferStateUnspecified -- ^ @TRANSFER_STATE_UNSPECIFIED@ -- State placeholder (0). | TCSPending -- ^ @PENDING@ -- Data transfer is scheduled and is waiting to be picked up by data -- transfer backend (2). | TCSRunning -- ^ @RUNNING@ -- Data transfer is in progress (3). | TCSSucceeded -- ^ @SUCCEEDED@ -- Data transfer completed successfully (4). | TCSFailed -- ^ @FAILED@ -- Data transfer failed (5). | TCSCancelled -- ^ @CANCELLED@ -- Data transfer is cancelled (6). deriving (Eq, Ord, Enum, Read, Show, Data, Typeable, Generic) instance Hashable TransferConfigState instance FromHttpApiData TransferConfigState where parseQueryParam = \case "TRANSFER_STATE_UNSPECIFIED" -> Right TCSTransferStateUnspecified "PENDING" -> Right TCSPending "RUNNING" -> Right TCSRunning "SUCCEEDED" -> Right TCSSucceeded "FAILED" -> Right TCSFailed "CANCELLED" -> Right TCSCancelled x -> Left ("Unable to parse TransferConfigState from: " <> x) instance ToHttpApiData TransferConfigState where toQueryParam = \case TCSTransferStateUnspecified -> "TRANSFER_STATE_UNSPECIFIED" TCSPending -> "PENDING" TCSRunning -> "RUNNING" TCSSucceeded -> "SUCCEEDED" TCSFailed -> "FAILED" TCSCancelled -> "CANCELLED" instance FromJSON TransferConfigState where parseJSON = parseJSONText "TransferConfigState" instance ToJSON TransferConfigState where toJSON = toJSONText
brendanhay/gogol
gogol-bigquerydatatransfer/gen/Network/Google/BigQueryDataTransfer/Types/Sum.hs
mpl-2.0
21,658
0
11
4,708
2,943
1,580
1,363
353
0
{-# 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.DialogFlow.Projects.Agent.Sessions.Contexts.Create -- Copyright : (c) 2015-2016 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Creates a context. If the specified context already exists, overrides -- the context. -- -- /See:/ <https://cloud.google.com/dialogflow-enterprise/ Dialogflow API Reference> for @dialogflow.projects.agent.sessions.contexts.create@. module Network.Google.Resource.DialogFlow.Projects.Agent.Sessions.Contexts.Create ( -- * REST Resource ProjectsAgentSessionsContextsCreateResource -- * Creating a Request , projectsAgentSessionsContextsCreate , ProjectsAgentSessionsContextsCreate -- * Request Lenses , pasccParent , pasccXgafv , pasccUploadProtocol , pasccAccessToken , pasccUploadType , pasccPayload , pasccCallback ) where import Network.Google.DialogFlow.Types import Network.Google.Prelude -- | A resource alias for @dialogflow.projects.agent.sessions.contexts.create@ method which the -- 'ProjectsAgentSessionsContextsCreate' request conforms to. type ProjectsAgentSessionsContextsCreateResource = "v2" :> Capture "parent" Text :> "contexts" :> QueryParam "$.xgafv" Xgafv :> QueryParam "upload_protocol" Text :> QueryParam "access_token" Text :> QueryParam "uploadType" Text :> QueryParam "callback" Text :> QueryParam "alt" AltJSON :> ReqBody '[JSON] GoogleCloudDialogflowV2Context :> Post '[JSON] GoogleCloudDialogflowV2Context -- | Creates a context. If the specified context already exists, overrides -- the context. -- -- /See:/ 'projectsAgentSessionsContextsCreate' smart constructor. data ProjectsAgentSessionsContextsCreate = ProjectsAgentSessionsContextsCreate' { _pasccParent :: !Text , _pasccXgafv :: !(Maybe Xgafv) , _pasccUploadProtocol :: !(Maybe Text) , _pasccAccessToken :: !(Maybe Text) , _pasccUploadType :: !(Maybe Text) , _pasccPayload :: !GoogleCloudDialogflowV2Context , _pasccCallback :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'ProjectsAgentSessionsContextsCreate' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'pasccParent' -- -- * 'pasccXgafv' -- -- * 'pasccUploadProtocol' -- -- * 'pasccAccessToken' -- -- * 'pasccUploadType' -- -- * 'pasccPayload' -- -- * 'pasccCallback' projectsAgentSessionsContextsCreate :: Text -- ^ 'pasccParent' -> GoogleCloudDialogflowV2Context -- ^ 'pasccPayload' -> ProjectsAgentSessionsContextsCreate projectsAgentSessionsContextsCreate pPasccParent_ pPasccPayload_ = ProjectsAgentSessionsContextsCreate' { _pasccParent = pPasccParent_ , _pasccXgafv = Nothing , _pasccUploadProtocol = Nothing , _pasccAccessToken = Nothing , _pasccUploadType = Nothing , _pasccPayload = pPasccPayload_ , _pasccCallback = Nothing } -- | Required. The session to create a context for. Format: -- \`projects\/\/agent\/sessions\/\`. pasccParent :: Lens' ProjectsAgentSessionsContextsCreate Text pasccParent = lens _pasccParent (\ s a -> s{_pasccParent = a}) -- | V1 error format. pasccXgafv :: Lens' ProjectsAgentSessionsContextsCreate (Maybe Xgafv) pasccXgafv = lens _pasccXgafv (\ s a -> s{_pasccXgafv = a}) -- | Upload protocol for media (e.g. \"raw\", \"multipart\"). pasccUploadProtocol :: Lens' ProjectsAgentSessionsContextsCreate (Maybe Text) pasccUploadProtocol = lens _pasccUploadProtocol (\ s a -> s{_pasccUploadProtocol = a}) -- | OAuth access token. pasccAccessToken :: Lens' ProjectsAgentSessionsContextsCreate (Maybe Text) pasccAccessToken = lens _pasccAccessToken (\ s a -> s{_pasccAccessToken = a}) -- | Legacy upload protocol for media (e.g. \"media\", \"multipart\"). pasccUploadType :: Lens' ProjectsAgentSessionsContextsCreate (Maybe Text) pasccUploadType = lens _pasccUploadType (\ s a -> s{_pasccUploadType = a}) -- | Multipart request metadata. pasccPayload :: Lens' ProjectsAgentSessionsContextsCreate GoogleCloudDialogflowV2Context pasccPayload = lens _pasccPayload (\ s a -> s{_pasccPayload = a}) -- | JSONP pasccCallback :: Lens' ProjectsAgentSessionsContextsCreate (Maybe Text) pasccCallback = lens _pasccCallback (\ s a -> s{_pasccCallback = a}) instance GoogleRequest ProjectsAgentSessionsContextsCreate where type Rs ProjectsAgentSessionsContextsCreate = GoogleCloudDialogflowV2Context type Scopes ProjectsAgentSessionsContextsCreate = '["https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/dialogflow"] requestClient ProjectsAgentSessionsContextsCreate'{..} = go _pasccParent _pasccXgafv _pasccUploadProtocol _pasccAccessToken _pasccUploadType _pasccCallback (Just AltJSON) _pasccPayload dialogFlowService where go = buildClient (Proxy :: Proxy ProjectsAgentSessionsContextsCreateResource) mempty
brendanhay/gogol
gogol-dialogflow/gen/Network/Google/Resource/DialogFlow/Projects/Agent/Sessions/Contexts/Create.hs
mpl-2.0
6,034
0
17
1,343
787
461
326
121
1
----------------------------------------------------------------------------- -- -- Module : Main -- Copyright : -- License : AllRightsReserved -- -- Maintainer : -- Stability : -- Portability : -- -- | -- ----------------------------------------------------------------------------- module Main ( main ) where -- This strang looking comment adds code only needed when running the -- doctest tests embedded in the comments -- $setup -- >>> import Data.List (stripPrefix) -- | Simple function to create a hello message. -- prop> stripPrefix "Hello " (hello s) == Just s hello :: String -> String hello s = "Hello " ++ s main :: IO () main = putStrLn (hello "World")
MathiasGarnier/RandomProject
Haskell/Apprentissage/src/Main.hs
apache-2.0
729
0
7
164
73
48
25
6
1
{-# LANGUAGE OverloadedStrings #-} module Lst.Domain where import Text.Parsec.Char (char) import Text.Parsec.Combinator (sepBy) import ClassyPrelude import Modifications import Common type DomainSpell = (String, Int, String) data DomainDefinition = DomainDescription String | DomainSpellLevel [DomainSpell] | DomainType String deriving Show parseDescription :: PParser String parseDescription = tag "DESC" *> restOfTag parseType :: PParser String parseType = tag "TYPE" *> restOfTag parseSpellLevel :: PParser [DomainSpell] parseSpellLevel = do _ <- labeled "SPELLLEVEL:DOMAIN|" parseSpell `sepBy` char '|' where parseSpell :: PParser DomainSpell parseSpell = do word <- parseTill '=' level <- manyNumbers <* char '|' description <- parseString return (word, textToInt level, description) parseDomainTag :: PParser DomainDefinition parseDomainTag = DomainDescription <$> parseDescription <|> DomainType <$> parseType <|> DomainSpellLevel <$> parseSpellLevel instance LSTObject DomainDefinition where parseSpecificTags = parseDomainTag
gamelost/pcgen-rules
src/Lst/Domain.hs
apache-2.0
1,177
0
11
265
266
143
123
32
1
{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Kubernetes.V1.ComponentStatusList where import GHC.Generics import Data.Text import Kubernetes.Unversioned.ListMeta import Kubernetes.V1.ComponentStatus import qualified Data.Aeson -- | Status of all the conditions for the component as a list of ComponentStatus objects. data ComponentStatusList = ComponentStatusList { kind :: Maybe Text -- ^ Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds , apiVersion :: Maybe Text -- ^ APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#resources , metadata :: Maybe ListMeta -- ^ Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds , items :: [ComponentStatus] -- ^ List of ComponentStatus objects. } deriving (Show, Eq, Generic) instance Data.Aeson.FromJSON ComponentStatusList instance Data.Aeson.ToJSON ComponentStatusList
minhdoboi/deprecated-openshift-haskell-api
kubernetes/lib/Kubernetes/V1/ComponentStatusList.hs
apache-2.0
1,441
0
9
191
125
77
48
19
0
{-# OPTIONS -fglasgow-exts #-} ----------------------------------------------------------------------------- {-| Module : QStyleOptionTabWidgetFrame.hs Copyright : (c) David Harley 2010 Project : qtHaskell Version : 1.1.4 Modified : 2010-09-02 17:02:35 Warning : this file is machine generated - do not modify. --} ----------------------------------------------------------------------------- module Qtc.Enums.Gui.QStyleOptionTabWidgetFrame ( QStyleOptionTabWidgetFrameStyleOptionType , StyleOptionVersio ) where import Foreign.C.Types import Qtc.Classes.Base import Qtc.ClassTypes.Core (QObject, TQObject, qObjectFromPtr) import Qtc.Core.Base (Qcs, connectSlot, qtc_connectSlot_int, wrapSlotHandler_int) import Qtc.Enums.Base import Qtc.Enums.Classes.Core data CQStyleOptionTabWidgetFrameStyleOptionType a = CQStyleOptionTabWidgetFrameStyleOptionType a type QStyleOptionTabWidgetFrameStyleOptionType = QEnum(CQStyleOptionTabWidgetFrameStyleOptionType Int) ieQStyleOptionTabWidgetFrameStyleOptionType :: Int -> QStyleOptionTabWidgetFrameStyleOptionType ieQStyleOptionTabWidgetFrameStyleOptionType x = QEnum (CQStyleOptionTabWidgetFrameStyleOptionType x) instance QEnumC (CQStyleOptionTabWidgetFrameStyleOptionType Int) where qEnum_toInt (QEnum (CQStyleOptionTabWidgetFrameStyleOptionType x)) = x qEnum_fromInt x = QEnum (CQStyleOptionTabWidgetFrameStyleOptionType x) withQEnumResult x = do ti <- x return $ qEnum_fromInt $ fromIntegral ti withQEnumListResult x = do til <- x return $ map qEnum_fromInt til instance Qcs (QObject c -> QStyleOptionTabWidgetFrameStyleOptionType -> IO ()) where connectSlot _qsig_obj _qsig_nam _qslt_obj _qslt_nam _handler = do funptr <- wrapSlotHandler_int slotHandlerWrapper_int stptr <- newStablePtr (Wrap _handler) withObjectPtr _qsig_obj $ \cobj_sig -> withCWString _qsig_nam $ \cstr_sig -> withObjectPtr _qslt_obj $ \cobj_slt -> withCWString _qslt_nam $ \cstr_slt -> qtc_connectSlot_int cobj_sig cstr_sig cobj_slt cstr_slt (toCFunPtr funptr) (castStablePtrToPtr stptr) return () where slotHandlerWrapper_int :: Ptr fun -> Ptr () -> Ptr (TQObject c) -> CInt -> IO () slotHandlerWrapper_int funptr stptr qobjptr cint = do qobj <- qObjectFromPtr qobjptr let hint = fromCInt cint if (objectIsNull qobj) then do when (stptr/=ptrNull) (freeStablePtr (castPtrToStablePtr stptr)) when (funptr/=ptrNull) (freeHaskellFunPtr (castPtrToFunPtr funptr)) else _handler qobj (qEnum_fromInt hint) return () instance QeType QStyleOptionTabWidgetFrameStyleOptionType where eType = ieQStyleOptionTabWidgetFrameStyleOptionType $ 13 data CStyleOptionVersio a = CStyleOptionVersio a type StyleOptionVersio = QEnum(CStyleOptionVersio Int) ieStyleOptionVersio :: Int -> StyleOptionVersio ieStyleOptionVersio x = QEnum (CStyleOptionVersio x) instance QEnumC (CStyleOptionVersio Int) where qEnum_toInt (QEnum (CStyleOptionVersio x)) = x qEnum_fromInt x = QEnum (CStyleOptionVersio x) withQEnumResult x = do ti <- x return $ qEnum_fromInt $ fromIntegral ti withQEnumListResult x = do til <- x return $ map qEnum_fromInt til instance Qcs (QObject c -> StyleOptionVersio -> IO ()) where connectSlot _qsig_obj _qsig_nam _qslt_obj _qslt_nam _handler = do funptr <- wrapSlotHandler_int slotHandlerWrapper_int stptr <- newStablePtr (Wrap _handler) withObjectPtr _qsig_obj $ \cobj_sig -> withCWString _qsig_nam $ \cstr_sig -> withObjectPtr _qslt_obj $ \cobj_slt -> withCWString _qslt_nam $ \cstr_slt -> qtc_connectSlot_int cobj_sig cstr_sig cobj_slt cstr_slt (toCFunPtr funptr) (castStablePtrToPtr stptr) return () where slotHandlerWrapper_int :: Ptr fun -> Ptr () -> Ptr (TQObject c) -> CInt -> IO () slotHandlerWrapper_int funptr stptr qobjptr cint = do qobj <- qObjectFromPtr qobjptr let hint = fromCInt cint if (objectIsNull qobj) then do when (stptr/=ptrNull) (freeStablePtr (castPtrToStablePtr stptr)) when (funptr/=ptrNull) (freeHaskellFunPtr (castPtrToFunPtr funptr)) else _handler qobj (qEnum_fromInt hint) return () instance QeVersion StyleOptionVersio where eVersion = ieStyleOptionVersio $ 1
keera-studios/hsQt
Qtc/Enums/Gui/QStyleOptionTabWidgetFrame.hs
bsd-2-clause
4,488
0
18
921
1,080
532
548
90
1
{- (c) The University of Glasgow 2006 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 Desugaring exporessions. -} {-# LANGUAGE CPP #-} module DsExpr ( dsExpr, dsLExpr, dsLocalBinds, dsValBinds, dsLit ) where #include "HsVersions.h" import Match import MatchLit import DsBinds import DsGRHSs import DsListComp import DsUtils import DsArrows import DsMonad import Name import NameEnv import FamInstEnv( topNormaliseType ) #ifdef GHCI -- Template Haskell stuff iff bootstrapped import DsMeta #endif import HsSyn import Platform -- NB: The desugarer, which straddles the source and Core worlds, sometimes -- needs to see source types import TcType import Coercion ( Role(..) ) import TcEvidence import TcRnMonad import Type import CoreSyn import CoreUtils import CoreFVs import MkCore import DynFlags import CostCentre import Id import Module import VarSet import VarEnv import ConLike import DataCon import TysWiredIn import PrelNames import BasicTypes import Maybes import SrcLoc import Util import Bag import Outputable import FastString import IdInfo import Data.IORef ( atomicModifyIORef', modifyIORef ) import Control.Monad import GHC.Fingerprint {- ************************************************************************ * * dsLocalBinds, dsValBinds * * ************************************************************************ -} dsLocalBinds :: HsLocalBinds Id -> CoreExpr -> DsM CoreExpr dsLocalBinds EmptyLocalBinds body = return body dsLocalBinds (HsValBinds binds) body = dsValBinds binds body dsLocalBinds (HsIPBinds binds) body = dsIPBinds binds body ------------------------- dsValBinds :: HsValBinds Id -> CoreExpr -> DsM CoreExpr dsValBinds (ValBindsOut binds _) body = foldrM ds_val_bind body binds dsValBinds (ValBindsIn _ _) _ = panic "dsValBinds ValBindsIn" ------------------------- dsIPBinds :: HsIPBinds Id -> CoreExpr -> DsM CoreExpr dsIPBinds (IPBinds ip_binds ev_binds) body = do { ds_binds <- dsTcEvBinds ev_binds ; let inner = mkCoreLets ds_binds body -- The dict bindings may not be in -- dependency order; hence Rec ; foldrM ds_ip_bind inner ip_binds } where ds_ip_bind (L _ (IPBind ~(Right n) e)) body = do e' <- dsLExpr e return (Let (NonRec n e') body) ------------------------- ds_val_bind :: (RecFlag, LHsBinds Id) -> CoreExpr -> DsM CoreExpr -- Special case for bindings which bind unlifted variables -- We need to do a case right away, rather than building -- a tuple and doing selections. -- Silently ignore INLINE and SPECIALISE pragmas... ds_val_bind (NonRecursive, hsbinds) body | [L loc bind] <- bagToList hsbinds, -- Non-recursive, non-overloaded bindings only come in ones -- ToDo: in some bizarre case it's conceivable that there -- could be dict binds in the 'binds'. (See the notes -- below. Then pattern-match would fail. Urk.) strictMatchOnly bind = putSrcSpanDs loc (dsStrictBind bind body) -- Ordinary case for bindings; none should be unlifted ds_val_bind (_is_rec, binds) body = do { prs <- dsLHsBinds binds ; ASSERT2( not (any (isUnLiftedType . idType . fst) prs), ppr _is_rec $$ ppr binds ) case prs of [] -> return body _ -> return (Let (Rec prs) body) } -- Use a Rec regardless of is_rec. -- Why? Because it allows the binds to be all -- mixed up, which is what happens in one rare case -- Namely, for an AbsBind with no tyvars and no dicts, -- but which does have dictionary bindings. -- See notes with TcSimplify.inferLoop [NO TYVARS] -- It turned out that wrapping a Rec here was the easiest solution -- -- NB The previous case dealt with unlifted bindings, so we -- only have to deal with lifted ones now; so Rec is ok ------------------ dsStrictBind :: HsBind Id -> CoreExpr -> DsM CoreExpr dsStrictBind (AbsBinds { abs_tvs = [], abs_ev_vars = [] , abs_exports = exports , abs_ev_binds = ev_binds , abs_binds = lbinds }) body = do { let body1 = foldr bind_export body exports bind_export export b = bindNonRec (abe_poly export) (Var (abe_mono export)) b ; body2 <- foldlBagM (\body lbind -> dsStrictBind (unLoc lbind) body) body1 lbinds ; ds_binds <- dsTcEvBinds_s ev_binds ; return (mkCoreLets ds_binds body2) } dsStrictBind (FunBind { fun_id = L _ fun, fun_matches = matches, fun_co_fn = co_fn , fun_tick = tick, fun_infix = inf }) body -- Can't be a bang pattern (that looks like a PatBind) -- so must be simply unboxed = do { (args, rhs) <- matchWrapper (FunRhs (idName fun ) inf) matches ; MASSERT( null args ) -- Functions aren't lifted ; MASSERT( isIdHsWrapper co_fn ) ; let rhs' = mkOptTickBox tick rhs ; return (bindNonRec fun rhs' body) } dsStrictBind (PatBind {pat_lhs = pat, pat_rhs = grhss, pat_rhs_ty = ty }) body = -- let C x# y# = rhs in body -- ==> case rhs of C x# y# -> body do { rhs <- dsGuarded grhss ty ; let upat = unLoc pat eqn = EqnInfo { eqn_pats = [upat], eqn_rhs = cantFailMatchResult body } ; var <- selectMatchVar upat ; result <- matchEquations PatBindRhs [var] [eqn] (exprType body) ; return (bindNonRec var rhs result) } dsStrictBind bind body = pprPanic "dsLet: unlifted" (ppr bind $$ ppr body) ---------------------- strictMatchOnly :: HsBind Id -> Bool strictMatchOnly (AbsBinds { abs_binds = lbinds }) = anyBag (strictMatchOnly . unLoc) lbinds strictMatchOnly (PatBind { pat_lhs = lpat, pat_rhs_ty = rhs_ty }) = isUnLiftedType rhs_ty || isStrictLPat lpat || any (isUnLiftedType . idType) (collectPatBinders lpat) strictMatchOnly (FunBind { fun_id = L _ id }) = isUnLiftedType (idType id) strictMatchOnly _ = False -- I hope! Checked immediately by caller in fact {- ************************************************************************ * * \subsection[DsExpr-vars-and-cons]{Variables, constructors, literals} * * ************************************************************************ -} dsLExpr :: LHsExpr Id -> DsM CoreExpr dsLExpr (L loc e) = putSrcSpanDs loc $ dsExpr e dsExpr :: HsExpr Id -> DsM CoreExpr dsExpr (HsPar e) = dsLExpr e dsExpr (ExprWithTySigOut e _) = dsLExpr e dsExpr (HsVar var) = return (varToCoreExpr var) -- See Note [Desugaring vars] dsExpr (HsIPVar _) = panic "dsExpr: HsIPVar" dsExpr (HsLit lit) = dsLit lit dsExpr (HsOverLit lit) = dsOverLit lit dsExpr (HsWrap co_fn e) = do { e' <- dsExpr e ; wrapped_e <- dsHsWrapper co_fn e' ; dflags <- getDynFlags ; warnAboutIdentities dflags e' (exprType wrapped_e) ; return wrapped_e } dsExpr (NegApp expr neg_expr) = App <$> dsExpr neg_expr <*> dsLExpr expr dsExpr (HsLam a_Match) = uncurry mkLams <$> matchWrapper LambdaExpr a_Match dsExpr (HsLamCase arg matches) = do { arg_var <- newSysLocalDs arg ; ([discrim_var], matching_code) <- matchWrapper CaseAlt matches ; return $ Lam arg_var $ bindNonRec discrim_var (Var arg_var) matching_code } dsExpr (HsApp fun arg) = mkCoreAppDs <$> dsLExpr fun <*> dsLExpr arg dsExpr (HsUnboundVar _) = panic "dsExpr: HsUnboundVar" {- Note [Desugaring vars] ~~~~~~~~~~~~~~~~~~~~~~ In one situation we can get a *coercion* variable in a HsVar, namely the support method for an equality superclass: class (a~b) => C a b where ... instance (blah) => C (T a) (T b) where .. Then we get $dfCT :: forall ab. blah => C (T a) (T b) $dfCT ab blah = MkC ($c$p1C a blah) ($cop a blah) $c$p1C :: forall ab. blah => (T a ~ T b) $c$p1C ab blah = let ...; g :: T a ~ T b = ... } in g That 'g' in the 'in' part is an evidence variable, and when converting to core it must become a CO. Operator sections. At first it looks as if we can convert \begin{verbatim} (expr op) \end{verbatim} to \begin{verbatim} \x -> op expr x \end{verbatim} But no! expr might be a redex, and we can lose laziness badly this way. Consider \begin{verbatim} map (expr op) xs \end{verbatim} for example. So we convert instead to \begin{verbatim} let y = expr in \x -> op y x \end{verbatim} If \tr{expr} is actually just a variable, say, then the simplifier will sort it out. -} dsExpr (OpApp e1 op _ e2) = -- for the type of y, we need the type of op's 2nd argument mkCoreAppsDs <$> dsLExpr op <*> mapM dsLExpr [e1, e2] dsExpr (SectionL expr op) -- Desugar (e !) to ((!) e) = mkCoreAppDs <$> dsLExpr op <*> dsLExpr expr -- dsLExpr (SectionR op expr) -- \ x -> op x expr dsExpr (SectionR op expr) = do core_op <- dsLExpr op -- for the type of x, we need the type of op's 2nd argument let (x_ty:y_ty:_, _) = splitFunTys (exprType core_op) -- See comment with SectionL y_core <- dsLExpr expr x_id <- newSysLocalDs x_ty y_id <- newSysLocalDs y_ty return (bindNonRec y_id y_core $ Lam x_id (mkCoreAppsDs core_op [Var x_id, Var y_id])) dsExpr (ExplicitTuple tup_args boxity) = do { let go (lam_vars, args) (L _ (Missing ty)) -- For every missing expression, we need -- another lambda in the desugaring. = do { lam_var <- newSysLocalDs ty ; return (lam_var : lam_vars, Var lam_var : args) } go (lam_vars, args) (L _ (Present expr)) -- Expressions that are present don't generate -- lambdas, just arguments. = do { core_expr <- dsLExpr expr ; return (lam_vars, core_expr : args) } ; (lam_vars, args) <- foldM go ([], []) (reverse tup_args) -- The reverse is because foldM goes left-to-right ; return $ mkCoreLams lam_vars $ mkCoreConApps (tupleCon (boxityNormalTupleSort boxity) (length tup_args)) (map (Type . exprType) args ++ args) } dsExpr (HsSCC _ cc expr@(L loc _)) = do dflags <- getDynFlags if gopt Opt_SccProfilingOn dflags then do mod_name <- getModule count <- goptM Opt_ProfCountEntries uniq <- newUnique Tick (ProfNote (mkUserCC cc mod_name loc uniq) count True) <$> dsLExpr expr else dsLExpr expr dsExpr (HsCoreAnn _ _ expr) = dsLExpr expr dsExpr (HsCase discrim matches) = do { core_discrim <- dsLExpr discrim ; ([discrim_var], matching_code) <- matchWrapper CaseAlt matches ; return (bindNonRec discrim_var core_discrim matching_code) } -- Pepe: The binds are in scope in the body but NOT in the binding group -- This is to avoid silliness in breakpoints dsExpr (HsLet binds body) = do body' <- dsLExpr body dsLocalBinds binds body' -- We need the `ListComp' form to use `deListComp' (rather than the "do" form) -- because the interpretation of `stmts' depends on what sort of thing it is. -- dsExpr (HsDo ListComp stmts res_ty) = dsListComp stmts res_ty dsExpr (HsDo PArrComp stmts _) = dsPArrComp (map unLoc stmts) dsExpr (HsDo DoExpr stmts _) = dsDo stmts dsExpr (HsDo GhciStmtCtxt stmts _) = dsDo stmts dsExpr (HsDo MDoExpr stmts _) = dsDo stmts dsExpr (HsDo MonadComp stmts _) = dsMonadComp stmts dsExpr (HsIf mb_fun guard_expr then_expr else_expr) = do { pred <- dsLExpr guard_expr ; b1 <- dsLExpr then_expr ; b2 <- dsLExpr else_expr ; case mb_fun of Just fun -> do { core_fun <- dsExpr fun ; return (mkCoreApps core_fun [pred,b1,b2]) } Nothing -> return $ mkIfThenElse pred b1 b2 } dsExpr (HsMultiIf res_ty alts) | null alts = mkErrorExpr | otherwise = do { match_result <- liftM (foldr1 combineMatchResults) (mapM (dsGRHS IfAlt res_ty) alts) ; error_expr <- mkErrorExpr ; extractMatchResult match_result error_expr } where mkErrorExpr = mkErrorAppDs nON_EXHAUSTIVE_GUARDS_ERROR_ID res_ty (ptext (sLit "multi-way if")) {- \noindent \underline{\bf Various data construction things} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -} dsExpr (ExplicitList elt_ty wit xs) = dsExplicitList elt_ty wit xs -- We desugar [:x1, ..., xn:] as -- singletonP x1 +:+ ... +:+ singletonP xn -- dsExpr (ExplicitPArr ty []) = do emptyP <- dsDPHBuiltin emptyPVar return (Var emptyP `App` Type ty) dsExpr (ExplicitPArr ty xs) = do singletonP <- dsDPHBuiltin singletonPVar appP <- dsDPHBuiltin appPVar xs' <- mapM dsLExpr xs return . foldr1 (binary appP) $ map (unary singletonP) xs' where unary fn x = mkApps (Var fn) [Type ty, x] binary fn x y = mkApps (Var fn) [Type ty, x, y] dsExpr (ArithSeq expr witness seq) = case witness of Nothing -> dsArithSeq expr seq Just fl -> do { ; fl' <- dsExpr fl ; newArithSeq <- dsArithSeq expr seq ; return (App fl' newArithSeq)} dsExpr (PArrSeq expr (FromTo from to)) = mkApps <$> dsExpr expr <*> mapM dsLExpr [from, to] dsExpr (PArrSeq expr (FromThenTo from thn to)) = mkApps <$> dsExpr expr <*> mapM dsLExpr [from, thn, to] dsExpr (PArrSeq _ _) = panic "DsExpr.dsExpr: Infinite parallel array!" -- the parser shouldn't have generated it and the renamer and typechecker -- shouldn't have let it through {- \noindent \underline{\bf Static Pointers} ~~~~~~~~~~~~~~~ \begin{verbatim} g = ... static f ... ==> sptEntry:N = StaticPtr (fingerprintString "pkgKey:module.sptEntry:N") (StaticPtrInfo "current pkg key" "current module" "sptEntry:0") f g = ... sptEntry:N \end{verbatim} -} dsExpr (HsStatic expr@(L loc _)) = do expr_ds <- dsLExpr expr let ty = exprType expr_ds n' <- mkSptEntryName loc static_binds_var <- dsGetStaticBindsVar staticPtrTyCon <- dsLookupTyCon staticPtrTyConName staticPtrInfoDataCon <- dsLookupDataCon staticPtrInfoDataConName staticPtrDataCon <- dsLookupDataCon staticPtrDataConName fingerprintDataCon <- dsLookupDataCon fingerprintDataConName dflags <- getDynFlags let (line, col) = case loc of RealSrcSpan r -> ( srcLocLine $ realSrcSpanStart r , srcLocCol $ realSrcSpanStart r ) _ -> (0, 0) srcLoc = mkCoreConApps (tupleCon BoxedTuple 2) [ Type intTy , Type intTy , mkIntExprInt dflags line, mkIntExprInt dflags col ] info <- mkConApp staticPtrInfoDataCon <$> (++[srcLoc]) <$> mapM mkStringExprFS [ packageKeyFS $ modulePackageKey $ nameModule n' , moduleNameFS $ moduleName $ nameModule n' , occNameFS $ nameOccName n' ] let tvars = varSetElems $ tyVarsOfType ty speTy = mkForAllTys tvars $ mkTyConApp staticPtrTyCon [ty] speId = mkExportedLocalId VanillaId n' speTy fp@(Fingerprint w0 w1) = fingerprintName $ idName speId fp_core = mkConApp fingerprintDataCon [ mkWord64LitWordRep dflags w0 , mkWord64LitWordRep dflags w1 ] sp = mkConApp staticPtrDataCon [Type ty, fp_core, info, expr_ds] liftIO $ modifyIORef static_binds_var ((fp, (speId, mkLams tvars sp)) :) putSrcSpanDs loc $ return $ mkTyApps (Var speId) (map mkTyVarTy tvars) where -- | Choose either 'Word64#' or 'Word#' to represent the arguments of the -- 'Fingerprint' data constructor. mkWord64LitWordRep dflags | platformWordSize (targetPlatform dflags) < 8 = mkWord64LitWord64 | otherwise = mkWordLit dflags . toInteger fingerprintName :: Name -> Fingerprint fingerprintName n = fingerprintString $ unpackFS $ concatFS [ packageKeyFS $ modulePackageKey $ nameModule n , fsLit ":" , moduleNameFS (moduleName $ nameModule n) , fsLit "." , occNameFS $ occName n ] {- \noindent \underline{\bf Record construction and update} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For record construction we do this (assuming T has three arguments) \begin{verbatim} T { op2 = e } ==> let err = /\a -> recConErr a T (recConErr t1 "M.hs/230/op1") e (recConErr t1 "M.hs/230/op3") \end{verbatim} @recConErr@ then converts its arugment string into a proper message before printing it as \begin{verbatim} M.hs, line 230: missing field op1 was evaluated \end{verbatim} We also handle @C{}@ as valid construction syntax for an unlabelled constructor @C@, setting all of @C@'s fields to bottom. -} dsExpr (RecordCon (L _ data_con_id) con_expr rbinds) = do con_expr' <- dsExpr con_expr let (arg_tys, _) = tcSplitFunTys (exprType con_expr') -- A newtype in the corner should be opaque; -- hence TcType.tcSplitFunTys mk_arg (arg_ty, lbl) -- Selector id has the field label as its name = case findField (rec_flds rbinds) lbl of (rhs:rhss) -> ASSERT( null rhss ) dsLExpr rhs [] -> mkErrorAppDs rEC_CON_ERROR_ID arg_ty (ppr lbl) unlabelled_bottom arg_ty = mkErrorAppDs rEC_CON_ERROR_ID arg_ty Outputable.empty labels = dataConFieldLabels (idDataCon data_con_id) -- The data_con_id is guaranteed to be the wrapper id of the constructor con_args <- if null labels then mapM unlabelled_bottom arg_tys else mapM mk_arg (zipEqual "dsExpr:RecordCon" arg_tys labels) return (mkCoreApps con_expr' con_args) {- Record update is a little harder. Suppose we have the decl: \begin{verbatim} data T = T1 {op1, op2, op3 :: Int} | T2 {op4, op2 :: Int} | T3 \end{verbatim} Then we translate as follows: \begin{verbatim} r { op2 = e } ===> let op2 = e in case r of T1 op1 _ op3 -> T1 op1 op2 op3 T2 op4 _ -> T2 op4 op2 other -> recUpdError "M.hs/230" \end{verbatim} It's important that we use the constructor Ids for @T1@, @T2@ etc on the RHSs, and do not generate a Core constructor application directly, because the constructor might do some argument-evaluation first; and may have to throw away some dictionaries. Note [Update for GADTs] ~~~~~~~~~~~~~~~~~~~~~~~ Consider data T a b where T1 { f1 :: a } :: T a Int Then the wrapper function for T1 has type $WT1 :: a -> T a Int But if x::T a b, then x { f1 = v } :: T a b (not T a Int!) So we need to cast (T a Int) to (T a b). Sigh. -} dsExpr expr@(RecordUpd record_expr (HsRecFields { rec_flds = fields }) cons_to_upd in_inst_tys out_inst_tys) | null fields = dsLExpr record_expr | otherwise = ASSERT2( notNull cons_to_upd, ppr expr ) do { record_expr' <- dsLExpr record_expr ; field_binds' <- mapM ds_field fields ; let upd_fld_env :: NameEnv Id -- Maps field name to the LocalId of the field binding upd_fld_env = mkNameEnv [(f,l) | (f,l,_) <- field_binds'] -- It's important to generate the match with matchWrapper, -- and the right hand sides with applications of the wrapper Id -- so that everything works when we are doing fancy unboxing on the -- constructor aguments. ; alts <- mapM (mk_alt upd_fld_env) cons_to_upd ; ([discrim_var], matching_code) <- matchWrapper RecUpd (MG { mg_alts = alts, mg_arg_tys = [in_ty] , mg_res_ty = out_ty, mg_origin = FromSource }) -- FromSource is not strictly right, but we -- want incomplete pattern-match warnings ; return (add_field_binds field_binds' $ bindNonRec discrim_var record_expr' matching_code) } where ds_field :: LHsRecField Id (LHsExpr Id) -> DsM (Name, Id, CoreExpr) -- Clone the Id in the HsRecField, because its Name is that -- of the record selector, and we must not make that a lcoal binder -- else we shadow other uses of the record selector -- Hence 'lcl_id'. Cf Trac #2735 ds_field (L _ rec_field) = do { rhs <- dsLExpr (hsRecFieldArg rec_field) ; let fld_id = unLoc (hsRecFieldId rec_field) ; lcl_id <- newSysLocalDs (idType fld_id) ; return (idName fld_id, lcl_id, rhs) } add_field_binds [] expr = expr add_field_binds ((_,b,r):bs) expr = bindNonRec b r (add_field_binds bs expr) -- Awkwardly, for families, the match goes -- from instance type to family type tycon = dataConTyCon (head cons_to_upd) in_ty = mkTyConApp tycon in_inst_tys out_ty = mkFamilyTyConApp tycon out_inst_tys mk_alt upd_fld_env con = do { let (univ_tvs, ex_tvs, eq_spec, theta, arg_tys, _) = dataConFullSig con subst = mkTopTvSubst (univ_tvs `zip` in_inst_tys) -- I'm not bothering to clone the ex_tvs ; eqs_vars <- mapM newPredVarDs (substTheta subst (eqSpecPreds eq_spec)) ; theta_vars <- mapM newPredVarDs (substTheta subst theta) ; arg_ids <- newSysLocalsDs (substTys subst arg_tys) ; let val_args = zipWithEqual "dsExpr:RecordUpd" mk_val_arg (dataConFieldLabels con) arg_ids mk_val_arg field_name pat_arg_id = nlHsVar (lookupNameEnv upd_fld_env field_name `orElse` pat_arg_id) inst_con = noLoc $ HsWrap wrap (HsVar (dataConWrapId con)) -- Reconstruct with the WrapId so that unpacking happens wrap = mkWpEvVarApps theta_vars <.> mkWpTyApps (mkTyVarTys ex_tvs) <.> mkWpTyApps [ty | (tv, ty) <- univ_tvs `zip` out_inst_tys , not (tv `elemVarEnv` wrap_subst) ] rhs = foldl (\a b -> nlHsApp a b) inst_con val_args -- Tediously wrap the application in a cast -- Note [Update for GADTs] wrap_co = mkTcTyConAppCo Nominal tycon [ lookup tv ty | (tv,ty) <- univ_tvs `zip` out_inst_tys ] lookup univ_tv ty = case lookupVarEnv wrap_subst univ_tv of Just co' -> co' Nothing -> mkTcReflCo Nominal ty wrap_subst = mkVarEnv [ (tv, mkTcSymCo (mkTcCoVarCo eq_var)) | ((tv,_),eq_var) <- eq_spec `zip` eqs_vars ] pat = noLoc $ ConPatOut { pat_con = noLoc (RealDataCon con) , pat_tvs = ex_tvs , pat_dicts = eqs_vars ++ theta_vars , pat_binds = emptyTcEvBinds , pat_args = PrefixCon $ map nlVarPat arg_ids , pat_arg_tys = in_inst_tys , pat_wrap = idHsWrapper } ; let wrapped_rhs | null eq_spec = rhs | otherwise = mkLHsWrap (mkWpCast (mkTcSubCo wrap_co)) rhs ; return (mkSimpleMatch [pat] wrapped_rhs) } -- Here is where we desugar the Template Haskell brackets and escapes -- Template Haskell stuff dsExpr (HsRnBracketOut _ _) = panic "dsExpr HsRnBracketOut" #ifdef GHCI dsExpr (HsTcBracketOut x ps) = dsBracket x ps #else dsExpr (HsTcBracketOut _ _) = panic "dsExpr HsBracketOut" #endif dsExpr (HsSpliceE s) = pprPanic "dsExpr:splice" (ppr s) -- Arrow notation extension dsExpr (HsProc pat cmd) = dsProcExpr pat cmd -- Hpc Support dsExpr (HsTick tickish e) = do e' <- dsLExpr e return (Tick tickish e') -- There is a problem here. The then and else branches -- have no free variables, so they are open to lifting. -- We need someway of stopping this. -- This will make no difference to binary coverage -- (did you go here: YES or NO), but will effect accurate -- tick counting. dsExpr (HsBinTick ixT ixF e) = do e2 <- dsLExpr e do { ASSERT(exprType e2 `eqType` boolTy) mkBinaryTickBox ixT ixF e2 } dsExpr (HsTickPragma _ _ expr) = do dflags <- getDynFlags if gopt Opt_Hpc dflags then panic "dsExpr:HsTickPragma" else dsLExpr expr -- HsSyn constructs that just shouldn't be here: dsExpr (ExprWithTySig {}) = panic "dsExpr:ExprWithTySig" dsExpr (HsBracket {}) = panic "dsExpr:HsBracket" dsExpr (HsArrApp {}) = panic "dsExpr:HsArrApp" dsExpr (HsArrForm {}) = panic "dsExpr:HsArrForm" dsExpr (EWildPat {}) = panic "dsExpr:EWildPat" dsExpr (EAsPat {}) = panic "dsExpr:EAsPat" dsExpr (EViewPat {}) = panic "dsExpr:EViewPat" dsExpr (ELazyPat {}) = panic "dsExpr:ELazyPat" dsExpr (HsType {}) = panic "dsExpr:HsType" dsExpr (HsDo {}) = panic "dsExpr:HsDo" findField :: [LHsRecField Id arg] -> Name -> [arg] findField rbinds lbl = [rhs | L _ (HsRecField { hsRecFieldId = id, hsRecFieldArg = rhs }) <- rbinds , lbl == idName (unLoc id) ] {- %-------------------------------------------------------------------- Note [Desugaring explicit lists] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Explicit lists are desugared in a cleverer way to prevent some fruitless allocations. Essentially, whenever we see a list literal [x_1, ..., x_n] we: 1. Find the tail of the list that can be allocated statically (say [x_k, ..., x_n]) by later stages and ensure we desugar that normally: this makes sure that we don't cause a code size increase by having the cons in that expression fused (see later) and hence being unable to statically allocate any more 2. For the prefix of the list which cannot be allocated statically, say [x_1, ..., x_(k-1)], we turn it into an expression involving build so that if we find any foldrs over it it will fuse away entirely! So in this example we will desugar to: build (\c n -> x_1 `c` x_2 `c` .... `c` foldr c n [x_k, ..., x_n] If fusion fails to occur then build will get inlined and (since we defined a RULE for foldr (:) []) we will get back exactly the normal desugaring for an explicit list. This optimisation can be worth a lot: up to 25% of the total allocation in some nofib programs. Specifically Program Size Allocs Runtime CompTime rewrite +0.0% -26.3% 0.02 -1.8% ansi -0.3% -13.8% 0.00 +0.0% lift +0.0% -8.7% 0.00 -2.3% Of course, if rules aren't turned on then there is pretty much no point doing this fancy stuff, and it may even be harmful. =======> Note by SLPJ Dec 08. I'm unconvinced that we should *ever* generate a build for an explicit list. See the comments in GHC.Base about the foldr/cons rule, which points out that (foldr k z [a,b,c]) may generate *much* less code than (a `k` b `k` c `k` z). Furthermore generating builds messes up the LHS of RULES. Example: the foldr/single rule in GHC.Base foldr k z [x] = ... We do not want to generate a build invocation on the LHS of this RULE! We fix this by disabling rules in rule LHSs, and testing that flag here; see Note [Desugaring RULE left hand sides] in Desugar To test this I've added a (static) flag -fsimple-list-literals, which makes all list literals be generated via the simple route. -} dsExplicitList :: PostTc Id Type -> Maybe (SyntaxExpr Id) -> [LHsExpr Id] -> DsM CoreExpr -- See Note [Desugaring explicit lists] dsExplicitList elt_ty Nothing xs = do { dflags <- getDynFlags ; xs' <- mapM dsLExpr xs ; let (dynamic_prefix, static_suffix) = spanTail is_static xs' ; if gopt Opt_SimpleListLiterals dflags -- -fsimple-list-literals || not (gopt Opt_EnableRewriteRules dflags) -- Rewrite rules off -- Don't generate a build if there are no rules to eliminate it! -- See Note [Desugaring RULE left hand sides] in Desugar || null dynamic_prefix -- Avoid build (\c n. foldr c n xs)! then return $ mkListExpr elt_ty xs' else mkBuildExpr elt_ty (mkSplitExplicitList dynamic_prefix static_suffix) } where is_static :: CoreExpr -> Bool is_static e = all is_static_var (varSetElems (exprFreeVars e)) is_static_var :: Var -> Bool is_static_var v | isId v = isExternalName (idName v) -- Top-level things are given external names | otherwise = False -- Type variables mkSplitExplicitList prefix suffix (c, _) (n, n_ty) = do { let suffix' = mkListExpr elt_ty suffix ; folded_suffix <- mkFoldrExpr elt_ty n_ty (Var c) (Var n) suffix' ; return (foldr (App . App (Var c)) folded_suffix prefix) } dsExplicitList elt_ty (Just fln) xs = do { fln' <- dsExpr fln ; list <- dsExplicitList elt_ty Nothing xs ; dflags <- getDynFlags ; return (App (App fln' (mkIntExprInt dflags (length xs))) list) } spanTail :: (a -> Bool) -> [a] -> ([a], [a]) spanTail f xs = (reverse rejected, reverse satisfying) where (satisfying, rejected) = span f $ reverse xs dsArithSeq :: PostTcExpr -> (ArithSeqInfo Id) -> DsM CoreExpr dsArithSeq expr (From from) = App <$> dsExpr expr <*> dsLExpr from dsArithSeq expr (FromTo from to) = do dflags <- getDynFlags warnAboutEmptyEnumerations dflags from Nothing to expr' <- dsExpr expr from' <- dsLExpr from to' <- dsLExpr to return $ mkApps expr' [from', to'] dsArithSeq expr (FromThen from thn) = mkApps <$> dsExpr expr <*> mapM dsLExpr [from, thn] dsArithSeq expr (FromThenTo from thn to) = do dflags <- getDynFlags warnAboutEmptyEnumerations dflags from (Just thn) to expr' <- dsExpr expr from' <- dsLExpr from thn' <- dsLExpr thn to' <- dsLExpr to return $ mkApps expr' [from', thn', to'] {- Desugar 'do' and 'mdo' expressions (NOT list comprehensions, they're handled in DsListComp). Basically does the translation given in the Haskell 98 report: -} dsDo :: [ExprLStmt Id] -> DsM CoreExpr dsDo stmts = goL stmts where goL [] = panic "dsDo" goL (L loc stmt:lstmts) = putSrcSpanDs loc (go loc stmt lstmts) go _ (LastStmt body _) stmts = ASSERT( null stmts ) dsLExpr body -- The 'return' op isn't used for 'do' expressions go _ (BodyStmt rhs then_expr _ _) stmts = do { rhs2 <- dsLExpr rhs ; warnDiscardedDoBindings rhs (exprType rhs2) ; then_expr2 <- dsExpr then_expr ; rest <- goL stmts ; return (mkApps then_expr2 [rhs2, rest]) } go _ (LetStmt binds) stmts = do { rest <- goL stmts ; dsLocalBinds binds rest } go _ (BindStmt pat rhs bind_op fail_op) stmts = do { body <- goL stmts ; rhs' <- dsLExpr rhs ; bind_op' <- dsExpr bind_op ; var <- selectSimpleMatchVarL pat ; let bind_ty = exprType bind_op' -- rhs -> (pat -> res1) -> res2 res1_ty = funResultTy (funArgTy (funResultTy bind_ty)) ; match <- matchSinglePat (Var var) (StmtCtxt DoExpr) pat res1_ty (cantFailMatchResult body) ; match_code <- handle_failure pat match fail_op ; return (mkApps bind_op' [rhs', Lam var match_code]) } go loc (RecStmt { recS_stmts = rec_stmts, recS_later_ids = later_ids , recS_rec_ids = rec_ids, recS_ret_fn = return_op , recS_mfix_fn = mfix_op, recS_bind_fn = bind_op , recS_rec_rets = rec_rets, recS_ret_ty = body_ty }) stmts = goL (new_bind_stmt : stmts) -- rec_ids can be empty; eg rec { print 'x' } where new_bind_stmt = L loc $ BindStmt (mkBigLHsPatTup later_pats) mfix_app bind_op noSyntaxExpr -- Tuple cannot fail tup_ids = rec_ids ++ filterOut (`elem` rec_ids) later_ids tup_ty = mkBigCoreTupTy (map idType tup_ids) -- Deals with singleton case rec_tup_pats = map nlVarPat tup_ids later_pats = rec_tup_pats rets = map noLoc rec_rets mfix_app = nlHsApp (noLoc mfix_op) mfix_arg mfix_arg = noLoc $ HsLam (MG { mg_alts = [mkSimpleMatch [mfix_pat] body] , mg_arg_tys = [tup_ty], mg_res_ty = body_ty , mg_origin = Generated }) mfix_pat = noLoc $ LazyPat $ mkBigLHsPatTup rec_tup_pats body = noLoc $ HsDo DoExpr (rec_stmts ++ [ret_stmt]) body_ty ret_app = nlHsApp (noLoc return_op) (mkBigLHsTup rets) ret_stmt = noLoc $ mkLastStmt ret_app -- This LastStmt will be desugared with dsDo, -- which ignores the return_op in the LastStmt, -- so we must apply the return_op explicitly go _ (ParStmt {}) _ = panic "dsDo ParStmt" go _ (TransStmt {}) _ = panic "dsDo TransStmt" handle_failure :: LPat Id -> MatchResult -> SyntaxExpr Id -> DsM CoreExpr -- In a do expression, pattern-match failure just calls -- the monadic 'fail' rather than throwing an exception handle_failure pat match fail_op | matchCanFail match = do { fail_op' <- dsExpr fail_op ; dflags <- getDynFlags ; fail_msg <- mkStringExpr (mk_fail_msg dflags pat) ; extractMatchResult match (App fail_op' fail_msg) } | otherwise = extractMatchResult match (error "It can't fail") mk_fail_msg :: DynFlags -> Located e -> String mk_fail_msg dflags pat = "Pattern match failure in do expression at " ++ showPpr dflags (getLoc pat) {- ************************************************************************ * * \subsection{Errors and contexts} * * ************************************************************************ -} -- Warn about certain types of values discarded in monadic bindings (#3263) warnDiscardedDoBindings :: LHsExpr Id -> Type -> DsM () warnDiscardedDoBindings rhs rhs_ty | Just (m_ty, elt_ty) <- tcSplitAppTy_maybe rhs_ty = do { warn_unused <- woptM Opt_WarnUnusedDoBind ; warn_wrong <- woptM Opt_WarnWrongDoBind ; when (warn_unused || warn_wrong) $ do { fam_inst_envs <- dsGetFamInstEnvs ; let norm_elt_ty = topNormaliseType fam_inst_envs elt_ty -- Warn about discarding non-() things in 'monadic' binding ; if warn_unused && not (isUnitTy norm_elt_ty) then warnDs (badMonadBind rhs elt_ty (ptext (sLit "-fno-warn-unused-do-bind"))) else -- Warn about discarding m a things in 'monadic' binding of the same type, -- but only if we didn't already warn due to Opt_WarnUnusedDoBind when warn_wrong $ do { case tcSplitAppTy_maybe norm_elt_ty of Just (elt_m_ty, _) | m_ty `eqType` topNormaliseType fam_inst_envs elt_m_ty -> warnDs (badMonadBind rhs elt_ty (ptext (sLit "-fno-warn-wrong-do-bind"))) _ -> return () } } } | otherwise -- RHS does have type of form (m ty), which is weird = return () -- but at lesat this warning is irrelevant badMonadBind :: LHsExpr Id -> Type -> SDoc -> SDoc badMonadBind rhs elt_ty flag_doc = vcat [ hang (ptext (sLit "A do-notation statement discarded a result of type")) 2 (quotes (ppr elt_ty)) , hang (ptext (sLit "Suppress this warning by saying")) 2 (quotes $ ptext (sLit "_ <-") <+> ppr rhs) , ptext (sLit "or by using the flag") <+> flag_doc ] {- ************************************************************************ * * \subsection{Static pointers} * * ************************************************************************ -} -- | Creates an name for an entry in the Static Pointer Table. -- -- The name has the form @sptEntry:<N>@ where @<N>@ is generated from a -- per-module counter. -- mkSptEntryName :: SrcSpan -> DsM Name mkSptEntryName loc = do uniq <- newUnique mod <- getModule occ <- mkWrapperName "sptEntry" return $ mkExternalName uniq mod occ loc where mkWrapperName what = do dflags <- getDynFlags thisMod <- getModule let -- Note [Generating fresh names for ccall wrapper] -- in compiler/typecheck/TcEnv.hs wrapperRef = nextWrapperNum dflags wrapperNum <- liftIO $ atomicModifyIORef' wrapperRef $ \mod_env -> let num = lookupWithDefaultModuleEnv mod_env 0 thisMod in (extendModuleEnv mod_env thisMod (num+1), num) return $ mkVarOcc $ what ++ ":" ++ show wrapperNum
gcampax/ghc
compiler/deSugar/DsExpr.hs
bsd-3-clause
38,169
48
25
11,444
7,900
4,030
3,870
-1
-1
{-# LANGUAGE PatternGuards #-} ----------------------------------------------------------------------------- -- | -- Module : Text.CSL.Pickle -- Copyright : (c) Uwe Schmidt Andrea Rossato -- License : BSD-style (see LICENSE) -- -- Maintainer : Andrea Rossato <andrea.rossato@unitn.it> -- Stability : unstable -- Portability : portable -- -- This module is mostly copied from Text.XML.HXT.Arrow.Pickle.Xml -- which is an adaptation of the pickler combinators developed by -- Andrew Kennedy. -- -- See: <http://research.microsoft.com/~akenn/fun/picklercombinators.pdf> ----------------------------------------------------------------------------- module Text.CSL.Pickle where import Control.Monad ( unless ) import Data.List ( elemIndex ) import Data.Maybe import System.Directory ( doesFileExist ) import qualified Data.ByteString as B import Data.ByteString.UTF8 ( toString ) import Control.Monad ( liftM ) import Text.XML.Light data St = St { attributes :: [Attr] , contents :: [Content] } data PU a = PU { appPickle :: (a, St) -> St , appUnPickle :: St -> (Maybe a, St) } pickleXML :: PU a -> a -> String pickleXML p v = concatMap showContent $ contents st where st = appPickle p (v, emptySt) unpickleXML :: PU a -> [Content] -> Maybe a unpickleXML p t = fst . appUnPickle p $ St { attributes = [] , contents = t } emptySt :: St emptySt = St { attributes = [] , contents = [] } addAtt :: Attr -> St -> St addAtt x s = s {attributes = x : attributes s} addCont :: Content -> St -> St addCont x s = s {contents = x : contents s} dropCont :: St -> St dropCont s = s { contents = drop 1 (contents s) } getAtt :: String -> St -> Maybe Attr getAtt name = listToMaybe . filter ((==) name . qName . attrKey) . attributes getCont :: St -> Maybe Content getCont = listToMaybe . contents class XmlPickler a where xpickle :: PU a instance XmlPickler Int where xpickle = xpPrim instance XmlPickler Integer where xpickle = xpPrim instance XmlPickler () where xpickle = xpUnit instance XmlPickler a => XmlPickler [a] where xpickle = xpList xpickle instance XmlPickler a => XmlPickler (Maybe a) where xpickle = xpOption xpickle xpPrim :: (Read a, Show a) => PU a xpPrim = xpWrapMaybe (readMaybe, show) xpText where readMaybe :: Read a => String -> Maybe a readMaybe str = val (reads str) where val [(x,"")] = Just x val _ = Nothing xpUnit :: PU () xpUnit = xpLift () xpZero :: PU a xpZero = PU { appPickle = snd , appUnPickle = \ s -> (Nothing, s) } xpLift :: a -> PU a xpLift x = PU { appPickle = snd , appUnPickle = \ s -> (Just x, s) } xpCondSeq :: PU b -> (b -> a) -> PU a -> (a -> PU b) -> PU b xpCondSeq pd f pa k = PU { appPickle = ( \ (b, s) -> let a = f b pb = k a in appPickle pa (a, (appPickle pb (b, s))) ) , appUnPickle = ( \ s -> let (a, s') = appUnPickle pa s in case a of Nothing -> appUnPickle pd s Just a' -> appUnPickle (k a') s' ) } xpSeq :: (b -> a) -> PU a -> (a -> PU b) -> PU b xpSeq = xpCondSeq xpZero xpChoice :: PU b -> PU a -> (a -> PU b) -> PU b xpChoice pb = xpCondSeq pb undefined xpWrap :: (a -> b, b -> a) -> PU a -> PU b xpWrap (f, g) pa = xpSeq g pa (xpLift . f) xpDefault :: (Eq a) => a -> PU a -> PU a xpDefault df = xpWrap ( fromMaybe df , \ x -> if x == df then Nothing else Just x ) . xpOption xpOption :: PU a -> PU (Maybe a) xpOption pa = PU { appPickle = ( \ (a, st) -> case a of Nothing -> st Just x -> appPickle pa (x, st) ) , appUnPickle = appUnPickle $ xpChoice (xpLift Nothing) pa (xpLift . Just) } xpAlt :: (a -> Int) -> [PU a] -> PU a xpAlt tag ps = PU { appPickle = ( \ (a, st) -> let pa = ps !! (tag a) in appPickle pa (a, st) ) , appUnPickle = appUnPickle $ ( case ps of [] -> xpZero pa:ps1 -> xpChoice (xpAlt tag ps1) pa xpLift ) } xpList :: PU a -> PU [a] xpList pa = PU { appPickle = ( \ (a, st) -> case a of [] -> st _:_ -> appPickle pc (a, st) ) , appUnPickle = appUnPickle $ xpChoice (xpLift []) pa (\ x -> xpSeq id (xpList pa) (\xs -> xpLift (x:xs))) } where pc = xpSeq head pa (\ x -> xpSeq tail (xpList pa) (\ xs -> xpLift (x:xs))) xpLiftMaybe :: Maybe a -> PU a xpLiftMaybe = maybe xpZero xpLift xpWrapMaybe :: (a -> Maybe b, b -> a) -> PU a -> PU b xpWrapMaybe (i, j) pa = xpSeq j pa (xpLiftMaybe . i) xpPair :: PU a -> PU b -> PU (a, b) xpPair pa pb = ( xpSeq fst pa (\ a -> xpSeq snd pb (\ b -> xpLift (a,b))) ) xpTriple :: PU a -> PU b -> PU c -> PU (a, b, c) xpTriple pa pb pc = xpWrap (toTriple, fromTriple) (xpPair pa (xpPair pb pc)) where toTriple ~(a, ~(b, c)) = (a, b, c ) fromTriple ~(a, b, c ) = (a, (b, c)) xp4Tuple :: PU a -> PU b -> PU c -> PU d -> PU (a, b, c, d) xp4Tuple pa pb pc pd = xpWrap (toQuad, fromQuad) (xpPair pa (xpPair pb (xpPair pc pd))) where toQuad ~(a, ~(b, ~(c, d))) = (a, b, c, d ) fromQuad ~(a, b, c, d ) = (a, (b, (c, d))) xp5Tuple :: PU a -> PU b -> PU c -> PU d -> PU e -> PU (a, b, c, d, e) xp5Tuple pa pb pc pd pe = xpWrap (toQuint, fromQuint) (xpPair pa (xpPair pb (xpPair pc (xpPair pd pe)))) where toQuint ~(a, ~(b, ~(c, ~(d, e)))) = (a, b, c, d, e ) fromQuint ~(a, b, c, d, e ) = (a, (b, (c, (d, e)))) xp6Tuple :: PU a -> PU b -> PU c -> PU d -> PU e -> PU f -> PU (a, b, c, d, e, f) xp6Tuple pa pb pc pd pe pf = xpWrap (toSix, fromSix) (xpPair pa (xpPair pb (xpPair pc (xpPair pd (xpPair pe pf))))) where toSix ~(a, ~(b, ~(c, ~(d, ~(e, f))))) = (a, b, c, d, e, f ) fromSix ~(a, b, c, d, e, f ) = (a, (b, (c, (d, (e, f))))) -------------------------------------------------------------------------------- getText :: Content -> Maybe String getText c | Text cd <- c = Just (showCData cd) | otherwise = Nothing getChildren :: Content -> [Content] getChildren c | Elem el <- c = elContent el | otherwise = [] getElemName :: Content -> Maybe QName getElemName c | Elem el <- c = Just (elName el) | otherwise = Nothing getAttrl :: Content -> [Attr] getAttrl c | Elem el <- c = elAttribs el | otherwise = [] mkText :: String -> Content mkText str = Text $ blank_cdata { cdData = str} mkName :: String -> QName mkName n = blank_name {qName = n} qualifiedName :: QName -> String qualifiedName qn = (fromMaybe [] $ qPrefix qn) ++ qName qn xpText :: PU String xpText = PU { appPickle = \ (s, st) -> addCont (mkText s) st , appUnPickle = \ st -> fromMaybe (Nothing, st) (unpickleString st) } where unpickleString st = do t <- getCont st s <- getText t return (Just s, dropCont st) xpText0 :: PU String xpText0 = xpWrap (fromMaybe "", emptyToNothing) $ xpOption $ xpText where emptyToNothing "" = Nothing emptyToNothing x = Just x xpElem :: String -> PU a -> PU a xpElem name pa = PU { appPickle = ( \ (a, st) -> let st' = appPickle pa (a, emptySt) in addCont (Elem $ Element (mkName name) (attributes st') (contents st') Nothing) st ) , appUnPickle = \ st -> fromMaybe (Nothing, st) (unpickleElement st) } where unpickleElement st = do e <- listToMaybe . map Elem . onlyElems . contents $ st n <- getElemName e if qualifiedName n /= name then fail "element name does not match" else do al <- Just $ getAttrl e res <- fst . appUnPickle pa $ St {attributes = al, contents = getChildren e} return (Just res, st {contents = filter ((/=) (show e) . show) $ contents st}) -- | A pickler for interleaved elements. xpIElem :: String -> PU a -> PU a xpIElem name pa = PU { appPickle = ( \ (a, st) -> let st' = appPickle pa (a, emptySt) in addCont (Elem $ Element (mkName name) (attributes st') (contents st') Nothing) st ) , appUnPickle = \ st -> fromMaybe (Nothing, st) (unpickleElement st) } where unpickleElement st = do let t = map Elem . onlyElems . contents $ st ns <- mapM getElemName t case elemIndex name (map qualifiedName ns) of Nothing -> fail "element name does not match" Just i -> do let cs = getChildren (t !! i) al <- Just $ getAttrl (t !! i) res <- fst . appUnPickle pa $ St {attributes = al, contents = cs} return (Just res, st {contents = take i t ++ drop (i + 1) t}) xpAttr :: String -> PU a -> PU a xpAttr name pa = PU { appPickle = ( \ (a, st) -> let st' = appPickle pa (a, emptySt) in addAtt (Attr (mkName name) (getAtVal $ contents st')) st ) , appUnPickle = \ st -> fromMaybe (Nothing, st) (unpickleAttr st) } where getAtVal at | Text cd : _ <- at = cdData cd | otherwise = [] unpickleAttr st = do a <- getAtt name st res <- fst . appUnPickle pa $ St { attributes = [] , contents = [Text blank_cdata {cdData = attrVal a}]} return (Just res, st) xpElemWithAttrValue :: String -> String -> String -> PU a -> PU a xpElemWithAttrValue n a v = xpElem n . xpAddFixedAttr a v xpAttrFixed :: String -> String -> PU () xpAttrFixed name val = ( xpWrapMaybe ( \ v -> if v == val then Just () else Nothing , const val ) $ xpAttr name xpText ) xpAddFixedAttr :: String -> String -> PU a -> PU a xpAddFixedAttr name val pa = xpWrap ( snd , (,) () ) $ xpPair (xpAttrFixed name val) pa uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d uncurry3 f (a,b,c) = f a b c uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e uncurry4 f (a,b,c,d) = f a b c d uncurry5 :: (a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f uncurry5 f (a,b,c,d,e) = f a b c d e readXmlString :: Show a => PU a -> String -> a readXmlString xp str = case parseXML str of [] -> error $ "error while reading the style" x -> case unpickleXML xp x of Just a -> a _ -> case getStyleVersion x of (_:_) -> error "error while parsing the style" _ -> error styleErr08 readXmlFile :: Show a => PU a -> String -> IO a readXmlFile xp f = do flip unless (error $ f ++ " file does not exist") =<< doesFileExist f readXmlString xp `fmap` liftM toString (B.readFile f) getStyleVersion :: [Content] -> String getStyleVersion c = case filterElems c of [x] -> case lookupAttr styleVersion (elAttribs x) of Just s -> s _ -> [] _ -> error "malformed style: no cs:style element found" where filterElems = catMaybes . map (filterElementName isStyle) . onlyElems styleVersion = mkName "version" isStyle (QName qn _ _) = qn == "style" styleErr08 :: String styleErr08 = "the parsed style seems to be CSL-0.8 while citeproc-hs only supports CSL 1.0.\n" ++ "Styles may be updated by using the csl-utils. For more information see:\n" ++ "http://citationstyles.org/downloads/upgrade-notes.html#updating-csl-0-8-styles"
singingwolfboy/citeproc-hs
src/Text/CSL/Pickle.hs
bsd-3-clause
11,718
135
22
3,719
4,927
2,575
2,352
286
4
{-# LANGUAGE DeriveDataTypeable #-} module Data.Minc.Types where import Control.Exception import Data.Typeable import System.IO (IOMode (..)) data MincType = Minc_Byte -- ^ 8-bit signed integer | Minc_Short -- ^ 16-bit signed integer | Minc_Int -- ^ 32-bit signed integer | Minc_Float -- ^ 32-bit floating point | Minc_Double -- ^ 64-bit floating point | Minc_String -- ^ ASCII string | Minc_UByte -- ^ 8-bit unsigned integer | Minc_UShort -- ^ 16-bit unsigned integer | Minc_UInt -- ^ 32-bit unsigned integer | Minc_SComplex -- ^ 16-bit signed integer complex | Minc_IComplex -- ^ 32-bit signed integer complex | Minc_FComplex -- ^ 32-bit floating point complex | Minc_DComplex -- ^ 64-bit floating point complex | Minc_Unknown -- ^ when the type is a record deriving (Eq, Show) -- | Type of an individual voxel as stored by MINC 2.0 (known as 'mitype_t'). data MincMiType = Minc_Mi_Type_Original -- ^ MI_ORIGINAL_TYPE | Minc_Mi_Type_Byte -- ^ 8-bit signed integer | Minc_Mi_Type_Short -- ^ 16-bit signed integer | Minc_Mi_Type_Int -- ^ 32-bit signed integer | Minc_Mi_Type_Float -- ^ 32-bit floating point | Minc_Mi_Type_Double -- ^ 64-bit floating point | Minc_Mi_Type_String -- ^ ASCII string | Minc_Mi_Type_UByte -- ^ 8-bit unsigned integer | Minc_Mi_Type_UShort -- ^ 16-bit unsigned integer | Minc_Mi_Type_UInt -- ^ 32-bit unsigned integer | Minc_Mi_Type_SComplex -- ^ 16-bit signed integer complex | Minc_Mi_Type_IComplex -- ^ 32-bit signed integer complex | Minc_Mi_Type_FComplex -- ^ 32-bit floating point complex | Minc_Mi_Type_DComplex -- ^ 64-bit floating point complex | Minc_Mi_Type_Unknown -- ^ when the type is a record deriving (Eq, Show) instance Enum MincMiType where fromEnum Minc_Mi_Type_Original = 0 fromEnum Minc_Mi_Type_Byte = 1 fromEnum Minc_Mi_Type_Short = 3 fromEnum Minc_Mi_Type_Int = 4 fromEnum Minc_Mi_Type_Float = 5 fromEnum Minc_Mi_Type_Double = 6 fromEnum Minc_Mi_Type_String = 7 fromEnum Minc_Mi_Type_UByte = 100 fromEnum Minc_Mi_Type_UShort = 101 fromEnum Minc_Mi_Type_UInt = 102 fromEnum Minc_Mi_Type_SComplex = 1000 fromEnum Minc_Mi_Type_IComplex = 1001 fromEnum Minc_Mi_Type_FComplex = 1002 fromEnum Minc_Mi_Type_DComplex = 1003 fromEnum Minc_Mi_Type_Unknown = -1 toEnum n = case n of 0 -> Minc_Mi_Type_Original 1 -> Minc_Mi_Type_Byte 3 -> Minc_Mi_Type_Short 4 -> Minc_Mi_Type_Int 5 -> Minc_Mi_Type_Float 6 -> Minc_Mi_Type_Double 7 -> Minc_Mi_Type_String 100 -> Minc_Mi_Type_UByte 101 -> Minc_Mi_Type_UShort 102 -> Minc_Mi_Type_UInt 1000 -> Minc_Mi_Type_SComplex 1001 -> Minc_Mi_Type_IComplex 1002 -> Minc_Mi_Type_FComplex 1003 -> Minc_Mi_Type_DComplex -1 -> Minc_Mi_Type_Unknown _ -> throw (MincInvalidMiType n) -- | Class of a MINC file ('miclass_t'). -- | Specifies the data's interpretation rather than its storage format. data MincMiClass = Mi_Class_Real -- ^ Floating point (default). | Mi_Class_Int -- ^ Integer. | Mi_Class_Label -- ^ Enumerated (named data values). | Mi_Class_Complex -- ^ Complex (real/imaginary) values. | Mi_Class_Uniform_Record -- ^ Aggregate datatypes consisting of multiple values of the same underlying type.. | Mi_Class_Non_Uniform_Record -- ^ Aggregate datatypes consisting of multiple values of potentially differing types (not yet implemented). deriving (Eq, Show) instance Enum MincMiClass where fromEnum Mi_Class_Real = 0 fromEnum Mi_Class_Int = 1 fromEnum Mi_Class_Label = 2 fromEnum Mi_Class_Complex = 3 fromEnum Mi_Class_Uniform_Record = 4 fromEnum Mi_Class_Non_Uniform_Record = 5 toEnum n = case n of 0 -> Mi_Class_Real 1 -> Mi_Class_Int 2 -> Mi_Class_Label 3 -> Mi_Class_Complex 4 -> Mi_Class_Uniform_Record 5 -> Mi_Class_Non_Uniform_Record _ -> throw (MincInvalidMiClass n) -- | Dimension attribute values. data MincDimAttribute = Minc_Dim_Attr_All -- ^ MI_DIMATTR_ALL 0 | Minc_Dim_Attr_Regularly_Sampled -- ^ MI_DIMATTR_REGULARLY_SAMPLED 0x1 | Minc_Dim_Attr_Not_Regularly_Sampled -- ^ MI_DIMATTR_NOT_REGULARLY_SAMPLED 0x2 instance Enum MincDimAttribute where fromEnum Minc_Dim_Attr_All = 0 fromEnum Minc_Dim_Attr_Regularly_Sampled = 1 fromEnum Minc_Dim_Attr_Not_Regularly_Sampled = 2 toEnum n = case n of 0 -> Minc_Dim_Attr_All 1 -> Minc_Dim_Attr_Regularly_Sampled 2 -> Minc_Dim_Attr_Not_Regularly_Sampled _ -> throw (MincInvalidDimAttribute n) data MincDimClass = Minc_Dim_Class_Any -- ^ Don't care (or unknown). | Minc_Dim_Class_Spatial -- ^ Spatial dimensions (x, y, z). | Minc_Dim_Class_Time -- ^ Time dimension. | Minc_Dim_Class_SFrequency -- ^ Spatial frequency dimensions. | Minc_Dim_Class_TFrequency -- ^ Temporal frequency dimensions. | Minc_Dim_Class_User -- ^ Arbitrary user-defined dimension. | Minc_Dim_Class_Record -- ^ Record as dimension. instance Enum MincDimClass where fromEnum Minc_Dim_Class_Any = 0 fromEnum Minc_Dim_Class_Spatial = 1 fromEnum Minc_Dim_Class_Time = 2 fromEnum Minc_Dim_Class_SFrequency = 3 fromEnum Minc_Dim_Class_TFrequency = 4 fromEnum Minc_Dim_Class_User = 5 fromEnum Minc_Dim_Class_Record = 6 toEnum n = case n of 0 -> Minc_Dim_Class_Any 1 -> Minc_Dim_Class_Spatial 2 -> Minc_Dim_Class_Time 3 -> Minc_Dim_Class_SFrequency 4 -> Minc_Dim_Class_TFrequency 5 -> Minc_Dim_Class_User 6 -> Minc_Dim_Class_Record _ -> throw (MincInvalidDimClass n) instance Enum MincType where fromEnum Minc_Byte = 1 fromEnum Minc_Short = 3 fromEnum Minc_Int = 4 fromEnum Minc_Float = 5 fromEnum Minc_Double = 6 fromEnum Minc_String = 7 fromEnum Minc_UByte = 100 fromEnum Minc_UShort = 101 fromEnum Minc_UInt = 102 fromEnum Minc_SComplex = 1000 fromEnum Minc_IComplex = 1001 fromEnum Minc_FComplex = 1002 fromEnum Minc_DComplex = 1003 fromEnum Minc_Unknown = (-1) toEnum n = case n of 1 -> Minc_Byte 3 -> Minc_Short 4 -> Minc_Int 5 -> Minc_Float 6 -> Minc_Double 7 -> Minc_String 100 -> Minc_UByte 101 -> Minc_UShort 102 -> Minc_UInt 1000 -> Minc_SComplex 1001 -> Minc_IComplex 1002 -> Minc_FComplex 1003 -> Minc_DComplex (-1) -> Minc_Unknown _ -> throw (MincInvalidType n) -- | Minc error types. data MincError = MincError String Int String FilePath | MincInvalidArgs String | MincInvalidType Int | MincInvalidDimClass Int | MincInvalidDimAttribute Int | MincInvalidDimOrder Int | MincInvalidVoxelOrder Int | MincInvalidMiType Int | MincInvalidMiClass Int deriving (Show, Typeable) instance Exception MincError mincIOMode :: IOMode -> Int mincIOMode ReadMode = 1 -- #define MI2_OPEN_READ 0x0001 mincIOMode WriteMode = 2 -- #define MI2_OPEN_RDWR 0x0002 mincIOMode _ = throw (MincInvalidArgs "IO mode") -- | Minc dimension order. data MincDimOrder = Minc_Dim_Order_File -- ^ File order. | Minc_Dim_Order_Apparent -- ^ Apparent order. deriving (Show, Typeable) instance Enum MincDimOrder where fromEnum Minc_Dim_Order_File = 0 fromEnum Minc_Dim_Order_Apparent = 1 toEnum n = case n of 0 -> Minc_Dim_Order_File 1 -> Minc_Dim_Order_Apparent _ -> throw (MincInvalidDimOrder n) -- | Minc voxel order. data MincVoxelOrder = Minc_Voxel_Order_File -- ^ File order. | Minc_Voxel_Order_Apparent -- ^ Apparent order. deriving (Show, Typeable) instance Enum MincVoxelOrder where fromEnum Minc_Voxel_Order_File = 0 fromEnum Minc_Voxel_Order_Apparent = 1 toEnum n = case n of 0 -> Minc_Voxel_Order_File 1 -> Minc_Voxel_Order_Apparent _ -> throw (MincInvalidVoxelOrder n)
carlohamalainen/hminc
Data/Minc/Types.hs
bsd-3-clause
9,561
0
11
3,382
1,380
753
627
193
1
-- Copyright (c) 2016-present, Facebook, Inc. -- All rights reserved. -- -- This source code is licensed under the BSD-style license found in the -- LICENSE file in the root directory of this source tree. {-# LANGUAGE OverloadedStrings #-} module Duckling.Duration.HU.Corpus ( corpus ) where import Data.String import Prelude import Duckling.Duration.Types import Duckling.Locale import Duckling.Resolve import Duckling.Testing.Types import Duckling.TimeGrain.Types (Grain(..)) corpus :: Corpus corpus = (testContext {locale = makeLocale HU Nothing}, testOptions, allExamples) allExamples :: [Example] allExamples = concat [ examples (DurationData 1 Second) [ "egy másodperc" , "1 másodperc" ] , examples (DurationData 2 Minute) [ "2 perc" , "kettő perc" ] , examples (DurationData 15 Minute) [ "negyed óra" , "negyedóra" , "negyed-óra" ] , examples (DurationData 30 Minute) [ "fél óra" , "félóra" , "fél-óra" ] , examples (DurationData 45 Minute) [ "háromnegyed óra" , "háromnegyed-óra" , "háromnegyedóra" , "3/4 óra" , "3/4óra" ] , examples (DurationData 150 Minute) [ "2.5 óra" , "kettő és fél óra" , "kettő és fél-óra" , "kettő és félóra" ] , examples (DurationData 30 Day) [ "30 nap" ] , examples (DurationData 7 Week) [ "hét hét" ] , examples (DurationData 1 Month) [ "egy hónap" ] , examples (DurationData 3 Quarter) [ "3 negyedév" ] , examples (DurationData 2 Year) [ "2 év" ] ]
facebookincubator/duckling
Duckling/Duration/HU/Corpus.hs
bsd-3-clause
1,913
0
9
703
360
208
152
49
1
module Tut.Imports (module X) where import Control.Arrow as X import Data.Map as X ( Map ) import Data.Text as X ( Text ) import Control.Monad.Except as X import Control.Monad.Reader as X import Control.Monad.Writer as X import Control.Monad.State as X import Control.Applicative as X import Control.Monad.Base as X import Control.Monad.Morph as X import Control.Lens as X
aaronvargo/htut
src/Tut/Imports.hs
bsd-3-clause
550
0
5
232
105
75
30
12
0
{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ViewPatterns #-} -- | A module for actually drawing mazes built from grids. It uses -- Cairo, which is a canvas-like drawing library based on GtK. module Draw where import Control.Applicative ((<$>), (<*>)) import Control.Monad (forM_) import Data.Function (on) import qualified Data.List as List import Data.Ord (comparing) import qualified Data.Graph.Inductive as Graph import Data.Graph.Inductive (DynGraph, Graph, match, (&)) import qualified Graphics.Rendering.Cairo as Cairo import Graphics.Rendering.Cairo (Render) import Maze -- | Settings that control what the resulting picture looks -- like. Sizes are in pixels. data Config = Config { step :: Int -- ^ the size of each cell , wall :: Int -- ^ how wide the wall lines are , width :: Int -- ^ how wide the canvas is , height :: Int -- ^ how high the canvas is } -- | Settings that look okay, producing reasonably sized images for -- 40 × 40 mazes. defaults :: Config defaults = Config { step = 10 , wall = 2 , width = 404 , height = 404 } -- | This draws a rectangle, coercing ints into doubles. rectangle :: (Integral n) => n -> n -> n -> n -> Render () rectangle x y width height = Cairo.rectangle (fromIntegral x) (fromIntegral y) (fromIntegral width) (fromIntegral height) -- | Renders a maze, which is specified as a list of walls. The order -- in the list shouldn't matter. renderMaze :: Config -> [Wall] -> Render () renderMaze Config {..} walls = do Cairo.setSourceRGB 0.02 0.24 0.54 Cairo.setLineWidth 5 rectangle 0 0 width height Cairo.stroke forM_ walls $ \ (Wall (x, y) dir) -> case dir of Horizontal -> rectangle (x * step) (y * step) (step + wall) wall >> Cairo.fill Vertical -> rectangle (x * step) (y * step) wall (step + wall) >> Cairo.fill -- | Export a maze, given as a list of walls, to PNG. mazePng :: Config -> FilePath -> [Wall] -> IO () mazePng config@Config {..} file walls = Cairo.withImageSurface Cairo.FormatARGB32 width height $ \ surface -> do Cairo.renderWith surface $ renderMaze config walls Cairo.surfaceWriteToPNG surface file -- | Generate a maze image with a maze of the given dimensions. genPng :: Config -> FilePath -> Int -> Int -> IO () genPng config file width height = do maze <- maze width height mazePng config file maze
proc0/inductive-mazes
src/Draw.hs
bsd-3-clause
2,701
0
15
770
631
351
280
45
2
module MaybeResult ( MaybeRes(..) , getResult , getError , isError , isOK ) where data MaybeRes a = JustRes a | Error String getResult :: MaybeRes a -> a getResult (JustRes x) = x getResult e = error ("Remember about using 'isError'. The error was: " ++ (getError e)) isError :: MaybeRes a -> Bool isError (Error _) = True isError (JustRes _) = False isOK :: MaybeRes a -> Bool isOK = not . isError getError :: MaybeRes a -> String getError (Error s) = s getError _ = error "It is not an error" instance Functor MaybeRes where fmap _ (Error s) = Error s fmap f (JustRes x) = JustRes (f x) instance Applicative MaybeRes where pure = JustRes (Error s) <*> _ = Error s (JustRes f) <*> sth = fmap f sth instance Monad MaybeRes where return = JustRes Error s >>= _ = Error s d >>= f = getResult . fmap f $ d x >> y = x >>= \_ -> y fail = error
kanes115/Regressions
src/MaybeResult.hs
bsd-3-clause
985
0
9
319
372
188
184
32
1
{-# OPTIONS -Wall -fwarn-tabs -fno-warn-type-defaults #-} {-# LANGUAGE TemplateHaskell, DeriveDataTypeable, DeriveGeneric #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-} import Control.Distributed.Process.Backend.SimpleLocalnet import Control.Distributed.Process.Node as Node hiding (newLocalNode) import System.Environment -- getArgs import Worker -- Main main :: IO() main = do [port, d_port, ring_size, ring_id] <- getArgs backend <- initializeBackend "localhost" port (Worker.rcdata initRemoteTable) node <- newLocalNode backend Node.runProcess node (Worker.master backend d_port ring_size ring_id)
weihu816/Adagio
app/Node.hs
bsd-3-clause
646
0
11
85
128
72
56
14
1
-- | Paragon Parser. Symbols and separators. module Language.Java.Paragon.Parser.Symbols where import Text.ParserCombinators.Parsec import Language.Java.Paragon.Lexer import Language.Java.Paragon.Parser.Helpers parens :: P a -> P a parens = between openParen closeParen openParen :: P () openParen = tok OpenParen <?> show OpenParen closeParen :: P () closeParen = tok CloseParen <?> show CloseParen braces :: P a -> P a braces = between openCurly closeCurly openCurly :: P () openCurly = tok OpenCurly <?> show OpenCurly closeCurly :: P () closeCurly = tok CloseCurly <?> show CloseCurly semiColon :: P () semiColon = tok SemiColon <?> show SemiColon comma :: P () comma = tok Comma <?> show Comma dot :: P () dot = tok Dot <?> show Dot colon :: P () colon = tok Colon <?> show Colon ellipsis :: P () ellipsis = tok Ellipsis <?> show Ellipsis
bvdelft/paragon
src/Language/Java/Paragon/Parser/Symbols.hs
bsd-3-clause
858
0
6
153
306
155
151
26
1
module BivarInterpolNewton where import qualified Data.Matrix as Mx import qualified Data.Vector as Vec import Library -- z = f(x, y) -- h₁ = 𝚫x = const, h₂ = 𝚫y = const -- 𝚫ₓzᵢⱼ = z_(i+1, j) - zᵢⱼ -- 𝚫ᵧzᵢⱼ = z_(i, j+1) - zᵢⱼ -- 𝚫²ₓₓzᵢⱼ = z_(i+2, j) - 2z_(i+1, j) + zᵢⱼ -- 𝚫²ᵧᵧzᵢⱼ = z_(i, j+2) - 2z_(i, j+1) + zᵢⱼ -- 𝚫²ₓᵧzᵢⱼ = [z_(i+1, j+1) - z_(i, j + 1)] - [z_(i+1, j) - zᵢⱼ] -- F(x,y) = z₀₀ -- + (x - x₀)/h₁ * 𝚫ₓz₀₀ -- + (y - y₀)/h₂ * 𝚫ᵧz₀₀ -- + [(x - x₀)(x - x₁)]/(2h²₁) * 𝚫²ₓₓz₀₀ -- + [(x - x₀)(y - y₀)]/(h₁h₂) * 𝚫²ₓᵧz₀₀ -- + [(y - y₀)(y - y₁)]/(2h²₂) * 𝚫²ᵧᵧz₀₀ compute :: Matrix -> Matrix compute m = Mx.fromLists $ ( \mx -> (:mx) $ Vec.foldl (++) [0] $ Vec.imap (\i x -> genArgs x $ xs Vec.! (i+2)) (Vec.slice 1 (Vec.length xs - 3) xs) ) $ ( zipWith (:) $ Vec.foldl (++) [] $ Vec.imap (\i y -> genArgs y $ ys Vec.! (i+2)) (Vec.slice 1 (Vec.length ys - 3) ys) ) $ Mx.toLists $ Mx.fromBlocks 0 $ Mx.toLists $ Mx.imap interpolate zss where xs = Mx.takeRow m 0 ys = Mx.takeColumn m 0 zss = Mx.subMatrix (1, 1) (Mx.rows m - 3, Mx.cols m - 3) m genArgs x0 x1 = [x | x <- [x0, x0 + (x1 - x0)/10 .. x1], x < x1] interpolate :: (Int, Int) -> Double -> Matrix interpolate (i, j) z = Mx.matrix (length xs') [ newtonPolynom zss' xyss x y | y <- ys', x <- xs' ] where xs' = genArgs xj xjj ys' = genArgs yi yii zss' = [ [ z, m Mx.! (i+1, j+2), m Mx.! (i+1, j+3)] , [m Mx.! (i+2, j+1), m Mx.! (i+2, j+2)] , [m Mx.! (i+3, j+1)] ] xj = m Mx.! (0, j+1) yi = m Mx.! (i+1, 0) xjj = m Mx.! (0, j+2) yii = m Mx.! (i+2, 0) xyss = [ [xj, xjj] , [yi, yii] ] newtonPolynom :: [[Double]] -> [[Double]] -> Double -> Double -> Double newtonPolynom zss xyss x y = z + (x - xj) / hx * dzx + (y - yi) / hy * dzy + ((x - xj) * (x - xjj)) / (2 * hx*hx) * dzxx + ((x - xj) * (y - yi )) / ( hx*hy) * dzxy + ((y - yi) * (y - yii)) / (2 * hy*hy) * dzyy where [ [z, zj, zjj], [zi, zij], [zii] ] = zss [ [xj, xjj], [yi, yii] ] = xyss hx = xjj - xj hy = yii - yi dzx = zj - z dzy = zi - z dzxx = zjj - 2 * zj + z dzyy = zii - 2 * zi + z dzxy = (zij - zi) - (zj - z)
hrsrashid/nummet
lib/BivarInterpolNewton.hs
bsd-3-clause
2,580
0
21
864
1,101
614
487
54
1
module Lib2 where import Control.Applicative import Control.Monad.State import System.Environment import System.IO import Lib data Option = OptionIo { inPath :: String, outPath :: String } | OptionStdout { inPath :: String } | OptionT { tPath :: String, outPath :: String } | OptionTStdout { tPath :: String } deriving Show type Parser a = StateT [String] Maybe a parseFlag :: String -> Parser String parseFlag f = do args <- get case args of [] -> empty (arg : args') | arg == "-" ++ f -> do put args' return f | otherwise -> empty parseField :: String -> Parser String parseField f = do parseFlag f args <- get case args of [] -> empty (arg : args') -> do put args' return arg parseInPath :: Parser String parseInPath = parseField "i" parseOutPath :: Parser String parseOutPath = parseField "o" parseTPath :: Parser String parseTPath = parseField "t" parseOption :: Parser Option parseOption = p0 <|> p1 <|> p2 <|> p3 where p0 = do i <- parseInPath o <- parseOutPath return (OptionIo i o) p1 = do i <- parseInPath return (OptionStdout i) p2 = do i <- parseTPath o <- parseOutPath return (OptionT i o) p3 = do i <- parseTPath return (OptionTStdout i) processArgs :: (Maybe Option) -> IO() processArgs Nothing = error "Args Error!" processArgs (Just op) = processOption op processOption :: Option -> IO() processOption (OptionIo inp outp) = do inh <- openFile inp ReadMode ouh <- openFile outp WriteMode processExpr inh ouh (show.eval) hClose inh hClose ouh processOption (OptionStdout inp) = do inh <- openFile inp ReadMode processExpr inh stdout (show.eval) hClose inh processOption (OptionT tp outp) = do inh <- openFile tp ReadMode ouh <- openFile outp WriteMode processExpr inh ouh (show.evalTree) hClose inh hClose ouh processOption (OptionTStdout tp) = do inh <- openFile tp ReadMode processExpr inh stdout (show.evalTree) hClose inh processOption _ = error "Args Error!" processExpr :: Handle -> Handle -> (String -> String) -> IO() processExpr inh ouh proc = do isEof <- hIsEOF inh if isEof then return () else do lineStr <- hGetLine inh hPutStrLn ouh (proc lineStr) processExpr inh ouh proc defaultMain :: IO () defaultMain = do args <- getArgs processArgs $ evalStateT parseOption args
mengcz13/haskell_project
src/Lib2.hs
bsd-3-clause
2,660
0
14
836
896
430
466
96
2
module Lib where someFunc :: IO () someFunc = putStrLn "someFunc" problemOne :: [a] -> Maybe a problemOne [] = Nothing problemOne (x:[]) = Just x problemOne (x:xs) = problemOne xs problemTwo :: [a] -> Maybe a problemTwo [] = Nothing problemTwo [x] = Nothing problemTwo (x:y:[]) = Just x problemTwo (x:xs) = problemTwo xs problemThree :: [a] -> Int -> Maybe a problemThree [] k = Nothing problemThree (x:xs) 1 = Just x problemThree (x:xs) k = problemThree xs (pred k) problemFour :: [a] -> Int problemFour xs = go xs 0 where go [] n = n go (x:xs) n = go xs (succ n) problemFive :: [a] -> [a] problemFive [] = [] problemFive [x] = [x] problemFive (x:xs) = (problemFive xs) ++ [x] problemSix :: (Eq a) => [a] -> Bool problemSix xs = xs == problemFive xs data NestedList a = Elem a | List [NestedList a] deriving (Show) problemSeven :: NestedList a -> [a] problemSeven nl = case nl of Elem a -> [a] List [] -> [] List as -> concatMap problemSeven as problemEight :: (Eq a) => [a] -> [a] problemEight [] = [] problemEight (x:xs) = x : (problemEight (myDropWhile (==x) xs)) where myDropWhile p xs | null xs = [] | otherwise = if p (head xs) then myDropWhile p (tail xs) else xs problemNine :: (Eq a) => [a] -> [[a]] problemNine [] = [] problemNine l@(x:xs) = xRun : (problemNine rest) where xRun = takeWhile (==x) l rest = dropWhile (==x) l problemTen :: (Eq a) => [a] -> [(Int, a)] problemTen xs = fmap (\x -> (length x, head x)) (problemNine xs) -- this doesn't protect against Multiple 1 _, Multiple (-1) _, etc. -- but it's enough for our purposes data SingOrMult a = Multiple Int a | Single a deriving Show problemEleven :: (Eq a) => [a] -> [SingOrMult a] problemEleven xs = fmap toSOM (problemTen xs) where toSOM (1, x) = Single x toSOM (n, x) = Multiple n x problemTwelve :: [SingOrMult a] -> [a] problemTwelve xs = concatMap fromSOM xs where fromSOM (Multiple n x) = take n $ repeat x fromSOM (Single x) = [x]
EFulmer/haskell-ninety-nine
src/Lib.hs
bsd-3-clause
2,032
0
11
484
989
519
470
54
3
{- Little endian byte string parser -} module Network.OpenFlow.Parser.Word where import Control.Applicative import Data.Attoparsec.ByteString import Data.Bits import Data.Word -- | -- >>> parseTest anyWord16 (pack [0x01, 0x02]) -- Done "" 18 anyWord16 :: Parser Word16 anyWord16 = do f <- fmap fromIntegral anyWord8 s <- fmap fromIntegral anyWord8 return $ shiftL f 8 .|. s anyWord32 :: Parser Word32 anyWord32 = do f <- fmap fromIntegral anyWord16 s <- fmap fromIntegral anyWord16 return $ shiftL f 16 .|. s
utky/openflow
src/Network/OpenFlow/Parser/Word.hs
bsd-3-clause
565
0
9
135
139
71
68
15
1
{-# LANGUAGE OverloadedStrings #-} module SatO.Karma.Graph (karmaGraph) where import Data.Bifunctor (second) import Control.Monad.Trans.State.Strict (State, get, put, runState) import Data.Time (NominalDiffTime, UTCTime, diffUTCTime) import Numeric.GSL.ODE (odeSolve) import Numeric.LinearAlgebra.Data (linspace, toList, toLists) import SatO.Karma.Types karmaGraph :: UTCTime -> [Action] -> Graph karmaGraph _ [] = Graph 0 [(0, 0)] [(0, 0), (30, 0)] karmaGraph now as = let ps = zip as (tail as ++ [pseudoAction]) (parts, curr) = runState (traverse calcPart ps) 0 (next, _) = part curr (0, 30) in Graph curr (concat parts) next where pseudoAction :: Action pseudoAction = Action "" Coffee now calcPart :: (Action, Action) -> State Double [(Double, Double)] calcPart (a, b) = do curr <- get let a' = diffTimeToDays $ diffUTCTime (_actionStamp a) now let b' = diffTimeToDays $ diffUTCTime (_actionStamp b) now let (xs, x) = part (curr + actionValue a) (a', b') put x return $ (a', curr) : xs actionValue :: Action -> Double actionValue (Action _ Coffee _) = 0.3 actionValue _ = 1.0 diffTimeToDays :: NominalDiffTime -> Double diffTimeToDays = fromRational . (/86400) . toRational part :: Double -> (Double, Double) -> ([(Double, Double)], Double) part start interval = let ini = [start] ts = linspace 100 interval ts' = toList ts sol = concat $ toLists $ odeSolve model ini ts l = last sol in (second (max 0) <$> zip ts' sol, l) model :: Double -> [Double] -> [Double] model _ = fmap (negate . decay) decay :: Double -> Double decay y = d y - d 0 where d x = k1 * exp (negate $ (4 * x - 2) ^ i2) + k2 * (1 - exp (negate $ x ^ i2 / 4)) ^ i2 k1 = 0.4 k2 = 0.8 i2 = 2 :: Int {- decay :: Double -> Double decay x = k * log (1 + max 0 x) where k = 0.3 -}
osakunta/karma
src/SatO/Karma/Graph.hs
bsd-3-clause
1,947
6
19
517
778
424
354
47
1
{-| Copyright : (c) Dave Laing, 2017 License : BSD3 Maintainer : dave.laing.80@gmail.com Stability : experimental Portability : non-portable -} module Fragment.Case.Ast ( module X ) where import Fragment.Case.Ast.Error as X import Fragment.Case.Ast.Warning as X import Fragment.Case.Ast.Term as X
dalaing/type-systems
src/Fragment/Case/Ast.hs
bsd-3-clause
313
0
4
55
41
31
10
5
0
module Test.Simulator.TestCommon where import Andromeda.Assets.SpaceshipSample import Andromeda.Simulator makeRunningSimulation = do simModel <- compileSimModel networkDef pipe <- createPipe :: IO SimulatorPipe simHandle <- startSimulation pipe process simModel return (pipe, simHandle) simulateSingleReq req = do (pipe, simHandle) <- makeRunningSimulation resp <- sendRequest pipe req stopSimulation simHandle return resp runNetworkAct = SimAction $ runNetwork setGen1Act idx = SimAction $ setValueGenerator idx floatIncrementGen setGen2Act idx = SimAction $ setValueGenerator idx floatDecrementGen
graninas/Andromeda
trash/TestCommon.hs
bsd-3-clause
620
0
8
87
160
78
82
16
1
{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Plugins.StdinReader -- Copyright : (c) Spencer Janssen -- License : BSD-style (see LICENSE) -- -- Maintainer : Spencer Janssen <spencerjanssen@gmail.com> -- Stability : unstable -- Portability : unportable -- -- A plugin to display information from _XMONAD_LOG, specified at -- http://code.haskell.org/XMonadContrib/XMonad/Hooks/DynamicLog.hs -- ----------------------------------------------------------------------------- module Plugins.XMonadLog (XMonadLog(..)) where import Control.Monad import Graphics.X11 import Graphics.X11.Xlib.Extras import Plugins #ifdef UTF8 #undef UTF8 import Codec.Binary.UTF8.String as UTF8 #define UTF8 #endif import Foreign.C (CChar) import XUtil (nextEvent') data XMonadLog = XMonadLog | XPropertyLog String deriving (Read, Show) instance Exec XMonadLog where alias XMonadLog = "XMonadLog" alias (XPropertyLog atom) = atom start x cb = do let atom = case x of XMonadLog -> "_XMONAD_LOG" XPropertyLog a -> a d <- openDisplay "" xlog <- internAtom d atom False root <- rootWindow d (defaultScreen d) selectInput d root propertyChangeMask let update = do mwp <- getWindowProperty8 d xlog root maybe (return ()) (cb . decodeCChar) mwp update allocaXEvent $ \ep -> forever $ do nextEvent' d ep e <- getEvent ep case e of PropertyEvent { ev_atom = a } | a == xlog -> update _ -> return () return () decodeCChar :: [CChar] -> String #ifdef UTF8 #undef UTF8 decodeCChar = UTF8.decode . map fromIntegral #define UTF8 #else decodeCChar = map (toEnum . fromIntegral) #endif
neglectedvalue/xmobar-freebsd
Plugins/XMonadLog.hs
bsd-3-clause
1,890
0
19
497
391
208
183
34
1
-- | To learn more about pipes-group and how to use these functions with it, check out the in -- depth tutorial at <http://hackage.haskell.org/package/pipes-group/docs/Pipes-Group-Tutorial.html> module Pipes.Break.Text ( -- * Group Producers By A Delimiter -- | Break any producer up into groups with the delimiter stripped out with the presumption that -- two 'Producer's are "equivalent" if they produce the same string when drained. -- -- @ -- 'unBreaksBy' delim ('breaksBy' delim foo) ≡ foo -- 'unBreakBy' delim ('breakBy' delim foo) ≡ foo -- @ breakBy, unBreakBy, breaksBy, unBreaksBy, -- * Group Producers Ending By A Delimiter -- | These are almost equivalent to the breakBy functions, however they imply that every chunk "ends" with a delimiter, -- rather than just being separated by them. -- -- Unfortunately it is impossible to know in a streaming fashion for sure that your next group will -- ever end with a delimiter (or end at all for that matter). The only way to find out is to store every line you receive until you find it. -- Therefore, the endsBy family of functions are not invertible. -- -- >>> mconcat $ Pipes.Prelude.toList (unEndsBy "\r\n" (endsBy "\r\n" (yield "A\r\nB\r\nC"))) -- "A\r\nB\r\nC\r\n" -- -- In other words: -- -- @ -- 'unEndsBy' delim ('endsBy' delim foo) ≠ foo -- 'unEndBy' delim ('endBy' delim foo) ≠ foo -- @ endBy, unEndBy, endsBy, unEndsBy, -- * Utilities replace ) where import Pipes as P import Pipes.Group as P import qualified Data.Text as T import Pipes.Break.Internal -- | Yield argument until it reaches delimiter or end of stream, then return the remainder (minus the delimiter). -- -- This is equivalent to 'breakBy'. endBy :: (Monad m) => T.Text -> Producer T.Text m r -> Producer T.Text m (Producer T.Text m r) endBy = breakBy -- | Recombine a producer that had been previously broken by using a separator. If the second stream is empty -- the delimiter will be added on at the end of the first producer anyways. -- -- >>> mconcat $ Pipes.Prelude.toList (unEndBy "\n" (yield "abc" >> return (yield "def"))) -- "abc\ndef" -- -- >>> mconcat $ Pipes.Prelude.toList (unEndBy "\n" (yield "abc" >> return (return ()))) -- "abc\n" -- -- This is /not/ equivalent to 'unBreakBy' and is not quite an inverse of 'endBy' unEndBy :: (Monad m) => T.Text -> Producer T.Text m (Producer T.Text m r) -> Producer T.Text m r unEndBy = _unEndBy -- | Recombine a producer that had been previously broken recombining it with the provided delimiter. -- -- >>> mconcat $ Pipes.Prelude.toList (unBreakBy "\n" (yield "abc" >> return (yield "def"))) -- "abc\ndef" -- -- >>> mconcat $ Pipes.Prelude.toList (unBreakBy "\n" (yield "abc" >> return (return ()))) -- "abc" -- -- The inverse of 'breakBy' unBreakBy :: (Monad m) => T.Text -> Producer T.Text m (Producer T.Text m r) -> Producer T.Text m r unBreakBy = _unBreakBy endsBy :: (Monad m) => T.Text -> Producer T.Text m r -> FreeT (Producer T.Text m) m r endsBy = _endsBy -- | Not quite the inverse of 'endsBy'. unEndsBy :: (Monad m) => T.Text -> FreeT (Producer T.Text m) m r -> Producer T.Text m r unEndsBy = _unEndsBy -- | The inverse of 'breaksBy'. unBreaksBy :: (Monad m) => T.Text -> FreeT (Producer T.Text m) m r -> Producer T.Text m r unBreaksBy = _unBreaksBy -- | Group a producer on any delimiter. breaksBy :: (Monad m) => T.Text -> Producer T.Text m r -> FreeT (Producer T.Text m) m r breaksBy = _breaksBy -- | Yield argument until it reaches delimiter or end of stream, then returns the remainder (minus the delimiter). -- -- >>> rest <- runEffect $ for (breakBy "\r\n" (yield "A\r\nB\r\nC\r\n")) (lift . Prelude.print) -- "A" -- -- >>> runEffect $ for rest (lift . print) -- "B\r\nC\r\n" -- -- This is almost equivalent to Pipes.Text.line except that it works for any delimiter, not just '\n', -- and it also consumes the delimiter. breakBy :: (Monad m) => T.Text -> Producer T.Text m r -> Producer T.Text m (Producer T.Text m r) breakBy = _breakBy -- | Replace one delimiter with another in a stream. -- -- >>> fmap mconcat <$> toListM $ replace "\r\n" "\n" (yield "abc\ndef\r\nfoo\n\r\nbar") -- "abc\ndef\nfoo\n\nbar" replace :: (Monad m) => T.Text -> T.Text -> Producer T.Text m r -> Producer T.Text m r replace from to = unBreaksBy to . breaksBy from
mindreader/pipes-break
src/Pipes/Break/Text.hs
bsd-3-clause
4,353
0
11
827
653
375
278
26
1
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TemplateHaskell #-} module Database.InfluxDB.Simple.Classy.Types.Precision ( Precision (..) , AsPrecision (..) , defaultPrecision ) where import Control.Lens (Iso', Prism', makeClassyPrisms, preview, prism', re, view, (^?)) import Data.ByteString (ByteString) import Data.ByteString.Lens (packedChars, unpackedChars) import Data.Text (Text) import Data.Text.Lens (packed, unpacked) -- | -- Precision of the timestamp in the writes or queries to Influx -- [n,u,ms,s,m,h] data Precision = Nanoseconds | Microseconds | Milliseconds | Seconds | Minutes | Hours deriving (Eq, Ord, Enum) makeClassyPrisms ''Precision instance AsPrecision String where _Precision = prism' (\case Nanoseconds -> "n" Microseconds -> "u" Milliseconds -> "ms" Seconds -> "s" Minutes -> "m" Hours -> "h" ) (\case "n" -> Just Nanoseconds "u" -> Just Microseconds "ms" -> Just Milliseconds "s" -> Just Seconds "m" -> Just Minutes "h" -> Just Hours _ -> Nothing ) {-# INLINABLE pris' #-} pris' :: Iso' a String -> Iso' String a -> Prism' a Precision pris' f t = prism' (view (re _Precision . t)) (preview (f . _Precision)) instance AsPrecision Text where _Precision = pris' unpacked packed instance AsPrecision ByteString where _Precision = pris' unpackedChars packedChars instance Show Precision where show = view (re _Precision) defaultPrecision :: Precision defaultPrecision = Seconds
mankyKitty/classy-influxdb-simple
src/Database/InfluxDB/Simple/Classy/Types/Precision.hs
bsd-3-clause
1,766
0
11
514
427
236
191
52
1
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GHCForeignImportPrim #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UnliftedFFITypes #-} module GHC.VacuumTube.Limbo ( Limbo , LimboMap , vacuumGet ) where import Control.Monad.ST.Unsafe (unsafeIOToST) import Data.Array.Base import Data.Binary import Data.Foldable import Data.Graph import Data.Map.Lazy as Map import Data.Monoid hiding (Any) import Data.STRef import Data.Set as Set import GHC.Prim import GHC.Ptr import GHC.ST import GHC.Types import GHC.VacuumTube.EncodedState import GHC.VacuumTube.Types import GHC.VacuumTube.VacuumNode import Debug.Trace foreign import prim "VacuumAssembler_allocateClosure" unsafeAllocateClosure :: Addr# -> Word# -> State# s -> (# State# s, Any #) foreign import prim "VacuumAssembler_allocateThunk" unsafeAllocateThunk :: Addr# -> Word# -> State# s -> (# State# s, Any #) foreign import prim "VacuumAssembler_setPtr" unsafeSetPtr :: Any -> Word# -> Any -> State# s -> (# State# s #) foreign import prim "VacuumAssembler_setNPtr" unsafeSetNPtr :: Any -> Word# -> Word# -> State# s -> (# State# s #) foreign import prim "VacuumAssembler_indirectByteArray" unsafeIndirectByteArray :: Any -> ByteArray# -> State# s -> (# State# s #) foreign import prim "VacuumAssembler_getInfoTable" unsafeGetInfoTable :: Any -> State# s -> (# State# s, Addr# #) type LimboMap s a = ClosureMap (Limbo s a) countPayload :: Foldable t => t Payload -> (Ptrs, NPtrs) countPayload = e . foldMap s where e (Sum x, Sum y) = (x, y) s PtrPayload{} = (Sum 1, Sum 0) s NPtrPayload{} = (Sum 0, Sum 1) allocateClosures :: LimboMap s Any -> SCC (Ptr Closure, VacuumNode) -> ST s (LimboMap s Any) allocateClosures limboMap (AcyclicSCC (closure, node)) = case node of VacuumClosure infoTable tag payload -> do let (ptrs, nptrs) = countPayload payload l <- limboClosure infoTable tag ptrs nptrs setPayload limboMap l payload return $! Map.insert closure l limboMap VacuumThunk infoTable tag payload -> do let (ptrs, nptrs) = countPayload payload l <- limboThunk infoTable tag ptrs nptrs setPayload limboMap l payload return $! Map.insert closure l limboMap VacuumArray infoTable payload -> do l <- limboArray infoTable payload return $! Map.insert closure l limboMap VacuumStatic -> do l <- limboStatic closure return $! Map.insert closure l limboMap setPayload :: LimboMap s Any -> Limbo s Any -> Map Word Payload -> ST s () setPayload limboMap l = traverse_ (uncurry step) . Map.toList where step k (PtrPayload p) | Just p' <- Map.lookup p limboMap = trace ("ptr match") $ setPtr l k p' | otherwise = trace ("ptr nomatch") $ error "foo" -- setPtr l k (vacuumInfoTable step k (NPtrPayload p) = trace "nptr" $ setNPtr l k p sccNodeMap :: Map (Ptr Closure) VacuumNode -> [SCC (Ptr Closure, VacuumNode)] sccNodeMap = fmap swapAndDropSCC . scc . Map.toList where scc = stronglyConnCompR . fmap pieces ptrElems p = [p | PtrPayload p <- Map.elems p] pieces (k, v) = (v, k, ptrs v) swapAndDrop (v, k, _) = (k, v) swapAndDropSCC (AcyclicSCC x) = AcyclicSCC (swapAndDrop x) swapAndDropSCC (CyclicSCC xs) = CyclicSCC (fmap swapAndDrop xs) ptrs VacuumClosure{vacuumPayload} = ptrElems vacuumPayload ptrs VacuumThunk {vacuumPayload} = ptrElems vacuumPayload ptrs VacuumArray {} = [] ptrs VacuumStatic {} = [] vacuumGet :: Get a vacuumGet = do EncodedState (Just (root, _)) [] nodeMap <- get runST $ do limboMap <- foldlM allocateClosures Map.empty (sccNodeMap nodeMap) case Map.lookup root limboMap of Just limboRoot -> do mval <- ascend limboRoot return $ case mval of Just val -> return val Nothing -> fail "Ascension failed" Nothing -> return $ fail "Root closure not found after construction" data Limbo s a = Limbo {limboPtrs :: STRef s (Set Word), limboNPtrs :: STRef s (Set Word), limboVal :: a} allocateClosure :: Ptr InfoTable -> PointerTag -> ST s Any allocateClosure (Ptr infoTable#) (W# tag#) = ST $ \ st -> case unsafeAllocateClosure infoTable# tag# st of (# st', clos# #) -> (# st', clos# #) allocateThunk :: Ptr InfoTable -> PointerTag -> ST s Any allocateThunk (Ptr infoTable#) (W# tag#) = ST $ \ st -> case unsafeAllocateThunk infoTable# tag# st of (# st', clos# #) -> (# st', clos# #) limboClosure :: Ptr InfoTable -> PointerTag -> Ptrs -> NPtrs -> ST s (Limbo s Any) limboClosure infoTable tag ptrs nptrs = do let ptrSet = Set.fromList [i-1 | i <- [1..ptrs]] nptrSet = Set.fromList [i+ptrs-1 | i <- [1..nptrs]] clos <- traceShow ("allocating", infoTable, ptrs, nptrs) $ allocateClosure infoTable tag ptrRef <- newSTRef ptrSet nptrRef <- newSTRef nptrSet return Limbo{limboPtrs = ptrRef, limboNPtrs = nptrRef, limboVal = clos} limboThunk :: Ptr InfoTable -> PointerTag -> Ptrs -> NPtrs -> ST s (Limbo s Any) limboThunk infoTable tag ptrs nptrs = do let ptrSet = Set.fromList [i-1 | i <- [1..ptrs]] nptrSet = Set.fromList [i+ptrs-1 | i <- [1..nptrs]] clos <- allocateThunk infoTable tag ptrRef <- newSTRef ptrSet nptrRef <- newSTRef nptrSet return Limbo{limboPtrs = ptrRef, limboNPtrs = nptrRef, limboVal = clos} limboArray :: Ptr InfoTable -> UArray Word Word8 -> ST s (Limbo s Any) limboArray _infoTable (UArray _ _ _ arr) = do ptrRef <- newSTRef Set.empty nptrRef <- newSTRef Set.empty return Limbo{limboPtrs = ptrRef, limboNPtrs = nptrRef, limboVal = unsafeCoerce# arr :: Any} limboStatic :: Ptr Closure -> ST s (Limbo s Any) limboStatic (Ptr clos#) = do ptrRef <- newSTRef Set.empty nptrRef <- newSTRef Set.empty return Limbo{limboPtrs = ptrRef, limboNPtrs = nptrRef, limboVal = unsafeCoerce# clos# :: Any} setByteArray :: Limbo s a -> Word -> ByteArray# -> ST s () setByteArray Limbo{limboPtrs = ptrRef, limboVal = closure} slot arr# = do ST $ \ st -> case unsafeIndirectByteArray (unsafeCoerce# closure :: Any) arr# st of (# st' #) -> (# st', () #) modifySTRef' ptrRef (Set.delete slot) setPtr :: Limbo s Any -> Word -> Limbo s Any -> ST s () {-# NOINLINE setPtr #-} setPtr Limbo{limboPtrs = ptrRef, limboVal = closure} slot@(W# slot#) Limbo{limboVal = val} = do ST $ \ st -> case unsafeSetPtr closure slot# val st of (# st' #) -> (# st', () #) modifySTRef' ptrRef (Set.delete slot) setNPtr :: Limbo s Any -> Word -> Word -> ST s () setNPtr Limbo{limboNPtrs = nptrRef, limboVal = closure} slot@(W# slot#) (W# val#) = do ST $ \ st -> case unsafeSetNPtr closure slot# val# st of (# st' #) -> (# st', () #) modifySTRef' nptrRef (Set.delete slot) ascend :: forall a s . Limbo s Any -> ST s (Maybe a) {-# NOINLINE ascend #-} ascend Limbo{limboPtrs = ptrRef, limboNPtrs = nptrRef, limboVal = val} = do ptrSet <- readSTRef ptrRef nptrSet <- readSTRef nptrRef return $ case (Set.null ptrSet, Set.null nptrSet) of (True, True) -> Just (unsafeCoerce# val :: a) _ -> Nothing
alphaHeavy/vacuum-tube
GHC/VacuumTube/Limbo.hs
bsd-3-clause
7,131
0
19
1,428
2,641
1,334
1,307
-1
-1
{-# LANGUAGE MultiParamTypeClasses #-} module Lexer.Types where import Protolude import qualified Data.Text as T import Common.ParserT import Common.Stream instance Stream Text Char where read = T.uncons type Lexer = ParserT Text Identity execLexer :: Lexer a -> Text -> Either ParserError a execLexer = (runIdentity .) . execParserT
noraesae/monkey-hs
lib/Lexer/Types.hs
bsd-3-clause
361
0
7
75
90
52
38
11
1
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, TemplateHaskell, QuasiQuotes #-} module UntypedTests where import Test.Framework (defaultMain, testGroup, defaultMainWithArgs) import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 (testProperty) import Test.QuickCheck import Test.HUnit import Text.Parsec import Debug.Trace.Helpers import Debug.Trace import Language.Lambda.Untyped.Arbitrary import Language.Lambda.Untyped.Syntax import Language.Lambda.Untyped.Quote import Language.Lambda.Untyped.Parser import Language.Lambda.Untyped.Pretty import Language.Haskell.TH import Language.Haskell.TH.Syntax import Language.Haskell.TH.Syntax.Internals import NLam instance Arbitrary Expr where arbitrary = expr_arb shrink = gexpr_shrink untyped_tests = [ testGroup "Parse Var" [ testCase "test_parse_var_0" test_parse_var_0 ], testGroup "Parse Lam" [ testCase "test_parse_lam_0" test_parse_lam_0, testCase "test_parse_lam_1" test_parse_lam_1 ], testGroup "Parse App" [ testCase "test_parse_app_0" test_parse_app_0, testCase "test_parse_app_1" test_parse_app_1 ], testGroup "Complex Expression" [ testCase "test_parse_exp_0" test_parse_exp_0, testCase "test_parse_exp_1" test_parse_exp_1, testProperty "prop_parse_is_inverse_of_ppr" $ mapSize (const 10) prop_parse_is_inverse_of_ppr ], testGroup "AntiQuotes Expr" [ testCase "test_antivar_0" test_antivar_0, testCase "test_antivar_1" test_antivar_1, testCase "test_antivar_2" test_antivar_2, testCase "test_antivar_3" test_antivar_3, testCase "test_antivar_4" test_antivar_4, testCase "test_antivar_4" test_antivar_5 ], testGroup "AntiQuotes Pat" [ testCase "test_antipat_0" test_antipat_0, testCase "test_antipat_1" test_antipat_1, testCase "test_antipat_2" test_antipat_2, testCase "test_antipat_3" test_antipat_3, testCase "test_antipat_4" test_antipat_4, testCase "test_antipat_5" test_antipat_5, testCase "test_antipat_6" test_antipat_6, testCase "test_antipat_6" test_antipat_7 ] ] test_parse_var_0 = (meta_to_expr actual) @?= expected where (Right actual) = runParser (parse_var parse_sym) () "" "x" expected = Var "x" test_parse_lam_0 = actual @?= expected where result = runParser (parse_lambda parse_sym) () "" "\\x.x" actual = case result of Right x -> meta_to_expr x Left x -> error $ show x expected = Lam "x" $ Var "x" test_parse_lam_1 = actual @?= expected where result = runParser (parse_expr parse_sym) () "" "(\\x.x)" actual = case result of Right x -> meta_to_expr x Left x -> error $ show x expected = Lam "x" $ Var "x" test_parse_app_0 = actual @?= expected where result = runParser (parse_app parse_sym) () "" "x y" actual = case result of Right x -> meta_to_expr x Left x -> error $ show x expected = App (Var "x") $ Var "y" test_parse_app_1 = actual @?= expected where result = runParser (parse_expr parse_sym) () "" "(x y)" actual = case result of Right x -> meta_to_expr x Left x -> error $ show x expected = App (Var "x") $ Var "y" test_parse_exp_0 = actual @?= expected where actual = [lam| ((\x.x) y) |] expected = App (Lam "x" $ Var "x") $ Var "y" test_parse_exp_1 = actual @?= expected where result = runParser (parse_expr parse_sym) () "" "((\\x.x) y)" actual = case result of Right x -> meta_to_expr x Left x -> error $ show x expected = App (Lam "x" $ Var "x") $ Var "y" run_p = runParser (parse_expr parse_sym) () "" prop_parse_is_inverse_of_ppr :: Expr -> Bool prop_parse_is_inverse_of_ppr x = result where parsed = runParser (parse_expr parse_sym) () "" $ Language.Lambda.Untyped.Pretty.ppr x result = case parsed of Right e -> meta_to_expr e == x Left _ -> trace (show x) False test_antivar_0 = actual @?= expected where actual = [lam| (\x.$y) |] y = Var "yo" expected = Lam "x" $ y test_antivar_1 = actual @?= expected where actual = [lam| (x $y) |] y = Lam "yo" $ Var "y" expected = App (Var "x") $ y test_antivar_2 = actual @?= expected where actual = [lam| (x $y) |] y = App (Lam "yo" $ Var "y") (Var "h") expected = App (Var "x") $ y test_antivar_3 = actual @?= expected where actual = [lam| (\^x.y) |] x = "hey" expected = [lam| (\hey.y) |] test_antivar_4 = actual @?= expected where actual = [lam| (^x y) |] x = "hey" expected = [lam| (hey y) |] test_antivar_5 = actual @?= expected where actual = [lam| (x *y) |] y = "hey" expected = [lam| (x hey) |] test_antipat_0 = f input @?= expected where f [lam| \x.$y |] = y input = [lam| \x.$expected |] expected = [lam| (x y) |] test_antipat_1 = f input @?= expected where f [lam| $y |] = y input = [lam| $expected |] expected = [lam| x |] test_antipat_2 = f input @?= expected where f [lam| (x $y) |] = y input = [lam| (x $expected) |] expected = [lam| \x.(\y. x y) |] test_antipat_3 = f input @?= expected where f [lam| \^x. y |] = x input = [lam| \^expected.y |] expected = "hey" test_antipat_4 = f input @?= expected where f [lam| \x. *y |] = y input = [lam| \x. *expected |] expected = "hey" test_antipat_5 = f input @?= expected where f [lam| (x ^y) |] = y input = [lam| (x ^expected) |] expected = "yo" test_antipat_6 = f input @?= expected where f [lam| \^x.(\^y. x y) |] = (x, y) input = [lam| \^x'.(\^y'. x y) |] expected = (x', y') x' = "hey" y' = "you" test_antipat_7 = f input @?= expected where f [nlam| \^x.(\^y. x y) |] = (x, y) input = [nlam| \^x'.(\^y'. x y) |] expected = (x', y') x' = mkName "hey" y' = mkName "you"
jfischoff/LambdaPrettyQuote
tests/UntypedTests.hs
bsd-3-clause
6,153
0
12
1,647
1,697
943
754
154
2
module CodeGeneration.JavascriptCode where import qualified Tree.TemplateExpression as TE data JavascriptCode = JavascriptCode { -- | Write the JS code for an anonymous function writeFunction :: [String] -> String -> String, -- | Check if a word is reserved in JS isReserved :: String -> Bool, -- | Write a string from a template stringTemplate :: TE.Text -> String }
sergioifg94/Hendoman
src/CodeGeneration/JavascriptCode.hs
bsd-3-clause
402
0
10
93
65
41
24
6
0
module SyntaxRec(module SyntaxRec,module HasBaseStruct,module Recursive,module HsConstants) where import Maybe(fromMaybe) import SrcLoc1 import BaseSyntax import HasBaseStruct import SpecialNames import Recursive import HsConstants(main_mod,main_name,mod_Prelude,is_unit_tycon_name) import Data.Generics -- Tie the recursive knots: type BaseDeclI i = DI i (HsExpI i) (HsPatI i) [HsDeclI i] -- nested declarations (HsTypeI i) -- type expressions [HsTypeI i] -- contexts are lists of types (HsTypeI i) -- lhs of type defs type BaseExpI i = EI i (HsExpI i) (HsPatI i) [HsDeclI i] (HsTypeI i) [HsTypeI i] type BasePatI i = PI i (HsPatI i) type BaseTypeI i = TI i (HsTypeI i) newtype HsDeclI i = Dec (BaseDeclI i) deriving (Ord,Read, Eq, Show, Data, Typeable) newtype HsExpI i = Exp (BaseExpI i) deriving (Ord, Read, Eq, Show, Data, Typeable) newtype HsPatI i = Pat (BasePatI i) deriving (Ord, Read, Eq, Show, Data, Typeable) newtype HsTypeI i = Typ (BaseTypeI i) deriving (Ord, Eq, Show ,Data, Typeable) newtype HsKind = Knd (K HsKind) deriving (Ord,Eq, Show, Data, Typeable) instance Rec (HsDeclI i) (BaseDeclI i) where r = Dec; struct (Dec d) = d instance Rec (HsExpI i) (BaseExpI i) where r = Exp; struct (Exp e) = e instance Rec (HsPatI i) (PI i (HsPatI i)) where r = Pat; struct (Pat p) = p instance Rec (HsTypeI i) (TI i (HsTypeI i)) where r = Typ; struct (Typ t) = t instance Rec HsKind (K HsKind) where r = Knd; struct (Knd k) = k -- This makes all the convenience constructor functions available for -- the base syntax (There is some overlap with the Rec class, but for -- extensions to the syntax, base will be different from rec...): instance HasBaseStruct (HsDeclI i) (BaseDeclI i) where base = Dec instance HasBaseStruct (HsExpI i) (BaseExpI i) where base = Exp instance HasBaseStruct (HsPatI i) (BasePatI i) where base = Pat instance HasBaseStruct (HsTypeI i) (BaseTypeI i) where base = Typ instance HasBaseStruct HsKind (K HsKind) where base = Knd instance GetBaseStruct (HsDeclI i) (BaseDeclI i) where basestruct = Just . struct instance GetBaseStruct (HsPatI i) (BasePatI i) where basestruct = Just . struct instance GetBaseStruct (HsExpI i) (BaseExpI i) where basestruct = Just . struct instance HasSrcLoc (HsDeclI i) where srcLoc = srcLoc . struct -- Module building hsModule s m es (imp, decls) = HsModule s m es (reverse imp) (reverse decls) -- An omitted module header is equivalent to module Main(main) where ... hsMainModule loc body = hsModule loc (main_mod (srcFile loc)) (Just [exportVar main_name]) body -- When consing a Decl onto a Decl list if the new Decl and the Decl on the -- front of the list are for the same function, we can merge the Match lists -- rather than just cons the new decl to the front of the list. --funCons :: HsDecl -> [HsDecl] -> [HsDecl] funCons (d1 @ (Dec (HsFunBind s1 m1))) (ds @ ((d2 @ (Dec (HsFunBind s2 m2))) : more)) = if same m1 m2 then Dec (HsFunBind s2 (m2 ++ m1)) : more else d1 : ds where same ((HsMatch _ n1 _ _ _):_) ((HsMatch _ n2 _ _ _):_) = n1 == n2 same _ _ = False funCons d ds = d : ds -- Exp building hsVar name = HsVar name hsCon name = HsCon name --mkRecord :: HsExp -> [HsFieldUpdate HsExp] -> HsExp mkRecord s (Exp (HsId (HsCon c))) fbinds = hsRecConstr s c fbinds mkRecord s e fbinds = hsRecUpdate s e fbinds -- Used to construct contexts in the parser --tupleTypeToContext :: HsType -> [HsType] tupleTypeToContext t = tupleTypeToContext' is_unit_tycon_name is_tuple_tycon_name t tupleTypeToContext' is_unit_tycon_name is_tuple_tycon_name t = fromMaybe [t] (ctx t []) where ctx (Typ t) ts = case t of HsTyApp t1 t2 -> ctx t1 (t2:ts) HsTyCon c -> if if null ts then is_unit_tycon_name c else is_tuple_tycon_name (length ts-1) c then Just ts else Nothing _ -> Nothing -- instance Show i => Show (HsTypeI i) where showsPrec p (Typ x) = (showsPrec p x) instance Read i => Read (HsTypeI i) where readsPrec p s = [(Typ t,r)|(t,r)<-readsPrec p s]
forste/haReFork
tools/base/syntax/SyntaxRec.hs
bsd-3-clause
4,249
13
17
1,007
1,429
768
661
-1
-1
-- | -- Experimental combinators, that may become part of the main distribution, if -- they turn out to be useful for a wider audience. module Test.Hspec.Expectations.Contrib ( module Test.Hspec.Expectations -- * Predicates -- | (useful in combination with `shouldSatisfy`) , isLeft , isRight ) where import Test.Hspec.Expectations isLeft :: Either a b -> Bool isLeft (Left _) = True isLeft (Right _) = False isRight :: Either a b -> Bool isRight (Left _) = False isRight (Right _) = True
adinapoli/hspec-expectations
src/Test/Hspec/Expectations/Contrib.hs
mit
498
0
7
91
118
67
51
11
1
import System.Environment (getArgs) import NumberTheory (toDigs) -- TODO: use log 10 and check palindrome with division and mod -- see if there's a good bit hack for this pe4 :: Int -> Int pe4 n = maximum [ x*y | x <- dom, y <- dom, x <= y, toDigs (x*y) == reverse (toDigs (x*y)) ] where dom = [10^n - 1, 10^n - 2 ..10^(n-1)] main = getArgs >>= print . pe4 . read . head
sergsr/projeu
src/pe004.hs
mit
397
0
13
103
170
91
79
7
1
{-# LANGUAGE OverloadedStrings #-} {- | Module : Crypto.Gpgme.Key.Gen License : Public Domain Maintainer : daveparrish@tutanota.com Stability : experimental Portability : untested Key generation for h-gpgme. It is suggested to import as qualified. For example: > import qualified Crypto.Gpgme.Key.Gen as G -} module Crypto.Gpgme.Key.Gen ( -- * Usage genKey -- * Parameters , GenKeyParams (..) -- ** BitSize , BitSize , Crypto.Gpgme.Key.Gen.bitSize -- ** UsageList , UsageList (..) , Encrypt (..) , Sign (..) , Auth (..) -- ** ExpireDate , ExpireDate (..) -- ** CreationDate , CreationDate (..) -- * Other , Positive (unPositive) , toPositive , toParamsString ) where import Crypto.Gpgme.Types import Crypto.Gpgme.Internal import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC8 import Text.Email.Validate import Data.Monoid ((<>)) import Foreign as F import Foreign.C.String as FCS import Bindings.Gpgme import Data.Time.Clock import Data.Time.Format import Data.Default -- | Key generation parameters. -- -- See: https://www.gnupg.org/documentation/manuals/gnupg/Unattended-GPG-key-generation.html data GenKeyParams = GenKeyParams { keyType :: Maybe PubKeyAlgo , keyLength :: Maybe BitSize , keyGrip :: BS.ByteString , keyUsage :: Maybe UsageList , subkeyType :: Maybe PubKeyAlgo , subkeyLength :: Maybe BitSize , passphrase :: BS.ByteString , nameReal :: BS.ByteString , nameComment :: BS.ByteString , nameEmail :: Maybe EmailAddress , expireDate :: Maybe ExpireDate , creationDate :: Maybe CreationDate , preferences :: BS.ByteString , revoker :: BS.ByteString , keyserver :: BS.ByteString , handle :: BS.ByteString , rawParams :: BS.ByteString -- ^ Add custom XML } -- | Default parameters -- -- Intended to be used to build custom paramemters. -- -- > params = (def :: GenKeyParams) { keyType = Just Dsa } -- -- See tests for working example of all parameters in use. instance Default GenKeyParams where def = GenKeyParams Nothing Nothing "" Nothing Nothing Nothing "" "" "" Nothing Nothing Nothing "" "" "" "" "" -- | Key-Length parameter data BitSize = BitSize Int -- | Bit size constrained to 1024-4096 bits bitSize :: Int -> Either String BitSize bitSize x | x < 1024 = Left "BitSize must be greater than 1024" | x > 4096 = Left "BitSize must be less than 4096" | otherwise = Right $ BitSize x -- Key-Usage types data Encrypt = Encrypt data Sign = Sign data Auth = Auth data UsageList = UsageList { encrypt :: Maybe Encrypt , sign :: Maybe Sign , auth :: Maybe Auth } -- | Default UsageList -- -- Intended to be used to build custom UsageList parameter -- -- > usageListParam = (def :: UsageList) (Just Encrypt) -- -- See tests for working example of all parameters in use. instance Default UsageList where def = UsageList Nothing Nothing Nothing -- | Expire-Date parameter -- -- Beware, 'genKey' will not check that ExpireDate is after -- CreationDate of generated key. data ExpireDate = ExpireT UTCTime | ExpireD Positive | ExpireW Positive | ExpireM Positive | ExpireY Positive | ExpireS Positive -- TODO: Constrain ExpireDate to something that is valid. -- No ISODate before today or creation date. -- | Creation-Date parameter data CreationDate = CreationT UTCTime | CreationS Positive -- ^ Seconds since epoch -- | Only a positive Int data Positive = Positive { unPositive :: Int } -- | Create a Positive type as long as the Int is greater than @-1@ toPositive :: Int -> Maybe Positive toPositive n = if (n < 0) then Nothing else Just (Positive n) -- | Generate a GPG key genKey :: Ctx -- ^ context to operate in -> GenKeyParams -- ^ parameters to use for generating key -> IO (Either GpgmeError Fpr) genKey (Ctx {_ctx=ctxPtr}) params = do ctx <- F.peek ctxPtr ret <- BS.useAsCString (toParamsString params) $ \p -> do let nullGpgmeData = 0 -- Using 0 as NULL for gpgme_data_t c'gpgme_op_genkey ctx p nullGpgmeData nullGpgmeData if ret == noError then do rPtr <- c'gpgme_op_genkey_result ctx r <- F.peek rPtr let fprPtr = c'_gpgme_op_genkey_result'fpr r fpr <- FCS.peekCString fprPtr return . Right $ BSC8.pack fpr else return . Left $ GpgmeError ret -- | Used by 'genKey' generate a XML string for GPG toParamsString :: GenKeyParams -> BS.ByteString toParamsString params = (BSC8.unlines . filter ((/=)"")) [ "<GnupgKeyParms format=\"internal\">" , "Key-Type: " <> (maybe "default" keyTypeToString $ keyType params) , maybeLine "Key-Length: " keyLengthToString $ keyLength params , addLabel "Key-Grip: " $ keyGrip params , maybeLine "Key-Usage: " keyUsageListToString $ keyUsage params , maybeLine "Subkey-Type: " keyTypeToString $ subkeyType params , maybeLine "Subkey-Length: " keyLengthToString $ subkeyLength params , addLabel "Passphrase: " $ passphrase params , addLabel "Name-Real: " $ nameReal params , addLabel "Name-Comment: " $ nameComment params , maybeLine "Name-Email: " toByteString $ nameEmail params , maybeLine "Expire-Date: " expireDateToString $ expireDate params , maybeLine "Creation-Date: " creationDateToString $ creationDate params , addLabel "Preferences: " $ preferences params , addLabel "Revoker: " $ revoker params , addLabel "Keyserver: " $ keyserver params , addLabel "Handle: " $ handle params -- Allow for additional parameters as a raw ByteString , rawParams params , "</GnupgKeyParms>" ] where maybeLine :: BS.ByteString -> (a -> BS.ByteString) -> Maybe a -> BS.ByteString maybeLine h f p = addLabel h $ maybe "" f p -- Add label if not an empty string addLabel :: BS.ByteString -> BS.ByteString -> BS.ByteString addLabel _ "" = "" addLabel h s = h <> s keyTypeToString :: PubKeyAlgo -> BS.ByteString keyTypeToString Rsa = "RSA" keyTypeToString RsaE = "RSA-E" keyTypeToString RsaS = "RSA-S" keyTypeToString ElgE = "ELG-E" keyTypeToString Dsa = "DSA" keyTypeToString Elg = "ELG" keyLengthToString :: BitSize -> BS.ByteString keyLengthToString (BitSize i) = BSC8.pack $ show i keyUsageListToString :: UsageList -> BS.ByteString keyUsageListToString (UsageList e s a) = let eStr = maybe (""::BS.ByteString) (const "encrypt") e sStr = maybe (""::BS.ByteString) (const "sign") s aStr = maybe (""::BS.ByteString) (const "auth") a in (BSC8.intercalate "," . filter ((/=) "" )) [eStr, sStr, aStr] expireDateToString :: ExpireDate -> BS.ByteString expireDateToString (ExpireD p) = BSC8.pack $ ((show $ unPositive p) ++ "d") expireDateToString (ExpireW p) = BSC8.pack $ ((show $ unPositive p) ++ "w") expireDateToString (ExpireM p) = BSC8.pack $ ((show $ unPositive p) ++ "m") expireDateToString (ExpireY p) = BSC8.pack $ ((show $ unPositive p) ++ "y") expireDateToString (ExpireS p) = BSC8.pack $ ("seconds=" ++ (show $ unPositive p)) expireDateToString (ExpireT t) = BSC8.pack $ formatTime defaultTimeLocale "%Y%m%dT%H%M%S" t creationDateToString :: CreationDate -> BS.ByteString creationDateToString (CreationS p) = BSC8.pack $ ("seconds=" ++ (show $ unPositive p)) creationDateToString (CreationT t) = BSC8.pack $ formatTime defaultTimeLocale "%Y%m%dT%H%M%S" t
mmhat/h-gpgme
src/Crypto/Gpgme/Key/Gen.hs
mit
7,755
0
14
1,879
1,798
972
826
145
13
-- -- -- ---------------- -- Exercise 4.1. ---------------- -- -- -- module E'4''1 where maxThree :: Integer -> Integer -> Integer -> Integer maxThree a b c = max (max a b) c {- GHCi> -- Three equal: maxThree 0 0 0 -- Two equal: maxThree 0 0 1 maxThree 0 1 0 maxThree 1 0 0 -- All different: maxThree 0 1 2 maxThree 0 2 1 maxThree 1 0 2 maxThree 1 2 0 maxThree 2 0 1 maxThree 2 1 0 -} -- 0 -- -- 1 -- 1 -- 1 -- -- 2 -- 2 -- 2 -- 2 -- 2 -- 2 maxFour1, maxFour2, maxFour3 :: Integer -> Integer -> Integer -> Integer -> Integer maxFour1 a b c d | a > b && a > c && a > d = a | b > c && b > d = b | c > d = c | otherwise = d maxFour2 a b c d = max ( max (max a b) c ) d maxFour3 a b c d = max (maxThree a b c) d
pascal-knodel/haskell-craft
_/links/E'4''1.hs
mit
793
0
12
271
240
131
109
17
1
{-# LANGUAGE MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances #-} {- | Module : $Header$ Description : skolemization as an institution comorphism Copyright : (c) Mihai Codescu, 2016 License : GPLv2 or higher, see LICENSE.txt Maintainer : codescu@iws.cs.uni-magdeburg.de Stability : provisional Portability : non-portable (imports Logic.Comorphism) removing existential quantifiers from every formula follows http://resources.mpi-inf.mpg.de/departments/rg1/teaching/autrea-ss10/script/lecture10.pdf -} module Comorphisms.CASL2Skolem where import Logic.Logic import Logic.Comorphism import CASL.Logic_CASL import CASL.AS_Basic_CASL import CASL.Sign import CASL.Morphism import CASL.Sublogic as SL hiding (bottom) import CASL.Induction import CASL.Quantification import Common.Result import Common.Id import qualified Data.Set as Set import Common.AS_Annotation import Common.ProofTree import qualified Common.Lib.MapSet as MapSet import qualified Common.Lib.Rel as Rel data CASL2Skolem = CASL2Skolem deriving Show instance Language CASL2Skolem where language_name CASL2Skolem = "CASL2Skolem" instance Comorphism CASL2Skolem CASL CASL_Sublogics CASLBasicSpec CASLFORMULA SYMB_ITEMS SYMB_MAP_ITEMS CASLSign CASLMor Symbol RawSymbol ProofTree CASL CASL_Sublogics CASLBasicSpec CASLFORMULA SYMB_ITEMS SYMB_MAP_ITEMS CASLSign CASLMor Symbol RawSymbol ProofTree where sourceLogic CASL2Skolem = CASL sourceSublogic CASL2Skolem = SL.cPrenex targetLogic CASL2Skolem = CASL mapSublogic CASL2Skolem sl = Just sl map_theory CASL2Skolem = mapTheory map_morphism CASL2Skolem = error "nyi" map_sentence CASL2Skolem = mapSentence map_symbol CASL2Skolem _ = Set.singleton . id has_model_expansion CASL2Skolem = True is_weakly_amalgamable CASL2Skolem = True eps CASL2Skolem = False mapSentence :: CASLSign -> CASLFORMULA -> Result CASLFORMULA mapSentence sig sen = do let (_n', _nsig', sen1) = skolemize 0 [] sig sig sen return sen1 mapTheory :: (CASLSign, [Named CASLFORMULA]) -> Result (CASLSign, [Named CASLFORMULA]) mapTheory (sig, nsens) = do let (_, nsig, nsens') = foldl (\(n, nsig0, sens0) nsen -> let (n', nsig', sen1) = skolemize n [] sig nsig0 $ sentence nsen in (n', nsig', nsen{sentence = sen1}:sens0)) (0, emptySign (), []) nsens sig' = uniteCASLSign sig nsig return (sig', reverse nsens') mkSkolemFunction :: Int -> Id mkSkolemFunction x = genName $ "sk_f" ++ show x -- replace each variable from an argument list vars -- in a sentence sen' -- with a new skolem function of arguments in a list fVars -- the names are generated starting with a given number replaceBoundVars :: [(VAR, SORT)] -> [(VAR, SORT)] -> Int -> CASLFORMULA -> (CASLSign, CASLFORMULA) replaceBoundVars vars fVars n sen = let -- for each variable that occurs free in sen, -- generate a new skolem function name fNames = map (mkSkolemFunction . snd) $ zip fVars $ [n..] -- for each such name, its arguments will be the types of vars -- and the result, the corresponding sort in fVars otypes = map (\x -> Op_type Total (map snd vars) x nullRange) $ map snd fVars -- now create the operation symbols with names in fNames and arity in otypes osyms = map (\(x, y) -> Qual_op_name x y nullRange) $ zip fNames otypes -- the arguments are the outer variables args = map (\(v,s) -> Qual_var v s nullRange) vars -- now create the term gn_sk_k(outerVariables) tms = map (\os -> Application os args nullRange) osyms substs = map (\((a,b),c) -> (a,b,c)) $ zip fVars tms sen' = foldl (\f (v,s,t)-> substitute v s t f) sen substs sign' = (emptySign ()) { sortRel = foldl (\r x -> Rel.insertKey x r) Rel.empty $ map snd $ vars ++ fVars, opMap = foldl (\m (f,o) -> MapSet.insert f (toOpType o) m) MapSet.empty $ zip fNames otypes } in (sign', sen') -- skolemization: -- exists x H => -- H(f(y_1,...,y_n)/x) -- where y_1, ..., y_n are free in exists x H -- f is a new function symbol of arity n skolemize :: Int -> [(VAR, SORT)] -> CASLSign -> CASLSign -> CASLFORMULA -> (Int, CASLSign, CASLFORMULA) skolemize n outerFreeVars osig nsig sen = case sen of Quantification Existential vdecls sen1 _ -> let vars = flatVAR_DECLs vdecls (n', nsig', sen') = skolemize n outerFreeVars osig nsig sen1 --fVars = freeVars osig sen' n'' = n' + (length vars) (nsig0, sen'') = replaceBoundVars outerFreeVars vars n sen' nsig'' = uniteCASLSign nsig' nsig0 in (n'', nsig'', sen'') Quantification q vars sen1 _ -> let (n', nsig', sen') = skolemize n (outerFreeVars ++ flatVAR_DECLs vars) osig nsig sen1 in (n', nsig', Quantification q vars sen' nullRange) Junction j sens _ -> let (n', nsig', sens') = foldl (\(x, nsig0, sens0) s -> let (y, nsig1, s') = skolemize x outerFreeVars osig nsig0 s in (y, uniteCASLSign nsig1 nsig0, s':sens0)) (n, nsig, []) sens in (n', nsig', Junction j (reverse sens') nullRange) Relation sen1 rel sen2 _ -> let (n', nsig', sen') = skolemize n outerFreeVars osig nsig sen1 (n'', nsig'', sen'') = skolemize n' outerFreeVars osig nsig' sen2 in (n'', nsig'', Relation sen' rel sen'' nullRange) Negation sen1 _ -> let (n', nsig', sen') = skolemize n outerFreeVars osig nsig sen1 in (n', nsig', Negation sen' nullRange) x -> (n, nsig, x)
spechub/Hets
Comorphisms/CASL2Skolem.hs
gpl-2.0
5,693
0
19
1,361
1,585
857
728
105
6
<?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="el-GR"> <title>Support for the Open API Specification | ZAP Extension</title> <maps> <homeID>top</homeID> <mapref location="map.jhm"/> </maps> <view> <name>TOC</name> <label>Contents</label> <type>org.zaproxy.zap.extension.help.ZapTocView</type> <data>toc.xml</data> </view> <view> <name>Index</name> <label>Index</label> <type>javax.help.IndexView</type> <data>index.xml</data> </view> <view> <name>Search</name> <label>Search</label> <type>javax.help.SearchView</type> <data engine="com.sun.java.help.search.DefaultSearchEngine"> JavaHelpSearch </data> </view> <view> <name>Favorites</name> <label>Favorites</label> <type>javax.help.FavoritesView</type> </view> </helpset>
veggiespam/zap-extensions
addOns/openapi/src/main/javahelp/org/zaproxy/zap/extension/openapi/resources/help_el_GR/helpset_el_GR.hs
apache-2.0
1,000
80
66
164
423
214
209
-1
-1
module System.Console.Haskeline.Monads( module System.Console.Haskeline.MonadException, MonadTrans(..), MonadIO(..), ReaderT(..), runReaderT', mapReaderT, asks, StateT, runStateT, evalStateT', mapStateT, gets, modify, update, MonadReader(..), MonadState(..), MaybeT(..), orElse ) where import Control.Monad (liftM) import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.Class (MonadTrans(..)) import Control.Monad.Trans.Maybe (MaybeT(..)) import Control.Monad.Trans.Reader hiding (ask,asks) import qualified Control.Monad.Trans.Reader as Reader import Data.IORef #if __GLASGOW_HASKELL__ < 705 import Prelude hiding (catch) #endif import System.Console.Haskeline.MonadException class Monad m => MonadReader r m where ask :: m r instance Monad m => MonadReader r (ReaderT r m) where ask = Reader.ask instance Monad m => MonadReader s (StateT s m) where ask = get instance (MonadReader r m, MonadTrans t, Monad (t m)) => MonadReader r (t m) where ask = lift ask asks :: MonadReader r m => (r -> a) -> m a asks f = liftM f ask class Monad m => MonadState s m where get :: m s put :: s -> m () gets :: MonadState s m => (s -> a) -> m a gets f = liftM f get modify :: MonadState s m => (s -> s) -> m () modify f = get >>= put . f update :: MonadState s m => (s -> (a,s)) -> m a update f = do s <- get let (x,s') = f s put s' return x runReaderT' :: Monad m => r -> ReaderT r m a -> m a runReaderT' = flip runReaderT newtype StateT s m a = StateT { getStateTFunc :: forall r . s -> m ((a -> s -> r) -> r)} instance Monad m => Monad (StateT s m) where return x = StateT $ \s -> return $ \f -> f x s StateT f >>= g = StateT $ \s -> do useX <- f s useX $ \x s' -> getStateTFunc (g x) s' instance MonadTrans (StateT s) where lift m = StateT $ \s -> do x <- m return $ \f -> f x s instance MonadIO m => MonadIO (StateT s m) where liftIO = lift . liftIO mapStateT :: (forall b . m b -> n b) -> StateT s m a -> StateT s n a mapStateT f (StateT m) = StateT (\s -> f (m s)) runStateT :: Monad m => StateT s m a -> s -> m (a, s) runStateT f s = do useXS <- getStateTFunc f s return $ useXS $ \x s' -> (x,s') makeStateT :: Monad m => (s -> m (a,s)) -> StateT s m a makeStateT f = StateT $ \s -> do (x,s') <- f s return $ \g -> g x s' instance Monad m => MonadState s (StateT s m) where get = StateT $ \s -> return $ \f -> f s s put s = s `seq` StateT $ \_ -> return $ \f -> f () s instance (MonadState s m, MonadTrans t, Monad (t m)) => MonadState s (t m) where get = lift get put = lift . put -- ReaderT (IORef s) is better than StateT s for some applications, -- since StateT loses its state after an exception such as ctrl-c. instance MonadIO m => MonadState s (ReaderT (IORef s) m) where get = ask >>= liftIO . readIORef put s = ask >>= liftIO . flip writeIORef s evalStateT' :: Monad m => s -> StateT s m a -> m a evalStateT' s f = liftM fst $ runStateT f s instance MonadException m => MonadException (StateT s m) where controlIO f = makeStateT $ \s -> controlIO $ \run -> fmap (flip runStateT s) $ f $ stateRunIO s run where stateRunIO :: s -> RunIO m -> RunIO (StateT s m) stateRunIO s (RunIO run) = RunIO (\m -> fmap (makeStateT . const) $ run (runStateT m s)) orElse :: Monad m => MaybeT m a -> m a -> m a orElse (MaybeT f) g = f >>= maybe g return
leroux/packages-haskeline
System/Console/Haskeline/Monads.hs
bsd-2-clause
3,885
0
14
1,287
1,607
838
769
-1
-1
import Test.Tasty (defaultMain,testGroup) import qualified Tests.Distribution import qualified Tests.Function import qualified Tests.KDE import qualified Tests.Matrix import qualified Tests.NonParametric import qualified Tests.Parametric import qualified Tests.Transform import qualified Tests.Correlation import qualified Tests.Serialization import qualified Tests.Quantile main :: IO () main = defaultMain $ testGroup "statistics" [ Tests.Distribution.tests , Tests.Function.tests , Tests.KDE.tests , Tests.Matrix.tests , Tests.NonParametric.tests , Tests.Parametric.tests , Tests.Transform.tests , Tests.Correlation.tests , Tests.Serialization.tests , Tests.Quantile.tests ]
bos/statistics
tests/tests.hs
bsd-2-clause
702
0
8
88
158
100
58
23
1
module Network.API.Builder.SendSpec where import Network.API.Builder.Builder import Network.API.Builder.Routes import Network.API.Builder.Send import Data.Aeson import Data.ByteString.Lazy (ByteString) import qualified Network.HTTP.Client as HTTP import Test.Hspec main :: IO () main = hspec spec spec :: Spec spec = do describe "Sendable" $ do describe "()" $ do it "should be able to construct a basic request" $ do case send exampleBuilder (Route ["api.json"] [] "GET") () of Just req -> do HTTP.secure req `shouldBe` True HTTP.host req `shouldBe` "example.com" HTTP.method req `shouldBe` "GET" HTTP.port req `shouldBe` 443 HTTP.queryString req `shouldBe` "" HTTP.path req `shouldBe` "/api.json" Nothing -> expectationFailure "req construction failed" it "should be able to construct request with query params" $ do case send exampleBuilder (Route ["api.json"] ["a_query" =. True] "GET") () of Just req -> do HTTP.secure req `shouldBe` True HTTP.host req `shouldBe` "example.com" HTTP.method req `shouldBe` "GET" HTTP.port req `shouldBe` 443 HTTP.queryString req `shouldBe` "?a_query=true" HTTP.path req `shouldBe` "/api.json" Nothing -> expectationFailure "req construction failed" it "should be able to construct a POST request" $ do case send exampleBuilder (Route ["api.json"] ["query" =. False] "POST") () of Just req -> do HTTP.secure req `shouldBe` True HTTP.host req `shouldBe` "example.com" HTTP.method req `shouldBe` "POST" HTTP.port req `shouldBe` 443 HTTP.queryString req `shouldBe` "" HTTP.path req `shouldBe` "/api.json" case HTTP.requestBody req of HTTP.RequestBodyBS "query=false" -> return () _ -> expectationFailure "incorrect POST body" Nothing -> expectationFailure "req construction failed" describe "PostQuery" $ do it "should be able to construct a POST request with no body" $ do case send exampleBuilder (Route ["api.json"] ["query" =. False] "POST") PostQuery of Just req -> do HTTP.secure req `shouldBe` True HTTP.host req `shouldBe` "example.com" HTTP.method req `shouldBe` "POST" HTTP.port req `shouldBe` 443 HTTP.queryString req `shouldBe` "?query=false" HTTP.path req `shouldBe` "/api.json" case HTTP.requestBody req of HTTP.RequestBodyLBS "" -> return () _ -> expectationFailure "incorrect POST body" Nothing -> expectationFailure "req construction failed" describe "Value" $ do it "should be able to construct a POST request with the correct JSON body" $ do case send exampleBuilder (Route ["api.json"] ["query" =. False] "POST") $ object ["hello" .= Null] of Just req -> do HTTP.secure req `shouldBe` True HTTP.host req `shouldBe` "example.com" HTTP.method req `shouldBe` "POST" HTTP.port req `shouldBe` 443 HTTP.queryString req `shouldBe` "?query=false" HTTP.path req `shouldBe` "/api.json" case HTTP.requestBody req of HTTP.RequestBodyLBS "{\"hello\":null}" -> return () _ -> expectationFailure "incorrect POST body" Nothing -> expectationFailure "req construction failed" describe "ByteString" $ do it "should be able to construct a POST request with the correct ByteString body" $ do case send exampleBuilder (Route ["api.json"] ["query" =. False] "POST") ("hello world" :: ByteString) of Just req -> do HTTP.secure req `shouldBe` True HTTP.host req `shouldBe` "example.com" HTTP.method req `shouldBe` "POST" HTTP.port req `shouldBe` 443 HTTP.queryString req `shouldBe` "?query=false" HTTP.path req `shouldBe` "/api.json" case HTTP.requestBody req of HTTP.RequestBodyLBS "hello world" -> return () _ -> expectationFailure "incorrect POST body" Nothing -> expectationFailure "req construction failed" exampleBuilder :: Builder exampleBuilder = basicBuilder "example" "https://example.com"
eryx67/api-builder
test/Network/API/Builder/SendSpec.hs
bsd-3-clause
4,452
0
25
1,302
1,195
584
611
91
11
module Syntax.ParseState ( module Syntax.ParseState , module Text.Megaparsec.String ) where import Syntax.Tree import qualified Syntax.Env as E import Control.Monad.State.Lazy (StateT, modify, get) import Text.Megaparsec.String -- Types that can be declared. Used to keep track of identifiers while parsing. data EnvDecl = PVar DataType | PFunc [DataType] | PStruct [StructMemberVar] deriving (Eq, Show) -- Keeps track of what identifiers, and their associated types, have been -- parsed so far. type ParseState = E.Env EnvDecl type ParserM = StateT ParseState Parser -- Populates a parse state with the given variables. fromVars :: [(Identifier, DataType)] -> ParseState fromVars vs = E.fromList $ fmap (\(i,t) -> (i, PVar t)) vs -- Adds a variable name to the current scope. putM :: Identifier -> EnvDecl -> ParserM () putM i v = modify (E.put i v) getP :: (Monad m) => Identifier -> ParseState -> m EnvDecl getP i state = do case E.get i state of Nothing -> fail $ i ++ " does not exist" Just x -> return x -- Returns whether a identifier can be used, i.e. if the identifier has been -- declared in this scope or the scope above. getM :: Identifier -> ParserM EnvDecl getM i = do state <- get getP i state getStruct :: (Monad m) => Identifier -> ParseState -> m [StructMemberVar] getStruct i state = do decl <- getP i state case decl of PStruct mems -> return mems _ -> fail $ "expected " ++ i ++ " to be struct" -- Retrive the identifier from the environment and modify it. If the identifier -- does not exist then the supplied env is returned. modifyM :: Identifier -> (EnvDecl -> EnvDecl) -> ParserM () modifyM i f = modify (E.modify i f) -- Moves any used names into the scope above. descendScopeM :: ParserM () descendScopeM = modify E.descendScope -- Returns whether a identifier has already been used to declare a variable/function. -- i.e. if the name is in use at this scope. isTakenM :: Identifier -> ParserM Bool isTakenM i = do state <- get return (E.isTaken i state)
BakerSmithA/Turing
src/Syntax/ParseState.hs
bsd-3-clause
2,105
0
12
469
537
286
251
40
2
{-# LANGUAGE CPP #-} -- | Re-export the operations of the chosen raw frontend -- (determined at compile time with cabal flags). module Game.LambdaHack.Client.UI.Frontend.Chosen ( RawFrontend(..), chosenStartup, stdStartup, nullStartup , frontendName ) where import Control.Concurrent import qualified Game.LambdaHack.Client.Key as K import Game.LambdaHack.Client.UI.Animation (SingleFrame (..)) import Game.LambdaHack.Common.ClientOptions #ifdef VTY import qualified Game.LambdaHack.Client.UI.Frontend.Vty as Chosen #elif CURSES import qualified Game.LambdaHack.Client.UI.Frontend.Curses as Chosen #else import qualified Game.LambdaHack.Client.UI.Frontend.Gtk as Chosen #endif import qualified Game.LambdaHack.Client.UI.Frontend.Std as Std -- | The name of the chosen frontend. frontendName :: String frontendName = Chosen.frontendName data RawFrontend = RawFrontend { fdisplay :: Maybe SingleFrame -> IO () , fpromptGetKey :: SingleFrame -> IO K.KM , fsyncFrames :: IO () , fescMVar :: !(Maybe (MVar ())) , fdebugCli :: !DebugModeCli } chosenStartup :: DebugModeCli -> (RawFrontend -> IO ()) -> IO () chosenStartup fdebugCli cont = Chosen.startup fdebugCli $ \fs -> cont RawFrontend { fdisplay = Chosen.fdisplay fs , fpromptGetKey = Chosen.fpromptGetKey fs , fsyncFrames = Chosen.fsyncFrames fs , fescMVar = Chosen.sescMVar fs , fdebugCli } stdStartup :: DebugModeCli -> (RawFrontend -> IO ()) -> IO () stdStartup fdebugCli cont = Std.startup fdebugCli $ \fs -> cont RawFrontend { fdisplay = Std.fdisplay fs , fpromptGetKey = Std.fpromptGetKey fs , fsyncFrames = Std.fsyncFrames fs , fescMVar = Std.sescMVar fs , fdebugCli } nullStartup :: DebugModeCli -> (RawFrontend -> IO ()) -> IO () nullStartup fdebugCli cont = -- Std used to fork (async) the server thread, to avoid bound thread overhead. Std.startup fdebugCli $ \_ -> cont RawFrontend { fdisplay = \_ -> return () , fpromptGetKey = \_ -> return K.escKM , fsyncFrames = return () , fescMVar = Nothing , fdebugCli }
Concomitant/LambdaHack
Game/LambdaHack/Client/UI/Frontend/Chosen.hs
bsd-3-clause
2,143
0
14
443
518
297
221
-1
-1
{- | Module : $Header$ Description : Conversion to core CspCASL Copyright : (c) Andy Gimblett and Uni Bremen 2006 License : GPLv2 or higher, see LICENSE.txt Maintainer : a.m.gimblett@swansea.ac.uk Stability : provisional Portability : portable Converting sugared CspCASL to core CspCASL. The following process types are core: Skip Stop PrefixProcess ev p ExternalPrefixProcess v es p InternalPrefixProcess v es p Sequential p q ExternalChoice p q InternalChoice p q GeneralisedParallel p es q Hiding p es RelationalRenaming p RENAMING NamedProcess pn evs ConditionalProcess CSP_FORMULA p q (Also the interrupt operator should be added, and core?) -} module CspCASL.Core_CspCASL (basicToCore) where import Common.Id import CspCASL.AS_CspCASL import CspCASL.AS_CspCASL_Process basicToCore :: CspBasicSpec -> CspBasicSpec basicToCore c = CspBasicSpec (channels c) core_procs where core_procs = map procEqToCore (proc_items c) procEqToCore (Proc_Eq pn p) = Proc_Eq pn (procToCore p) procEqToCore x = x procToCore :: PROCESS -> PROCESS procToCore proc = let p' = procToCore in case proc of -- First the core operators: we just need to recurse. (Skip r) -> Skip r (Stop r) -> Stop r (PrefixProcess ev p r) -> PrefixProcess ev (p' p) r (ExternalPrefixProcess v es p r) -> ExternalPrefixProcess v es (p' p) r (InternalPrefixProcess v es p r) -> InternalPrefixProcess v es (p' p) r (Sequential p q r) -> Sequential (p' p) (p' q) r (ExternalChoice p q r) -> ExternalChoice (p' p) (p' q) r (InternalChoice p q r) -> InternalChoice (p' p) (p' q) r (GeneralisedParallel p es q r) -> GeneralisedParallel (p' p) es (p' q) r (Hiding p es r) -> Hiding (p' p) es r (RelationalRenaming p rn r) -> RelationalRenaming (p' p) rn r (NamedProcess pn evs r) -> NamedProcess pn evs r (ConditionalProcess f p q r) -> ConditionalProcess f (p' p) (p' q) r -- Non-core, done. (Interleaving p q r) -> GeneralisedParallel (p' p (EventSet [] nullRange) (p' q) r) -- Non-core, not done yet. (Div r) -> Div r (Run es r) -> Run es r (Chaos es r) -> Chaos es r (SynchronousParallel p q r) -> SynchronousParallel (p' p) (p' q) r (AlphabetisedParallel p esp esq q r) -> AlphabetisedParallel (p' p) esp esq (p' q) r
mariefarrell/Hets
CspCASL/Core_CspCASL.hs
gpl-2.0
2,385
0
15
573
710
350
360
32
19
{-# LANGUAGE TypeInType #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE PatternSynonyms #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeApplications #-} module T14270 (pattern App) where import Data.Kind (Type) import GHC.Fingerprint (Fingerprint, fingerprintFingerprints) import GHC.Types (RuntimeRep, TYPE, TyCon) data (a :: k1) :~~: (b :: k2) where HRefl :: a :~~: a data TypeRep (a :: k) where TrTyCon :: {-# UNPACK #-} !Fingerprint -> !TyCon -> [SomeTypeRep] -> TypeRep (a :: k) TrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). {-# UNPACK #-} !Fingerprint -> TypeRep (a :: k1 -> k2) -> TypeRep (b :: k1) -> TypeRep (a b) TrFun :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep) (a :: TYPE r1) (b :: TYPE r2). {-# UNPACK #-} !Fingerprint -> TypeRep a -> TypeRep b -> TypeRep (a -> b) data SomeTypeRep where SomeTypeRep :: forall k (a :: k). !(TypeRep a) -> SomeTypeRep typeRepFingerprint :: TypeRep a -> Fingerprint typeRepFingerprint = undefined mkTrApp :: forall k1 k2 (a :: k1 -> k2) (b :: k1). TypeRep (a :: k1 -> k2) -> TypeRep (b :: k1) -> TypeRep (a b) mkTrApp rep@(TrApp _ (TrTyCon _ con _) (x :: TypeRep x)) (y :: TypeRep y) | con == funTyCon -- cheap check first , Just (IsTYPE (rx :: TypeRep rx)) <- isTYPE (typeRepKind x) , Just (IsTYPE (ry :: TypeRep ry)) <- isTYPE (typeRepKind y) , Just HRefl <- withTypeable x $ withTypeable rx $ withTypeable ry $ typeRep @((->) x :: TYPE ry -> Type) `eqTypeRep` rep = undefined mkTrApp a b = TrApp fpr a b where fpr_a = typeRepFingerprint a fpr_b = typeRepFingerprint b fpr = fingerprintFingerprints [fpr_a, fpr_b] pattern App :: forall k2 (t :: k2). () => forall k1 (a :: k1 -> k2) (b :: k1). (t ~ a b) => TypeRep a -> TypeRep b -> TypeRep t pattern App f x <- (splitApp -> Just (IsApp f x)) where App f x = mkTrApp f x data IsApp (a :: k) where IsApp :: forall k k' (f :: k' -> k) (x :: k'). () => TypeRep f -> TypeRep x -> IsApp (f x) splitApp :: forall k (a :: k). () => TypeRep a -> Maybe (IsApp a) splitApp (TrApp _ f x) = Just (IsApp f x) splitApp rep@(TrFun _ a b) = Just (IsApp (mkTrApp arr a) b) where arr = bareArrow rep splitApp (TrTyCon{}) = Nothing withTypeable :: forall a r. TypeRep a -> (Typeable a => r) -> r withTypeable = undefined eqTypeRep :: forall k1 k2 (a :: k1) (b :: k2). TypeRep a -> TypeRep b -> Maybe (a :~~: b) eqTypeRep = undefined typeRepKind :: TypeRep (a :: k) -> TypeRep k typeRepKind = undefined bareArrow :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep) (a :: TYPE r1) (b :: TYPE r2). () => TypeRep (a -> b) -> TypeRep ((->) :: TYPE r1 -> TYPE r2 -> Type) bareArrow = undefined data IsTYPE (a :: Type) where IsTYPE :: forall (r :: RuntimeRep). TypeRep r -> IsTYPE (TYPE r) isTYPE :: TypeRep (a :: Type) -> Maybe (IsTYPE a) isTYPE = undefined class Typeable (a :: k) where typeRep :: Typeable a => TypeRep a typeRep = undefined funTyCon :: TyCon funTyCon = undefined instance (Typeable f, Typeable a) => Typeable (f a) instance Typeable ((->) :: TYPE r -> TYPE s -> Type) instance Typeable TYPE
ezyang/ghc
testsuite/tests/polykinds/T14270.hs
bsd-3-clause
3,525
4
15
972
1,360
746
614
-1
-1
{-# LANGUAGE OverloadedStrings #-} module DeleteTeamMembershipFor where import qualified Github.Auth as Github import qualified Github.Teams.Memberships as Github import System.Environment (getArgs) main = do args <- getArgs result <- case args of [token, team_id, username] -> Github.deleteTeamMembershipFor' (Github.GithubOAuth token) (read team_id) username _ -> error "usage: DeleteTeamMembershipFor <token> <team_id> <username>" case result of Left err -> putStrLn $ "Error: " ++ show err Right team -> putStrLn $ show team
beni55/github
samples/Teams/Memberships/DeleteTeamMembershipFor.hs
bsd-3-clause
662
0
14
202
145
77
68
15
3
main = do a; a; a; a; a; a; a
bitemyapp/apply-refact
tests/examples/Duplicate2.hs
bsd-3-clause
29
0
6
9
33
16
17
1
1
{-# LANGUAGE RankNTypes, FlexibleContexts, NamedFieldPuns, RecordWildCards, PatternGuards #-} module Distribution.Server.Features.Documentation ( DocumentationFeature(..), DocumentationResource(..), initDocumentationFeature ) where import Distribution.Server.Framework import Distribution.Server.Features.Documentation.State import Distribution.Server.Features.Upload import Distribution.Server.Features.Core import Distribution.Server.Features.TarIndexCache import Distribution.Server.Framework.BackupRestore import qualified Distribution.Server.Framework.ResponseContentTypes as Resource import Distribution.Server.Framework.BlobStorage (BlobId) import qualified Distribution.Server.Framework.BlobStorage as BlobStorage import qualified Distribution.Server.Util.ServeTarball as ServerTarball import Data.TarIndex (TarIndex) import qualified Codec.Archive.Tar as Tar import qualified Codec.Archive.Tar.Check as Tar import Distribution.Text import Distribution.Package import Distribution.Version (Version(..)) import qualified Data.ByteString.Lazy as BSL import qualified Data.Map as Map import Data.Function (fix) import Data.Aeson (toJSON) -- TODO: -- 1. Write an HTML view for organizing uploads -- 2. Have cabal generate a standard doc tarball, and serve that here data DocumentationFeature = DocumentationFeature { documentationFeatureInterface :: HackageFeature, queryHasDocumentation :: forall m. MonadIO m => PackageIdentifier -> m Bool, queryDocumentation :: forall m. MonadIO m => PackageIdentifier -> m (Maybe BlobId), queryDocumentationIndex :: forall m. MonadIO m => m (Map.Map PackageId BlobId), uploadDocumentation :: DynamicPath -> ServerPartE Response, deleteDocumentation :: DynamicPath -> ServerPartE Response, documentationResource :: DocumentationResource, -- | Notification of documentation changes documentationChangeHook :: Hook PackageId () } instance IsHackageFeature DocumentationFeature where getFeatureInterface = documentationFeatureInterface data DocumentationResource = DocumentationResource { packageDocsContent :: Resource, packageDocsWhole :: Resource, packageDocsStats :: Resource, packageDocsContentUri :: PackageId -> String, packageDocsWholeUri :: String -> PackageId -> String } initDocumentationFeature :: String -> ServerEnv -> IO (CoreResource -> IO [PackageIdentifier] -> UploadFeature -> TarIndexCacheFeature -> IO DocumentationFeature) initDocumentationFeature name env@ServerEnv{serverStateDir} = do -- Canonical state documentationState <- documentationStateComponent name serverStateDir -- Hooks documentationChangeHook <- newHook return $ \core getPackages upload tarIndexCache -> do let feature = documentationFeature name env core getPackages upload tarIndexCache documentationState documentationChangeHook return feature documentationStateComponent :: String -> FilePath -> IO (StateComponent AcidState Documentation) documentationStateComponent name stateDir = do st <- openLocalStateFrom (stateDir </> "db" </> name) initialDocumentation return StateComponent { stateDesc = "Package documentation" , stateHandle = st , getState = query st GetDocumentation , putState = update st . ReplaceDocumentation , backupState = \_ -> dumpBackup , restoreState = updateDocumentation (Documentation Map.empty) , resetState = documentationStateComponent name } where dumpBackup doc = let exportFunc (pkgid, blob) = BackupBlob ([display pkgid, "documentation.tar"]) blob in map exportFunc . Map.toList $ documentation doc updateDocumentation :: Documentation -> RestoreBackup Documentation updateDocumentation docs = RestoreBackup { restoreEntry = \entry -> case entry of BackupBlob [str, "documentation.tar"] blobId | Just pkgId <- simpleParse str -> do docs' <- importDocumentation pkgId blobId docs return (updateDocumentation docs') _ -> return (updateDocumentation docs) , restoreFinalize = return docs } importDocumentation :: PackageId -> BlobId -> Documentation -> Restore Documentation importDocumentation pkgId blobId (Documentation docs) = return (Documentation (Map.insert pkgId blobId docs)) documentationFeature :: String -> ServerEnv -> CoreResource -> IO [PackageIdentifier] -> UploadFeature -> TarIndexCacheFeature -> StateComponent AcidState Documentation -> Hook PackageId () -> DocumentationFeature documentationFeature name ServerEnv{serverBlobStore = store, serverBaseURI} CoreResource{ packageInPath , guardValidPackageId , corePackagePage , corePackagesPage , lookupPackageId } getPackages UploadFeature{..} TarIndexCacheFeature{cachedTarIndex} documentationState documentationChangeHook = DocumentationFeature{..} where documentationFeatureInterface = (emptyHackageFeature name) { featureDesc = "Maintain and display documentation" , featureResources = map ($ documentationResource) [ packageDocsContent , packageDocsWhole , packageDocsStats ] , featureState = [abstractAcidStateComponent documentationState] } queryHasDocumentation :: MonadIO m => PackageIdentifier -> m Bool queryHasDocumentation pkgid = queryState documentationState (HasDocumentation pkgid) queryDocumentation :: MonadIO m => PackageIdentifier -> m (Maybe BlobId) queryDocumentation pkgid = queryState documentationState (LookupDocumentation pkgid) queryDocumentationIndex :: MonadIO m => m (Map.Map PackageId BlobId) queryDocumentationIndex = liftM documentation (queryState documentationState GetDocumentation) documentationResource = fix $ \r -> DocumentationResource { packageDocsContent = (extendResourcePath "/docs/.." corePackagePage) { resourceDesc = [ (GET, "Browse documentation") ] , resourceGet = [ ("", serveDocumentation) ] } , packageDocsWhole = (extendResourcePath "/docs.:format" corePackagePage) { resourceDesc = [ (GET, "Download documentation") , (PUT, "Upload documentation") , (DELETE, "Delete documentation") ] , resourceGet = [ ("tar", serveDocumentationTar) ] , resourcePut = [ ("tar", uploadDocumentation) ] , resourceDelete = [ ("", deleteDocumentation) ] } , packageDocsStats = (extendResourcePath "/docs.:format" corePackagesPage) { resourceDesc = [ (GET, "Get information about which packages have documentation") ] , resourceGet = [ ("json", serveDocumentationStats) ] } , packageDocsContentUri = \pkgid -> renderResource (packageDocsContent r) [display pkgid] , packageDocsWholeUri = \format pkgid -> renderResource (packageDocsWhole r) [display pkgid, format] } serveDocumentationStats :: DynamicPath -> ServerPartE Response serveDocumentationStats _dpath = do pkgs <- mapParaM queryHasDocumentation =<< liftIO getPackages return . toResponse . toJSON . map aux $ pkgs where aux :: (PackageIdentifier, Bool) -> (String, Bool) aux (pkgId, hasDocs) = (display pkgId, hasDocs) serveDocumentationTar :: DynamicPath -> ServerPartE Response serveDocumentationTar dpath = withDocumentation (packageDocsWhole documentationResource) dpath $ \_ blobid _ -> do cacheControl [Public, maxAgeDays 1] (BlobStorage.blobETag blobid) file <- liftIO $ BlobStorage.fetch store blobid return $ toResponse $ Resource.DocTarball file blobid -- return: not-found error or tarball serveDocumentation :: DynamicPath -> ServerPartE Response serveDocumentation dpath = do withDocumentation (packageDocsContent documentationResource) dpath $ \pkgid blob index -> do let tarball = BlobStorage.filepath store blob etag = BlobStorage.blobETag blob -- if given a directory, the default page is index.html -- the root directory within the tarball is e.g. foo-1.0-docs/ ServerTarball.serveTarball (display pkgid ++ " documentation") [{-no index-}] (display pkgid ++ "-docs") tarball index [Public, maxAgeDays 1] etag uploadDocumentation :: DynamicPath -> ServerPartE Response uploadDocumentation dpath = do pkgid <- packageInPath dpath guardValidPackageId pkgid guardAuthorisedAsMaintainerOrTrustee (packageName pkgid) -- The order of operations: -- * Insert new documentation into blob store -- * Generate the new index -- * Drop the index for the old tar-file -- * Link the new documentation to the package fileContents <- expectUncompressedTarball mres <- liftIO $ BlobStorage.addWith store fileContents (\content -> return (checkDocTarball pkgid content)) case mres of Left err -> errBadRequest "Invalid documentation tarball" [MText err] Right ((), blobid) -> do updateState documentationState $ InsertDocumentation pkgid blobid runHook_ documentationChangeHook pkgid noContent (toResponse ()) {- To upload documentation using curl: curl -u admin:admin \ -X PUT \ -H "Content-Type: application/x-tar" \ --data-binary @transformers-0.3.0.0-docs.tar \ http://localhost:8080/package/transformers-0.3.0.0/docs or curl -u admin:admin \ -X PUT \ -H "Content-Type: application/x-tar" \ -H "Content-Encoding: gzip" \ --data-binary @transformers-0.3.0.0-docs.tar.gz \ http://localhost:8080/package/transformers-0.3.0.0/docs The tarfile is expected to have the structure transformers-0.3.0.0-docs/index.html .. -} deleteDocumentation :: DynamicPath -> ServerPartE Response deleteDocumentation dpath = do pkgid <- packageInPath dpath guardValidPackageId pkgid guardAuthorisedAsMaintainerOrTrustee (packageName pkgid) updateState documentationState $ RemoveDocumentation pkgid runHook_ documentationChangeHook pkgid noContent (toResponse ()) withDocumentation :: Resource -> DynamicPath -> (PackageId -> BlobId -> TarIndex -> ServerPartE Response) -> ServerPartE Response withDocumentation self dpath func = do pkgid <- packageInPath dpath -- lookupPackageId returns the latest version if no version is specified. pkginfo <- lookupPackageId pkgid -- Set up the canonical URL to point to the unversioned path let basedpath = [ if var == "package" then (var, unPackageName $ pkgName pkgid) else e | e@(var, _) <- dpath ] basePkgPath = (renderResource' self basedpath) canonicalLink = show serverBaseURI ++ basePkgPath canonicalHeader = "<" ++ canonicalLink ++ ">; rel=\"canonical\"" -- Link: <http://canonical.link>; rel="canonical" -- See https://support.google.com/webmasters/answer/139066?hl=en#6 setHeaderM "Link" canonicalHeader case pkgVersion pkgid of -- if no version is given we want to redirect to the latest version Version [] _ -> tempRedirect latestPkgPath (toResponse "") where latest = packageId pkginfo dpath' = [ if var == "package" then (var, display latest) else e | e@(var, _) <- dpath ] latestPkgPath = (renderResource' self dpath') _ -> do mdocs <- queryState documentationState $ LookupDocumentation pkgid case mdocs of Nothing -> errNotFoundH "Not Found" [MText $ "There is no documentation for " ++ display pkgid ++ ". See " ++ canonicalLink ++ " for the latest version."] where -- Essentially errNotFound, but overloaded to specify a header. -- (Needed since errNotFound throws away result of setHeaderM) errNotFoundH title message = throwError (ErrorResponse 404 [("Link", canonicalHeader)] title message) Just blob -> do index <- liftIO $ cachedTarIndex blob func pkgid blob index -- Check the tar file is well formed and all files are within foo-1.0-docs/ checkDocTarball :: PackageId -> BSL.ByteString -> Either String () checkDocTarball pkgid = checkEntries . fmapErr (either id show) . Tar.checkTarbomb (display pkgid ++ "-docs") . fmapErr (either id show) . Tar.checkSecurity . fmapErr (either id show) . Tar.checkPortability . fmapErr show . Tar.read where fmapErr f = Tar.foldEntries Tar.Next Tar.Done (Tar.Fail . f) checkEntries = Tar.foldEntries (\_ remainder -> remainder) (Right ()) Left {------------------------------------------------------------------------------ Auxiliary ------------------------------------------------------------------------------} mapParaM :: Monad m => (a -> m b) -> [a] -> m [(a, b)] mapParaM f = mapM (\x -> (,) x `liftM` f x)
ocharles/hackage-server
Distribution/Server/Features/Documentation.hs
bsd-3-clause
14,412
0
23
4,156
2,782
1,473
1,309
236
6
{-# LANGUAGE StandaloneKindSignatures #-} {-# LANGUAGE RankNTypes, PolyKinds, DataKinds #-} module SAKS_010 where import Data.Kind (Type) type W :: forall (a :: forall k. k -> Type) -> a Int -> a Maybe -> Type data W x (y :: x Int) (z :: x Maybe)
sdiehl/ghc
testsuite/tests/saks/should_compile/saks010.hs
bsd-3-clause
250
0
9
49
80
48
32
-1
-1
{-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-unused-top-binds #-} module EmptyEntityTest (specsWith, migration, cleanDB) where import Database.Persist.Sql import Database.Persist.TH import Init -- Test lower case names share [mkPersist sqlSettings { mpsGeneric = True }, mkMigrate "migration"] [persistLowerCase| EmptyEntity |] cleanDB :: ( PersistQueryWrite backend , MonadIO m , PersistStoreWrite (BaseBackend backend) ) => ReaderT backend m () cleanDB = deleteWhere ([] :: [Filter (EmptyEntityGeneric backend)]) specsWith :: Runner backend m => RunDb backend m -> Maybe (ReaderT backend m a) -> Spec specsWith runConn mmigrate = describe "empty entity" $ it "inserts" $ asIO $ runConn $ do _ <- sequence_ mmigrate -- Ensure reading the data from the database works... _ <- sequence_ mmigrate x <- insert EmptyEntity Just EmptyEntity <- get x return ()
yesodweb/persistent
persistent-test/src/EmptyEntityTest.hs
mit
966
0
10
222
258
132
126
-1
-1
import System.Posix.Process main = do pid <- getProcessID ppid <- getParentProcessID ppgid <- getProcessGroupIDOf ppid -- join the parent process putStr "Testing joinProcessGroup: " joinProcessGroup ppgid pgid1 <- getProcessGroupID print $ ppgid == pgid1 -- be a leader putStr "Testing createProcessGroupFor: " createProcessGroupFor pid pgid2 <- getProcessGroupID print $ pid == fromIntegral pgid2 -- and join the parent again putStr "Testing setProcessGroupIDOf: " setProcessGroupIDOf pid ppgid pgid3 <- getProcessGroupID print $ ppgid == pgid3
jimenezrick/unix
tests/processGroup002.hs
bsd-3-clause
565
0
8
93
134
58
76
17
1
{-# LANGUAGE CPP #-} -- !!! Testing Typeable instances module Main(main) where import Data.Dynamic #if MIN_VERSION_base(4,10,0) import Data.Typeable (TyCon, TypeRep, typeOf) #endif import Data.Array import Data.Array.MArray import Data.Array.ST import Data.Array.IO import Data.Array.Unboxed import Data.Complex import Data.Int import Data.Word import Data.IORef import System.IO import Control.Monad.ST import System.Mem.StableName import System.Mem.Weak import Foreign.StablePtr import Control.Exception import Foreign.C.Types main :: IO () main = do print (typeOf (undefined :: [()])) print (typeOf (undefined :: ())) print (typeOf (undefined :: ((),()))) print (typeOf (undefined :: ((),(),()))) print (typeOf (undefined :: ((),(),(),()))) print (typeOf (undefined :: ((),(),(),(),()))) print (typeOf (undefined :: (() -> ()))) print (typeOf (undefined :: (Array () ()))) print (typeOf (undefined :: Bool)) print (typeOf (undefined :: Char)) print (typeOf (undefined :: (Complex ()))) print (typeOf (undefined :: Double)) print (typeOf (undefined :: (Either () ()))) print (typeOf (undefined :: Float)) print (typeOf (undefined :: Handle)) print (typeOf (undefined :: Int)) print (typeOf (undefined :: Integer)) print (typeOf (undefined :: IO ())) print (typeOf (undefined :: (Maybe ()))) print (typeOf (undefined :: Ordering)) print (typeOf (undefined :: Dynamic)) print (typeOf (undefined :: (IORef ()))) print (typeOf (undefined :: Int8)) print (typeOf (undefined :: Int16)) print (typeOf (undefined :: Int32)) print (typeOf (undefined :: Int64)) print (typeOf (undefined :: (ST () ()))) print (typeOf (undefined :: (StableName ()))) print (typeOf (undefined :: (StablePtr ()))) print (typeOf (undefined :: TyCon)) print (typeOf (undefined :: TypeRep)) print (typeOf (undefined :: Word8)) print (typeOf (undefined :: Word16)) print (typeOf (undefined :: Word32)) print (typeOf (undefined :: Word64)) print (typeOf (undefined :: ArithException)) print (typeOf (undefined :: AsyncException)) print (typeOf (undefined :: (IOArray () ()))) print (typeOf (undefined :: (IOUArray () ()))) print (typeOf (undefined :: (STArray () () ()))) print (typeOf (undefined :: (STUArray () () ()))) print (typeOf (undefined :: (StableName ()))) print (typeOf (undefined :: (StablePtr ()))) print (typeOf (undefined :: (UArray () ()))) print (typeOf (undefined :: (Weak ()))) print (typeOf (undefined :: CChar)) print (typeOf (undefined :: CSChar)) print (typeOf (undefined :: CUChar)) print (typeOf (undefined :: CShort)) print (typeOf (undefined :: CUShort)) print (typeOf (undefined :: CInt)) print (typeOf (undefined :: CUInt)) print (typeOf (undefined :: CLong)) print (typeOf (undefined :: CULong)) print (typeOf (undefined :: CLLong)) print (typeOf (undefined :: CULLong)) print (typeOf (undefined :: CFloat)) print (typeOf (undefined :: CDouble)) print (typeOf (undefined :: CPtrdiff)) print (typeOf (undefined :: CSize)) print (typeOf (undefined :: CWchar)) print (typeOf (undefined :: CSigAtomic)) print (typeOf (undefined :: CClock)) print (typeOf (undefined :: CTime))
ezyang/ghc
libraries/base/tests/dynamic002.hs
bsd-3-clause
3,269
0
13
609
1,550
801
749
85
1
mmmodule Foo where foo = 'c'
wxwxwwxxx/ghc
testsuite/tests/module/Mod178_2.hs
bsd-3-clause
32
0
5
9
14
6
8
-1
-1
module Bench where import Bench.Macro import Bench.Triangles import Criterion.Main width = 800 height = 800 main :: IO () main = defaultMain [ macro width height , triangles ]
SASinestro/lil-render
bin/Bench.hs
isc
195
0
7
48
58
33
25
10
1
----------------------------------------------------------------------------- -- -- Module : Network.Google.Contacts -- Copyright : (c) 2012-13 Brian W Bush -- License : MIT -- -- Maintainer : Brian W Bush <b.w.bush@acm.org> -- Stability : Stable -- Portability : Portable -- -- | Functions for accessing the Google Contacts API, see <https://developers.google.com/google-apps/contacts/v3/>. -- ----------------------------------------------------------------------------- module Network.Google.Contacts ( -- * Functions listContacts , extractGnuPGNotes ) where import Control.Monad ((<=<), (>>), liftM) import Crypto.GnuPG (Recipient, decrypt, encrypt) import Data.List (stripPrefix) import Data.Maybe (fromJust, fromMaybe, mapMaybe) import Network.Google (AccessToken, doRequest, makeRequest, makeRequestValue) import Network.HTTP.Conduit (Request(..), def, httpLbs, responseBody, withManager) import Text.XML.Light (Element, elChildren, filterChildName, parseXMLDoc, qName, strContent) -- | The host for API access. contactsHost :: String contactsHost = "www.google.com" -- | The API version used here. contactsApi :: (String, String) contactsApi = ("Gdata-version", "3.0") -- | List the contacts, see <https://developers.google.com/google-apps/contacts/v3/#retrieving_all_contacts>. listContacts :: AccessToken -- ^ The OAuth 2.0 access token. -> IO Element -- ^ The action returning the contacts in XML format. listContacts accessToken = do let request = listContactsRequest accessToken doRequest request -- | Make an HTTP request to list the contacts. listContactsRequest :: AccessToken -- ^ The OAuth 2.0 access token. -> Request m -- ^ The request. listContactsRequest accessToken = (makeRequest accessToken contactsApi "GET" (contactsHost, "/m8/feeds/contacts/default/full/")) { queryString = makeRequestValue "?max-results=100000" } -- | Extract the GnuPG\/PGP text in the \"Notes\" fields of a contact list. Extracts are re-encrypted if recipients for the re-encrypted list are specified. extractGnuPGNotes :: [Recipient] -- ^ The recipients to re-encrypt the extracts to. -> Element -- ^ The contact list. -> IO String -- ^ The action return the decrypted and then possibly re-encrypted extracts. extractGnuPGNotes recipients text = do let passwords = extractGnuPGNotes' text replacePassword (t, o, p) = do p' <- decrypt p return $ unlines ["-----", "", t, o, "", p'] passwords' <- mapM replacePassword passwords (if null recipients then return . id else encrypt recipients) $ unlines passwords' -- | Extract the GnuPG\/PGP from a contact list. extractGnuPGNotes' :: Element -- ^ The contact list. -> [(String, String, String)] -- ^ The contacts in (title, organization, GnuPG\/PGP extract) format. extractGnuPGNotes' xml = let findChildName :: String -> Element -> Maybe Element findChildName x = filterChildName (\z -> qName z == x) checkPrefix :: String -> String -> Maybe String checkPrefix p x = liftM (const x) . stripPrefix p $ x getTitle :: Element -> Maybe String getTitle = liftM strContent . findChildName "title" getOrganization :: Element -> Maybe String getOrganization = liftM strContent . findChildName "orgName" <=< findChildName "organization" getPGP :: Element -> Maybe String getPGP = checkPrefix "-----BEGIN PGP MESSAGE-----" <=< liftM strContent . findChildName "content" getEntry :: Element -> Maybe (String, String, String) getEntry x = do let t = fromMaybe "" $ getTitle x o = fromMaybe "" $ getOrganization x p <- getPGP x return (t, o, p) in mapMaybe getEntry $ elChildren xml
rrnewton/hgdata_trash
src/Network/Google/Contacts.hs
mit
3,808
0
15
768
752
413
339
-1
-1
{-# LANGUAGE BangPatterns #-} {-# LANGUAGE NamedFieldPuns #-} module Main (main) where import Control.Applicative ((<$>)) import Control.Concurrent (getNumCapabilities) import Control.Monad (forM_, void) import Data.Time.Clock (getCurrentTime, diffUTCTime) import System.IO (stdout) import Data.Array (Array) import Graphics.Rendering.OpenGL (($=)) import qualified Data.Array as Array import qualified Data.ByteString.Char8 as B import qualified Graphics.Rendering.OpenGL as GL import qualified Graphics.UI.GLUT as GLUT import Data.Colour (Colour, black, white, toGL) import Data.Vec (Vec, vec, scale) import Graphics.Ray.Tracer (renderAll) import Graphics.Ray.Types (Camera, mkCamera, Scene(..), SomeShape(..), PointSource(..), SomeLight(..)) import Graphics.Ray.Ppm (writePpm) import Text.Obj (parse) resolution :: (Int, Int) resolution = (640, 480) origin :: Vec origin = vec 0 0 0 up :: Vec up = vec 0 1 0 camera :: Camera camera = mkCamera (vec 50 50 80) origin up 80 (40, 30) resolution mkScene :: [SomeShape] -> Scene mkScene objs = let light1 = PointSource (vec 100 0 100) white light2 = PointSource (vec (-100) 0 100) white in Scene { sceneCamera = camera , sceneShapes = objs , sceneLights = [SomeLight light1, SomeLight light2] , sceneColour = black , sceneLight = scale 0.1 white } display :: Array (Int, Int) Colour -> IO () display pixels = do start <- getCurrentTime GL.clearColor $= GL.Color4 0 0 0 0 GL.clear [GL.ColorBuffer] GL.renderPrimitive GL.Points $ forM_ (Array.assocs pixels) drawPixel GLUT.flush GLUT.swapBuffers finish <- getCurrentTime print $ show (diffUTCTime finish start) ++ " for frame" where drawPixel ((x, y), color) = do GL.color $ toGL color GL.vertex $ GL.Vertex2 (fromIntegral x :: GL.GLint) (fromIntegral y :: GL.GLint) reshape :: GL.Size -> IO () reshape _size = do GLUT.windowSize $= GL.Size 640 480 GL.viewport $= (GL.Position 0 0, GL.Size 640 480) GL.matrixMode $= GL.Projection GL.loadIdentity GL.ortho2D 0 640 0 480 GL.matrixMode $= GL.Modelview 0 GL.loadIdentity main :: IO () main = do numCapabilities <- getNumCapabilities scene <- mkScene . parse <$> B.getContents let !pixels = renderAll numCapabilities scene writePpm stdout pixels -- (_, _) <- GLUT.getArgsAndInitialize -- GLUT.initialDisplayMode $= [GLUT.DoubleBuffered] -- void $ GLUT.createWindow "Ray" -- GLUT.displayCallback $= display pixels -- GLUT.reshapeCallback $= Just reshape -- GLUT.mainLoop
matklad/raytracer
bin/Ray.hs
mit
2,731
0
13
657
850
465
385
70
1
{-# LANGUAGE PatternSynonyms #-} -- For HasCallStack compatibility {-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} module JSDOM.Generated.MimeType (getType, getSuffixes, getDescription, getEnabledPlugin, MimeType(..), gTypeMimeType) 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/MimeType.type Mozilla MimeType.type documentation> getType :: (MonadDOM m, FromJSString result) => MimeType -> m result getType self = liftDOM ((self ^. js "type") >>= fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeType.suffixes Mozilla MimeType.suffixes documentation> getSuffixes :: (MonadDOM m, FromJSString result) => MimeType -> m result getSuffixes self = liftDOM ((self ^. js "suffixes") >>= fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeType.description Mozilla MimeType.description documentation> getDescription :: (MonadDOM m, FromJSString result) => MimeType -> m result getDescription self = liftDOM ((self ^. js "description") >>= fromJSValUnchecked) -- | <https://developer.mozilla.org/en-US/docs/Web/API/MimeType.enabledPlugin Mozilla MimeType.enabledPlugin documentation> getEnabledPlugin :: (MonadDOM m) => MimeType -> m Plugin getEnabledPlugin self = liftDOM ((self ^. js "enabledPlugin") >>= fromJSValUnchecked)
ghcjs/jsaddle-dom
src/JSDOM/Generated/MimeType.hs
mit
2,160
0
10
282
522
317
205
33
1
-- print2.hs module Print2 where main :: IO () main = do putStr "Count to for for me:" putStrLn "One, two" putStrLn ", three and" putStr " four!"
RazvanCosmeanu/Haskellbook
ch03/print2.hs
mit
167
0
7
49
44
20
24
7
1
-- * Built-in types type Undefined type Null type Int type UInt32 type Number type String type DateTime type Array a -- [a] type Object a -- { String -> a } type Function a b -- a -> b -- Arrays Array a :: new Number -> [a] Array a :: new a... -> [a] Array.isArray :: a -> Bool data SortingRank :: Lower -1 | Equal 0 | Greater 1 class Array a deriving Object a -- * Reflection length :: UInt32 -- * Manipulating elements push! :: a... -> Number pop! :: () -> Maybe a unshift! :: a... -> Number shift! :: () -> Maybe a splice! :: Number, Number, a... -> this -- * Sorting reverse! :: () -> [a] sort! :: (a, b -> SortingRank) -> [a] -- * Constructing concat :: [a]... -> [a] slice :: Number?, Number? -> [a] -- * Transforming join :: String -> String toString :: () -> String toSource :: () -> String -- @nonStandard -- * Accessing elements indexOf :: a -> Number lastIndexOf :: a -> Number -- * Iteration forEach :: (a, Number, [a] -> ()), Object? -> () -- * Folds every :: (a, Number, [a] -> Bool), Object? -> Bool some :: (a, Number, [a] -> Bool), Object? -> Bool filter :: (a, Number, [a] -> Bool), Object? -> [a] map :: (a, Number, [a] -> b), Object? -> [b] reduce :: (b, a, Number, [a] -> b), b? -> b reduceRight :: (b, a, Number, [a] -> b), b? -> b -- Booleans Boolean :: new Boolean -> Boolean class Boolean deriving Object a toString :: () -> String valueOf :: () -> Number toSource :: () -> String -- @nonStandard -- Date Date :: new -> Date Date :: new Number -> Date Date :: new String -> Date Date :: new y:Number, m:Number, d:Number, h:Number?, m:Number, s:Number, ms:Number -> Date Date.now :: () -> Number Date.parse :: String -> Number Date.UTC :: y:Number, m:Number, d:Number?, h:Number, m:Number, s:Number, ms:Number -> Number class Date deriving Object a getDate :: () -> Number getDay :: () -> Number getFullYear :: () -> Number getHours :: () -> Number getMilliseconds :: () -> Number getMinutes :: () -> Number getMonth :: () -> Number getSeconds :: () -> Number getTime :: () -> Number getTimezoneOffset :: () -> Number getUTCDate :: () -> Number getUTCDay :: () -> Number getUTCFullYear :: () -> Number getUTCHours :: () -> Number getUTCMilliseconds :: () -> Number getUTCMinutes :: () -> Number getUTCMonth :: () -> Number getUTCSeconds :: () -> Number getYear :: () -> Number -- @deprecated setDate :: Number -> Number setFullYear :: Number -> Number setHours :: Number -> Number setMilliseconds :: Number -> Number setMinutes :: Number -> Number setMonth :: Number -> Number setSeconds :: Number -> Number setTime :: Number -> Number setUTCDate :: Number -> Number setUTCFullYear :: Number -> Number setUTCHours :: Number -> Number setUTCMilliseconds :: Number -> Number setUTCMinutes :: Number -> Number setUTCMonth :: Number -> Number setUTCSeconds :: Number -> Number setYear :: Number -> Number -- @deprecated toDateString :: () -> String toISOString :: () -> String toJSON :: () -> String toGMTString :: () -> String toLocaleDateString :: () -> String toLocaleString :: () -> String toLocaleTimeString :: () -> String toString :: () -> String toTimeString :: () -> String toUTCString :: () -> String valueOf :: () -> Number toLocaleFormat :: () -> String -- @nonStandard toSource :: () -> String -- @nonStandard -- Functions Function :: new String -> Function Function :: new args:String..., String -> String class Function a b deriving Object a arguments :: [a] -- @deprecated arity :: Number -- @obsolete caller :: Function -- @nonStandard length :: Number name :: String -- @nonStandard apply :: Object, [a] -> b bind :: Object, a... -> Function a b call :: Object, a... -> b isGenerator :: () -> Boolean toSource :: () -> String -- @nonStandard toString :: () -> String -- Numbers Number :: new Number -> Number Number.MAX_VALUE :: Number Number.MIN_VALUE :: Number Number.NaN :: Number Number.NEGATIVE_INFINITY :: Number Number.POSITIVE_INFINITY :: Number Number.isNaN :: Number -> Bool -- @experimental, ES6 Number.isFinite :: Number -> Bool -- @experimental, ES6 Number.isInteger :: Number -> Bool -- @experimental, ES6 Number.toInteger :: Number -> Int32 -- @experimental, ES6 -- Object Object a :: new b -> b -- (as object) Object.create :: c:Object, PropertyDescriptors -> c <| Object Object.defineProperty :: c:Object, String, PropertyDescriptor -> c Object.defineProperties :: c:Object, String, PropertyDescriptors -> c Object.getOwnPropertyDescriptor :: Object, String -> Maybe a Object.keys :: Object -> [String] Object.getOwnPropertyNames :: Object -> [String] Object.getPrototypeOf :: a <| Object -> a Object.preventExtensions :: Object -> Object Object.isExtensible :: Object -> Bool Object.seal :: Object -> Object Object.is :: a, b -> Bool -- @experimental, ES6 Object.isSealed :: Object -> Bool Object.freeze :: Object -> Object Object.isFrozen :: Object -> Object class Object a deriving Object a __count__ :: Number -- @obsolete __parent__ :: Number -- @obsolete __proto__ :: Object -- @nonStandard __defineGetter__ :: String, Function -> Object -- @nonStandard __defineSetter__ :: String, Function -> Object -- @nonStandard eval :: String -> a -- @obsolete hasOwnProperty :: String -> Bool isPrototypeOf :: Object -> Bool __lookupGetter__ :: String -> Function -- @nonStandard __lookupSetter__ :: String -> Function -- @nonStandard __noSuchMethod__ :: (String, [a] -> b) -- @nonStandard propertyIsEnumerable :: String -> Bool toSource :: () -> String -- @nonStandard toLocaleString :: () -> String toString :: () -> String unwatch :: String -> ? -- @nonStandard valueOf :: () -> ? watch :: String -> (String, a, b -> ()) -> ? -- @nonStandard -- String String :: new a -> String String.fromCharCode :: Number -> String class String deriving Object a length :: UInt32
robotlolita/alexandria.js
types.hs
mit
5,997
396
7
1,249
2,109
1,131
978
-1
-1
group :: Int -> [a] -> [[a]] group n = takeWhile (not . null) . map (take n) . iterate (drop n) map1 = map . map map2 = (map, map) map3 = [map id, reverse, map not]
craynafinal/cs557_functional_languages
practice/week2/practice.hs
mit
172
0
9
45
107
57
50
7
1
module Math.Combinatorics where -- | Computes the sum from m to n. O(1) sumFrom :: Integral a => a -> a -> a sumFrom m n = (n + m)*(n - m + 1) `div` 2
taylor1791/HakTools
haskell/src/Numeric/Combinatorics.hs
mit
158
0
9
43
65
36
29
3
1
{-# LANGUAGE CPP #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiWayIf #-} module EventQueue ( EventQueue , newQueue , Event(..) , FileEventType(..) , emitEvent , Status(..) , processQueue #ifdef TEST , Action(..) , processEvents , combineFileEvents , groupFileEvents #endif ) where import Imports import Control.Monad.STM import Control.Concurrent.STM.TChan import Util type EventQueue = TChan Event data Event = TriggerAll | FileEvent FileEventType FilePath | Done deriving (Eq, Show) data FileEventType = FileAdded | FileRemoved | FileModified deriving (Eq, Show) newQueue :: IO EventQueue newQueue = atomically $ newTChan emitEvent :: EventQueue -> Event -> IO () emitEvent chan = atomically . writeTChan chan readEvents :: EventQueue -> IO [Event] readEvents chan = do e <- atomically $ readTChan chan unless (isKeyboardInput e) $ do threadDelay 100000 es <- atomically emptyQueue return (e : es) where isKeyboardInput :: Event -> Bool isKeyboardInput event = event == Done || event == TriggerAll emptyQueue :: STM [Event] emptyQueue = do mEvent <- tryReadTChan chan case mEvent of Nothing -> return [] Just e -> (e :) <$> emptyQueue data Status = Terminate | Reload processQueue :: EventQueue -> IO () -> IO () -> IO Status processQueue chan triggerAll trigger = go where go = readEvents chan >>= processEvents >>= \ case NoneAction -> do go TriggerAction files -> do output files trigger go TriggerAllAction -> do triggerAll go ReloadAction file t -> do output [file <> " (" <> show t <> ", reloading)"] return Reload DoneAction -> do return Terminate output :: [String] -> IO () output = withInfoColor . mapM_ (putStrLn . mappend "--> ") data Action = NoneAction | TriggerAction [FilePath] | TriggerAllAction | ReloadAction FilePath FileEventType | DoneAction deriving (Eq, Show) processEvents :: [Event] -> IO Action processEvents events = do files <- fileEvents events return $ if | Done `elem` events -> DoneAction | (file, t) : _ <- filter shouldReload files -> ReloadAction file t | TriggerAll `elem` events -> TriggerAllAction | not (null files) -> TriggerAction $ nub . sort $ map fst files | otherwise -> NoneAction shouldReload :: (FilePath, FileEventType) -> Bool shouldReload (name, event) = "Spec.hs" `isSuffixOf` name && case event of FileAdded -> True FileRemoved -> True FileModified -> False fileEvents :: [Event] -> IO [(FilePath, FileEventType)] fileEvents events = filterGitIgnored $ combineFileEvents [(p, e) | FileEvent e p <- events] filterGitIgnored :: [(FilePath, FileEventType)] -> IO [(FilePath, FileEventType)] filterGitIgnored events = map f <$> filterGitIgnoredFiles (map fst events) where f :: FilePath -> (FilePath, FileEventType) f p = (p, fromJust $ lookup p events) combineFileEvents :: [(FilePath, FileEventType)] -> [(FilePath, FileEventType)] combineFileEvents events = [(file, e) | (file, Just e) <- map (second combineFileEventTypes) $ groupFileEvents events] groupFileEvents :: [(FilePath, FileEventType)] -> [(FilePath, [FileEventType])] groupFileEvents = map (second $ map snd) . groupOn fst groupOn :: Eq b => (a -> b) -> [a] -> [(b, [a])] groupOn f = go where go = \ case [] -> [] x : xs -> case partition (\ a -> f a == f x) xs of (ys, zs) -> (f x, (x : ys)) : go zs combineFileEventTypes :: [FileEventType] -> Maybe FileEventType combineFileEventTypes = go where go events = case events of [] -> Nothing [e] -> Just e e1 : e2 : es -> go $ (combine e1 e2) es combine e1 e2 = case (e1, e2) of (FileAdded, FileAdded) -> ignoreDuplicate FileAdded (FileAdded, FileRemoved) -> id (FileAdded, FileModified) -> (FileAdded :) (FileRemoved, FileAdded) -> (FileModified :) (FileRemoved, FileRemoved) -> ignoreDuplicate FileRemoved (FileRemoved, FileModified) -> shouldNeverHappen (FileModified, FileAdded) -> shouldNeverHappen (FileModified, FileRemoved) -> (FileRemoved :) (FileModified, FileModified) -> ignoreDuplicate FileModified ignoreDuplicate = (:) shouldNeverHappen = (FileModified :)
hspec/sensei
src/EventQueue.hs
mit
4,346
0
17
1,014
1,495
796
699
109
11
module Main where import Data.List main = interact (concat . sort . lines)
dicander/progp_haskell
concatsort.hs
mit
78
0
8
16
28
16
12
4
1
module Web.WeChat ( module Web.WeChat.Types , parseInMessage , printOutMessage , sha1VerifySignature , encodeMsg , decodeMsg ) where import Web.WeChat.Internal import Web.WeChat.Types import Web.WeChat.JSONPrint() import Web.WeChat.XMLParse import Web.WeChat.XMLPrint import Control.Monad.IO.Class import qualified Data.ByteArray.Encoding as BA import Data.ByteString (ByteString) import Data.Monoid ((<>)) import Data.Text (Text) import qualified Data.Text as T import Text.XML.Light parseInMessage :: Text -> Maybe (Either InEncryptedMessage InMessage) parseInMessage s = parseXMLDoc s >>= parseInMessage' printOutMessage :: OutCallbackMessage -> Text printOutMessage = T.pack . showElement . eltTag "xml" . printOutMessage' sha1VerifySignature :: ToByteString a => [a] -> ByteString sha1VerifySignature = BA.convertToBase BA.Base16 . mkVerifySignature encodeMsg :: (MonadIO m, ToByteString a) => EncodeMsg a -> m (Either String EncodedMessage) encodeMsg EncodeMsg{..} = case verifyAESkeyLength encodeMsgAESKey of Left err -> return $ Left err Right verifiedAES -> do encrypted <- encryptMsg verifiedAES replyMsg appId case encrypted of Left err -> return $ Left err Right enc -> do let sha1sig = sha1VerifySignature [token,timeStamp,nonce,enc] encodedMessage = "<xml>" <> "<Encrypt><![CDATA[" <> enc <> "]]></Encrypt>" <> "<MsgSignature><![CDATA[" <> sha1sig <> "]]></MsgSignature>" <> "<TimeStamp>" <> timeStamp <> "</TimeStamp>" <> "<Nonce><![CDATA[" <> nonce <> "]]></Nonce>" <> "</xml>" return $ Right $ Encoded encodedMessage where replyMsg = toByteString encodeMsgReplyMsg appId = toByteString encodeMsgAppId token = toByteString encodeMsgToken timeStamp = toByteString encodeMsgTimeStamp nonce = toByteString encodeMsgNonce decodeMsg :: (MonadIO m, ToByteString a) => DecodeMsg a -> m (Either String DecodedMessage) decodeMsg DecodeMsg{..} = case verifyAESkeyLength decodeMsgAESKey of Left err -> return $ Left err Right verifiedAES -> do let decodedSignature = sha1VerifySignature [decodeMsgToken,decodeMsgNonce,decodeMsgTimeStamp,decodeMsgEncrypt] if decodedSignature /= signature then return $ Left "ValidateSignatureError: decodeMsg failed to validate signature" else do return . either Left (Right . Decoded) =<< decryptMsg verifiedAES encrypt appId where appId = toByteString decodeMsgAppId encrypt = toByteString decodeMsgEncrypt signature = toByteString decodeMsgSignature
Vlix/wechat
Web/WeChat.hs
mit
2,858
0
30
752
679
355
324
-1
-1
module Darcs.Patch.Inspect ( PatchInspect(..) ) where import Darcs.Patch.Witnesses.Ordered ( FL, RL, reverseRL, mapFL ) import qualified Data.ByteString.Char8 as BC import Data.List ( nub ) class PatchInspect p where listTouchedFiles :: p wX wY -> [FilePath] hunkMatches :: (BC.ByteString -> Bool) -> p wX wY -> Bool instance PatchInspect p => PatchInspect (FL p) where listTouchedFiles xs = nub $ concat $ mapFL listTouchedFiles xs hunkMatches f = or . mapFL (hunkMatches f) instance PatchInspect p => PatchInspect (RL p) where listTouchedFiles = listTouchedFiles . reverseRL hunkMatches f = hunkMatches f . reverseRL
DavidAlphaFox/darcs
src/Darcs/Patch/Inspect.hs
gpl-2.0
671
0
10
144
217
117
100
14
0
{- | Module : $Header$ Copyright : (c) C. Maeder, DFKI GmbH 2010 License : GPLv2 or higher, see LICENSE.txt Maintainer : Christian.Maeder@dfki.de Stability : experimental Portability : portable testing random data -} module Main where import System.Environment import System.Random import ATerm.SimpPretty import ATerm.AbstractSyntax import ATerm.Conversion import ATerm.ReadWrite import ATerm.Unshared import Common.Utils (readMaybe) import qualified Data.Map as Map import Data.List (isPrefixOf) main :: IO () main = do args <- getArgs setStdGen (mkStdGen 50) {- setting an initial RandomGenerator is like setting the seed in C -} let (cmd, files) = (head args, tail args) let cmdFun = case cmd of "ReadWrite" -> testATC cmds | isPrefixOf "BigMap" cmds -> testDDataMap (drop 6 cmds) | isPrefixOf "BigList" cmds -> testListConv (drop 7 cmds) | isPrefixOf "CheckBigMap" cmds -> checkDDataMap (drop 11 cmds) | isPrefixOf "CheckBigList" cmds -> checkListConv (drop 12 cmds) | otherwise -> usage cmd mapM_ cmdFun files usage :: String -> FilePath -> IO () usage cmd _ = do putStrLn ("unknown command: " ++ cmd) putStrLn "Known commands are: ReadWrite, [Check]Big{Map,List}<n>" fail "no known command given" generateRandomLists :: String -> IO [(Int, Int)] generateRandomLists upstr = do up <- case readMaybe upstr of Just u -> do putStrLn $ "generating list with " ++ show u ++ " items" return u Nothing -> do putStrLn "no upper_number read" putStrLn "generating list with 2000 items" return 2000 genIList up genIList :: Int -> IO [(Int, Int)] genIList cnt = if cnt <= 0 then return [] else do v <- getStdRandom (randomR (1, maxBound :: Int)) l <- genIList (cnt - 1) return ((cnt, v) : l) testDDataMap :: String -> FilePath -> IO () testDDataMap upperstr fp = do int_list <- generateRandomLists upperstr let int_map = (Map.fromList int_list) att0 = emptyATermTable (int_att, selectedATermIndex) <- toShATerm' att0 int_map print (getTopIndex int_att, selectedATermIndex) writeFileSDoc fp $ writeSharedATermSDoc int_att putStrLn "File written\nstart reading" str <- readFile fp let read_map :: Map.Map Int Int read_map = fromShATerm (readATerm str) putStrLn ("BigMap of Int -> Int is " ++ (if read_map == int_map then "consistent." else "inconsistent!!")) checkDDataMap :: String -> FilePath -> IO () checkDDataMap upperstr fp = do int_list <- generateRandomLists upperstr let int_map = (Map.fromList int_list) str <- readFile fp let read_map = fromShATerm (readATerm str) putStrLn ("BigMap of Int -> Int is " ++ (if read_map == int_map then "consistent." else "inconsistent!!")) testListConv :: String -> FilePath -> IO () testListConv upperstr fp = do int_list <- generateRandomLists upperstr let att0 = emptyATermTable (int_att, selectedATermIndex) <- toShATerm' att0 $ reverse int_list print (getTopIndex int_att, selectedATermIndex) writeFileSDoc fp $ writeSharedATermSDoc int_att putStrLn "File written\nstart reading" str <- readFile fp let read_list :: [(Int, Int)] read_list = fromShATerm (readATerm str) putStrLn ("BigList of (Int,Int) is " ++ (if read_list == reverse int_list then "consistent." else "inconsistent!!")) checkListConv :: String -> FilePath -> IO () checkListConv upperstr fp = do int_list <- generateRandomLists upperstr str <- readFile fp let read_list = fromShATerm (readATerm str) putStrLn ("BigList of (Int,Int) is " ++ (if read_list == reverse int_list then "consistent." else "inconsistent!!")) resultFP :: String -> String resultFP fp = fp ++ ".ttttt" testATC :: FilePath -> IO () testATC fp = do str <- readFile fp let att = readATerm str putStrLn ("Reading File " ++ fp ++ " ...") let fp' = resultFP fp putStrLn ("Writing File " ++ fp' ++ " ...") writeFileSDoc fp' (writeSharedATermSDoc att)
nevrenato/Hets_Fork
ATC/ATCTest2.hs
gpl-2.0
5,218
0
16
2,061
1,229
589
640
113
2
--{-# LANGUAGE InstanceSigs #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} module SIR.Pure ( runPureSIR ) where import Data.Maybe import Control.Monad.Random import Control.Monad.Reader import Control.Monad.Writer import Control.Monad.State.Strict import Data.MonadicStreamFunction.InternalCore import qualified Data.IntMap.Strict as Map import qualified Data.PQueue.Min as PQ import SIR.Agent import SIR.API import SIR.Model data QueueItem e = QueueItem !e !AgentId !Time deriving Show type EventQueue e = PQ.MinQueue (QueueItem e) instance Eq (QueueItem e) where (==) (QueueItem _ _ t1) (QueueItem _ _ t2) = t1 == t2 instance Ord (QueueItem e) where compare (QueueItem _ _ t1) (QueueItem _ _ t2) = compare t1 t2 type SIRAgent = MSF SIRAgentPure SIREvent SIRState type SIRAgentPureMap = Map.IntMap (SIRAgent, SIRState) data SimState = SimState { simStateRng :: !StdGen , simStateAgents :: !SIRAgentPureMap } runPureSIR :: [SIRState] -> Int -> Double -> Double -> Int -> Double -> StdGen -> [(Time, (Int, Int, Int))] runPureSIR as cor inf ild maxEvents tLimit rng = reverse $ processQueue maxEvents tLimit ss0 eq ais [(0, sir0)] where (ss0, eq) = initSIRPure as cor inf ild rng ais = Map.keys (simStateAgents ss0) sir0 = aggregateAgentMap (simStateAgents ss0) aggregateAgentMap :: SIRAgentPureMap -> (Int, Int, Int) aggregateAgentMap = Prelude.foldr aggregateAgentMapAux (0,0,0) where aggregateAgentMapAux :: (MSF m SIREvent SIRState, SIRState) -> (Int, Int, Int) -> (Int, Int, Int) aggregateAgentMapAux (_, Susceptible) (s,i,r) = (s+1,i,r) aggregateAgentMapAux (_, Infected) (s,i,r) = (s,i+1,r) aggregateAgentMapAux (_, Recovered) (s,i,r) = (s,i,r+1) initSIRPure :: [SIRState] -> Int -> Double -> Double -> StdGen -> (SimState, EventQueue SIREvent) initSIRPure as cor inf ild rng = (ss0'', eq) where -- NOTE: sendSync does not work in initialisation sirAgent function (and -- also not required and would also violate semantics of the simulation as -- the simulation is not running yet and a send event would not make sense) -- Thus we use an empty map and ignore the returned (empty) map in -- createAgent. If an agent performs sendSync in the initialisation phase, -- it will always result in a Nothing because it ais = [0.. length as - 1] ss0 = SimState { simStateRng = rng, simStateAgents = Map.empty } (ss0', ret) = foldr createAgent (ss0, []) (zip ais as) (ags, ess0) = unzip ret es0 = concat ess0 am = Prelude.foldr (\(aid, a, s) acc -> Map.insert aid (a, s) acc) Map.empty (Prelude.zip3 ais ags as) eq = foldr PQ.insert PQ.empty es0 ss0'' = ss0' { simStateAgents = am } createAgent :: (AgentId, SIRState) -> (SimState, [(SIRAgent, [QueueItem SIREvent])]) -> (SimState, [(SIRAgent, [QueueItem SIREvent])]) createAgent (ai, s) (ss, acc) = (ss', (a, es) : acc) where (a, es, ss') = runSIRAgentPure 0 ai ais ss (sirAgent cor inf ild s) processQueue :: Int -> Double -> SimState -> EventQueue SIREvent -> [AgentId] -> [(Time, (Int, Int, Int))] -> [(Time, (Int, Int, Int))] processQueue 0 _ _ _ _ acc = acc -- terminated by externals of simulation: hit event limit processQueue n tLimit ss q ais acc -- terminated by internals of simulation model: no more events | isNothing mayHead = acc -- terminated by externals of simulation: hit time limit | evtTime > tLimit = acc -- event-receiver not found, next event | isNothing retMay = processQueue (n-1) tLimit ss q' ais acc -- event receiver found | otherwise = processQueue (n-1) tLimit ss' q'' ais acc' where mayHead = PQ.getMin q evt = fromJust mayHead evtTime = eventTime evt q' = PQ.drop 1 q retMay = processEvent ss ais evt (ss', es) = fromJust retMay -- insert new events into queue q'' = foldr PQ.insert q' es -- sample domain-state for current event (tPre, sirPre) = head acc sir = aggregateAgentMap (simStateAgents ss') acc' = if evtTime == tPre || sirPre == sir then (evtTime, sir) : tail acc else (evtTime, sir) : acc eventTime :: QueueItem e -> Time eventTime (QueueItem _ _ et) = et processEvent :: SimState -> [AgentId] -> QueueItem SIREvent -> Maybe (SimState, [QueueItem SIREvent]) processEvent ss ais (QueueItem e receiver evtTime) = do (a,_) <- Map.lookup receiver (simStateAgents ss) let agentAct = unMSF a e let ((ao, a'), es, ss') = runSIRAgentPure evtTime receiver ais ss agentAct let ss'' = ss' { simStateAgents = Map.insert receiver (a', ao) (simStateAgents ss') } Just (ss'', es) -------------------------------------------------------------------------------- -- INTERPRETER -------------------------------------------------------------------------------- runSIRAgentPure :: Time -> AgentId -> [AgentId] -> SimState -> SIRAgentPure a -> (a, [QueueItem SIREvent], SimState) runSIRAgentPure t ai ais ss agentAct = (ret, es, ss') where actEvtWriter = runReaderT (unSirAgentPure agentAct) (t, ai, ais) actState = runWriterT actEvtWriter ((ret, es), ss') = runState actState ss newtype SIRAgentPure a = SIRAgentPure { unSirAgentPure :: ReaderT (Time, AgentId, [AgentId]) (WriterT [QueueItem SIREvent] (State SimState)) a} deriving (Functor, Applicative, Monad, MonadWriter [QueueItem SIREvent], MonadReader (Time, AgentId, [AgentId]), MonadState SimState) runRandWithSimState :: MonadState SimState m => Rand StdGen a -> m a runRandWithSimState act = do g <- gets simStateRng let (ret, g') = runRand act g modify' (\s -> s { simStateRng = g' }) return ret instance MonadAgent SIREvent SIRAgentPure where randomBool = runRandWithSimState . randomBoolM randomElem = runRandWithSimState . randomElemM randomExp = runRandWithSimState . randomExpM -- schedEvent :: AgentId -> SIREvent -> Double -> m () schedEvent e receiver dt = do t <- getTime tell [QueueItem e receiver (t + dt)] -- getAgentIds :: m [AgentId] getAgentIds = asks trd -- getTime :: m Time getTime = asks fst3 getMyId = asks snd3 instance MonadAgentSync SIREvent SIRAgentPure where -- NOTE: this schedules an event with dt = 0 to the receiver by running the -- receiver and filtering the replies with dt = 0 to the sender sendSync evt receiverId = do -- get the id of the agent who initiates the synchronous send senderId <- getMyId -- don't allow to send to itself because this will cause problems when (receiverId == senderId) (error "sendSync semantic error: receiver and sender cannot be the same!") -- look for the receiver aMay <- Map.lookup receiverId <$> gets simStateAgents case aMay of -- not found, communicate to the initiating agent Nothing -> return Nothing -- receiver found, process (Just (aAct, _)) -> do -- get current time tNow <- getTime -- get all agent ids ais <- getAgentIds -- get sim state ss <- get -- IMPORTANT TODO -- Engageing in multiple sendSync e.g. agent A sendSync to -- Agent B which sendSync to agent C should work withouth problems BUT -- it is not allowed to sendSync to an agent which is already part -- of a sendSync "call stack": agent A sendSync -> agent B sendSync -> -- sendSync agent C -> agent A. -- This will result in wrong semantics: the last agent A will be -- overridden by the results of the first agent A, which is (proably) -- not what we want and (proably) results in erroneous / unexpected behaviour. -- get the receivers MSF by sending the event let receiverAct = unMSF aAct evt -- run the receiver let ((ao, aAct'), es, ss') = runSIRAgentPure tNow receiverId ais ss receiverAct -- update state put ss' -- update the agent MSF and update the State Monad with it modify' (\s -> s { simStateAgents = Map.insert receiverId (aAct', ao) (simStateAgents s)}) -- filter the events to the initiator: agent id has to match AND -- it has to be an instantaneous event with dt = 0/time to schedule is -- the current time. let esToSender = map (\(QueueItem e _ _) -> e) $ filter (\(QueueItem _ ai t) -> ai == senderId && t == tNow) es -- NOTE: all other events not in this list have to be put into the -- queue... this is not directly possible but we can use a trick: -- we simply add it to the initiator event writer using tell ;) let esOthers = filter (\(QueueItem _ ai t) -> not (ai == senderId || t == tNow)) es -- schedule the other events through the event writer of the initiator tell esOthers return (Just esToSender) fst3 :: (a,b,c) -> a fst3 (a,_,_) = a snd3 :: (a,b,c) -> b snd3 (_,b,_) = b trd :: (a,b,c) -> c trd (_,_,c) = c randomElemM :: MonadRandom m => [a] -> m a randomElemM es = do let len = length es idx <- getRandomR (0, len - 1) return $ es !! idx randomBoolM :: MonadRandom m => Double -> m Bool randomBoolM p = getRandomR (0, 1) >>= (\r -> return $ r <= p) randomExpM :: MonadRandom m => Double -> m Double randomExpM lambda = avoid 0 >>= (\r -> return ((-log r) / lambda)) where avoid :: (MonadRandom m, Eq a, Random a) => a -> m a avoid x = do r <- getRandom if r == x then avoid x else return r
thalerjonathan/phd
thesis/code/taglessfinal/src/SIR/Pure.hs
gpl-3.0
10,319
1
23
3,003
2,779
1,509
1,270
197
3
module Interface.Common where import Control.Applicative import Data.Either import Data.List (partition) import Data.Maybe import qualified Data.Text as Text import Game ( Color(..) , Tile(..) , maxValue , minValue ) import qualified Safe -- | Parse a list of tile specifications from input. parseTiles :: String -> ([Game.Tile], [Game.Tile]) parseTiles input = do if length (lefts tiles) > 0 then ([], []) else (concat $ rights removeTiles, concat $ rights addTiles) where tileStringToTile :: String -> Either String [Game.Tile] tileStringToTile tileString = if length tileString == 0 then Left "Provided empty string. Empty string is invalid." else if tileString == "j" then Right [Game.Joker] else if length colors == 0 || length values == 0 || head values < Game.minValue || last values > Game.maxValue then Left $ "Could not parse string: " ++ tileString else Right $ [Game.ValueTile (v, c) | v <- values, c <- colors] where colorMap = [('r', Game.Red) , ('l', Game.Blue) , ('y', Game.Yellow) , ('b', Game.Black)] colorChars = map fst colorMap (colorsPrefix, valueSuffix) = break (not . flip elem colorChars) tileString colors :: [Game.Color] colors = catMaybes $ map (flip lookup colorMap) colorsPrefix values = parseValueSuffix valueSuffix :: [Int] parseValueSuffix :: String -> [Int] parseValueSuffix valueStr = let bounds :: [Maybe Int] bounds = map (Safe.readMay . Text.unpack . Text.strip) . Text.splitOn (Text.pack "-") . Text.pack $ valueStr in if length bounds > 2 || length bounds == 0 || length (filter isNothing bounds) > 0 then [] else if length bounds == 2 then [(fromJust $ bounds !! 0) .. (fromJust $ bounds !! 1)] else [(fromJust $ bounds !! 0)] tileStrings = map (Text.unpack . Text.strip) . Text.splitOn (Text.pack ",") . Text.pack $ input (removeStrings, addStrings) = partition ((&&) <$> ((> 0) . length) <*> ((== '-') . head)) tileStrings addTiles = map tileStringToTile addStrings removeTiles = map (tileStringToTile . tail) removeStrings tiles = removeTiles ++ addTiles
gregorias/rummikubsolver
src/Interface/Common.hs
gpl-3.0
2,462
0
20
776
780
425
355
61
7
module Main where import Export.CSV import SIR.SD -- contact rate beta :: Double beta = 5 -- infectivity gamma :: Double gamma = 0.05 -- illness duration delta :: Double delta = 15.0 tLimit :: Double tLimit = 150 main :: IO () main = do let ret = runSIRSD 999 1 0 beta gamma delta tLimit --writeMatlabFile "sir-sd.m" ret writeCSVFile "sir-sd.csv" ret
thalerjonathan/phd
thesis/code/sir/src/MainSD.hs
gpl-3.0
470
0
10
182
105
59
46
22
1
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE FlexibleContexts #-} module Nucleic.Element ( Window, Element, ContainerElement, Style, style, DocumentM, asHTMLElement, runDocument, withDocument, attachChild, body, div, helem, para, text, textInput, inputButton, button, anchor, spacer, flow, row, rowrev, column ) where import Control.Monad.Reader (ReaderT , MonadIO, runReaderT, liftIO, ask) import Data.Monoid ((<>)) import Data.Text (Text) import qualified GHCJS.DOM as DOM import qualified GHCJS.DOM.Document as DOC import GHCJS.DOM.Element (elementGetAttribute, elementSetAttribute, elementOnkeyup, elementOnclick) import qualified GHCJS.DOM.EventM as EVT import qualified GHCJS.DOM.HTMLAnchorElement as ANCHOR import qualified GHCJS.DOM.HTMLButtonElement as BUTTON import qualified GHCJS.DOM.HTMLDivElement as DIV import GHCJS.DOM.HTMLElement (HTMLElement, castToHTMLElement) import qualified GHCJS.DOM.HTMLInputElement as INPUT import qualified GHCJS.DOM.HTMLParagraphElement as PARA import qualified GHCJS.DOM.Node as NODE import qualified GHCJS.DOM.Types as DTYPE import Prelude hiding (div) import Nucleic.IO (Signal, Edge, pushS, pushE) import Nucleic.Style (Style (..)) type Window = DOM.WebView type Element = HTMLElement type ContainerElement = DIV.HTMLDivElement type DocumentM e = (DTYPE.IsHTMLElement e, MonadIO m) => ReaderT DOC.Document m e type FlowLayout = (DTYPE.IsHTMLElement e) => ContainerElement -> [e] -> IO ContainerElement styleAttr :: Text styleAttr = "style" styleSep :: Text styleSep = ";" runDocument :: (DTYPE.IsHTMLElement e) => DocumentM e -> DOC.Document -> IO e runDocument docM doc = runReaderT docM doc withDocument :: (DTYPE.IsHTMLElement e) => DOC.Document -> DocumentM e -> IO e withDocument doc docM = runDocument docM doc -- Low Level Helpers style :: (DTYPE.IsHTMLElement e) => Style -> e -> DocumentM e style (Style s') e = appendStyle e s' appendStyle :: (DTYPE.IsHTMLElement e) => e -> Text -> DocumentM e appendStyle e style' = do _ <- liftIO $ do s <- (elementGetAttribute e styleAttr) :: IO Text elementSetAttribute e styleAttr (style' <> styleSep <> s) return e -- Flow Item -- Flow Container flowLayout :: Text -> FlowLayout flowLayout dir container elems = do elementSetAttribute container styleAttr (layout) mapM_ append elems return container where append e = NODE.nodeAppendChild container (Just e) layout = ("display:-webkit-flex;display:flex;-webkit-flex-direction:" ::Text) <> dir <> (";flex-direction:" :: Text) <> dir row :: FlowLayout row = flowLayout "row" rowrev :: FlowLayout rowrev = flowLayout "row-reverse" column :: FlowLayout column = flowLayout "column" spacer :: DocumentM ContainerElement spacer = div flow :: (DTYPE.IsHTMLElement e) => FlowLayout -> [e] -> DocumentM ContainerElement flow layout kids = do root <- div liftIO $ layout root kids --liftIO $ layout root kids --return root helem :: (DTYPE.IsHTMLElement e) => e -> Element helem e = castToHTMLElement e -- Elements div :: DocumentM ContainerElement div = do e <- createElement "div" [] return $ DIV.castToHTMLDivElement e -- Input Elements createElement :: Text -> [(Text,Text)] -> DocumentM Element createElement etype attrs = do doc <- ask liftIO $ do Just e <- DOC.documentCreateElement doc etype elementSetAttribute e styleAttr ("" :: Text) mapM_ (\(akey, aval) -> elementSetAttribute e akey aval) attrs let e' = castToHTMLElement e return e' anchor :: Text -> Text -> DocumentM ANCHOR.HTMLAnchorElement anchor txt href = do e <- createElement "a" [] _ <- liftIO $ do NODE.nodeSetTextContent e txt elementSetAttribute e ("href" :: Text) href return $ ANCHOR.castToHTMLAnchorElement e inputElement :: Text -> [(Text, Text)] -> DocumentM INPUT.HTMLInputElement inputElement itype attrs = do e <- createElement inputTag ((attrType, itype) : attrs) liftIO $ return (INPUT.castToHTMLInputElement e) where attrType = "type" :: Text inputTag = "input" :: Text inputButton :: Text -> DocumentM INPUT.HTMLInputElement inputButton label = inputElement inputType [("value" :: Text, label)] where inputType = "button" :: Text button :: Text -> Edge () -> DocumentM BUTTON.HTMLButtonElement button label evt = do e <- createElement "button" [] _ <- liftIO $ NODE.nodeSetTextContent e label let handler = liftIO $ pushE evt () liftIO $ elementOnclick e handler return $ BUTTON.castToHTMLButtonElement e textInput :: Signal Text -> Text -> DocumentM INPUT.HTMLInputElement textInput s val = do input <- inputElement inputTag [(attrType, textAttrInput), (attrDefault, val), (attrPlaceholder, val), (attrAuto, "true" :: Text)] let handler = do tgt <- EVT.target liftIO $ INPUT.htmlInputElementGetValue tgt >>= pushS s _ <- liftIO $ elementOnkeyup input handler return input where attrAuto = "autocomplete" :: Text attrDefault = "defaultValue" :: Text attrPlaceholder = "placeholder" :: Text attrType = "type" :: Text textAttrInput = "text" :: Text inputTag = "input" :: Text para :: Text -> DocumentM PARA.HTMLParagraphElement para txt = do e <- createElement "p" [] e' <- liftIO $ do let e'' = PARA.castToHTMLParagraphElement e NODE.nodeSetTextContent e'' txt return e'' return e' text :: Text -> DocumentM Element text txt = do e <- createElement "span" [] liftIO $ NODE.nodeSetTextContent e txt return e -- DOM body :: DocumentM Element body = do doc <- ask Just b <- liftIO $ DOC.documentGetBody doc return b attachChild :: (DTYPE.IsHTMLElement p, DTYPE.IsHTMLElement c) => c -> p -> DocumentM p attachChild c p = do _ <- liftIO $ NODE.nodeAppendChild (helem p) (Just (helem c)) return p asHTMLElement :: DTYPE.IsHTMLElement e => e -> DocumentM Element asHTMLElement = return . helem
RayRacine/nucleic
Nucleic/Element.hs
gpl-3.0
6,300
0
15
1,422
1,893
1,001
892
156
1
module Interface where import Language.Copilot import qualified Prelude as P ledPwmSet :: Stream Word8 -> Stream Float -> Spec ledPwmSet id val = trigger "led_pwm_set" (constB True) [arg id, arg val] btnStatus :: Stream Bool btnStatus = externFun "btn_status" [] $ Just $ constB False
yuchangyuan/copilot1
src/hs/Interface.hs
gpl-3.0
290
0
8
50
100
52
48
8
1
{-# LANGUAGE ScopedTypeVariables #-} import Text.Printf (printf) import Control.Exception (catch, IOException) tip, total :: Float -> Float -> Float tip amt rate = amt * (rate / 100) total amt rate = amt + tip amt rate promptF :: String -> IO Float promptF s = do putStr s (readLn :: IO Float) `catch` \ (ex :: IOException) -> promptFErr ex s promptFErr :: IOException -> String -> IO Float promptFErr ex s = do putStr "Couldn't parse that as a number. Haskell says:\n " print ex promptF s promptC :: String -> IO Char promptC s = do putStr s getChar continue :: IO () continue = do c <- promptC "Continue (Y/n) ? " putStrLn "" if c == 'N' || c == 'n' then putStrLn "Bye!" else main main :: IO () main = do amt <- promptF "Bill amount: " rate <- promptF "Tip rate as percentage: " if rate > 0 && amt > 0 then do putStrLn $ printf "Tip: $%.2f" (tip amt rate) putStrLn $ printf "Rate: $%.2f" (total amt rate) continue else do putStrLn "Invalid input: must be both positive numbers" continue
ciderpunx/57-exercises-for-programmers
src/tipcalc.hs
gpl-3.0
1,112
0
13
313
381
184
197
38
2
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveDataTypeable #-} {-| - - This module contains functions related to CLI arguement parsing and - dispatch. - -} module Main.CLI ( hkredmine , dispatch ) where import qualified Web.HTTP.Redmine as R import qualified Data.ByteString.Char8 as BC (pack) import qualified Data.ByteString.Lazy as LB (ByteString) import Control.Monad (when) import Control.Monad.IO.Class (liftIO) import Data.Aeson ((.=), object, encode, FromJSON) import Data.Maybe (isNothing, isJust, fromJust) import System.Console.CmdArgs import System.Directory (removeFile) import System.Environment (getEnv) import System.IO (hClose) import System.IO.Temp (withSystemTempDirectory, withTempFile) import System.Process (callProcess) import Web.HTTP.Redmine (Redmine, IssueFilter, redmineLeft, redmineMVar, redmineTakeMVar) import Main.Actions -- | Usage modes options for the CLI interface. data HKRedmine = Use { accountName :: String } | Status { } | Fields { } | Categories { projectIdent :: String } | Projects { } | Project { projectIdent :: String } | Issue { issueId :: Integer } | Issues { projectIdent :: String , trackerIdent :: String , statusIdent :: String , priorityIdent :: String , categoryIdent :: String , assignedTo :: String , sortByField :: String , limitTo :: Integer , issueOffset :: Integer } | Watched { projectIdent :: String , trackerIdent :: String , statusIdent :: String , priorityIdent :: String , categoryIdent :: String , assignedTo :: String , sortByField :: String , limitTo :: Integer , issueOffset :: Integer } | NewIssue { projectIdent :: String , trackerIdent :: String , statusIdent :: String , priorityIdent :: String , categoryIdent :: String , subject :: String , description :: String , versionId :: Integer , doneRatio :: Integer , editDescript :: Bool , isNotMine :: Bool } | Update { issueId :: Integer , projectIdent :: String , trackerIdent :: String , statusIdent :: String , priorityIdent :: String , categoryIdent :: String , subject :: String , description :: String , versionId :: Integer , doneRatio :: Integer , editDescript :: Bool , notes :: String } | Close { issueId :: Integer , comment :: Maybe String } | NewCat { projectIdent :: String , categoryName :: String , assignToMe :: Bool } | StartWork { issueId :: Integer } | StopWork { activityType :: Maybe String , timeComment :: Maybe String } | Pause { } | Resume { } | Abort { } | Watch { issueId :: Integer } | Unwatch { issueId :: Integer } | Versions { projectIdent :: String } | Version { versionId :: Integer , trackerIdent :: String , statusIdent :: String , priorityIdent :: String , categoryIdent :: String , assignedTo :: String , sortByField :: String , limitTo :: Integer , issueOffset :: Integer } | NextVersion { projectIdent :: String , trackerIdent :: String , statusIdent :: String , priorityIdent :: String , categoryIdent :: String , assignedTo :: String , sortByField :: String , limitTo :: Integer , issueOffset :: Integer } deriving (Show, Data, Typeable) -- | Route a 'HKRedmine' Mode to a 'Redmine' Action. dispatch :: HKRedmine -> Redmine () dispatch m = case m of Use a -> liftIO $ switchAccount a Status -> liftIO printStatus Fields -> printFields Categories p -> printCategories p Projects -> printProjects Project p -> printProject p Issue i -> printIssue i i@(Issues {}) -> argsToIssueFilter i >>= printIssues i@(Watched {}) -> argsToIssueFilter i >>= printIssues . (++ [ ("watcher_id", "me" ) ]) i@(NewIssue {}) -> argsToIssueObject i >>= createNewIssue i@(Update {}) -> argsToIssueObject i >>= R.updateIssue (issueId i) >> liftIO (putStrLn $ "Updated Issue #" ++ show (issueId i) ++ ".") Close i s -> closeIssue i s NewCat p c me -> newCategory p c me StartWork i -> startTimeTracking i StopWork a c -> stopTimeTracking a c Pause -> liftIO pauseTimeTracking Resume -> liftIO resumeTimeTracking Abort -> liftIO abortTimeTracking Watch i -> watchIssue i Unwatch i -> unwatchIssue i Versions p -> printVersions p v@(Version {}) -> argsToIssueFilter v >>= printVersion (versionId v) nv@(NextVersion {}) -> argsToIssueFilter nv >>= printNextVersion (projectIdent nv) -- | Available usage modes hkredmine :: Annotate Ann hkredmine = modes_ [ use, status , project, projects , issue, issues, watched, newissue, update, close, watch, unwatch , fields, categories, newcategory , startwork, stopwork, pause, resume, abort , version, versions, nextversion ] += help "A Redmine CLI client" += program "hkredmine" += summary "HKRedmine v0.1" -- | Default options for modes use, status, fields, categories, newcategory, projects, project, issue, issues, watched, newissue, update, close, startwork, stopwork, pause, resume, abort, watch, unwatch, versions, version, nextversion :: Annotate Ann use = record Use { accountName = def } [ accountName := def += argPos 0 += typ "ACCOUNTNAME" ] += help "Switch to a different redmine account." += details [ "Multiple accounts are available by adding a \"[AccountName]\" line" , "before each account's \"apikey\" and \"url\" in your ~/.hkredminerc:" , "" , "[account1]" , "apikey = \"longalphanumericstring\"" , "url = http://redmine.yourdomain.com/" , "" , "[account2]" , "apikey = \"differentkey\"" , "url = http://redmine.otherdomain.com/" , "" , "Then you can use the \"use\" command to switch to the second account:" , "hkredmine use account2" ] status = record Status {} [] += help "Print the current Account, Issue and Tracked Time." += auto fields = record Fields {} [] += help "Print available field values(Statuses, Priorities, etc.)." += groupname "Options" categories = record Categories { projectIdent = def } [ projectArg ] += help "Print a Project's Categories." += groupname "Options" projects = record Projects {} [] += help "Print all Projects." += groupname "Projects" project = record Project { projectIdent = def } [ projectArg ] += help "Print the details of a Project." += groupname "Projects" issue = record Issue { issueId = def } [ issueArg ] += help "Print the details of an Issue." += groupname "Issues" issues = record Issues { projectIdent = def, statusIdent = def , trackerIdent = def, priorityIdent = def , categoryIdent = def, assignedTo = def , sortByField = def, limitTo = def , issueOffset = def } [ projectFlag += groupname "Filter" , statusFlag "open" += groupname "Filter" += name "s" , trackerFlag += groupname "Filter" , priorityFlag += groupname "Filter" , categoryFlag += help "A Category Name. Requires a Project" += groupname "Filter" , assignedTo := "" += opt ("me" :: String) += name "userid" += name "u" += groupname "Filter" += explicit += help "A User ID(defaults to yours)" , issueOffset := 0 += typ "INT" += name "offset" += name "o" += explicit += groupname "Range" += help "Start listing Issues at this row number" , sortByField := "updated_on" += typ "FIELD" += name "sort" += name "S" += explicit += groupname "Sort" += help ("Comma-separated columns to sort by. Append " ++ "':desc' to reverse the sorting. Valid options " ++ "are project, priority, status, category, " ++ "updated_on and created_on" ) , limitTo := 20 += typ "INT" += name "limit" += name "n" += name "l" += explicit += groupname "Range" += help "Limit the number of Issues to show" ] += help "Filter and Print Issues." += groupname "Issues" += details [ "Run `hkredmine fields` for valid Status, Priority and" , "Tracker values." , "" , "Example Usage:" , "hkredmine issues -u" , "hkredmine issues -n 50 -p accounting-app -S priority" , "hkredmine issues --status=open -t Bug" , "hkredmine issues -S priority:desc" ] watched = record Watched { projectIdent = def, statusIdent = def , trackerIdent = def, priorityIdent = def , categoryIdent = def, assignedTo = def , sortByField = def, limitTo = def , issueOffset = def } [] += help "Filter and Print your Watched Issues." += groupname "Issues" newissue = record NewIssue { projectIdent = def, trackerIdent = def , statusIdent = def, priorityIdent = def , categoryIdent = def, isNotMine = def , subject = def, description = def , doneRatio = def, versionId = def , editDescript = False } [ projectFlag += groupname "Required" , subjectFlag += groupname "Required" , description := def += typ "STRING" += name "description" += name "d" += explicit += groupname "Optional" += help "A Full Description About the Issue" , statusFlag def += groupname "Optional" += name "a" , trackerFlag += groupname "Optional" , priorityFlag += groupname "Optional" , categoryFlag += help "A Category Name" += groupname "Optional" , isNotMine := def += name "not-mine" += name "n" += explicit += groupname "Optional" += help "Don't assign it to me" , versionId := def += typ "INT" += name "vers" += name "v" += explicit += groupname "Optional" += help "A Version's ID" , doneRatio := def += name "done-ratio" += name "r" += explicit += groupname "Optional" += help "The Percentage Completed" , editDescript := def += name "e" += name "edit-description" += explicit += help "Edit the description in $EDITOR. Ignores -d" ] += help "Create a New Issue." += groupname "Issues" += details [ "A minimum of a project and status are required to create an Issue:" , "hkredmine newissue -p my-project -s 'Do Some Things'" , "" , "You can also write the description in your $EDITOR by setting the '-e' flag:" , "hkredmine newissue -p my-project -s 'Test Writing Description in Vim' -e" , "" , "This may not work correctly if your $EDITOR runs asynchronously. Try" , "using a CLI text editor:" , "EDITOR=vim hkredmine newissue -e ..." ] update = record Update { issueId = def, projectIdent = def , trackerIdent = def, statusIdent = def , priorityIdent = def, categoryIdent = def , subject = def, description = def , versionId = def, doneRatio = def , editDescript = False , notes = def } [ issueArg , projectFlag += groupname "Optional" , subjectFlag += groupname "Optional" , notes := def += typ "STRING" += name "comment" += name "n" += groupname "Optional" += explicit += help "A Comment about the Update" ] += help "Update an New Issue." += groupname "Issues" newcategory = record NewCat { projectIdent = def, categoryName = def , assignToMe = def } [ projectArg , categoryName := def += argPos 1 += typ "NAME" , assignToMe := def += name "me" += name "m" += explicit += help "Assign Issue's to You" ] += name "newcategory" += help "Create a Category." += groupname "Options" += details [ "hkredmine newcategory my-proj \"My Category\" -m" ] close = record Close { issueId = def, comment = def } [ issueArg , comment := def += typ "STRING" += name "comment" += name "c" += explicit += help "A Comment to Include" ] += help "Close an Issue." += groupname "Issues" += details [ "This command changes and Issue's status to Closed, it's Done Ratio to 100%" , "and the Due Date to today, if previously unset:" , "" , "hkredmine close 154" , "" , "You can modify the comment that is added:" , "" , "hkredmine close 154 -c \"Merged into master\"" ] watch = record Watch { issueId = def } [ issueArg ] += help "Watch an Issue." += groupname "Issues" unwatch = record Unwatch { issueId = def } [ issueArg ] += help "Unwatch an Issue." += groupname "Issues" startwork = record StartWork { issueId = def } [ issueArg ] += help "Start tracking time for an Issue." += groupname "Time Tracking" stopwork = record StopWork { activityType = def, timeComment = def } [ activityType := Nothing += typ "ACTIVITYNAME" += name "activity" += name "a" += explicit += help "The time entry activity to use." , timeComment := Nothing += typ "STRING" += name "comment" += name "c" += explicit += help "A comment to add with the time entry." ] += help "Stop time tracking and submit a time entry." += groupname "Time Tracking" += details [ "This command stops tracking time for the current Issue, prompts for a" , "Time Entry Activity and Comment and creates a new Time Entry using" , "these values." , "" , "Flags can be passed to skip the prompts:" , "" , "hkredmine stopwork" , "hkredmine stopwork --comment=\"Responding to User Bug Reports\"" , "hkredmine stopwork -a Design -c \"Write specs\"" , "" , "Run `hkredmine fields` to get the available Time Entry Activities." ] pause = record Pause {} [] += help "Pause time tracking." += groupname "Time Tracking" resume = record Resume {} [] += help "Resume time tracking." += groupname "Time Tracking" abort = record Abort {} [] += help "Abort time tracking." += groupname "Time Tracking" version = record Version { versionId = def, statusIdent = def , trackerIdent = def, priorityIdent = def , categoryIdent = def, assignedTo = def , sortByField = def, limitTo = def , issueOffset = def } [ versionId := def += argPos 0 += typ "VERSIONID" , statusFlag "open" += groupname "Filter" += name "s" , trackerFlag += groupname "Filter" , priorityFlag += groupname "Filter" , categoryFlag += help "A Category Name. Requires a Project" += groupname "Filter" ] += help "Print the details of a Version." += groupname "Versions" nextversion = record NextVersion { projectIdent = def, statusIdent = def , trackerIdent = def, priorityIdent = def , categoryIdent = def, assignedTo = def , sortByField = def, limitTo = def , issueOffset = def } [ projectArg ] += help "Print the next Version due for a Project." += groupname "Versions" versions = record Versions { projectIdent = def } [ projectArg ] += help "Print all of a Project's Versions." += groupname "Versions" -- Standard Arguments projectArg, issueArg, projectFlag, trackerFlag, priorityFlag, categoryFlag, subjectFlag :: Annotate Ann -- | Make the projectIdent the first required argument. projectArg = projectIdent := def += argPos 0 += typ "PROJECTIDENT" -- | Make the issueId the first required arugment. issueArg = issueId := def += argPos 0 += typ "ISSUEID" -- | An optional flag for a projectIdent argument. projectFlag = projectIdent := def += typ "PROJECTIDENT" += name "project" += name "p" += explicit += help "A Project's Identifier or ID" -- | An optional flag for a trackerIdent argument. trackerFlag = trackerIdent := def += typ "TRACKERNAME" += name "tracker" += name "t" += explicit += help "A Tracker Name" -- | An optional flag for a priorityIdent argument. priorityFlag = priorityIdent := def += typ "PRIORITYNAME" += name "priority" += name "i" += explicit += help "A Priority Name" -- | An optional flag for a categoryIdent argument. categoryFlag = categoryIdent := def += typ "CATEGORYNAME" += name "category" += name "c" += explicit -- | An optional flag for a subject argument. subjectFlag = subject := def += typ "STRING" += name "subject" += name "s" += explicit += help "The Issue's Subject" -- | An optional flag for a statusIdent argument. statusFlag :: String -> Annotate Ann statusFlag d = statusIdent := d += typ "STATUS" += name "status" += explicit += help "A Status Name" -- Utils -- | Transform the arguements of the Issues mode into an IssueFilter. The -- special statuses "open", "closed" and "*" are also allowed. argsToIssueFilter :: HKRedmine -> Redmine IssueFilter argsToIssueFilter i@(Issues {}) = do projectFork <- redmineMVar . R.getProjectFromIdent $ projectIdent i trackerFork <- redmineMVar . grabFromName R.getTrackerFromName "Tracker" $ trackerIdent i priorityFork <- redmineMVar . grabFromName R.getPriorityFromName "Priority" $ priorityIdent i statusFork <- redmineMVar . R.getStatusFromName $ statusIdent i filterProject <- if projectIdent i /= "" then Just <$> redmineTakeMVar projectFork else return Nothing categoryFork <- redmineMVar $ case (categoryIdent i, projectIdent i) of ("", "") -> return "" ("", _) -> return "" (_, "") -> redmineLeft $ "You must filter by Project if " ++ "you want to filter by Category." (c, _) -> show . R.categoryId <$> grabFromName (R.getCategoryFromName . R.projectId $ fromJust filterProject) "Category" c filterTracker <- redmineTakeMVar trackerFork filterPriority <- redmineTakeMVar priorityFork filterStatus <- redmineTakeMVar statusFork filterCategory <- redmineTakeMVar categoryFork when (isNothing filterStatus && statusIdent i `notElem` ["", "open", "closed", "*"]) $ redmineLeft "Not a valid Status name." return . map packIt $ [ ("project_id", R.projectIdentifier $ fromJust filterProject) | isJust filterProject ] ++ [ ("tracker_id", show . R.trackerId $ filterTracker) | trackerIdent i /= "" ] ++ [ ("status_id", show . R.statusId $ fromJust filterStatus) | statusIdent i `notElem` ["", "open", "closed", "*"] ] ++ [ ("status_id", statusIdent i) | statusIdent i `elem` ["open", "closed", "*"] ] ++ [ ("priority_id", show . R.priorityId $ filterPriority) | priorityIdent i /= "" ] ++ [ ("assigned_to_id", assignedTo i) | assignedTo i /= "" ] ++ [ ("category_id", filterCategory) | filterCategory /= "" ] ++ [ ("sort", sortByField i) , ("limit", show $ limitTo i) , ("offset", show $ issueOffset i) ] where packIt (s1, s2) = (s1, BC.pack s2) argsToIssueFilter w@(Watched {}) = argsToIssueFilter Issues { projectIdent = projectIdent w , trackerIdent = trackerIdent w , statusIdent = statusIdent w , priorityIdent = priorityIdent w , categoryIdent = categoryIdent w , assignedTo = assignedTo w , sortByField = sortByField w , limitTo = limitTo w , issueOffset = issueOffset w } argsToIssueFilter v@(Version {}) = do vers <- R.getVersion $ versionId v argsToIssueFilter Issues { projectIdent = show $ R.versionProjectId vers , trackerIdent = trackerIdent v , statusIdent = statusIdent v , priorityIdent = priorityIdent v , categoryIdent = categoryIdent v , assignedTo = assignedTo v , sortByField = sortByField v , limitTo = limitTo v , issueOffset = issueOffset v } argsToIssueFilter v@(NextVersion {}) = argsToIssueFilter Issues { projectIdent = projectIdent v , trackerIdent = trackerIdent v , statusIdent = statusIdent v , priorityIdent = priorityIdent v , categoryIdent = categoryIdent v , assignedTo = assignedTo v , sortByField = sortByField v , limitTo = limitTo v , issueOffset = issueOffset v } argsToIssueFilter _ = redmineLeft "Tried applying an issue filter to non-issue command." -- | Transform the arguments of the NewIssue mode into a JSON object for -- the 'createIssue' API function. argsToIssueObject :: HKRedmine -> Redmine LB.ByteString argsToIssueObject i@(NewIssue {}) = do when (projectIdent i == "" || subject i == "") $ redmineLeft "Both a Project Identifier and a Subject are required." (validProject, validTracker, validPriority, validStatus, validCategory) <- validateIssueOptions (projectIdent i) (trackerIdent i) (priorityIdent i) (statusIdent i) (categoryIdent i) currentUser <- R.getCurrentUser actualDescript <- if editDescript i then liftIO getTextFromEditor else return $ description i return . encode $ object [ "issue" .= object ( [ "project_id" .= show (R.projectId validProject) , "subject" .= subject i ] ++ [ "tracker_id" .= show (R.trackerId validTracker) | trackerIdent i /= "" ] ++ [ "priority_id" .= show (R.priorityId validPriority) | priorityIdent i /= "" ] ++ [ "status_id" .= show (R.statusId validStatus) | statusIdent i /= "" ] ++ [ "assigned_to_id" .= show (R.userId currentUser) | not (isNotMine i) ] ++ [ "fixed_version_id" .= versionId i | versionId i /= 0 ] ++ [ "category_id" .= show (R.categoryId validCategory) | categoryIdent i /= "" ] ++ [ "done_ratio" .= show (doneRatio i) | doneRatio i /= 0 ] ++ [ "description" .= actualDescript | actualDescript /= "" ] ) ] argsToIssueObject u@(Update {}) = do i <- R.getIssue $ issueId u (validProject, validTracker, validPriority, validStatus, validCategory) <- validateIssueOptions (if projectIdent u /= "" then projectIdent u else show $ R.issueProjectId i) (trackerIdent u) (priorityIdent u) (statusIdent u) (categoryIdent u) actualDescript <- if editDescript u then liftIO $ editTextInEditor $ R.issueDescription i else return $ description u return . encode $ object [ "issue" .= object ( [ "project_id" .= show (R.projectId validProject) ] ++ [ "subject" .= subject u | subject u /= "" ] ++ [ "tracker_id" .= show (R.trackerId validTracker) | trackerIdent u /= "" ] ++ [ "priority_id" .= show (R.priorityId validPriority) | priorityIdent u /= "" ] ++ [ "status_id" .= show (R.statusId validStatus) | statusIdent u /= "" ] ++ [ "fixed_version_id" .= versionId u | versionId u /= 0 ] ++ [ "category_id" .= show (R.categoryId validCategory) | categoryIdent u /= "" ] ++ [ "done_ratio" .= show (doneRatio u) | doneRatio u /= 0 ] ++ [ "description" .= actualDescript | actualDescript /= "" ] ++ [ "notes" .= notes u | notes u /= "" ] ) ] argsToIssueObject _ = redmineLeft "The wrong command tried parsing newissues arguments." -- | Concurrently validate a Project, Tracker, Priority, Status and Category. validateIssueOptions :: R.ProjectIdent -- ^ The Project Identifier -> String -- ^ The Tracker Name -> String -- ^ The Priority Name -> String -- ^ The Status Name -> String -- ^ The Category Name -> Redmine (R.Project, R.Tracker, R.Priority, R.Status, R.Category) validateIssueOptions p t i s c = do projectFork <- redmineMVar . R.getProjectFromIdent $ p trackerFork <- redmineMVar . grabFromName R.getTrackerFromName "Tracker" $ t priorityFork <- redmineMVar . grabFromName R.getPriorityFromName "Priority" $ i statusFork <- redmineMVar . grabFromName R.getStatusFromName "Status" $ s validProject <- redmineTakeMVar projectFork categoryFork <- redmineMVar . grabFromName (R.getCategoryFromName $ R.projectId validProject) "Category" $ c validTracker <- redmineTakeMVar trackerFork validPriority <- redmineTakeMVar priorityFork validStatus <- redmineTakeMVar statusFork validCategory <- redmineTakeMVar categoryFork return (validProject, validTracker, validPriority, validStatus, validCategory) -- | Get an item from it's name or return an error. grabFromName :: FromJSON a => (String -> Redmine (Maybe a)) -> String -> String -> Redmine a grabFromName grab item itemName = do mayValue <- grab itemName when (isNothing mayValue && itemName /= "") $ redmineLeft $ "Not a valid " ++ item ++ " name." return $ fromJust mayValue -- | Open a temporary file with the user's editor and return it's final -- contents. getTextFromEditor :: IO String getTextFromEditor = editTextInEditor "\n" -- | Write a string to a Temporary File, open the file in the $EDITOR and -- return the final contents. editTextInEditor :: String -> IO String editTextInEditor s = withSystemTempDirectory "hkredmine" $ \dir -> do fn <- withTempFile dir "hkr.redmine" (\fn' fh -> hClose fh >> return fn') writeFile fn s contents <- openInEditorAndRead fn removeFile fn >> return contents -- | Open a file in the User's $EDITOR, read and return the contents -- afterwards. openInEditorAndRead :: FilePath -> IO String openInEditorAndRead fn = getEnv "EDITOR" >>= flip callProcess [fn] >> readFile fn
prikhi/hkredmine
bin/Main/CLI.hs
gpl-3.0
33,852
6
27
14,940
6,413
3,412
3,001
640
23
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, RankNTypes#-} {-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Numerical.PETSc.Internal.PutGet.PF -- Copyright : (c) Marco Zocca 2015 -- License : LGPL3 -- Maintainer : zocca . marco . gmail . com -- Stability : experimental -- -- | PF Mid-level interface -- ----------------------------------------------------------------------------- module Numerical.PETSc.Internal.PutGet.PF where import Numerical.PETSc.Internal.InlineC import Numerical.PETSc.Internal.Types import Numerical.PETSc.Internal.Exception import Numerical.PETSc.Internal.Utils import Foreign import Foreign.C.Types import System.IO.Unsafe (unsafePerformIO) import Control.Monad import Control.Arrow import Control.Concurrent import Control.Exception import Control.Monad.ST (ST, runST) import Control.Monad.ST.Unsafe (unsafeIOToST) -- for HMatrix bits import qualified Data.Vector as V import qualified Data.Vector.Storable as V (unsafeWith, unsafeFromForeignPtr, unsafeToForeignPtr) pfCreate :: Comm -> Int -> -- dimension of domain Int -> -- dimension of range IO PF pfCreate comm dimin dimout = chk1 $ pfCreate' comm dimin dimout pfDestroy :: PF -> IO () pfDestroy pf = chk0 $ pfDestroy' pf withPf :: Comm -> Int -> Int -> (PF -> IO a) -> IO a withPf comm dimin dimout = bracket (pfCreate comm dimin dimout) pfDestroy dmdaCreatePF :: DM -> IO PF dmdaCreatePF dm = chk1 $ dmdaCreatePF' dm -- pfSetType pf t
ocramz/petsc-hs
src/Numerical/PETSc/Internal/PutGet/PF.hs
gpl-3.0
1,540
0
11
232
308
184
124
30
1
{-# LANGUAGE DeriveDataTypeable #-} -- | -- Copyright : (c) 2010, 2011 Benedikt Schmidt & Simon Meier -- License : GPL v3 (see LICENSE) -- -- Maintainer : Simon Meier <iridcode@gmail.com> -- Portability : GHC only -- -- Main module for the Tamarin prover. module Main.Mode.Batch ( batchMode ) where import Control.Basics import Control.DeepSeq (force) import Control.Exception (evaluate) import Data.List import Data.Maybe import System.Console.CmdArgs.Explicit as CmdArgs import System.FilePath import System.Timing (timed) import qualified Text.PrettyPrint.Class as Pretty import Theory import Theory.Tools.Wellformedness (checkWellformedness, checkWellformednessDiff) import Main.Console import Main.Environment import Main.TheoryLoader import Main.Utils -- import Debug.Trace -- | Batch processing mode. batchMode :: TamarinMode batchMode = tamarinMode "batch" "Security protocol analysis and verification." setupFlags run where setupFlags defaultMode = defaultMode { modeArgs = ([], Just $ flagArg (updateArg "inFile") "FILES") , modeGroupFlags = Group { groupUnnamed = theoryLoadFlags ++ -- [ flagNone ["html"] (addEmptyArg "html") -- "generate HTML visualization of proofs" [ flagNone ["no-compress"] (addEmptyArg "noCompress") "Do not use compressed sequent visualization" , flagNone ["parse-only"] (addEmptyArg "parseOnly") "Just parse the input file and pretty print it as-is" ] ++ outputFlags ++ toolFlags , groupHidden = [] , groupNamed = [] } } outputFlags = [ flagOpt "" ["output","o"] (updateArg "outFile") "FILE" "Output file" , flagOpt "" ["Output","O"] (updateArg "outDir") "DIR" "Output directory" ] -- | Process a theory file. run :: TamarinMode -> Arguments -> IO () run thisMode as | null inFiles = helpAndExit thisMode (Just "no input files given") | otherwise = do _ <- ensureMaude as putStrLn $ "" summaries <- mapM processThy $ inFiles putStrLn $ "" putStrLn $ replicate 78 '=' putStrLn $ "summary of summaries:" putStrLn $ "" putStrLn $ renderDoc $ Pretty.vcat $ intersperse (Pretty.text "") summaries putStrLn $ "" putStrLn $ replicate 78 '=' where -- handles to arguments ----------------------- inFiles = reverse $ findArg "inFile" as -- output generation -------------------- dryRun = not (argExists "outFile" as || argExists "outDir" as) mkOutPath :: FilePath -- ^ Input file name. -> FilePath -- ^ Output file name. mkOutPath inFile = fromMaybe (error "please specify an output file or directory") $ do outFile <- findArg "outFile" as guard (outFile /= "") return outFile <|> do outDir <- findArg "outDir" as return $ mkAutoPath outDir (takeBaseName inFile) -- automatically generate the filename for output mkAutoPath :: FilePath -> String -> FilePath mkAutoPath dir baseName | argExists "html" as = dir </> baseName | otherwise = dir </> addExtension (baseName ++ "_analyzed") "spthy" -- theory processing functions ------------------------------ processThy :: FilePath -> IO (Pretty.Doc) processThy inFile -- | argExists "html" as = -- generateHtml inFile =<< loadClosedThy as inFile | (argExists "parseOnly" as) && (argExists "diff" as) = out (const Pretty.emptyDoc) prettyOpenDiffTheory (loadOpenDiffThy as inFile) | argExists "parseOnly" as = out (const Pretty.emptyDoc) prettyOpenTranslatedTheory (loadOpenThy as inFile) | argExists "diff" as = out ppWfAndSummaryDiff prettyClosedDiffTheory (loadClosedDiffThy as inFile) | otherwise = out ppWfAndSummary prettyClosedTheory (loadClosedThy as inFile) where ppAnalyzed = Pretty.text $ "analyzed: " ++ inFile ppWfAndSummary thy = case checkWellformedness (removeSapicItems (openTheory thy)) of [] -> Pretty.emptyDoc errs -> Pretty.vcat $ map Pretty.text $ [ "WARNING: " ++ show (length errs) ++ " wellformedness check failed!" , " The analysis results might be wrong!" ] Pretty.$--$ prettyClosedSummary thy ppWfAndSummaryDiff thy = case checkWellformednessDiff (openDiffTheory thy) of [] -> Pretty.emptyDoc errs -> Pretty.vcat $ map Pretty.text $ [ "WARNING: " ++ show (length errs) ++ " wellformedness check failed!" , " The analysis results might be wrong!" ] Pretty.$--$ prettyClosedDiffSummary thy out :: (a -> Pretty.Doc) -> (a -> Pretty.Doc) -> IO a -> IO Pretty.Doc out summaryDoc fullDoc load | dryRun = do thy <- load putStrLn $ renderDoc $ fullDoc thy return $ ppAnalyzed Pretty.$--$ Pretty.nest 2 (summaryDoc thy) | otherwise = do putStrLn $ "" putStrLn $ "analyzing: " ++ inFile putStrLn $ "" let outFile = mkOutPath inFile (thySummary, t) <- timed $ do thy <- load writeFileWithDirs outFile $ renderDoc $ fullDoc thy -- ensure that the summary is in normal form evaluate $ force $ summaryDoc thy let summary = Pretty.vcat [ ppAnalyzed , Pretty.text $ "" , Pretty.text $ " output: " ++ outFile , Pretty.text $ " processing time: " ++ show t , Pretty.text $ "" , Pretty.nest 2 thySummary ] putStrLn $ replicate 78 '-' putStrLn $ renderDoc summary putStrLn $ "" putStrLn $ replicate 78 '-' return summary {- TO BE REACTIVATED once infrastructure from interactive mode can be used -- static html generation ------------------------- generateHtml :: FilePath -- ^ Input file -> ClosedTheory -- ^ Theory to pretty print -> IO () generateHtml inFile thy = do cmdLine <- getCommandLine time <- getCurrentTime cpu <- getCpuModel template <- getHtmlTemplate theoryToHtml $ GenerationInput { giHeader = "Generated by " ++ htmlVersionStr , giTime = time , giSystem = cpu , giInputFile = inFile , giTemplate = template , giOutDir = mkOutPath inFile , giTheory = thy , giCmdLine = cmdLine , giCompress = not $ argExists "noCompress" as } -}
kmilner/tamarin-prover
src/Main/Mode/Batch.hs
gpl-3.0
7,447
0
19
2,743
1,395
702
693
125
3
-- -*-haskell-*- -- Vision (for the Voice): an XMMS2 client. -- -- Author: Oleg Belozeorov -- Created: 2 Jul. 2010 -- -- Copyright (C) 2010 Oleg Belozeorov -- -- 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. -- module Playlist.Control ( clearPlaylist , currentTrackThisPlaylist , removeTracks , insertIds , moveTracks , playTrack , showPropertyEditor , showPropertyExport , getOrder , setOrder , insertURIs ) where import Control.Monad import Control.Monad.Trans import Data.Maybe import Network.URL import XMMS2.Client import XMMS import Utils import Playback import qualified Properties as P import Playlist.Model import Playlist.View clearPlaylist = do playlistClear xmms =<< getPlaylistName return () currentTrackThisPlaylist = do maybeName <- getPlaylistName maybeCPos <- getCurrentTrack return $ case (maybeName, maybeCPos) of (Just pname, Just (track, cname)) | pname == cname -> Just track _ -> Nothing removeTracks tracks = do name <- getPlaylistName mapM_ (playlistRemoveEntry xmms name) $ reverse tracks insertIds ids pos = do start <- case pos of Just n -> return n Nothing -> getPlaylistSize name <- getPlaylistName zipWithM_ (playlistInsertId xmms name) [start .. ] ids moveTracks tracks = do name <- getPlaylistName mapM_ (uncurry (playlistMoveEntry xmms name)) tracks playTrack n = do playlistSetNext xmms $ fromIntegral n startPlayback True showPropertyEditor = withSelectedIds P.showPropertyEditor showPropertyExport = withSelectedIds P.showPropertyExport withSelectedIds f = do trs <- getSelectedTracks ids <- playlistGetIds trs f ids getOrder = return [] setOrder order = do name <- getPlaylistName playlistSort xmms name $ P.encodeOrder order return () insertURIs uris pos = do name <- getPlaylistName base <- case pos of Just n -> return n Nothing -> getPlaylistSize insertURIs' name base . mapMaybe (decString False) $ reverse uris insertURIs' _ _ [] = return () insertURIs' name base (uri : rest) = xformMediaBrowse xmms uri >>* do isDir <- catchResult False (const True) liftIO $ if isDir then do playlistRInsert xmms name base uri insertURIs' name base rest else do let insertColl coll = do playlistInsertCollection xmms name base coll [] return () insertURL = do playlistInsertURL xmms name base uri return () collIdlistFromPlaylistFile xmms uri >>* do func <- catchResult insertURL insertColl liftIO $ do func insertURIs' name base rest
upwawet/vision
src/Playlist/Control.hs
gpl-3.0
3,131
0
18
743
762
373
389
88
2
{- lat - tool to track alerts from LWN. - Copyright (C) 2010 Magnus Therning - - 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, version 3 of the License. - - 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 Main ( main ) where import qualified Commands as C main = C.doCommand
magthe/lat
src/lat.hs
gpl-3.0
771
0
5
161
23
16
7
4
1
{-# LANGUAGE NoMonomorphismRestriction#-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NamedFieldPuns #-} module Bamboo.Controller.Helper where import Bamboo.Controller.Type import Bamboo.Env hiding (get) import Bamboo.Type.State import Control.Monad.State import Data.Default import Data.List hiding (length) import Data.Maybe import Hack import System.IO as IO import qualified Bamboo.Model.Comment as Comment import qualified Bamboo.Model.Post as Post import qualified Bamboo.Model.Tag as Tag import qualified Bamboo.Type.Pager as Pager import qualified Bamboo.Type.State as S import qualified Hack import qualified Hack.Contrib.Request as Request init_state :: Controller init_state = fill_latest_posts >> fill_tags params, inputs :: Env -> Assoc params = Request.params > map_fst b2u > map_snd b2u inputs = Request.inputs > map_fst b2u > map_snd b2u param_with_default, input_with_default :: String -> String -> Env -> String param_with_default s d env = env .get_param s .fromMaybe d input_with_default s d env = env .get_input s .fromMaybe d get_param, get_input :: String -> Env -> Maybe String get_param s env = env .params .lookup s get_input s env = env .inputs .lookup s just_param, just_input :: String -> Env -> String just_param s env = env .get_param s .fromJust just_input s env = env .get_input s .fromJust io :: (MonadIO m) => IO a -> m a io = liftIO fill_latest_posts :: Part () fill_latest_posts = do s <- get latest_posts <- Post.latest ( s.config.number_of_latest_posts ) .io put s { latest_posts } fill_tags :: Part () fill_tags = do s <- get tags <- list .io put s { tags } paginate :: [a] -> Part Pager paginate xs = do s <- get let per_page' = s.config.per_page current = s.env.param_with_default "page" "1" .read total = xs.length has_next = current * per_page' < total.from_i has_previous = current `gt` n1 next = current + n1 previous = current + (- n1) n1 = 1 :: Int return def { Pager.per_page = per_page' , current , has_next , has_previous , next , previous , total } paged :: [a] -> Part ([a], Pager) paged xs = do pager <- paginate xs return (xs.for_current_page pager, pager) for_current_page :: Pager -> [a] -> [a] for_current_page p xs = xs .drop ((p.current - 1) * p.Pager.per_page) .take (p.Pager.per_page) init_post_meta_data :: Post.Post -> Part Post.Post init_post_meta_data x = do tags <- get ^ tags x .Tag.fill_tag tags .Comment.fill_comment_size .io run :: Controller -> View -> Application run x v env = execStateT x def {env} >>= v not_found :: Controller not_found = get >>= \s -> put s {S.status = 404}
nfjinjing/bamboo
src/Bamboo/Controller/Helper.hs
gpl-3.0
2,779
22
12
622
930
505
425
-1
-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.AndroidPublisher.Edits.ExpansionFiles.Patch -- Copyright : (c) 2015-2016 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay <brendan.g.hay@gmail.com> -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Patches the APK\'s expansion file configuration to reference another -- APK\'s expansion file. To add a new expansion file use the Upload -- method. -- -- /See:/ <https://developers.google.com/android-publisher Google Play Android Developer API Reference> for @androidpublisher.edits.expansionfiles.patch@. module Network.Google.Resource.AndroidPublisher.Edits.ExpansionFiles.Patch ( -- * REST Resource EditsExpansionFilesPatchResource -- * Creating a Request , editsExpansionFilesPatch , EditsExpansionFilesPatch -- * Request Lenses , eefpXgafv , eefpUploadProtocol , eefpPackageName , eefpAPKVersionCode , eefpAccessToken , eefpUploadType , eefpPayload , eefpExpansionFileType , eefpEditId , eefpCallback ) where import Network.Google.AndroidPublisher.Types import Network.Google.Prelude -- | A resource alias for @androidpublisher.edits.expansionfiles.patch@ method which the -- 'EditsExpansionFilesPatch' request conforms to. type EditsExpansionFilesPatchResource = "androidpublisher" :> "v3" :> "applications" :> Capture "packageName" Text :> "edits" :> Capture "editId" Text :> "apks" :> Capture "apkVersionCode" (Textual Int32) :> "expansionFiles" :> Capture "expansionFileType" EditsExpansionFilesPatchExpansionFileType :> QueryParam "$.xgafv" Xgafv :> QueryParam "upload_protocol" Text :> QueryParam "access_token" Text :> QueryParam "uploadType" Text :> QueryParam "callback" Text :> QueryParam "alt" AltJSON :> ReqBody '[JSON] ExpansionFile :> Patch '[JSON] ExpansionFile -- | Patches the APK\'s expansion file configuration to reference another -- APK\'s expansion file. To add a new expansion file use the Upload -- method. -- -- /See:/ 'editsExpansionFilesPatch' smart constructor. data EditsExpansionFilesPatch = EditsExpansionFilesPatch' { _eefpXgafv :: !(Maybe Xgafv) , _eefpUploadProtocol :: !(Maybe Text) , _eefpPackageName :: !Text , _eefpAPKVersionCode :: !(Textual Int32) , _eefpAccessToken :: !(Maybe Text) , _eefpUploadType :: !(Maybe Text) , _eefpPayload :: !ExpansionFile , _eefpExpansionFileType :: !EditsExpansionFilesPatchExpansionFileType , _eefpEditId :: !Text , _eefpCallback :: !(Maybe Text) } deriving (Eq, Show, Data, Typeable, Generic) -- | Creates a value of 'EditsExpansionFilesPatch' with the minimum fields required to make a request. -- -- Use one of the following lenses to modify other fields as desired: -- -- * 'eefpXgafv' -- -- * 'eefpUploadProtocol' -- -- * 'eefpPackageName' -- -- * 'eefpAPKVersionCode' -- -- * 'eefpAccessToken' -- -- * 'eefpUploadType' -- -- * 'eefpPayload' -- -- * 'eefpExpansionFileType' -- -- * 'eefpEditId' -- -- * 'eefpCallback' editsExpansionFilesPatch :: Text -- ^ 'eefpPackageName' -> Int32 -- ^ 'eefpAPKVersionCode' -> ExpansionFile -- ^ 'eefpPayload' -> EditsExpansionFilesPatchExpansionFileType -- ^ 'eefpExpansionFileType' -> Text -- ^ 'eefpEditId' -> EditsExpansionFilesPatch editsExpansionFilesPatch pEefpPackageName_ pEefpAPKVersionCode_ pEefpPayload_ pEefpExpansionFileType_ pEefpEditId_ = EditsExpansionFilesPatch' { _eefpXgafv = Nothing , _eefpUploadProtocol = Nothing , _eefpPackageName = pEefpPackageName_ , _eefpAPKVersionCode = _Coerce # pEefpAPKVersionCode_ , _eefpAccessToken = Nothing , _eefpUploadType = Nothing , _eefpPayload = pEefpPayload_ , _eefpExpansionFileType = pEefpExpansionFileType_ , _eefpEditId = pEefpEditId_ , _eefpCallback = Nothing } -- | V1 error format. eefpXgafv :: Lens' EditsExpansionFilesPatch (Maybe Xgafv) eefpXgafv = lens _eefpXgafv (\ s a -> s{_eefpXgafv = a}) -- | Upload protocol for media (e.g. \"raw\", \"multipart\"). eefpUploadProtocol :: Lens' EditsExpansionFilesPatch (Maybe Text) eefpUploadProtocol = lens _eefpUploadProtocol (\ s a -> s{_eefpUploadProtocol = a}) -- | Package name of the app. eefpPackageName :: Lens' EditsExpansionFilesPatch Text eefpPackageName = lens _eefpPackageName (\ s a -> s{_eefpPackageName = a}) -- | The version code of the APK whose expansion file configuration is being -- read or modified. eefpAPKVersionCode :: Lens' EditsExpansionFilesPatch Int32 eefpAPKVersionCode = lens _eefpAPKVersionCode (\ s a -> s{_eefpAPKVersionCode = a}) . _Coerce -- | OAuth access token. eefpAccessToken :: Lens' EditsExpansionFilesPatch (Maybe Text) eefpAccessToken = lens _eefpAccessToken (\ s a -> s{_eefpAccessToken = a}) -- | Legacy upload protocol for media (e.g. \"media\", \"multipart\"). eefpUploadType :: Lens' EditsExpansionFilesPatch (Maybe Text) eefpUploadType = lens _eefpUploadType (\ s a -> s{_eefpUploadType = a}) -- | Multipart request metadata. eefpPayload :: Lens' EditsExpansionFilesPatch ExpansionFile eefpPayload = lens _eefpPayload (\ s a -> s{_eefpPayload = a}) -- | The file type of the expansion file configuration which is being -- updated. eefpExpansionFileType :: Lens' EditsExpansionFilesPatch EditsExpansionFilesPatchExpansionFileType eefpExpansionFileType = lens _eefpExpansionFileType (\ s a -> s{_eefpExpansionFileType = a}) -- | Identifier of the edit. eefpEditId :: Lens' EditsExpansionFilesPatch Text eefpEditId = lens _eefpEditId (\ s a -> s{_eefpEditId = a}) -- | JSONP eefpCallback :: Lens' EditsExpansionFilesPatch (Maybe Text) eefpCallback = lens _eefpCallback (\ s a -> s{_eefpCallback = a}) instance GoogleRequest EditsExpansionFilesPatch where type Rs EditsExpansionFilesPatch = ExpansionFile type Scopes EditsExpansionFilesPatch = '["https://www.googleapis.com/auth/androidpublisher"] requestClient EditsExpansionFilesPatch'{..} = go _eefpPackageName _eefpEditId _eefpAPKVersionCode _eefpExpansionFileType _eefpXgafv _eefpUploadProtocol _eefpAccessToken _eefpUploadType _eefpCallback (Just AltJSON) _eefpPayload androidPublisherService where go = buildClient (Proxy :: Proxy EditsExpansionFilesPatchResource) mempty
brendanhay/gogol
gogol-android-publisher/gen/Network/Google/Resource/AndroidPublisher/Edits/ExpansionFiles/Patch.hs
mpl-2.0
7,460
0
24
1,795
1,046
607
439
158
1
module SyntaxTwo where let y = 2 x : \xs -> x
thewoolleyman/haskellbook
04/09/chad/SyntaxTwo.hs
unlicense
50
2
5
16
21
13
8
-1
-1
import Control.Monad import qualified Data.Map.Strict as M import Data.List type Primes = M.Map Int Int fromString :: String -> Primes fromString = M.fromList . go . (map read) . words where go [] = [] go (k:v:rest) = (k, v) : go rest toString :: Primes -> String toString = unwords . (map show) . go . M.toAscList where go [] = [] go ((k, v):rest) = k : v : go rest gcdPrimes :: Primes -> Primes -> Primes gcdPrimes = M.intersectionWith min listGcd = foldl1' gcdPrimes main = do n <- readLn xs <- replicateM n $ fmap fromString getLine putStrLn $ toString $ listGcd xs
itsbruce/hackerrank
func/recur/listGCD.hs
unlicense
628
2
10
166
271
140
131
19
2
{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE RecordWildCards #-} module Player where import Control.Arrow import Control.Lens import Data.AffineSpace import Data.Default import Data.Foldable (toList) import Data.Monoid (mempty) import Data.Sequence (Seq) import qualified Data.Sequence as Seq import qualified Data.Set as Set import Data.VectorSpace import Graphics.Gloss import Graphics.Gloss.Data.Vector import Graphics.Gloss.Geometry.Angle import Keys type Tail = Seq (Point,Point) data Player = Player { _pPos :: !Point , _pSpd :: !Point , _pAng :: !Float , _pRot :: !Float , _pColor :: !Color , _pAcc :: !Bool , _pName :: !String , _pScore :: !Float , _pTail :: !Tail } deriving (Show) makeLenses ''Player instance Default Player where def = Player (0,0) (0,0) 0 0 black False "" 0 mempty playerR :: Float playerR = 15 drawPlayer :: Player -> Picture drawPlayer Player{..} = translateP _pPos $ rotate (-radToDeg _pAng) $ -- scale 3 3 $ Pictures $ body1 . body2 . flame $ [] where body1 = (:) $ Color (dim $ dim _pColor) $ circleSolid playerR body2 = (:) $ Color (light _pColor) $ polygon [(30,0),(-21,-6),(-16,0),(-21,6)] flameP = [(-25,0), (-30,3), (-35,4), (-40,3), (-45,0)] flameP' = tail $ reverse $ tail $ map (second negate) flameP flame = if not _pAcc then id else (:) $ Color red $ polygon $ flameP ++ flameP' drawTail :: Player -> Picture drawTail Player{..} = Color col $ Pictures $ quads where col = light . light . light . dim . dim $ _pColor ps = toList _pTail quads = zipWith f ps (tail ps) f (ph1, pt1) (ph2, pt2) = Polygon [ph1, ph2, pt2, pt1] -- TODO(klao): factor out translateP :: Point -> Picture -> Picture translateP (x,y) = translate x y updateFromKeys :: KeySet -> Int -> Player -> Player updateFromKeys keys pId = pRot .~ rot >>> pAcc .~ acc where [bal, jobb, fel] = map (\k -> Set.member (PKey pId k) keys) [Bal, Jobb, Fel] rot = case (bal,jobb) of (True,False) -> 1 (False,True) -> -1 _ -> 0 acc = not fel addToTail :: Point -> (Float, Float) -> Tail -> Tail addToTail p d t = Seq.take 400 $ (p',p'') <| t where p' = p .+^ 4 *^ d p'' = p .-^ 4 *^ d stepPlayer :: Float -> Player -> Player stepPlayer dt p@Player{..} = p & pAng +~ dt*3*_pRot & pPos .~ pos' & pSpd .~ spd' & pTail %~ addToTail _pPos dir where pos' = _pPos .+^ _pSpd spd' = _pSpd ^+^ acc dir = unitVectorAtAngle _pAng acc = -0.01 *^ _pSpd ^+^ (if _pAcc then 0.02 else 0) *^ dir bounceOffBorder :: (Float,Float) -> Float -> Player -> Player bounceOffBorder sz bw p@Player{..} = p & horiz & vert where (w,h) = sz & both %~ (/2) & both -~ (bw + playerR) (x,y) = _pPos (vx, vy) = _pSpd horiz = if abs x > w && signum x == signum vx then pSpd._1 %~ negate else id vert = if abs y > h && signum y == signum vy then pSpd._2 %~ negate else id drawScore :: (Float,Float) -> Int -> Player -> Picture drawScore sz k Player{..} = translate x y $ color c $ Pictures [ name, score ] where (w,h) = sz & both %~ (/2) x = w - 180 y = h - 50 - 30 * fromIntegral k c = dark $ dim _pColor sc = scale 0.18 0.18 name = sc $ Text _pName score = translate 80 0 $ sc $ Text (show $ floor _pScore)
nilcons/tag-game
src/Player.hs
apache-2.0
3,457
1
14
970
1,451
796
655
-1
-1
{-# LANGUAGE DeriveDataTypeable #-} module Data.Ranks ( RankStats (..) , PlayerStore , empty , newPlayer , voteMod , getStats , allStats , searchStats , playerCount , playerExists ) where import Prelude import Data.Typeable (Typeable) import Data.SafeCopy (base, deriveSafeCopy) import qualified Data.Map as M import qualified Data.IntMap as I import Data.Maybe (fromMaybe, fromJust, isJust) import Data.Name import qualified Data.Text as T data StoredPlayer = StoredPlayer { playerName :: Name , playerUpvotes :: Int , playerDownvotes :: Int } deriving (Eq, Typeable) $(deriveSafeCopy 0 'base ''StoredPlayer) playerScore :: StoredPlayer -> Int playerScore p = playerUpvotes p - playerDownvotes p data PlayerStore = PlayerStore { nameMap :: M.Map Name StoredPlayer , scoreMap :: I.IntMap (M.Map Name StoredPlayer) } deriving (Typeable) setNameMap :: M.Map Name StoredPlayer -> PlayerStore -> PlayerStore setNameMap nm store = store { nameMap = nm } setScoreMap :: I.IntMap (M.Map Name StoredPlayer) -> PlayerStore -> PlayerStore setScoreMap sm store = store { scoreMap = sm } $(deriveSafeCopy 0 'base ''PlayerStore) empty :: PlayerStore empty = PlayerStore M.empty I.empty newPlayer :: Name -> PlayerStore -> PlayerStore newPlayer name store = if validName (unName name) then case M.lookup name (nameMap store) of Nothing -> store' Just _ -> store else store where store' = PlayerStore names' scores' p = StoredPlayer name 0 0 names' = M.insert name p $ nameMap store scores' = addScore p $ scoreMap store voteMod :: Name -> Int -> Int -> PlayerStore -> Maybe PlayerStore voteMod _ 0 0 _ = Nothing voteMod name u d store = fmap (voteModStored u d store) . M.lookup name . nameMap $ store voteModStored :: Int -> Int -> PlayerStore -> StoredPlayer -> PlayerStore voteModStored u d store stored = setNameMap names . setScoreMap scores $ store where names = M.insert name player' . nameMap $ store scores = setOldLevel . setNewLevel . scoreMap $ store setOldLevel = if M.null oldScoreLevel then I.delete oldScore else I.insert oldScore oldScoreLevel setNewLevel = I.insert newScore newScoreLevel oldScoreLevel = M.delete name . fromJust . I.lookup oldScore . scoreMap $ store newScoreLevel = M.insert name player' . fromMaybe M.empty . I.lookup newScore . scoreMap $ store player' = StoredPlayer name (playerUpvotes stored + u) (playerDownvotes stored + d) name = playerName stored oldScore = playerScore stored newScore = playerScore player' playerCount :: PlayerStore -> Int playerCount = M.size . nameMap data RankStats = RankStats { rankName :: Name , upvotes :: Int , downvotes :: Int , rank :: Int } getStats :: Name -> PlayerStore -> Maybe RankStats getStats name store = fmap (playerStats store) . M.lookup name . nameMap $ store allStats :: PlayerStore -> [RankStats] allStats store = map (playerStats store) . concatMap extractPlayers . sortedResults $ store where sortedResults = reverse . I.toAscList . scoreMap extractPlayers = map snd . M.toAscList . snd searchStats :: T.Text -> PlayerStore -> [RankStats] searchStats x store = map (playerStats store) . filter match . concatMap extractPlayers . sortedResults $ store where match = T.isInfixOf (normalize x) . normalize . unName . playerName sortedResults = reverse . I.toAscList . scoreMap extractPlayers = map snd . M.toAscList . snd playerStats :: PlayerStore -> StoredPlayer -> RankStats playerStats store p@(StoredPlayer n u d) = RankStats n u d (fr . playerScore $ p) where fr = findRank (scoreMap store) findRank :: I.IntMap (M.Map Name StoredPlayer) -> Int -> Int findRank scores score = 1 + I.foldr' sumSizes 0 higherRanked where higherRanked = snd $ I.split score scores sumSizes scoreLevel total = M.size scoreLevel + total addScore :: StoredPlayer -> I.IntMap (M.Map Name StoredPlayer) -> I.IntMap (M.Map Name StoredPlayer) addScore p scores = I.insert (playerScore p) scoreLevel scores where scoreLevel = case I.lookup (playerScore p) scores of Nothing -> M.singleton (playerName p) p Just nm -> M.insert (playerName p) p nm playerExists :: Name -> PlayerStore -> Bool playerExists name store = isJust . M.lookup name . nameMap $ store
JerrySun/league-famous
Data/Ranks.hs
bsd-2-clause
5,031
0
12
1,562
1,474
762
712
-1
-1
{-# OPTIONS -fglasgow-exts #-} ----------------------------------------------------------------------------- {-| Module : QPrinter.hs Copyright : (c) David Harley 2010 Project : qtHaskell Version : 1.1.4 Modified : 2010-09-02 17:02:16 Warning : this file is machine generated - do not modify. --} ----------------------------------------------------------------------------- module Qtc.Gui.QPrinter ( QqPrinter(..) ,QqPrinter_nf(..) ,collateCopies ,colorMode ,creator ,docName ,doubleSidedPrinting ,fontEmbeddingEnabled ,fullPage ,newPage ,numCopies ,outputFileName ,outputFormat ,pageOrder ,qpageRect, pageRect ,qpaperRect, paperRect ,paperSource ,printEngine ,printProgram ,printerName ,printerState ,resolution ,setCollateCopies ,setColorMode ,setCreator ,setDocName ,setDoubleSidedPrinting ,QsetEngines(..) ,setFontEmbeddingEnabled ,setFullPage ,setNumCopies ,setOutputFileName ,setOutputFormat ,setPageOrder ,setPaperSource ,setPrintProgram ,setPrinterName ,setResolution ,supportedResolutions ,qPrinter_delete, qPrinter_delete1 ) where import Foreign.C.Types import Qth.ClassTypes.Core import Qtc.Enums.Base import Qtc.Enums.Gui.QPaintDevice import Qtc.Enums.Gui.QPrinter import Qtc.Classes.Base import Qtc.Classes.Qccs import Qtc.Classes.Core import Qtc.ClassTypes.Core import Qth.ClassTypes.Core import Qtc.Classes.Gui import Qtc.ClassTypes.Gui instance QuserMethod (QPrinter ()) (()) (IO ()) where userMethod qobj evid () = withObjectPtr qobj $ \cobj_qobj -> qtc_QPrinter_userMethod cobj_qobj (toCInt evid) foreign import ccall "qtc_QPrinter_userMethod" qtc_QPrinter_userMethod :: Ptr (TQPrinter a) -> CInt -> IO () instance QuserMethod (QPrinterSc a) (()) (IO ()) where userMethod qobj evid () = withObjectPtr qobj $ \cobj_qobj -> qtc_QPrinter_userMethod cobj_qobj (toCInt evid) instance QuserMethod (QPrinter ()) (QVariant ()) (IO (QVariant ())) where userMethod qobj evid qvoj = withObjectRefResult $ withObjectPtr qobj $ \cobj_qobj -> withObjectPtr qvoj $ \cobj_qvoj -> qtc_QPrinter_userMethodVariant cobj_qobj (toCInt evid) cobj_qvoj foreign import ccall "qtc_QPrinter_userMethodVariant" qtc_QPrinter_userMethodVariant :: Ptr (TQPrinter a) -> CInt -> Ptr (TQVariant ()) -> IO (Ptr (TQVariant ())) instance QuserMethod (QPrinterSc a) (QVariant ()) (IO (QVariant ())) where userMethod qobj evid qvoj = withObjectRefResult $ withObjectPtr qobj $ \cobj_qobj -> withObjectPtr qvoj $ \cobj_qvoj -> qtc_QPrinter_userMethodVariant cobj_qobj (toCInt evid) cobj_qvoj class QqPrinter x1 where qPrinter :: x1 -> IO (QPrinter ()) instance QqPrinter (()) where qPrinter () = withQPrinterResult $ qtc_QPrinter foreign import ccall "qtc_QPrinter" qtc_QPrinter :: IO (Ptr (TQPrinter ())) instance QqPrinter ((PrinterMode)) where qPrinter (x1) = withQPrinterResult $ qtc_QPrinter1 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter1" qtc_QPrinter1 :: CLong -> IO (Ptr (TQPrinter ())) class QqPrinter_nf x1 where qPrinter_nf :: x1 -> IO (QPrinter ()) instance QqPrinter_nf (()) where qPrinter_nf () = withObjectRefResult $ qtc_QPrinter instance QqPrinter_nf ((PrinterMode)) where qPrinter_nf (x1) = withObjectRefResult $ qtc_QPrinter1 (toCLong $ qEnum_toInt x1) instance Qabort (QPrinter a) (()) (IO (Bool)) where abort x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_abort cobj_x0 foreign import ccall "qtc_QPrinter_abort" qtc_QPrinter_abort :: Ptr (TQPrinter a) -> IO CBool collateCopies :: QPrinter a -> (()) -> IO (Bool) collateCopies x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_collateCopies cobj_x0 foreign import ccall "qtc_QPrinter_collateCopies" qtc_QPrinter_collateCopies :: Ptr (TQPrinter a) -> IO CBool colorMode :: QPrinter a -> (()) -> IO (ColorMode) colorMode x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_colorMode cobj_x0 foreign import ccall "qtc_QPrinter_colorMode" qtc_QPrinter_colorMode :: Ptr (TQPrinter a) -> IO CLong creator :: QPrinter a -> (()) -> IO (String) creator x0 () = withStringResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_creator cobj_x0 foreign import ccall "qtc_QPrinter_creator" qtc_QPrinter_creator :: Ptr (TQPrinter a) -> IO (Ptr (TQString ())) instance QdevType (QPrinter ()) (()) where devType x0 () = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_devType_h cobj_x0 foreign import ccall "qtc_QPrinter_devType_h" qtc_QPrinter_devType_h :: Ptr (TQPrinter a) -> IO CInt instance QdevType (QPrinterSc a) (()) where devType x0 () = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_devType_h cobj_x0 docName :: QPrinter a -> (()) -> IO (String) docName x0 () = withStringResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_docName cobj_x0 foreign import ccall "qtc_QPrinter_docName" qtc_QPrinter_docName :: Ptr (TQPrinter a) -> IO (Ptr (TQString ())) doubleSidedPrinting :: QPrinter a -> (()) -> IO (Bool) doubleSidedPrinting x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_doubleSidedPrinting cobj_x0 foreign import ccall "qtc_QPrinter_doubleSidedPrinting" qtc_QPrinter_doubleSidedPrinting :: Ptr (TQPrinter a) -> IO CBool fontEmbeddingEnabled :: QPrinter a -> (()) -> IO (Bool) fontEmbeddingEnabled x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_fontEmbeddingEnabled cobj_x0 foreign import ccall "qtc_QPrinter_fontEmbeddingEnabled" qtc_QPrinter_fontEmbeddingEnabled :: Ptr (TQPrinter a) -> IO CBool instance QfromPage (QPrinter a) (()) where fromPage x0 () = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_fromPage cobj_x0 foreign import ccall "qtc_QPrinter_fromPage" qtc_QPrinter_fromPage :: Ptr (TQPrinter a) -> IO CInt fullPage :: QPrinter a -> (()) -> IO (Bool) fullPage x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_fullPage cobj_x0 foreign import ccall "qtc_QPrinter_fullPage" qtc_QPrinter_fullPage :: Ptr (TQPrinter a) -> IO CBool instance Qmetric (QPrinter ()) ((PaintDeviceMetric)) where metric x0 (x1) = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_metric cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_metric" qtc_QPrinter_metric :: Ptr (TQPrinter a) -> CLong -> IO CInt instance Qmetric (QPrinterSc a) ((PaintDeviceMetric)) where metric x0 (x1) = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_metric cobj_x0 (toCLong $ qEnum_toInt x1) newPage :: QPrinter a -> (()) -> IO (Bool) newPage x0 () = withBoolResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_newPage cobj_x0 foreign import ccall "qtc_QPrinter_newPage" qtc_QPrinter_newPage :: Ptr (TQPrinter a) -> IO CBool numCopies :: QPrinter a -> (()) -> IO (Int) numCopies x0 () = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_numCopies cobj_x0 foreign import ccall "qtc_QPrinter_numCopies" qtc_QPrinter_numCopies :: Ptr (TQPrinter a) -> IO CInt instance Qorientation (QPrinter a) (()) (IO (QPrinterOrientation)) where orientation x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_orientation cobj_x0 foreign import ccall "qtc_QPrinter_orientation" qtc_QPrinter_orientation :: Ptr (TQPrinter a) -> IO CLong outputFileName :: QPrinter a -> (()) -> IO (String) outputFileName x0 () = withStringResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_outputFileName cobj_x0 foreign import ccall "qtc_QPrinter_outputFileName" qtc_QPrinter_outputFileName :: Ptr (TQPrinter a) -> IO (Ptr (TQString ())) outputFormat :: QPrinter a -> (()) -> IO (OutputFormat) outputFormat x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_outputFormat cobj_x0 foreign import ccall "qtc_QPrinter_outputFormat" qtc_QPrinter_outputFormat :: Ptr (TQPrinter a) -> IO CLong pageOrder :: QPrinter a -> (()) -> IO (PageOrder) pageOrder x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_pageOrder cobj_x0 foreign import ccall "qtc_QPrinter_pageOrder" qtc_QPrinter_pageOrder :: Ptr (TQPrinter a) -> IO CLong qpageRect :: QPrinter a -> (()) -> IO (QRect ()) qpageRect x0 () = withQRectResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_pageRect cobj_x0 foreign import ccall "qtc_QPrinter_pageRect" qtc_QPrinter_pageRect :: Ptr (TQPrinter a) -> IO (Ptr (TQRect ())) pageRect :: QPrinter a -> (()) -> IO (Rect) pageRect x0 () = withRectResult $ \crect_ret_x crect_ret_y crect_ret_w crect_ret_h -> withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_pageRect_qth cobj_x0 crect_ret_x crect_ret_y crect_ret_w crect_ret_h foreign import ccall "qtc_QPrinter_pageRect_qth" qtc_QPrinter_pageRect_qth :: Ptr (TQPrinter a) -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO () instance QpageSize (QPrinter a) (()) (IO (PageSize)) where pageSize x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_pageSize cobj_x0 foreign import ccall "qtc_QPrinter_pageSize" qtc_QPrinter_pageSize :: Ptr (TQPrinter a) -> IO CLong instance QpaintEngine (QPrinter ()) (()) where paintEngine x0 () = withObjectRefResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_paintEngine_h cobj_x0 foreign import ccall "qtc_QPrinter_paintEngine_h" qtc_QPrinter_paintEngine_h :: Ptr (TQPrinter a) -> IO (Ptr (TQPaintEngine ())) instance QpaintEngine (QPrinterSc a) (()) where paintEngine x0 () = withObjectRefResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_paintEngine_h cobj_x0 qpaperRect :: QPrinter a -> (()) -> IO (QRect ()) qpaperRect x0 () = withQRectResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_paperRect cobj_x0 foreign import ccall "qtc_QPrinter_paperRect" qtc_QPrinter_paperRect :: Ptr (TQPrinter a) -> IO (Ptr (TQRect ())) paperRect :: QPrinter a -> (()) -> IO (Rect) paperRect x0 () = withRectResult $ \crect_ret_x crect_ret_y crect_ret_w crect_ret_h -> withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_paperRect_qth cobj_x0 crect_ret_x crect_ret_y crect_ret_w crect_ret_h foreign import ccall "qtc_QPrinter_paperRect_qth" qtc_QPrinter_paperRect_qth :: Ptr (TQPrinter a) -> Ptr CInt -> Ptr CInt -> Ptr CInt -> Ptr CInt -> IO () paperSource :: QPrinter a -> (()) -> IO (PaperSource) paperSource x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_paperSource cobj_x0 foreign import ccall "qtc_QPrinter_paperSource" qtc_QPrinter_paperSource :: Ptr (TQPrinter a) -> IO CLong printEngine :: QPrinter a -> (()) -> IO (QPrintEngine ()) printEngine x0 () = withObjectRefResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_printEngine cobj_x0 foreign import ccall "qtc_QPrinter_printEngine" qtc_QPrinter_printEngine :: Ptr (TQPrinter a) -> IO (Ptr (TQPrintEngine ())) printProgram :: QPrinter a -> (()) -> IO (String) printProgram x0 () = withStringResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_printProgram cobj_x0 foreign import ccall "qtc_QPrinter_printProgram" qtc_QPrinter_printProgram :: Ptr (TQPrinter a) -> IO (Ptr (TQString ())) printerName :: QPrinter a -> (()) -> IO (String) printerName x0 () = withStringResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_printerName cobj_x0 foreign import ccall "qtc_QPrinter_printerName" qtc_QPrinter_printerName :: Ptr (TQPrinter a) -> IO (Ptr (TQString ())) printerState :: QPrinter a -> (()) -> IO (PrinterState) printerState x0 () = withQEnumResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_printerState cobj_x0 foreign import ccall "qtc_QPrinter_printerState" qtc_QPrinter_printerState :: Ptr (TQPrinter a) -> IO CLong resolution :: QPrinter a -> (()) -> IO (Int) resolution x0 () = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_resolution cobj_x0 foreign import ccall "qtc_QPrinter_resolution" qtc_QPrinter_resolution :: Ptr (TQPrinter a) -> IO CInt setCollateCopies :: QPrinter a -> ((Bool)) -> IO () setCollateCopies x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setCollateCopies cobj_x0 (toCBool x1) foreign import ccall "qtc_QPrinter_setCollateCopies" qtc_QPrinter_setCollateCopies :: Ptr (TQPrinter a) -> CBool -> IO () setColorMode :: QPrinter a -> ((ColorMode)) -> IO () setColorMode x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setColorMode cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_setColorMode" qtc_QPrinter_setColorMode :: Ptr (TQPrinter a) -> CLong -> IO () setCreator :: QPrinter a -> ((String)) -> IO () setCreator x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> withCWString x1 $ \cstr_x1 -> qtc_QPrinter_setCreator cobj_x0 cstr_x1 foreign import ccall "qtc_QPrinter_setCreator" qtc_QPrinter_setCreator :: Ptr (TQPrinter a) -> CWString -> IO () setDocName :: QPrinter a -> ((String)) -> IO () setDocName x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> withCWString x1 $ \cstr_x1 -> qtc_QPrinter_setDocName cobj_x0 cstr_x1 foreign import ccall "qtc_QPrinter_setDocName" qtc_QPrinter_setDocName :: Ptr (TQPrinter a) -> CWString -> IO () setDoubleSidedPrinting :: QPrinter a -> ((Bool)) -> IO () setDoubleSidedPrinting x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setDoubleSidedPrinting cobj_x0 (toCBool x1) foreign import ccall "qtc_QPrinter_setDoubleSidedPrinting" qtc_QPrinter_setDoubleSidedPrinting :: Ptr (TQPrinter a) -> CBool -> IO () class QsetEngines x0 x1 where setEngines :: x0 -> x1 -> IO () instance QsetEngines (QPrinter ()) ((QPrintEngine t1, QPaintEngine t2)) where setEngines x0 (x1, x2) = withObjectPtr x0 $ \cobj_x0 -> withObjectPtr x1 $ \cobj_x1 -> withObjectPtr x2 $ \cobj_x2 -> qtc_QPrinter_setEngines cobj_x0 cobj_x1 cobj_x2 foreign import ccall "qtc_QPrinter_setEngines" qtc_QPrinter_setEngines :: Ptr (TQPrinter a) -> Ptr (TQPrintEngine t1) -> Ptr (TQPaintEngine t2) -> IO () instance QsetEngines (QPrinterSc a) ((QPrintEngine t1, QPaintEngine t2)) where setEngines x0 (x1, x2) = withObjectPtr x0 $ \cobj_x0 -> withObjectPtr x1 $ \cobj_x1 -> withObjectPtr x2 $ \cobj_x2 -> qtc_QPrinter_setEngines cobj_x0 cobj_x1 cobj_x2 setFontEmbeddingEnabled :: QPrinter a -> ((Bool)) -> IO () setFontEmbeddingEnabled x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setFontEmbeddingEnabled cobj_x0 (toCBool x1) foreign import ccall "qtc_QPrinter_setFontEmbeddingEnabled" qtc_QPrinter_setFontEmbeddingEnabled :: Ptr (TQPrinter a) -> CBool -> IO () instance QsetFromTo (QPrinter a) ((Int, Int)) where setFromTo x0 (x1, x2) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setFromTo cobj_x0 (toCInt x1) (toCInt x2) foreign import ccall "qtc_QPrinter_setFromTo" qtc_QPrinter_setFromTo :: Ptr (TQPrinter a) -> CInt -> CInt -> IO () setFullPage :: QPrinter a -> ((Bool)) -> IO () setFullPage x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setFullPage cobj_x0 (toCBool x1) foreign import ccall "qtc_QPrinter_setFullPage" qtc_QPrinter_setFullPage :: Ptr (TQPrinter a) -> CBool -> IO () setNumCopies :: QPrinter a -> ((Int)) -> IO () setNumCopies x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setNumCopies cobj_x0 (toCInt x1) foreign import ccall "qtc_QPrinter_setNumCopies" qtc_QPrinter_setNumCopies :: Ptr (TQPrinter a) -> CInt -> IO () instance QsetOrientation (QPrinter a) ((QPrinterOrientation)) where setOrientation x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setOrientation cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_setOrientation" qtc_QPrinter_setOrientation :: Ptr (TQPrinter a) -> CLong -> IO () setOutputFileName :: QPrinter a -> ((String)) -> IO () setOutputFileName x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> withCWString x1 $ \cstr_x1 -> qtc_QPrinter_setOutputFileName cobj_x0 cstr_x1 foreign import ccall "qtc_QPrinter_setOutputFileName" qtc_QPrinter_setOutputFileName :: Ptr (TQPrinter a) -> CWString -> IO () setOutputFormat :: QPrinter a -> ((OutputFormat)) -> IO () setOutputFormat x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setOutputFormat cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_setOutputFormat" qtc_QPrinter_setOutputFormat :: Ptr (TQPrinter a) -> CLong -> IO () setPageOrder :: QPrinter a -> ((PageOrder)) -> IO () setPageOrder x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setPageOrder cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_setPageOrder" qtc_QPrinter_setPageOrder :: Ptr (TQPrinter a) -> CLong -> IO () instance QsetPageSize (QPrinter a) ((PageSize)) where setPageSize x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setPageSize cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_setPageSize" qtc_QPrinter_setPageSize :: Ptr (TQPrinter a) -> CLong -> IO () setPaperSource :: QPrinter a -> ((PaperSource)) -> IO () setPaperSource x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setPaperSource cobj_x0 (toCLong $ qEnum_toInt x1) foreign import ccall "qtc_QPrinter_setPaperSource" qtc_QPrinter_setPaperSource :: Ptr (TQPrinter a) -> CLong -> IO () setPrintProgram :: QPrinter a -> ((String)) -> IO () setPrintProgram x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> withCWString x1 $ \cstr_x1 -> qtc_QPrinter_setPrintProgram cobj_x0 cstr_x1 foreign import ccall "qtc_QPrinter_setPrintProgram" qtc_QPrinter_setPrintProgram :: Ptr (TQPrinter a) -> CWString -> IO () setPrinterName :: QPrinter a -> ((String)) -> IO () setPrinterName x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> withCWString x1 $ \cstr_x1 -> qtc_QPrinter_setPrinterName cobj_x0 cstr_x1 foreign import ccall "qtc_QPrinter_setPrinterName" qtc_QPrinter_setPrinterName :: Ptr (TQPrinter a) -> CWString -> IO () setResolution :: QPrinter a -> ((Int)) -> IO () setResolution x0 (x1) = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_setResolution cobj_x0 (toCInt x1) foreign import ccall "qtc_QPrinter_setResolution" qtc_QPrinter_setResolution :: Ptr (TQPrinter a) -> CInt -> IO () supportedResolutions :: QPrinter a -> (()) -> IO ([Int]) supportedResolutions x0 () = withQListIntResult $ \arr -> withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_supportedResolutions cobj_x0 arr foreign import ccall "qtc_QPrinter_supportedResolutions" qtc_QPrinter_supportedResolutions :: Ptr (TQPrinter a) -> Ptr CInt -> IO CInt instance QtoPage (QPrinter a) (()) where toPage x0 () = withIntResult $ withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_toPage cobj_x0 foreign import ccall "qtc_QPrinter_toPage" qtc_QPrinter_toPage :: Ptr (TQPrinter a) -> IO CInt qPrinter_delete :: QPrinter a -> IO () qPrinter_delete x0 = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_delete cobj_x0 foreign import ccall "qtc_QPrinter_delete" qtc_QPrinter_delete :: Ptr (TQPrinter a) -> IO () qPrinter_delete1 :: QPrinter a -> IO () qPrinter_delete1 x0 = withObjectPtr x0 $ \cobj_x0 -> qtc_QPrinter_delete1 cobj_x0 foreign import ccall "qtc_QPrinter_delete1" qtc_QPrinter_delete1 :: Ptr (TQPrinter a) -> IO ()
keera-studios/hsQt
Qtc/Gui/QPrinter.hs
bsd-2-clause
19,258
0
14
3,197
6,218
3,161
3,057
-1
-1
-- Copyright (c) 2016-present, Facebook, Inc. -- All rights reserved. -- -- This source code is licensed under the BSD-style license found in the -- LICENSE file in the root directory of this source tree. An additional grant -- of patent rights can be found in the PATENTS file in the same directory. {-# LANGUAGE GADTs #-} {-# LANGUAGE OverloadedStrings #-} module Duckling.Numeral.SV.Rules ( rules ) where import Data.HashMap.Strict (HashMap) import qualified Data.HashMap.Strict as HashMap import Data.Maybe import Data.Text (Text) import qualified Data.Text as Text import Prelude import Data.String import Duckling.Dimensions.Types import Duckling.Numeral.Helpers import Duckling.Numeral.Types (NumeralData (..)) import qualified Duckling.Numeral.Types as TNumeral import Duckling.Regex.Types import Duckling.Types ruleIntersectWithAnd :: Rule ruleIntersectWithAnd = Rule { name = "intersect (with and)" , pattern = [ numberWith (fromMaybe 0 . TNumeral.grain) (>1) , regex "och" , numberWith TNumeral.multipliable not ] , prod = \tokens -> case tokens of (Token Numeral (NumeralData {TNumeral.value = val1, TNumeral.grain = Just g}): _: Token Numeral (NumeralData {TNumeral.value = val2}): _) | (10 ** fromIntegral g) > val2 -> double $ val1 + val2 _ -> Nothing } ruleNumeralsPrefixWithNegativeOrMinus :: Rule ruleNumeralsPrefixWithNegativeOrMinus = Rule { name = "numbers prefix with -, negative or minus" , pattern = [ regex "-|minus\\s?|negativ\\s?" , dimension Numeral ] , prod = \tokens -> case tokens of (_: Token Numeral (NumeralData {TNumeral.value = v}): _) -> double $ v * (-1) _ -> Nothing } ruleIntegerNumeric :: Rule ruleIntegerNumeric = Rule { name = "integer (numeric)" , pattern = [ regex "(\\d{1,18})" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)): _) -> do v <- parseInt match integer $ toInteger v _ -> Nothing } ruleFew :: Rule ruleFew = Rule { name = "few" , pattern = [ regex "(n\x00e5gra )?f\x00e5" ] , prod = \_ -> integer 3 } ruleDecimalWithThousandsSeparator :: Rule ruleDecimalWithThousandsSeparator = Rule { name = "decimal with thousands separator" , pattern = [ regex "(\\d+(\\.\\d\\d\\d)+\\,\\d+)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)):_) -> let dot = Text.singleton '.' comma = Text.singleton ',' fmt = Text.replace comma dot $ Text.replace dot Text.empty match in parseDouble fmt >>= double _ -> Nothing } ruleDecimalNumeral :: Rule ruleDecimalNumeral = Rule { name = "decimal number" , pattern = [ regex "(\\d*,\\d+)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)): _) -> parseDecimal False match _ -> Nothing } ruleInteger3 :: Rule ruleInteger3 = Rule { name = "integer 21..99" , pattern = [ oneOf [70, 20, 60, 50, 40, 90, 30, 80] , numberBetween 1 10 ] , prod = \tokens -> case tokens of (Token Numeral (NumeralData {TNumeral.value = v1}): Token Numeral (NumeralData {TNumeral.value = v2}): _) -> double $ v1 + v2 _ -> Nothing } ruleSingle :: Rule ruleSingle = Rule { name = "single" , pattern = [ regex "enkel" ] , prod = \_ -> integer 1 >>= withGrain 1 } ruleIntersect :: Rule ruleIntersect = Rule { name = "intersect" , pattern = [ numberWith (fromMaybe 0 . TNumeral.grain) (>1) , numberWith TNumeral.multipliable not ] , prod = \tokens -> case tokens of (Token Numeral (NumeralData {TNumeral.value = val1, TNumeral.grain = Just g}): Token Numeral (NumeralData {TNumeral.value = val2}): _) | (10 ** fromIntegral g) > val2 -> double $ val1 + val2 _ -> Nothing } ruleMultiply :: Rule ruleMultiply = Rule { name = "compose by multiplication" , pattern = [ dimension Numeral , numberWith TNumeral.multipliable id ] , prod = \tokens -> case tokens of (token1:token2:_) -> multiply token1 token2 _ -> Nothing } ruleNumeralsSuffixesKMG :: Rule ruleNumeralsSuffixesKMG = Rule { name = "numbers suffixes (K, M, G)" , pattern = [ dimension Numeral , regex "([kmg])(?=[\\W\\$\x20ac]|$)" ] , prod = \tokens -> case tokens of (Token Numeral (NumeralData {TNumeral.value = v}): Token RegexMatch (GroupMatch (match:_)): _) -> case Text.toLower match of "k" -> double $ v * 1e3 "m" -> double $ v * 1e6 "g" -> double $ v * 1e9 _ -> Nothing _ -> Nothing } rulePowersOfTen :: Rule rulePowersOfTen = Rule { name = "powers of tens" , pattern = [ regex "(hundra?|tusen?|miljon(er)?)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)):_) -> case Text.toLower match of "hundr" -> double 1e2 >>= withGrain 2 >>= withMultipliable "hundra" -> double 1e2 >>= withGrain 2 >>= withMultipliable "tuse" -> double 1e3 >>= withGrain 3 >>= withMultipliable "tusen" -> double 1e3 >>= withGrain 3 >>= withMultipliable "miljon" -> double 1e6 >>= withGrain 6 >>= withMultipliable "miljoner" -> double 1e6 >>= withGrain 6 >>= withMultipliable _ -> Nothing _ -> Nothing } ruleCouple :: Rule ruleCouple = Rule { name = "couple, a pair" , pattern = [ regex "ett par" ] , prod = \_ -> integer 2 } ruleDozen :: Rule ruleDozen = Rule { name = "dozen" , pattern = [ regex "dussin" ] , prod = \_ -> integer 12 >>= withGrain 1 >>= withMultipliable } zeroToNineteenMap :: HashMap Text Integer zeroToNineteenMap = HashMap.fromList [ ( "inget" , 0 ) , ( "ingen" , 0 ) , ( "noll" , 0 ) , ( "en" , 1 ) , ( "ett" , 1 ) , ( "tv\x00e5" , 2 ) , ( "tre" , 3 ) , ( "fyra" , 4 ) , ( "fem" , 5 ) , ( "sex" , 6 ) , ( "sju" , 7 ) , ( "\x00e5tta", 8 ) , ( "nio" , 9 ) , ( "tio" , 10 ) , ( "elva" , 11 ) , ( "tolv" , 12 ) , ( "tretton" , 13 ) , ( "fjorton" , 14 ) , ( "femton" , 15 ) , ( "sexton" , 16 ) , ( "sjutton" , 17 ) , ( "arton" , 18 ) , ( "nitton" , 19 ) ] ruleInteger :: Rule ruleInteger = Rule { name = "integer (0..19)" , pattern = [ regex "(inget|ingen|noll|en|ett|tv\x00e5|tretton|tre|fyra|femton|fem|sexton|sex|sjutton|sju|\x00e5tta|nio|tio|elva|tolv|fjorton|arton|nitton)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)):_) -> HashMap.lookup (Text.toLower match) zeroToNineteenMap >>= integer _ -> Nothing } dozenMap :: HashMap Text Integer dozenMap = HashMap.fromList [ ( "tjugo" , 20) , ( "trettio" , 30) , ( "fyrtio" , 40) , ( "femtio" , 50) , ( "sextio" , 60) , ( "sjuttio" , 70) , ( "\x00e5ttio" , 80) , ( "nittio" , 90) ] ruleInteger2 :: Rule ruleInteger2 = Rule { name = "integer (20..90)" , pattern = [ regex "(tjugo|trettio|fyrtio|femtio|sextio|sjuttio|\x00e5ttio|nittio)" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)):_) -> HashMap.lookup (Text.toLower match) dozenMap >>= integer _ -> Nothing } ruleNumeralDotNumeral :: Rule ruleNumeralDotNumeral = Rule { name = "number dot number" , pattern = [ dimension Numeral , regex "komma" , numberWith TNumeral.grain isNothing ] , prod = \tokens -> case tokens of (Token Numeral nd1:_:Token Numeral nd2:_) -> double $ TNumeral.value nd1 + decimalsToDouble (TNumeral.value nd2) _ -> Nothing } ruleIntegerWithThousandsSeparator :: Rule ruleIntegerWithThousandsSeparator = Rule { name = "integer with thousands separator ." , pattern = [ regex "(\\d{1,3}(\\.\\d\\d\\d){1,5})" ] , prod = \tokens -> case tokens of (Token RegexMatch (GroupMatch (match:_)): _) -> let fmt = Text.replace (Text.singleton '.') Text.empty match in parseDouble fmt >>= double _ -> Nothing } rules :: [Rule] rules = [ ruleCouple , ruleDecimalNumeral , ruleDecimalWithThousandsSeparator , ruleDozen , ruleFew , ruleInteger , ruleInteger2 , ruleInteger3 , ruleIntegerNumeric , ruleIntegerWithThousandsSeparator , ruleIntersect , ruleIntersectWithAnd , ruleMultiply , ruleNumeralDotNumeral , ruleNumeralsPrefixWithNegativeOrMinus , ruleNumeralsSuffixesKMG , rulePowersOfTen , ruleSingle ]
rfranek/duckling
Duckling/Numeral/SV/Rules.hs
bsd-3-clause
8,629
0
19
2,282
2,549
1,433
1,116
252
8
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses #-} -- | The @nd@ element of a OSM file. module Data.Geo.OSM.Nd ( Nd , nd ) where import Text.XML.HXT.Arrow.Pickle import Data.Geo.OSM.Lens.RefL import Control.Lens.Lens import Control.Newtype -- | The @nd@ element of a OSM file. newtype Nd = Nd String deriving Eq instance XmlPickler Nd where xpickle = xpElem "nd" (xpWrap (nd, \(Nd r) -> r) (xpAttr "ref" xpText)) instance Show Nd where show = showPickled [] instance RefL Nd where refL = lens unpack (const pack) instance Newtype Nd String where pack = Nd unpack (Nd x) = x -- | Constructs a nd with a ref. nd :: String -- ^ The @ref@ attribute. -> Nd nd = Nd
tonymorris/geo-osm
src/Data/Geo/OSM/Nd.hs
bsd-3-clause
739
0
12
166
195
113
82
31
1
{-# LANGUAGE OverloadedStrings #-} import qualified Aws import qualified Aws.S3 as S3 import Data.Conduit import Data.Conduit.Binary import Data.IORef import Data.Monoid import BkrAwsConfig {- -- Credentials import Aws.Credentials import Aws.Aws import qualified Data.ByteString.Char8 as B -- Configuration import Aws.Http import Aws.S3.Info import Aws.Ses.Info import Aws.Signature import Aws.SimpleDb.Info import Aws.Sqs.Info -} -- A small function to save the object's data into a file. saveObject :: Aws.HTTPResponseConsumer () saveObject status headers source = source $$ sinkFile "tst.txt" listObject :: Aws.HTTPResponseConsumer () listObject status headers source = do obj <- source $$ Data.Conduit.Binary.lines print $ show obj main :: IO () main = do -- Set up AWS credentials and the default configuration. --cfg <- baseConfiguration' --let cfg = baseConfiguration'' let cfg = getS3Config -- Create an IORef to store the response Metadata (so it is also available in case of an error). metadataRef <- newIORef mempty -- Create a request object with S3.getObject and run the request with simpleAwsRef. --Aws.simpleAwsRef cfg metadataRef $ S3.getObject "haskell-aws" "cloud-remote.pdf" saveObject --Aws.simpleAwsRef cfg metadataRef $ S3.getObject "ms-bkr" "_DSC2283.NEF" saveObject bucket <- Aws.simpleAwsRef cfg metadataRef $ S3.getBucket "ms-bkr" print $ show bucket -- Print the response metadata. print =<< readIORef metadataRef {- getCredentials :: Credentials getCredentials = Credentials (B.pack "AKIAJNREVFV4JQNNNQRQ") (B.pack "dqQmkG7q4TwJemnEoqVeSppTuOcMp6RoBRZCpibp") baseConfiguration' :: IO Configuration baseConfiguration' = do --let cr = getCredentials let cr = Credentials (B.pack "AKIAJNREVFV4JQNNNQRQ") (B.pack "dqQmkG7q4TwJemnEoqVeSppTuOcMp6RoBRZCpibp") return Configuration { timeInfo = Timestamp , credentials = cr , sdbInfo = sdbHttpsPost sdbUsEast , sdbInfoUri = sdbHttpsGet sdbUsEast , s3Info = s3 HTTP s3EndpointUsClassic False , s3InfoUri = s3 HTTP s3EndpointUsClassic True , sqsInfo = sqs HTTP sqsEndpointUsClassic False , sqsInfoUri = sqs HTTP sqsEndpointUsClassic True , sesInfo = sesHttpsPost sesUsEast , sesInfoUri = sesHttpsGet sesUsEast , logger = defaultLog Warning } baseConfiguration'' :: Configuration baseConfiguration'' = do --let cr = getCredentials let cr = Credentials (B.pack "AKIAJNREVFV4JQNNNQRQ") (B.pack "dqQmkG7q4TwJemnEoqVeSppTuOcMp6RoBRZCpibp") Configuration { timeInfo = Timestamp , credentials = cr , sdbInfo = sdbHttpsPost sdbUsEast , sdbInfoUri = sdbHttpsGet sdbUsEast , s3Info = s3 HTTP s3EndpointUsClassic False , s3InfoUri = s3 HTTP s3EndpointUsClassic True , sqsInfo = sqs HTTP sqsEndpointUsClassic False , sqsInfoUri = sqs HTTP sqsEndpointUsClassic True , sesInfo = sesHttpsPost sesUsEast , sesInfoUri = sesHttpsGet sesUsEast , logger = defaultLog Warning } -}
miie/bkr
src/System/Bkr/TargetServices/S3/BkrAws.hs
bsd-3-clause
3,377
0
10
918
206
109
97
21
1
{-# LANGUAGE GADTs, RecordWildCards,ExistentialQuantification #-} module Llvm.Hir.Data.Module (module Llvm.Hir.Data.Module , module Llvm.Hir.Data.Inst , module Llvm.Hir.Data.Commentor , module Data.Word ) where import Llvm.Hir.Data.Inst import Llvm.Hir.Data.Commentor import qualified Llvm.Hir.Data.Inst as Ci import qualified Compiler.Hoopl as H import Data.Word (Word32) {- An intermediate representation that is suitable for Hoopl -} data Toplevel g a = ToplevelAlias (TlAlias g) | ToplevelUnamedMd (TlUnamedMd g) | ToplevelNamedMd TlNamedMd | ToplevelDeclare (TlDeclare g) | ToplevelDeclareIntrinsic TlDeclareIntrinsic | ToplevelDefine (TlDefine g a) | ToplevelGlobal (TlGlobal g) | ToplevelTypeDef TlTypeDef | ToplevelDepLibs TlDepLibs | ToplevelUnamedType TlUnamedType | ToplevelModuleAsm TlModuleAsm | ToplevelAttribute TlAttribute | ToplevelComdat (TlComdat g) | ToplevelIntrinsic (TlIntrinsic g) | ToplevelComment TlComment data TlComment = forall s.Commentor s => TlComment s data TlIntrinsic g = TlIntrinsic_llvm_used { tli_type :: Type RecordB D , tli_const :: Const g , tli_section :: Maybe Section } | TlIntrinsic_llvm_compiler_used { tli_type :: Type RecordB D , tli_const :: Const g , tli_section :: Maybe Section } | TlIntrinsic_llvm_global_ctors { tli_type :: Type RecordB D , tli_const :: Const g , tli_section :: Maybe Section } | TlIntrinsic_llvm_global_dtors { tli_type :: Type RecordB D , tli_const :: Const g , tli_section :: Maybe Section } data TlAlias g = TlAlias { tla_lhs :: g , tla_visibility :: Maybe Ci.Visibility , tla_dllstorage :: Maybe Ci.DllStorageClass , tla_tls :: Maybe Ci.ThreadLocalStorage , tla_addrnaming :: AddrNaming , tla_linkage :: Maybe Ci.Linkage , tla_aliasee :: Ci.Aliasee g } deriving (Eq, Ord, Show) data TlUnamedMd g = TlUnamedMd Word32 (MetaKindedConst g) | TlUnamedMd_Tagged Word32 DW_TAG [MetaKindedConst g] deriving (Eq, Ord, Show) data DW_TAG = DW_TAG_array_type | DW_TAG_class_type | DW_TAG_entry_point | DW_TAG_enumeration_type | DW_TAG_formal_parameter | DW_TAG_imported_declaration | DW_TAG_label | DW_TAG_lexical_block | DW_TAG_member | DW_TAG_pointer_type | DW_TAG_reference_type | DW_TAG_compile_unit | DW_TAG_string_type | DW_TAG_structure_type | DW_TAG_subroutine_type | DW_TAG_typedef | DW_TAG_union_type | DW_TAG_unspecified_parameters | DW_TAG_variant | DW_TAG_common_block | DW_TAG_common_inclusion | DW_TAG_inheritance | DW_TAG_inlined_subroutine | DW_TAG_module | DW_TAG_ptr_to_member_type | DW_TAG_set_type | DW_TAG_subrange_type | DW_TAG_with_stmt | DW_TAG_access_declaration | DW_TAG_base_type | DW_TAG_catch_block | DW_TAG_const_type | DW_TAG_constant | DW_TAG_enumerator | DW_TAG_file_type | DW_TAG_friend | DW_TAG_namelist | DW_TAG_namelist_item | DW_TAG_packed_type | DW_TAG_subprogram | DW_TAG_template_type_parameter | DW_TAG_template_value_parameter | DW_TAG_thrown_type | DW_TAG_try_block | DW_TAG_variant_part | DW_TAG_variable | DW_TAG_volatile_type | DW_TAG_dwarf_procedure | DW_TAG_restrict_type | DW_TAG_interface_type | DW_TAG_namespace | DW_TAG_imported_module | DW_TAG_unspecified_type | DW_TAG_partial_unit | DW_TAG_imported_unit | DW_TAG_condition | DW_TAG_shared_type | DW_TAG_type_unit | DW_TAG_rvalue_reference_type | DW_TAG_template_alias | DW_TAG_coarray_type | DW_TAG_generic_subrange | DW_TAG_dynamic_type | DW_TAG_auto_variable | DW_TAG_arg_variable | DW_TAG_user_base | DW_TAG_MIPS_loop | DW_TAG_format_label | DW_TAG_function_template | DW_TAG_class_template | DW_TAG_GNU_template_template_param | DW_TAG_GNU_template_parameter_pack | DW_TAG_GNU_formal_parameter_pack | DW_TAG_lo_user | DW_TAG_APPLE_property | DW_TAG_hi_user deriving (Eq, Show, Ord) data TlNamedMd = TlNamedMd String [Ci.MdNode] deriving (Eq, Ord, Show) data FunctionDeclare g = FunctionDeclareData { fd_linkage :: Maybe Linkage , fd_visibility :: Maybe Visibility , fd_dllstorage :: Maybe DllStorageClass , fd_signature :: FunSignature () , fd_fun_name :: g , fd_addr_naming :: Maybe AddrNaming , fd_fun_attrs :: [FunAttr] , fd_section :: Maybe Section , fd_comdat :: Maybe (Comdat g) , fd_alignment :: Maybe AlignInByte , fd_gc :: Maybe Gc , fd_prefix :: Maybe (Prefix g) , fd_prologue :: Maybe (Prologue g) } | FunctionDeclareMeta { fd_fun_name :: g , fd_fun_attrs :: [FunAttr] , fd_retType :: Rtype , fd_metakinds :: [Either MetaKind Dtype] } deriving (Eq,Ord,Show) data TlDeclare g = TlDeclare (FunctionDeclare g) deriving (Eq) data IntrinsicDeclare = IntrinsicDeclareData { id_signature :: FunSignature () , id_fun_name :: Gname , id_fun_attrs :: [FunAttr] } deriving (Eq,Ord,Show) data TlDeclareIntrinsic = TlDeclareIntrinsic IntrinsicDeclare deriving (Eq, Show) type NOOP = () data TlDefine g a = TlDefine (FunctionInterface g) H.Label (H.Graph (Node g a) H.C H.C) data TlGlobal g = TlGlobalDtype { tlg_lhs :: g , tlg_linkage :: (Maybe Ci.Linkage) , tlg_visibility :: (Maybe Ci.Visibility) , tlg_dllstorage :: (Maybe Ci.DllStorageClass) , tlg_tls :: (Maybe Ci.ThreadLocalStorage) , tlg_addrnaming :: AddrNaming , tlg_addrspace :: (Maybe Ci.AddrSpace) , tlg_externallyInitialized :: (IsOrIsNot Ci.ExternallyInitialized) , tlg_globalType :: Ci.GlobalType , tlg_dtype :: Ci.Dtype , tlg_const :: Maybe (Ci.Const g) , tlg_section :: Maybe Ci.Section , tlg_comdat :: Maybe (Ci.Comdat g) , tlg_alignment :: Maybe Ci.AlignInByte } | TlGlobalOpaque { tlg_lhs :: g , tlg_linkage :: (Maybe Ci.Linkage) , tlg_visiblity :: (Maybe Ci.Visibility) , tlg_dllstorage :: (Maybe Ci.DllStorageClass) , tlg_tls :: (Maybe Ci.ThreadLocalStorage) , tlg_addrnaming :: AddrNaming , tlg_addrspace :: (Maybe Ci.AddrSpace) , tlg_externallyInitialized :: (IsOrIsNot Ci.ExternallyInitialized) , tlg_globalType :: Ci.GlobalType , tlg_otype :: Ci.Type Ci.OpaqueB D , tlg_const :: Maybe (Ci.Const g) , tlg_section :: Maybe Ci.Section , tlg_comdat :: Maybe (Ci.Comdat g) , tlg_alignment :: (Maybe Ci.AlignInByte) } deriving (Eq, Ord, Show) data TlTypeDef = TlDatTypeDef Ci.Lname Ci.Dtype | TlOpqTypeDef Ci.Lname (Ci.Type OpaqueB D) | TlFunTypeDef Ci.Lname (Ci.Type CodeFunB X) deriving (Eq, Ord, Show) data TlDepLibs = TlDepLibs [Ci.DqString] deriving (Eq, Ord, Show) data TlUnamedType = TlUnamedType Word32 Ci.Dtype deriving (Eq, Ord, Show) data TlModuleAsm = TlModuleAsm Ci.DqString deriving (Eq, Ord, Show) data TlAttribute = TlAttribute Word32 [FunAttr] deriving (Eq, Ord, Show) data TlComdat g = TlComdat g Ci.SelectionKind deriving (Eq, Ord, Show) {- If a consumer does not demands specializing Cnode and GlobalId, then Module GlobalId () is a typical instance -} data Module g a = Module [Toplevel g a] {- Node g a e x ^ ^ ^ ^ | | | +-- the shape of exit | | +---- the shape of entry | +------ the enode parameter +-- global id parameter g and a are parameters used to specialize GlobalId and Cnode If a consumer does not need to specialize the above two, the unit type () can be used to instantiate g and a. So Node () () e x is a typical instantiation for many consumers. -} data Node g a e x where -- | Lnode represents the name of a basic block Lnode :: H.Label -> Node g a H.C H.O -- | Pnode, Phi nodes, if they ever exist, always follow up a Lnode in a basic block Pnode :: Ci.Pinst g -> [Dbg g] -> Node g a H.O H.O -- | Cnode, Computation nodes, it can be anyway between Lnode(+ Possibly Pnodes) and Tnode Cnode :: Ci.Cinst g -> [Dbg g] -> Node g a H.O H.O -- | Mnode, Metadata nodes, dataflow analysis can refer to, but should not depend on -- | , the information in Metadata nodes Mnode :: Ci.Minst g -> [Dbg g] -> Node g a H.O H.O -- | It's handy if we can communicate some decisions or changes made by -- | dataflow analyses/transformations back as comments, so I create this -- | Comment node, it is NOOP and will display as a comment in LLVM assembly codes Comment :: Commentor s => s -> Node g a H.O H.O -- | Extension node, it could be NOOP or any customization node used by -- | backends to facilitate dataflow analysis and transformations. -- | The clients of this library should never handle this node. If -- | a Enode represents anything other than NOOP, which is (), it should alwasy be -- | converted back to other nodes. Enode :: a -> [Dbg g] -> Node g a H.O H.O Tnode :: Ci.Tinst g -> [Dbg g] -> Node g a H.O H.C instance (Show g, Show a) => Show (Node g a e x) where show x = case x of Lnode v -> "Lnode: Node C O:" ++ show v Pnode v dbgs -> "Pnode : Node O O:" ++ show v ++ show dbgs Cnode v dbgs -> "Cnode : Node O O:" ++ show v ++ show dbgs Mnode v dbgs -> "Mnode : Node O O:" ++ show v ++ show dbgs Comment s -> "Comment : Node O O:" ++ show (commentize s) Enode a dbgs -> "Enode : Node O O:" ++ show a ++ show dbgs Tnode v dbgs -> "Tnode : Node O C:" ++ show v ++ show dbgs instance (Eq g, Show g, Eq a) => Eq (Node g a e x) where (==) x1 x2 = case (x1, x2) of (Lnode l1, Lnode l2) -> l1 == l2 (Pnode v1 d1, Pnode v2 d2) -> v1 == v2 && d1 == d2 (Cnode v1 d1, Cnode v2 d2) -> v1 == v2 && d1 == d2 (Mnode v1 d1, Mnode v2 d2) -> v1 == v2 && d1 == d2 (Comment v1, Comment v2) -> commentize v1 == commentize v2 (Enode a1 d1, Enode a2 d2) -> a1 == a2 && d1 == d2 (Tnode v1 d1, Tnode v2 d2) -> v1 == v2 && d1 == d2 (_, _) -> False instance (Ord g, Show g, Show a, Ord a) => Ord (Node g a e x) where compare x1 x2 = case (x1, x2) of (Lnode l1, Lnode l2) -> compare l1 l2 (Pnode v1 d1, Pnode v2 d2) -> compare (v1,d1) (v2,d2) (Cnode v1 d1, Cnode v2 d2) -> compare (v1,d1) (v2,d2) (Mnode v1 d1, Mnode v2 d2) -> compare (v1,d1) (v2,d2) (Comment v1, Comment v2) -> compare (commentize v1) (commentize v2) (Enode v1 d1, Enode v2 d2) -> compare (v1,d1) (v2,d2) (Tnode v1 d1, Tnode v2 d2) -> compare (v1,d1) (v2,d2) (_, _) -> compare (show x1) (show x2) instance H.NonLocal (Node g a) where entryLabel (Lnode l) = l successors (Tnode inst _) = case inst of Ci.T_unreachable -> [] Ci.T_return _ -> [] Ci.T_ret_void -> [] Ci.T_br l -> [l] Ci.T_cbr{..} -> [trueL, falseL] Ci.T_indirectbr _ ls -> ls Ci.T_switch d ls -> (snd d):(map snd ls) Ci.T_invoke{..} -> [invoke_normal_label, invoke_exception_label] Ci.T_invoke_asm{..} -> [invoke_normal_label, invoke_exception_label] Ci.T_resume _ -> [] Ci.T_unwind -> error "what is unwind"
mlite/hLLVM
src/Llvm/Hir/Data/Module.hs
bsd-3-clause
14,443
0
12
5,911
3,077
1,693
1,384
243
0
{-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DoAndIfThenElse #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE ViewPatterns #-} module Language.Rsc.Typecheck.Checker (verifyFile, typeCheck) where import Control.Arrow (first, second, (***)) import Control.Monad import Data.Default -- import qualified Data.Foldable as FO import Data.Function (on) import Data.Generics import qualified Data.IntMap.Strict as I import Data.List (partition, sortBy) import Data.Maybe (fromMaybe) import qualified Data.Traversable as T import Language.Fixpoint.Misc as FM import qualified Language.Fixpoint.Types as F import Language.Fixpoint.Types.Errors import Language.Rsc.Annotations import Language.Rsc.AST import Language.Rsc.ClassHierarchy import Language.Rsc.CmdLine (Config, noFailCasts) import Language.Rsc.Core.EitherIO import Language.Rsc.Environment import Language.Rsc.Errors import Language.Rsc.Locations import Language.Rsc.Lookup import Language.Rsc.Misc (nths, single, zipWith3M) import Language.Rsc.Names import Language.Rsc.Parser import Language.Rsc.Pretty import Language.Rsc.Program import Language.Rsc.SSA.SSA import Language.Rsc.Symbols import Language.Rsc.SystemUtils import Language.Rsc.Typecheck.Environment import Language.Rsc.Typecheck.Sub import Language.Rsc.Typecheck.Subst import Language.Rsc.Typecheck.TCMonad import Language.Rsc.Typecheck.Types import Language.Rsc.Typecheck.Unify import Language.Rsc.Types import Language.Rsc.TypeUtilities import Language.Rsc.Visitor import Text.PrettyPrint.HughesPJ (($+$)) -- import Debug.Trace hiding (traceShow) import qualified System.Console.CmdArgs.Verbosity as V -------------------------------------------------------------------------------- -- | Top-level Verifier -------------------------------------------------------------------------------- verifyFile :: Config -> [FilePath] -> IO (UAnnSol a, FError) -------------------------------------------------------------------------------- verifyFile cfg fs = runEitherIO (do p <- parseRscFromFiles fs cha <- liftEither (mkCHA p) ssa <- ssaTransform p cha tc <- typeCheck cfg ssa cha return tc) >>= either unsafe (pure . safe cfg) unsafe errs = do putStrLn "\n\n\nErrors Found!\n\n" return $ (NoAnn, errs) safe cfg (Rsc {code = Src fs}) = (NoAnn, failCasts (noFailCasts cfg) fs) where failCasts True _ = F.Safe failCasts False f = applyNonNull F.Safe F.Unsafe $ concatMap castErrors $ casts f casts :: Data r => [Statement (AnnTc r)] -> [AnnTc r] casts = foldStmts castVis () [] where castVis = defaultVisitor { accExpr = aE } aE _ (Cast_ a _) = [a] aE _ _ = [ ] -------------------------------------------------------------------------------- castErrors :: Unif r => AnnTc r -> [Error] -------------------------------------------------------------------------------- castErrors (FA _ l facts) = downErrors where downErrors = [ errorDownCast l t | TypeCast _ t <- facts] -------------------------------------------------------------------------------- typeCheck :: Unif r => Config -> TcRsc r -> ClassHierarchy r -> EitherIO FError (TcRsc r) -------------------------------------------------------------------------------- typeCheck cfg pgm cha = EitherIO $ do startPhase Loud "TC" v <- V.getVerbosity return $ execute cfg v pgm (tcRsc pgm cha) -------------------------------------------------------------------------------- -- | TypeCheck program -------------------------------------------------------------------------------- tcRsc :: Unif r => TcRsc r -> ClassHierarchy r -> TCM r (TcRsc r) -------------------------------------------------------------------------------- tcRsc p@(Rsc {code = Src fs}) cha = do γ <- initGlobalEnv p cha _ <- checkTypes cha (fs',_) <- tcStmts γ fs fs'' <- patch fs' ast_cnt <- getAstCount return $ p { code = Src fs'', maxId = ast_cnt } -- where -- as ss' = vcat $ map (\s0 -> vcat (map (\a -> pp (fSrc a) $+$ -- nest 6 (vcat (map pp (fFact a)))) (FO.toList s0))) ss' -- | Patch annotation on the AST -------------------------------------------------------------------------------- patch :: Unif r => [Statement (AnnTc r)] -> TCM r [Statement (AnnTc r)] -------------------------------------------------------------------------------- patch fs = do (m, θ) <- (,) <$> getAnns <*> getSubst return $ map (\f -> apply θ $ fmap (pa m) f) fs where pa m (FA i l f) = FA i l $ f ++ filter vld (I.findWithDefault [] i m) vld TypInst{} = True vld Overload{} = True vld EltOverload{} = True vld PhiVar{} = True vld PhiLoopTC{} = True vld TypeCast{} = True vld DeadCast{} = True vld _ = False -- accumNodeIds :: Unif r => Statement (AnnTc r) -> [(Int, [Fact r])] -- accumNodeIds = FD.foldl (\b (FA i _ f) -> (i, f): b) [] -------------------------------------------------------------------------------- -- | TypeCheck Function -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- tcFun :: Unif r => TCEnv r -> Statement (AnnTc r) -> TCM r (Statement (AnnTc r), Maybe (TCEnv r)) -------------------------------------------------------------------------------- tcFun γ (FunctionStmt l f xs Nothing) = return $ (FunctionStmt l f xs Nothing, Just γ) tcFun γ (FunctionStmt l f xs (Just body)) | Just ft <- tcEnvFindTy f γ = do ts <- tcFunTys l f xs ft body' <- foldM (tcCallable γ l f xs) body ts return $ (FunctionStmt l f xs (Just body'), Just γ) | otherwise = die $ errorMissingSpec (srcPos l) f tcFun _ s = die $ bug (srcPos s) $ "Calling tcFun not on FunctionStatement" -- | `tcCallable g l f xs fty body` checks @body@ under the environment @g@ -- (which needs to be set beforehand), with input arguments @xs@ and overload -- signature @fty@ (which includes the context number). -------------------------------------------------------------------------------- tcCallable :: (Unif r, PP f, IsLocated f) => TCEnv r -> AnnTc r -> f -> [Id (AnnTc r)] -> [Statement (AnnTc r)] -> IOverloadSig r -> TCM r [Statement (AnnTc r)] -------------------------------------------------------------------------------- tcCallable γ l f xs body fty = do γ' <- initCallableEnv l γ f fty xs body body' <- addReturnStmt l γ' body tcFunBody γ' l body' addReturnStmt l γ body | isTVoid (tcEnvFindReturn γ) = (body ++) . single <$> (`ReturnStmt` Nothing) <$> freshenAnn l | otherwise = return body tcFunBody γ l body = do z <- tcStmts γ body case z of (_, Just _) | rt /= tVoid -> fatal er (b, _ ) | otherwise -> return b where er = errorMissingReturn (srcPos l) rt = tcEnvFindReturn γ -------------------------------------------------------------------------------- tcSeq :: (TCEnv r -> a -> TCM r (a, TCEnvO r)) -> TCEnv r -> [a] -> TCM r ([a], TCEnvO r) -------------------------------------------------------------------------------- tcSeq f = go [] where go acc γ [] = return (reverse acc, Just γ) go acc γ (x:xs) = do (y, γo) <- f γ x case γo of Nothing -> return (reverse acc ++ y:xs, Nothing) Just γ' -> go (y:acc) γ' xs -------------------------------------------------------------------------------- tcStmts :: Unif r => TCEnv r -> [Statement (AnnTc r)] -> TCM r ([Statement (AnnTc r)], TCEnvO r) -------------------------------------------------------------------------------- tcStmts = tcSeq tcStmt -------------------------------------------------------------------------------- tcStmt :: Unif r => TCEnv r -> Statement (AnnTc r) -> TCM r (Statement (AnnTc r), TCEnvO r) -------------------------------------------------------------------------------- -- | skip tcStmt γ s@(EmptyStmt _) = return (s, Just γ) -- | interface Foo (this definition will be hoisted) tcStmt γ s@(InterfaceStmt _ _) = return (s, Just γ) -- | x = e tcStmt γ s@(ExprStmt l (AssignExpr l1 OpAssign (LVar lx x) e)) = tcWrap check >>= tcSW γ s where check = case tcEnvFindSymInfo x γ of -- Just (SI _ _ WriteGlobal t) -> do -- (e', _) <- tcExprT γ e t -- γ' <- pure (tcEnvAdd (SI xSym Local WriteGlobal t) γ) -- return (mkStmt e', Just γ') Just (SI _ _ WriteGlobal t) -> do (e', _) <- tcExprT γ e t return (mkStmt e', Just γ) Just (SI _ _ a _) -> error $ "Could this happen- x = e ?? " ++ ppshow a Nothing -> do (e', t) <- tcExpr γ e Nothing γ' <- pure (tcEnvAdd (SI xSym Local WriteLocal t) γ) return (mkStmt e', Just γ') mkStmt = ExprStmt l . AssignExpr l1 OpAssign (LVar lx x) xSym = F.symbol x -- | e1.f = e2 tcStmt γ s@(ExprStmt l (AssignExpr l2 OpAssign (LDot l1 e1 f) e2)) = tcWrap check >>= tcSW γ s where check = do ue1 <- pure (enableUnique e1) (e1', t1) <- tcExpr γ ue1 Nothing m1o <- pure (getMutability (envCHA γ) t1) m1fo <- pure (getFieldMutability (envCHA γ) t1 f) case (m1o, m1fo) of (Just m1, Just m1f) | isSubtype γ m1f tMU || isSubtypeWithUq γ m1 tUQ -> case getProp l γ F.dummySymbol f t1 of Left e -> tcError e Right (unzip -> (ts, fs)) -> do e1'' <- castM γ e1' True t1 (tOr ts) -- This is a consumable position --> UQ is allowed (e2' , _) <- tcScan (tcExprT γ) e2 (map f_ty fs) return (ExprStmt l (AssignExpr l2 OpAssign (LDot l1 e1'' f) e2'), Just γ) | otherwise -> tcError (errorImmutableRefAsgn l f e1 t1) (Nothing, _) -> tcError (errorExtractMut l t1 e1) (_, Nothing) -> tcError (errorExtractFldMut l f t1) -- | e tcStmt γ (ExprStmt l e) = do (e', to) <- tcExprW γ e return (ExprStmt l e', const γ <$> to) -- | s1;s2;...;sn tcStmt γ (BlockStmt l stmts) = do (stmts', g) <- tcStmts γ stmts return (BlockStmt l stmts', g) -- | if b { s1 } tcStmt γ (IfSingleStmt l b s) = tcStmt γ (IfStmt l b s (EmptyStmt l)) -- | if b { s1 } else { s2 } tcStmt γ s@(IfStmt l e s1 s2) = do opTy <- safeEnvFindTy l γ (builtinOpId BITruthy :: Identifier) ([e'], z) <- tcNormalCallW γ l (builtinOpId BITruthy :: Identifier) [e] opTy case z of Just _ -> do z1 <- tcStmt γ s1 z2 <- tcStmt γ s2 tcWrap (check e' z1 z2) >>= tcSW γ s Nothing -> return (IfStmt l e' s1 s2, Nothing) where check e' (s1', γ1) (s2', γ2) = do z <- envJoin l γ γ1 γ2 return (IfStmt l e' s1' s2', z) -- | while c { b } tcStmt γ (WhileStmt l c b) = tcExprW γ c >>= \case (c', Nothing) -> return (WhileStmt l c' b, Nothing) (c', Just t) -> do _ <- unifyTypeM (srcPos l) γ t tBool -- meh .. (b', γ') <- tcStmt γ b γ' <- envLoopJoin l γ γ' return (WhileStmt l c' b', Just γ') -- | var x1 [ = e1 ]; ... ; var xn [= en]; tcStmt γ (VarDeclStmt l ds) = do (ds', z) <- tcSeq tcVarDecl γ ds return (VarDeclStmt l ds', z) -- | return e tcStmt γ (ReturnStmt l (Just e)) = do (e', _) <- tcWrap check >>= tcEW γ e return (ReturnStmt l (Just e'), Nothing) where rt = tcEnvFindReturn γ check = do (e', t) <- tcExpr γ (enableUnique e) (Just rt) θ <- unifyTypeM (srcPos l) γ t rt (t', rt') <- pure (apply θ t, apply θ rt) e'' <- castM γ e' True t' rt' return (e'', rt') tcStmt _ (ReturnStmt l Nothing) = return (ReturnStmt l Nothing, Nothing) -- | throw e tcStmt γ (ThrowStmt l e) = do (e', _) <- tcExprW γ e return (ThrowStmt l e', Nothing) -- | function (xs) { s } tcStmt γ s@FunctionStmt{} = tcFun γ s -- | class A<S...> [extends B<T...>] [implements I,J,...] { ... } tcStmt γ (ClassStmt l x ce) = do d <- resolveTypeM l γ rn msS <- mapM (tcStaticClassElt γS d) ceS msI <- mapM (tcInstanceClassElt γI d) ceI return $ (ClassStmt l x (msS ++ msI), Just γ) where γS = γ γI = γ rn = QN (envPath γ) (F.symbol x) (ceS, ceI) = partition isStaticClassElt ce -- | module M { ... } tcStmt γ (ModuleStmt l n body) = do γ1 <- initModuleEnv γ n body (ModuleStmt l n *** return (Just γ)) <$> tcStmts γ1 body -- | enum M { ... } tcStmt γ (EnumStmt l n body) = return (EnumStmt l n body, Just $ tcEnvAdd si γ) where si = SI nSym exprt RdOnly tEnum tEnum = TRef (Gen name []) fTop path = envPath γ name = QN path nSym nSym = F.symbol n exprt = Exported -- TODO: do this check -- OTHER (Not handled) tcStmt _ s = convertError "tcStmt" s -------------------------------------------------------------------------------- tcVarDecl :: Unif r => TCEnv r -> VarDecl (AnnTc r) -> TCM r (VarDecl (AnnTc r), TCEnvO r) -------------------------------------------------------------------------------- tcVarDecl γ v@(VarDecl l x (Just e)) = case varDeclSymbol v of Left err -> fatal err Right Nothing -> do -- Local (no type annotation) (e', to) <- tcExprW γ e sio <- pure (SI xSym Local WriteLocal <$> to) return (VarDecl l x (Just e'), tcEnvAddo γ x sio) -- Local (with type annotation) Right (Just (SI _ lc WriteLocal t)) -> do (e', t') <- tcExprT γ e t return ( VarDecl l x $ Just e' , Just $ tcEnvAdd (SI xSym lc WriteLocal t') γ) -- Global Right (Just s@(SI _ _ WriteGlobal t)) -> do -- PV: the global variable should be in scope already, -- since it is being hoisted to the beginning of the -- scope. (e', _) <- tcExprT γ e t return (VarDecl l x (Just e'), Just $ tcEnvAdd s γ) -- ReadOnly Right (Just (SI _ lc RdOnly t)) -> do ([e'], Just t') <- tcNormalCallWCtx γ l exprTId [(e, Just t)] (idTy t) return ( VarDecl l x $ Just e' , Just $ tcEnvAdd (SI xSym lc RdOnly t') γ) c -> fatal (unimplemented l "tcVarDecl" ("case: " ++ ppshow c)) where xSym = F.symbol x exprTId = builtinOpId BIExprT :: Identifier tcVarDecl γ v@(VarDecl l x Nothing) = case varDeclSymbol v of Left err -> fatal err Right (Just (SI _ lc Ambient t)) -> return $ (v, Just $ tcEnvAdds [(x, SI xSym lc Ambient t)] γ) Right _ -> fatal (bug l "TC-tcVarDecl: this shouldn't happen") where xSym = F.symbol x -------------------------------------------------------------------------------- tcStaticClassElt :: Unif r => TCEnv r -> TypeDecl r -> ClassElt (AnnTc r) -> TCM r (ClassElt (AnnTc r)) -------------------------------------------------------------------------------- -- | Static method: The classes type parameters should not be included in env -- tcStaticClassElt γ (TD sig _ ms) (MemberMethDecl l True x xs body) = case F.lookupSEnv (F.symbol x) (s_mems ms) of Just FI{} -> tcError $ bugStaticField l x sig Just (MI _ _ mts) -> do let t = tAnd $ map snd mts its <- tcFunTys l x xs t body' <- foldM (tcCallable γ l x xs) body its return $ MemberMethDecl l True x xs body' Nothing -> fatal (errorClassEltAnnot (srcPos l) (sig) x) -- | Static field -- tcStaticClassElt γ (TD sig _ ms) (MemberVarDecl l True x (Just e)) = case F.lookupSEnv (F.symbol x) (s_mems ms) of Just MI{} -> tcError $ bugStaticField l x sig Just (FI _ _ _ t) -> do ([e'],_) <- tcNormalCall γ l (builtinOpId BIFieldInit :: Identifier) [(e, Just t)] (mkInitFldTy t) return $ MemberVarDecl l True x $ Just e' Nothing -> fatal (errorClassEltAnnot (srcPos l) sig x) tcStaticClassElt _ _ (MemberVarDecl l True x Nothing) = fatal (unsupportedStaticNoInit (srcPos l) x) tcStaticClassElt _ _ c = error (show $ pp "tcStaticClassElt - not a static element: " $+$ pp c) -------------------------------------------------------------------------------- tcInstanceClassElt :: Unif r => TCEnv r -> TypeDecl r -> ClassElt (AnnTc r) -> TCM r (ClassElt (AnnTc r)) -------------------------------------------------------------------------------- -- | Constructor tcInstanceClassElt γ typeDecl (Constructor l xs body) = do its <- tcFunTys l ctor xs ctorTy body' <- foldM (tcCallable γ' l ctor xs) body its return $ Constructor l xs body' where TD sig@(TS _ (BGen nm bs) _) _ ms = typeDecl γ' = tcEnvAdd viExit (initClassCtorEnv sig γ) ctor = builtinOpId BICtor :: Identifier thisT = TRef (Gen nm (map btVar bs)) fTop cExit = builtinOpId BICtorExit :: Identifier viExit = SI (F.symbol cExit) Local Ambient $ mkFun (bs, xts, ret) ret = thisT xts = case expandType def (envCHA γ) thisT of Just (TObj _ ms _ ) -> sortBy c_sym [ B x Req t | (x, FI _ _ _ t) <- F.toListSEnv (i_mems ms) ] _ -> [] c_sym = on compare (show . b_sym) -- XXX: Symbolic compare is on Symbol ID ctorTy = fromMaybe (die $ unsupportedNonSingleConsTy (srcPos l)) (tm_ctor ms) -- | Instance variable -- tcInstanceClassElt _ _ m@(MemberVarDecl _ False _ Nothing) = return m tcInstanceClassElt _ _ (MemberVarDecl l False x _) = die $ bugClassInstVarInit (srcPos l) x -- | Instance method -- -- TODO: check method mutability -- TODO: The method's mutability should influence the type of tThis that is used -- as a binder to this. -- TODO: Also might not need 'tce_this' -- tcInstanceClassElt γ (TD sig _ ms) (MemberMethDecl l False x xs bd) | Just (MI _ _ mts) <- F.lookupSEnv (F.symbol x) (i_mems ms) = do let (ms', ts) = unzip mts its <- tcFunTys l x xs $ tAnd ts let mts' = zip ms' its bd' <- foldM (\b (m,t) -> tcCallable (mkEnv m) l x xs b t) bd mts' return $ MemberMethDecl l False x xs bd' | otherwise = fatal (errorClassEltAnnot (srcPos l) (sig) x) where mkEnv m = initClassMethEnv m sig γ tcInstanceClassElt _ _ c = error (show $ pp "tcInstanceClassElt - not an instance element: " $+$ pp c) -- | `tcExprT l fn γ e t` checks expression `e` -- -- * under environment `γ`, -- -- * against a type `t`. -- -- Expressions that are ONLY contextually typed, do not need to be checked -- against type `t`. -------------------------------------------------------------------------------- tcExprT :: Unif r => TCEnv r -> ExprSSAR r -> RType r -> TCM r (ExprSSAR r, RType r) -------------------------------------------------------------------------------- tcExprT γ e t | onlyCtxTyped e = tcExprWD γ e (Just t) | otherwise = do ([e'], _) <- tcNormalCall γ l exprTId [(e, Just t)] (idTy t) return (e', t) where l = getAnnotation e exprTId = builtinOpId BIExprT :: Identifier tcEnvAddo _ _ Nothing = Nothing tcEnvAddo γ x (Just t) = Just (tcEnvAdds [(x, t)] γ) -------------------------------------------------------------------------------- tcExprW :: Unif r => TCEnv r -> ExprSSAR r -> TCM r (ExprSSAR r, Maybe (RType r)) -------------------------------------------------------------------------------- tcExprW γ e = tcWrap (tcExpr γ e Nothing) >>= tcEW γ e -- | `tcExprWD γ e t` checks expression @e@ under environment @γ@. -- (with an optional contextual type @t@ potentially wrapping it in a cast) -- -------------------------------------------------------------------------------- tcExprWD :: Unif r => TCEnv r -> ExprSSAR r -> Maybe (RType r) -> TCM r (ExprSSAR r, RType r) -------------------------------------------------------------------------------- tcExprWD γ e t = do eet <- tcWrap (tcExpr γ e t) et <- tcEW γ e eet case et of (e', Just t) -> return (e', t) (e', _ ) -> return (e', tBot) -- | Wraps `tcNormalCall` with a cast-wrapping check of an error. -- -------------------------------------------------------------------------------- tcNormalCallW :: Unif r => TCEnv r -> AnnTc r -> Identifier -> [ExprSSAR r] -> RType r -> TCM r ([ExprSSAR r], Maybe (RType r)) -------------------------------------------------------------------------------- tcNormalCallW γ l o es t = tcWrap (tcNormalCall γ l o (es `zip` nths) t) >>= \case Right (es', t') -> return (es', Just t') Left e -> (,Nothing) <$> mapM (deadcastM "tcNormalCallW" γ [e]) es -------------------------------------------------------------------------------- tcNormalCallWCtx :: Unif r => TCEnv r -> AnnTc r -> Identifier -> [(ExprSSAR r, Maybe (RType r))] -> RType r -> TCM r ([ExprSSAR r], Maybe (RType r)) -------------------------------------------------------------------------------- tcNormalCallWCtx γ l o es t = tcWrap (tcNormalCall γ l o es t) >>= \case Right (es', t') -> return (es', Just t') Left err -> (,Nothing) <$> mapM (deadcastM "tcNormalCallWCtx" γ [err]) (fst <$> es) -- | Like `tcNormalCallW`, but return _|_ in case of failure -- -------------------------------------------------------------------------------- tcNormalCallWD :: Unif r => TCEnv r -> AnnTc r -> Identifier -> [ExprSSAR r] -> RType r -> TCM r ([ExprSSAR r], RType r) -------------------------------------------------------------------------------- tcNormalCallWD γ l o es t = tcNormalCallW γ l o es t >>= \case (es', Just t) -> return (es', t) (es', _ ) -> return (es', tBot) -- | Wrap expressions and statement in deadcasts -- -- Both return empty environments in case of a failure. This causes the -- remainder of the basic block to not b checked at all. If this is not the -- prefered behavior, change by returning `Just γ`, where `γ` the input -- environment. -- -------------------------------------------------------------------------------- tcEW :: Unif r => TCEnv r -> ExprSSAR r -> Either Error (ExprSSAR r, b) -> TCM r ((ExprSSAR r), Maybe b) -------------------------------------------------------------------------------- tcEW _ _ (Right (e', t')) = return (e', Just t') tcEW γ e (Left er) = (,Nothing) <$> deadcastM "tcEW" γ [er] e -------------------------------------------------------------------------------- tcSW :: Unif r => TCEnv r -> Statement (AnnSSA r) -> Either Error (Statement (AnnSSA r), Maybe b) -> TCM r (Statement (AnnSSA r), Maybe b) -------------------------------------------------------------------------------- tcSW _ _ (Right (s, b)) = return (s, b) tcSW γ s (Left e) = do l1 <- freshenAnn l l2 <- freshenAnn l dc <- deadcastM "tcSW" γ [e] (NullLit l1) return (ExprStmt l2 dc, Nothing) where l = getAnnotation s -------------------------------------------------------------------------------- tcExpr :: Unif r => TCEnv r -> ExprSSAR r -> Maybe (RType r) -> TCM r (ExprSSAR r, RType r) -------------------------------------------------------------------------------- tcExpr _ e@(IntLit _ _) _ = return (e, tNum) tcExpr _ e@(NumLit _ _) _ = return (e, tReal) tcExpr _ e@(HexLit _ _) _ = return (e, tBV32) tcExpr _ e@(BoolLit _ _) _ = return (e, tBool) tcExpr _ e@(StringLit _ _) _ = return (e, tString) tcExpr _ e@(NullLit _) _ = return (e, tNull) tcExpr γ e@(ThisRef l) _ = case tcEnvFindTy thisSym γ of Just t -> return (e, t) Nothing -> fatal (errorUnboundId (fSrc l) "this") tcExpr γ e@(VarRef l x) _ -- | `undefined` | F.symbol x == F.symbol "undefined" = return (e, tUndef) -- | Ignore the `cast` variable | Just t <- to, isCastId x = return (e,t) -- | If `x` is a unique reference and it this does not appear to be -- place where unique references can appear, then flag an error. | Just t <- to , Just m <- getMutability (envCHA γ) t , isSubtypeWithUq γ m tUQ , not (isUniqueEnabled e) = tcError (errorUniqueRef l (Just e)) -- | Regural bound variable | Just t <- to = return (e,t) | otherwise = tcError (errorUnboundId (fSrc l) x) where to = tcEnvFindTy x γ tcExpr γ (CondExpr l e e1 e2) (Just t) = do opTy <- safeEnvFindTy l γ (builtinOpId BITruthy :: Identifier) ([e'], z) <- tcNormalCallW γ l (builtinOpId BITruthy :: Identifier) [e] opTy case z of Just _ -> do (e1', _) <- tcWrap (tcExprT γ e1 t) >>= tcEW γ e1 (e2', _) <- tcWrap (tcExprT γ e2 t) >>= tcEW γ e2 return (CondExpr l e' e1' e2', t) Nothing -> error "TODO: error tcExpr condExpr" tcExpr _ e@(CondExpr l _ _ _) Nothing = tcError $ unimpCondExpCtxType l e tcExpr γ e@(PrefixExpr _ _ _) s = tcCall γ e s tcExpr γ e@(InfixExpr _ _ _ _) s = tcCall γ e s -- | f(e) tcExpr γ e@(CallExpr _ _ _) s = tcCall γ e s -- | [e1,..,en] tcExpr γ e@(ArrayLit l es) to = arrayLitTy l γ e to (length es) >>= \case Left ee -> fatal ee Right opTy -> first (ArrayLit l) <$> tcNormalCallWD γ l (builtinOpId BIArrayLit) es opTy -- | { f1: e1, ..., fn: tn } tcExpr γ (ObjectLit l pes) to = do (es', ts) <- unzip <$> T.mapM (uncurry (tcExprWD γ)) ets t <- pure (TObj tUQ (tmsFromList (zipWith toFI ps ts)) fTop) return $ (ObjectLit l (zip ps es'), t) where (ps , _) = unzip pes toFI p t = FI (F.symbol p) Req tUQ t ets = map (\(p,e) -> (e, pTy p)) pes pTy p | Just f@FI{} <- lkup p = Just (f_ty f) | otherwise = Nothing lkup p = F.lookupSEnv (F.symbol p) ctxTys ctxTys = maybe mempty (i_mems . typeMembersOfType (envCHA γ)) to -- | <T>e tcExpr γ ex@(Cast l e) _ | [t] <- [ct | UserCast ct <- fFact l] = first (Cast l) <$> tcCast l γ e t | otherwise = die $ bugNoCasts (srcPos l) ex -- | Subtyping induced cast -- -- If the existing cast has been added by another context (i.e. e' == Cast_ ...) -- then typecheck the contents of the cast and return the type of the internal -- expression. -- -- If it's from the same context then the internal expression has been -- typechecked, so just return the inferred type. -- tcExpr γ (Cast_ l e) to = case tCasts ++ dCasts of -- No casts in this context [ ] -> do (e', t) <- tcExpr γ e to l' <- freshenAnn l return (Cast_ l' e', t) -- [Right t] -> pure (Cast_ l e, ofType t) -- [Left _ ] -> pure (Cast_ l e, tBot) _ -> die $ bugNestedCasts (srcPos l) e where tCasts = [ Right t_ | TypeCast ξ t_ <- fFact l, tce_ctx γ == ξ ] dCasts = [ Left es | DeadCast ξ es <- fFact l, tce_ctx γ == ξ ] -- | e.f tcExpr γ e@(DotRef _ _ _) s = tcCall γ e s -- | e1[e2] tcExpr γ e@(BracketRef _ _ _) s = tcCall γ e s -- | e1[e2] = e3 tcExpr γ e@(AssignExpr _ OpAssign (LBracket _ _ _) _) s = tcCall γ e s -- | new C(e, ...) tcExpr γ e@(NewExpr _ _ _) s = tcCall γ e s -- | super tcExpr γ e@(SuperRef l) _ = case tcEnvFindTy (builtinOpId BISuper :: Identifier) γ of Just t -> return (e,t) Nothing -> fatal (errorSuper (fSrc l)) -- | function (x,..) { } tcExpr γ (FuncExpr l fo xs body) tCtxO | Just ft <- funTy = do ts <- tcFunTys l f xs ft body' <- foldM (tcCallable γ l f xs) body ts return $ (FuncExpr l fo xs body', ft) | otherwise = fatal (errorNoFuncAnn $ srcPos l) where funTy | [ft] <- [ t | SigAnn _ _ t <- fFact l ] = Just ft | Just ft <- tCtxO = Just ft | otherwise = Nothing f = maybe (F.symbol "<anonymous>") F.symbol fo tcExpr _ e _ = convertError "tcExpr" e -- | @tcCast@ emulating a simplified version of a function call -------------------------------------------------------------------------------- tcCast :: Unif r => AnnTc r -> TCEnv r -> ExprSSAR r -> RType r -> TCM r (ExprSSAR r, RType r) -------------------------------------------------------------------------------- tcCast l γ e tc = do ([e'],t') <- tcNormalCall γ l (builtinOpId BICastExpr :: Identifier) [(e, Just tc)] (castTy tc) return (e', t') -------------------------------------------------------------------------------- tcCall :: Unif r => TCEnv r -> ExprSSAR r -> Maybe (RType r) -> TCM r (ExprSSAR r, RType r) -------------------------------------------------------------------------------- -- | `o e` tcCall γ (PrefixExpr l o e) _ = do opTy <- safeEnvFindTy l γ (prefixOpId o :: Identifier) z <- tcNormalCallWD γ l (prefixOpId o) [e] opTy case z of ([e'], t) -> return (PrefixExpr l o e', t) _ -> fatal (impossible l "tcCall PrefixExpr") -- | `e1 o e2` tcCall γ (InfixExpr l o@OpInstanceof e1 e2) _ = do (e2',t) <- tcExpr γ e2 Nothing case t of TClass (BGen (QN _ x) _) -> do opTy <- safeEnvFindTy l γ (infixOpId o :: Identifier) ([e1',_], t') <- let args = [e1, StringLit l2 (F.symbolSafeString x)] in tcNormalCallWD γ l (infixOpId o) args opTy -- TODO: add qualified name return (InfixExpr l o e1' e2', t') _ -> fatal (unimplemented l "tcCall-instanceof" $ ppshow e2) where l2 = getAnnotation e2 tcCall γ (InfixExpr l o e1 e2) _ = do opTy <- safeEnvFindTy l γ (infixOpId o :: Identifier) z <- tcNormalCallWD γ l (infixOpId o :: Identifier) [e1, e2'] opTy case z of ([e1', e2'], t) -> return (InfixExpr l o e1' e2', t) _ -> fatal (impossible (srcPos l) "tcCall InfixExpr") where e2' | o `elem` [OpIn] = enableUnique e2 | otherwise = e2 -- | `e1[e2]` Special case for Enumeration, and object literals with numeric -- or string arguments. -- tcCall γ e@(BracketRef l e1 e2) _ = runFailM (tcExpr γ e1 Nothing) >>= \case -- Enumeration Right (_, t) | isEnumType (envCHA γ) t -> fatal (unimplemented (srcPos l) msg e) -- Default _ -> safeEnvFindTy l γ (builtinOpId BIBracketRef :: Identifier) >>= call where msg = "Support for dynamic access of enumerations" call ty = tcNormalCallWD γ l (builtinOpId BIBracketRef :: Identifier) [e1, e2] ty >>= \case ([e1', e2'], t) -> return (BracketRef l e1' e2', t) _ -> fatal (impossible (srcPos l) "tcCall BracketRef") -- | `e1[e2] = e3` tcCall γ (AssignExpr l OpAssign (LBracket l1 e1 e2) e3) _ = do opTy <- safeEnvFindTy l γ (builtinOpId BIBracketAssign :: Identifier) z <- tcNormalCallWD γ l (builtinOpId BIBracketAssign :: Identifier) [enableUnique e1,e2,e3] opTy case z of ([e1', e2', e3'], t) -> return (AssignExpr l OpAssign (LBracket l1 e1' e2') e3', t) _ -> fatal (impossible (srcPos l) "tcCall AssignExpr") -- | `new e(e1,...,en)` tcCall γ (NewExpr l e es) s = do (e',t) <- tcExpr γ e Nothing case extractCtor γ t of Just ct -> do (es', tNew) <- tcNormalCallWD γ l (builtinOpId BICtor :: Identifier) es ct tNew' <- pure (adjustCtxMut tNew s) return (NewExpr l e' es', tNew') Nothing -> fatal (errorConstrMissing (srcPos l) t) -- | e.f -- tcCall γ (DotRef l e0 f) _ = do tOpt <- runFailM (tcExpr γ ue Nothing) case tOpt of Right et -> checkAccess et Left (TCErr Fatal e) -> fatal e Left (TCErr NonFatal e) -> tcError e where ue = enableUnique e0 checkAccess (_, tRcvr) = do b <- unifyAndSubtypeM l γ tRcvr genArrTy -- Is this an array '.length' access? if b && F.symbol f == F.symbol "length" then checkArrayLength -- Otherwise, treat as normal access. else checkProp (getProp l γ F.dummySymbol f tRcvr) -- `a.length` checkArrayLength = do l1 <- freshenAnn l l2 <- freshenAnn l i <- freshenId (builtinOpId BIGetLength) tcExpr γ (CallExpr l1 (VarRef l2 i) [ue]) Nothing -- Normal property access checkProp (Left er) = tcError er checkProp (Right tfs) = do let (rTs, fs) = unzip tfs (e0', _) <- tcExprT γ ue (tOr rTs) let t = tyWithOpt fs return (DotRef l e0' f, t) -- Add `or undef` in case of an optional field access tyWithOpt fs = case unzip [(t, o) | FI _ o _ t <- fs] of (ts, os) | Opt `elem` os -> orUndef (tOr ts) | otherwise -> tOr ts -- forall M T . Array<M,T> genArrTy = mkAll bvs (TRef (Gen arrayName vs) fTop) where bvs = [BTV m def (Just tRO), BTV t def Nothing] vs = map tVar [TV m def, TV t def] m = F.symbol "M" t = F.symbol "T" -- | `super(e1,...,en)` -- -- XXX: there shouldn't be any `super(..)` calls after SSA ... -- tcCall _ (CallExpr _ (SuperRef _) _) _ = error "BUG: super(..) calls should have been eliminated" -- | `e.m(es)` -- tcCall γ (CallExpr l em@(DotRef l1 e0 f) es) _ -- | isVariadicCall f = tcError (unimplemented l "Variadic" ex) | otherwise = checkNonVariadic where ue = enableUnique e0 -- -- Variadic check -- isVariadicCall f_ = F.symbol f_ == F.symbol "call" -- Non-variadic checkNonVariadic = runFailM (tcExpr γ ue Nothing) >>= \case Right (_, te) -> checkMemberAccess te Left (TCErr Fatal e) -> fatal e Left (TCErr NonFatal e) -> tcError e -- Check all corresponding type members `tms` checkMemberAccess te = case getProp l γ F.dummySymbol f te of Right tms@(map fst -> ts) -> do (e', _ ) <- tcExprT γ ue (tOr ts) (es', ts') <- foldM stepTypeMemM (es, []) tms return (CallExpr l (DotRef l1 e' f) es', tOr ts') Left e -> tcError e stepTypeMemM (es_, ts) (tR, m) = second (:ts) <$> checkTypeMember es_ tR m -- Check a single type member checkTypeMember es_ _ (FI _ Req _ ft) = tcNormalCallWD γ l biID es_ ft checkTypeMember _ _ (FI f _ _ _ ) = tcError $ errorOptFunUnsup l f ue checkTypeMember es_ tR (MI _ Req mts) = case getMutability (envCHA γ) tR of Just mR -> case [ t | (m, t) <- mts, isSubtypeWithUq γ mR m ] of [] -> tcError $ errorMethMutIncomp l em mts mR ts -> tcNormalCallWD γ l biID es_ (tAnd ts) Nothing -> tcError $ errorNoMutAvailable l ue tR checkTypeMember _ _ (MI _ Opt _) = error "TODO: Add error message at checkTypeMember MI Opt" biID = builtinOpId BIDotRefCallExpr -- | `e(es)` tcCall γ ex@(CallExpr l e es) _ = do (e', ft0) <- tcExpr γ e Nothing tcWrap (tcNormalCall γ l (builtinOpId BICallExpr) (es `zip` nths) ft0) >>= \case Right (es', t) -> return (CallExpr l e' es', t) Left e -> (,tBot) <$> deadcastM "tcCall-CallExpr" γ [e] ex -- (es', t) <- tcNormalCallWD γ l (builtinOpId BICallExpr) es ft0 -- return (CallExpr l e' es', t) tcCall _ e _ = fatal (unimplemented (srcPos e) "tcCall" e) -------------------------------------------------------------------------------- -- | @tcNormalCall@ resolves overloads and returns cast-wrapped versions of -- the arguments if subtyping fails. -- -- May throw exceptions. -- -------------------------------------------------------------------------------- tcNormalCall :: Unif r => TCEnv r -> AnnTc r -> Identifier -> [(ExprSSAR r, Maybe (RType r))] -> RType r -> TCM r ([ExprSSAR r], RType r) -------------------------------------------------------------------------------- tcNormalCall γ l fn etos ft0 = do ets <- T.mapM (uncurry (tcExpr γ)) etos z <- resolveOverload γ l fn ets ft0 case z of Just (i, θ, ft) -> do addAnn l (Overload (tce_ctx γ) (F.symbol fn) i) addSubst l θ (es, ts) <- pure (unzip ets) -- tcCallCase γ l fn es ts ft -- XXX: Why all this ?? tcWrap (tcCallCase γ l fn es ts ft) >>= \case Right ets' -> return ets' Left er -> do es' <- T.mapM (deadcastM "tcNormalCall" γ [er] . fst) ets return (es', tNull) Nothing -> tcError $ uncurry (errorCallNotSup (srcPos l) fn ft0) (unzip ets) -------------------------------------------------------------------------------- -- | `resolveOverload γ l fn es ts ft` -- -- When resolving an overload there are two prossible cases: -- -- 1. There is only a single signature available: then return just this -- signature regardless of subtyping constraints -- -- 2. There are more than one signature available: return all that pass the -- subtype check (this is what tcCallCaseTry does). -- -------------------------------------------------------------------------------- resolveOverload :: (Unif r, PP a) => TCEnv r -> AnnTc r -> a -> [(ExprSSAR r, RType r)] -> RType r -> TCM r (Maybe (IntCallSite, RSubst r, RType r)) -------------------------------------------------------------------------------- -- | A function signature is compatible if: -- -- * The supplied parameters have the same number of 'normal' arguments, i.e. -- not including the 'self' argument. -- -- * If the function requires a 'self' argument, the parameters provide one. -- resolveOverload γ l fn es ft = case validOverloads of [(i,t)] -> Just . (i,,t) <$> getSubst _ -> tcCallCaseTry γ l fn (snd <$> es) validOverloads where validOverloads = [ (i, mkFun s) | (i, s@(_, bs, _)) <- overloads γ ft , length bs == length es ] -------------------------------------------------------------------------------- -- | A successful pairing of formal to actual parameters will return `Just θ`, -- where @θ@ is the corresponding substitution. If the types are not acceptable -- this will return `Nothing`. In this case successful means: -- -- 1. Unifying without errors. -- -- 2. Passing the subtyping test. -- -- The monad state is completely reversed after this function returns, thanks -- to `runMaybeM`. We don't need to reverse the action of `instantiateFTy`. -------------------------------------------------------------------------------- tcCallCaseTry :: (Unif r, PP a) => TCEnv r -> AnnTc r -> a -> [RType r] -> [(IntCallSite, RType r)] -> TCM r (Maybe (IntCallSite, RSubst r, RType r)) -------------------------------------------------------------------------------- tcCallCaseTry _ _ _ _ [] = return Nothing tcCallCaseTry γ l fn ts ((i,ft):fts) = runFailM go >>= \case Right (Just θ') -> return $ Just (i, θ', ft) _ -> tcCallCaseTry γ l fn ts fts where go = do (βs, its1, _) <- instantiateFTy l (tce_ctx γ) fn ft ts1 <- zipWithM (instantiateTy l $ tce_ctx γ) [1..] ts θ <- unifyTypesM (srcPos l) γ ts1 its1 let (ts2, its2) = apply θ (ts1, its1) -- 1. Pick the type variables (V) that have a bound (B). -- 2. Find the binding that the unification braught to them (T := V θ). let (appVs, cs) = unzip [(apply θ (btVar bv), c) | bv@(BTV _ _ (Just c)) <- βs] -- 3. Use that to check against the bound B. -- 4. Also check the argument types. if appVs <:: cs && ts2 <:: its2 then return $ Just θ else return Nothing (<::) ts1 ts2 = and (zipWith (isSubtypeWithUq γ) ts1 ts2) -------------------------------------------------------------------------------- tcCallCase :: (PP a, Unif r) => TCEnv r -> AnnTc r -> a -> [ExprSSAR r] -> [RType r] -> RType r -> TCM r ([ExprSSAR r], RType r) -------------------------------------------------------------------------------- tcCallCase γ@(tce_ctx -> ξ) l fn es ts ft = do (βs, rhs, ot) <- instantiateFTy l ξ fn ft lhs <- zipWithM (instantiateTy l ξ) [1..] ts θ <- unifyTypesM (srcPos l) γ lhs rhs let (vs, appVs, cs) = unzip3 [ (s, apply θ (btVar bv), c) | bv@(BTV s l (Just c)) <- βs , not (unassigned (TV s l) θ) ] unless (appVs <:: cs) (tcError (errorBoundsInvalid l vs appVs cs)) let (lhs', rhs') = apply θ (lhs, rhs) es' <- zipWith3M (castMC γ) es lhs' rhs' return $ (es', apply θ ot) where (<::) ts1 ts2 = and (zipWith (isSubtypeWithUq γ) ts1 ts2) -------------------------------------------------------------------------------- instantiateTy :: Unif r => AnnTc r -> IContext -> Int -> RType r -> TCM r (RType r) -------------------------------------------------------------------------------- instantiateTy l ξ i (bkAll -> (bs, t)) = do (_, t) <- freshTyArgs l i ξ bs t -- TODO: need to take the first arg into account, i.e. add the -- constraint to the environment return $ t -------------------------------------------------------------------------------- instantiateFTy :: (Unif r, PP a) => AnnTc r -> IContext -> a -> RType r -> TCM r ([BTVar r], [RType r], RType r) -------------------------------------------------------------------------------- instantiateFTy l ξ fn ft@(bkAll -> (bs, t)) = do (fbs, ft') <- freshTyArgs l 0 ξ bs t (_, ts, t') <- maybe er return (bkFunNoBinds ft') return $ (fbs, ts, t') where er = tcError $ errorNonFunction (srcPos l) fn ft -------------------------------------------------------------------------------- unifyAndSubtypeM :: Unif r => AnnTc r -> TCEnv r -> RType r -> RType r -> TCM r Bool -------------------------------------------------------------------------------- unifyAndSubtypeM l γ t1 t2 = do eSubst <- unif case eSubst of Left _ -> return False Right (t1', t2') -> return $ isSubtype γ t1' t2' where (bs1, t1') = bkAll t1 (bs2, t2') = bkAll t2 unif = runFailM $ do (_, t1'') <- freshTyArgs l 1 (envCtx γ) bs1 t1' (_, t2'') <- freshTyArgs l 2 (envCtx γ) bs2 t2' θ <- unifyTypeM (srcPos l) γ t1'' t2'' return (apply θ t1'', apply θ t2'') -- | envJoin -- -- XXX: May throw `tcError`: wrap appropriately -- -------------------------------------------------------------------------------- envJoin :: Unif r => AnnTc r -> TCEnv r -> TCEnvO r -> TCEnvO r -> TCM r (Maybe (TCEnv r)) -------------------------------------------------------------------------------- envJoin _ _ Nothing x = return x envJoin _ _ x Nothing = return x envJoin l γ (Just γ1) (Just γ2) = do s1s <- mapM (safeEnvFindSI l γ1) xs -- SI entry at the end of the 1st branch s2s <- mapM (safeEnvFindSI l γ2) xs -- SI entry at the end of the 2nd branch return $ Just $ foldl (\γ' (s1, s2) -> tcEnvAdd (siJoin γ1 s1 s2) γ') γ (zip s1s s2s) where xs = [ x | PhiVar x <- fFact l ] siJoin γ s1 s2 | isSubtype γ (v_type s1) (v_type s2) = s2 | isSubtype γ (v_type s2) (v_type s1) = s1 | otherwise = s1 { v_type = tOr [v_type s1, v_type s2] } -------------------------------------------------------------------------------- envLoopJoin :: Unif r => AnnTc r -> TCEnv r -> TCEnvO r -> TCM r (TCEnv r) -------------------------------------------------------------------------------- envLoopJoin _ γ Nothing = return γ -- XXX: use the "next" name for the Φ-var in the propagated env γ_ -- envLoopJoin l γ (Just γ') = foldM (\γ_ (x, x') -> do s <- safeEnvFindSI l γ x s' <- safeEnvFindSI l γ' x' -- [ T2 <: T1 ==> T1 ] -- -- Lift uniqueness restriction since we are not allowing the loop SSA var -- to escape (any more than the original variable). -- if isSubtypeWithUq γ_ (v_type s') (v_type s) then do addAnn l (PhiLoopTC (x, x', toType (v_type s))) return (tcEnvAdd (s { v_name = v_name s' }) γ_) -- This would require a fixpoint computation, so it's not allowed else tcError (errorLoopWiden l x x' (v_type s) (v_type s')) ) γ (zip xs xs') where (xs, xs') = unzip [ x | PhiLoop x <- fFact l ] -------------------------------------------------------------------------------- tcScan :: (a -> b -> TCM r (a, b)) -> a -> [b] -> TCM r (a, [b]) -------------------------------------------------------------------------------- tcScan f e ts = second reverse <$> foldM step (e, []) ts where step (a, bs) b = second (:bs) <$> f a b -- Local Variables: -- flycheck-disabled-checkers: (haskell-liquid) -- End:
UCSD-PL/RefScript
src/Language/Rsc/Typecheck/Checker.hs
bsd-3-clause
46,663
0
24
12,826
15,162
7,639
7,523
743
21
{-# LANGUAGE PatternSynonyms #-} -------------------------------------------------------------------------------- -- | -- Module : Graphics.GL.ARB.TextureCompression -- Copyright : (c) Sven Panne 2019 -- License : BSD3 -- -- Maintainer : Sven Panne <svenpanne@gmail.com> -- Stability : stable -- Portability : portable -- -------------------------------------------------------------------------------- module Graphics.GL.ARB.TextureCompression ( -- * Extension Support glGetARBTextureCompression, gl_ARB_texture_compression, -- * Enums pattern GL_COMPRESSED_ALPHA_ARB, pattern GL_COMPRESSED_INTENSITY_ARB, pattern GL_COMPRESSED_LUMINANCE_ALPHA_ARB, pattern GL_COMPRESSED_LUMINANCE_ARB, pattern GL_COMPRESSED_RGBA_ARB, pattern GL_COMPRESSED_RGB_ARB, pattern GL_COMPRESSED_TEXTURE_FORMATS_ARB, pattern GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, pattern GL_TEXTURE_COMPRESSED_ARB, pattern GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, pattern GL_TEXTURE_COMPRESSION_HINT_ARB, -- * Functions glCompressedTexImage1DARB, glCompressedTexImage2DARB, glCompressedTexImage3DARB, glCompressedTexSubImage1DARB, glCompressedTexSubImage2DARB, glCompressedTexSubImage3DARB, glGetCompressedTexImageARB ) where import Graphics.GL.ExtensionPredicates import Graphics.GL.Tokens import Graphics.GL.Functions
haskell-opengl/OpenGLRaw
src/Graphics/GL/ARB/TextureCompression.hs
bsd-3-clause
1,345
0
5
159
125
85
40
25
0
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances #-} {- | Copyright : 2010 Aristid Breitkreuz License : BSD3 Stability : experimental Portability : portable This module provides Arrow-like monad composition for transformers. To be more precise, it is "Category-like", i.e. the parallels are to 'Control.Category.Category'. /This version has been adapted from monadLib-compose, to work with the transformers package./ 'Control.Category.Category' generalises '.' and 'id' to arrows and categories. One such arrow is 'Kleisli', which represents functions returning monadic values. Incidentally, that's equivalent to 'ReaderT'! So it turns out that it is possible to generalise '.' and 'id' to 'ReaderT' ('id' is just 'ask'), as well as to many monad transformer stacks that embed a 'ReaderT' inside. -} module Control.Monad.Compose.Class ( MonadCompose(..) , (<<<) , (>>>) ) where import Control.Monad.Trans.Class import Control.Monad.Trans.Error import Control.Monad.Trans.Identity import Control.Monad.Trans.Maybe import Control.Monad.Trans.Reader import Data.Monoid import qualified Control.Monad.Trans.RWS.Lazy as LazyRWS import qualified Control.Monad.Trans.RWS.Strict as StrictRWS import qualified Control.Monad.Trans.State.Lazy as Lazy import qualified Control.Monad.Trans.State.Strict as Strict import qualified Control.Monad.Trans.Writer.Lazy as Lazy import qualified Control.Monad.Trans.Writer.Strict as Strict --import Control.Monad.Logic (LogicT(..), runLogicT) -- | Composable monads. Compare with 'Control.Category.Category'. -- Note that there are two different monad types involved in each instance. class (Monad m, Monad n) => MonadCompose m n s t | m -> s, n -> t, n s -> m where -- | Compose two monadic values from right to left. @mcompose f g@ is -- comparable to @f . g@ but for monadic values. Compare with 'Control.Category..'. mcompose :: m a -> n s -> n a mcompose m n = mapply m =<< n -- | Apply a constant value to a composable monad. mapply :: m a -> s -> n a mapply m s = mcompose m (return s) -- | Compose two monadic values from right to left. Compare with 'Control.Category.<<<'. -- @f <<< g@ is equivalent to @mcompose f g@. (<<<) :: MonadCompose m n s t => m a -> n s -> n a (<<<) = mcompose infixr 1 <<< -- | Compose two monadic values from left to right. Compare with 'Control.Category.>>>'. -- @g >>> f@ is equivalent to @mcompose f g@. (>>>) :: MonadCompose m n s t => n s -> m a -> n a (>>>) = flip mcompose infixl 1 >>> instance MonadCompose ((->) s) ((->) t) s t where mcompose = (.) instance Monad m => MonadCompose (ReaderT s m) (ReaderT t m) s t where mapply m a = ReaderT $ \_ -> runReaderT m a x_mapply :: (MonadTrans xt, MonadCompose m n s t, Monad (xt n)) => (a -> xt n b) -> (xt m c -> m a) -> xt m c -> s -> xt n b x_mapply close open m s = lift (open m `mapply` s) >>= close x_mapply' :: (MonadTrans xt, MonadCompose m n s t, Monad (xt n)) => (n a -> xt n b) -> (xt m c -> m a) -> xt m c -> s -> xt n b x_mapply' close' open = x_mapply (close' . return) open instance MonadCompose m n s t => MonadCompose (IdentityT m) (IdentityT n) s t where mapply = x_mapply return runIdentityT instance MonadCompose m n s t => MonadCompose (MaybeT m) (MaybeT n) s t where mapply = x_mapply' MaybeT runMaybeT instance (MonadCompose m n s t, Error e) => MonadCompose (ErrorT e m) (ErrorT e n) s t where mapply = x_mapply' ErrorT runErrorT instance MonadCompose m n s t => MonadCompose (Lazy.StateT i m) (Lazy.StateT i n) s t where mapply m a = Lazy.StateT $ \i -> mapply (Lazy.runStateT m i) a instance MonadCompose m n s t => MonadCompose (Strict.StateT i m) (Strict.StateT i n) s t where mapply m a = Strict.StateT $ \i -> mapply (Strict.runStateT m i) a instance (MonadCompose m n s t, Monoid w) => MonadCompose (Lazy.WriterT w m) (Lazy.WriterT w n) s t where mapply = x_mapply' Lazy.WriterT Lazy.runWriterT instance (MonadCompose m n s t, Monoid w) => MonadCompose (Strict.WriterT w m) (Strict.WriterT w n) s t where mapply = x_mapply' Strict.WriterT Strict.runWriterT instance (Monad m, Monoid w) => MonadCompose (LazyRWS.RWST s w i m) (LazyRWS.RWST t w i m) s t where mapply m a = LazyRWS.RWST $ \_ i -> LazyRWS.runRWST m a i instance (Monad m, Monoid w) => MonadCompose (StrictRWS.RWST s w i m) (StrictRWS.RWST t w i m) s t where mapply m a = StrictRWS.RWST $ \_ i -> StrictRWS.runRWST m a i {- instance MonadCompose m n s t => MonadCompose (LogicT m) (LogicT n) s t where mcompose m n = LogicT $ \sk fk -> runLogicT (mcompose m n) sk fk -}
aristidb/transformers-compose
Control/Monad/Compose/Class.hs
bsd-3-clause
4,777
0
11
1,021
1,354
725
629
57
1
module Cis194.Hw.Week1 where import Data.Char ------------- -- Ex 1-4 -- ------------- digitToInteger :: Char->Integer digitToInteger = toInteger . digitToInt toDigits :: Integer -> [Integer] -- | this is some comment -- >>> toDigits 1234 -- [1,2,3,4] toDigits n | n <= 0 = [] | n > 0 = map digitToInteger $ (show n) -- pick off last digit last' :: Integer -> Integer last' = flip mod 10 -- allButLast allButLast :: Integer -> Integer allButLast = flip div 10 toDigitsRev :: Integer -> [Integer] toDigitsRev = reverse . toDigits -- | doublEveryOther: -- >>> doubleEveryOther [8,7,6,5] -- [16,7,12,5] -- >>> doubleEveryOther [1,2,3] -- [1,4,3] doubleEveryOther :: [Integer] -> [Integer] doubleEveryOther n = reverse (zipWith (*) (cycle [1,2]) (reverse n)) bigInt :: Int -> Integer bigInt = toInteger length' :: [Integer]->Integer length' = bigInt . length isEven :: Integer -> Bool isEven = (== 0) . (`mod` 2) sumDigits :: [Integer] -> Integer --sumDigits _ = 0 sumDigits = sum . concat . map toDigits doubleDigits :: Integer -> [Integer] doubleDigits = doubleEveryOther . toDigits validate :: Integer -> Bool validate = isEven . sumDigits . concat . map toDigits . doubleDigits --validate _ = False --------------------- -- Towers of Hanoi -- --------------------- type Peg = String type Move = (Peg, Peg) hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] hanoi _ _ _ _ = [] hanoi4 :: Integer -> Peg -> Peg -> Peg -> Peg -> [Move] hanoi4 _ _ _ _ _ = []
halarnold2000/cis194
src/Cis194/Hw/Week1.hs
bsd-3-clause
1,507
0
10
308
470
266
204
34
1
{-# LANGUAGE BangPatterns, DataKinds, DeriveDataTypeable, DeriveGeneric #-} {-# LANGUAGE FlexibleInstances, GADTs, LambdaCase, NamedFieldPuns #-} {-# LANGUAGE NoOverloadedLists, ParallelListComp, PatternGuards, PolyKinds #-} {-# LANGUAGE RecordWildCards, ScopedTypeVariables, StandaloneDeriving #-} {-# LANGUAGE TupleSections, TypeFamilies, TypeOperators, ViewPatterns #-} {-# OPTIONS_GHC -funbox-strict-fields #-} module Arithmetic.Presburger.Solver.DFA ( -- * Types Expr(..), Formula(..), Ident (Ident), Solution, Validity(..), liftFormula, substitute, Mode(..), -- * Solvers solve, isTautology, satisfiable, entail, leastSuch, minimized, -- * Internal functions and data-types buildDFA, buildDFAWith, getDFASolution, decodeSolution, DFA(..), encode, Bit(..)) where import Arithmetic.Presburger.Solver.DFA.Automata import Arithmetic.Presburger.Solver.DFA.Types import Control.Applicative (Alternative) import Control.Arrow (first) import Control.Monad.Trans.State.Strict (State, execState, get, gets) import Control.Monad.Trans.State.Strict (put) import Data.Either (partitionEithers) import Data.Foldable (asum, toList) import Data.Hashable (Hashable) import qualified Data.HashSet as HS import Data.List (nub, sort, transpose) import qualified Data.Map.Strict as M import Data.Maybe (fromMaybe, isJust) import qualified Data.Sequence as S import Data.Vector (Vector) import qualified Data.Vector as V import Unsafe.Coerce (unsafeCoerce) -- | Solution (or Model) is a map assigning @'Integer'@s to each variable. -- Variables without assingments are assumed to be @0@. -- -- Since 0.1.0.0 type Solution = M.Map Ident Integer -- | Validity of a given formula -- Since 0.1.0.0 data Validity = Proved -- ^ Given Formula is provable. | Refuted !Solution -- ^ Given Formula has coutnerexample(s). deriving (Show, Eq, Ord) -- | @'entail' [f1, ..., fn] [g1, ..., gm]@ tries to prove -- that @f1 :/\ ... :/\ fn@ implies @g1 :\/ ... :\/ gm@. -- -- Since 0.1.0.0 entail :: [Formula n] -> [Formula m] -> Validity entail prem goal = isTautology (foldr1 (:/\) prem :=> foldl1 (:\/) goal) -- | Test if given formula is tautology. -- -- Since 0.1.0.0 isTautology :: Formula m -> Validity isTautology = maybe Proved Refuted . solve . Not -- | @'solve phi'@ finds solutions for formula phi. -- Note that @'solve'@ MAY NOT exhaust all possible solutions for the given formula. solve :: Alternative f => Formula m -> f Solution solve f = let (targ, vdic) = buildDFA $ encode f in asum $ map pure $ nub $ getDFASolution vdic targ {-# INLINE solve #-} -- | Check if the given formula is satisfiable -- -- Since 0.1.0.0 satisfiable :: Formula m -> Bool satisfiable = isJust . solve liftFormula :: Formula e -> Formula 'Extended liftFormula = unsafeCoerce toConstr :: Solution -> [Formula 'Raw] toConstr dic = [ Not ((Var a :: Expr 'Raw) :== Num b) | (a, b) <- M.toList dic ] class Encodable f where encode :: f m -> f 'Raw instance Encodable Expr where encode (Var v) = Var v encode (n :- m) = encode $ n :+ (-1) :* m encode (Num i) = Num i encode (n :+ m) = encode n :+ encode m encode (n :* m) = n :* encode m instance Encodable Formula where encode (Not p) = Not (encode p) encode (p :/\ q) = encode p :/\ encode q encode (p :\/ q) = encode p :\/ encode q encode (p :=> q) = encode $ Not (encode p) :\/ encode q encode (Ex v p) = Ex v (encode p) encode (Any v p) = Not $ Ex v $ Not (encode p) encode (n :<= m) = encode n :<= encode m encode (n :>= m) = encode m :<= encode n encode (n :== m) = encode n :== encode m encode (n :< m) = let (m', n') = (encode m, encode n) in encode $ n' :<= m' :/\ Not (n' :== m') encode (n :> m) = encode $ m :< n -- | Minimizing operator leastSuch :: Ident -> Formula m -> Formula 'Extended leastSuch v f = let x = fresh f in f :/\ Any x (Var x :< Var v :=> Not (subst v x f)) minimized :: Formula m -> Formula 'Extended minimized f = foldr ((.) . leastSuch) id (vars f) (liftFormula f) type Summand = Either Integer (Ident, Integer) summands :: Expr mode -> [Summand] summands (n :* m :* t) = summands ((n * m) :* t) summands (n :- m) = summands (n :+ (-1) :* m) summands (0 :* _) = [] summands (n :* Var i) = [Right (i, n)] summands (n :* Num m) = [Left (n * m)] summands (n :* (l :+ m)) = summands (n :* l) ++ summands (n :* m) summands (n :* (l :- m)) = summands (n :* l) ++ summands ((-n) :* m) summands (Var t) = [Right (t, 1)] summands (Num t) = [Left t] summands (t1 :+ t2) = summands t1 ++ summands t2 type Index = Integer type VarDic = M.Map Ident Integer buildDFA :: Formula 'Raw -> (DFA Integer Bits, VarDic) buildDFA f = let (_, varDic) = execState (mapM getIdx $ sort (vars f)) (0, M.empty) in (buildDFAWith varDic f, varDic) toAtomic :: M.Map Ident Integer -> Expr mode1 -> Expr mode -> Atomic toAtomic vdic a b = let (nb, pxs) = partitionEithers (summands a) (pb, nxs) = partitionEithers (summands b) cfs0 = M.unionWith (+) (M.fromList pxs) (fmap negate $ M.fromList nxs) ub = sum pb - sum nb len = M.size vdic cds = map (first (vdic M.!)) $ M.toList cfs0 cfs = V.generate len $ \i -> fromMaybe 0 (lookup (toInteger i) cds) in Atomic cfs ub buildDFAWith :: VarDic -> Formula 'Raw -> DFA Integer Bits buildDFAWith vdic (a :<= b) = let atomic = toAtomic vdic a b in renumberStates $ leqToDFA atomic buildDFAWith vdic (a :== b) = let atomic = toAtomic vdic a b in renumberStates $ eqToDFA atomic buildDFAWith vdic (Not t) = complement $ buildDFAWith vdic t buildDFAWith vdic (t1 :/\ t2) = let d1 = buildDFAWith vdic (encode t1) d2 = buildDFAWith vdic (encode t2) in renumberStates $ minimize $ d1 `intersection` d2 buildDFAWith vdic (t1 :\/ t2) = let d1 = buildDFAWith vdic (encode t1) d2 = buildDFAWith vdic (encode t2) in renumberStates $ minimize $ d1 `union` d2 buildDFAWith vdic (Ex v t) | v `notElem` vars t = buildDFAWith vdic t | otherwise = let idx = toInteger $ M.size vdic var = Anonymous $ 1 + maximum ((-1) : [i | Anonymous i <- M.keys vdic]) dfa = buildDFAWith (M.insert var idx vdic) $ subst v var t in changeLetter (uncurry (V.++)) $ minimize $ renumberStates $ determinize $ projDFA $ changeLetter (splitNth idx) dfa fresh :: Formula a -> Ident fresh e = Anonymous $ 1 + maximum ((-1) : [i | Anonymous i <- allVarsF e]) allVarsF :: Formula a -> [Ident] allVarsF (e1 :<= e2) = nub $ vars e1 ++ vars e2 allVarsF (e1 :== e2) = nub $ vars e1 ++ vars e2 allVarsF (e1 :< e2) = nub $ vars e1 ++ vars e2 allVarsF (e1 :>= e2) = nub $ vars e1 ++ vars e2 allVarsF (e1 :> e2) = nub $ vars e1 ++ vars e2 allVarsF (Not e) = allVarsF e allVarsF (e1 :\/ e2) = nub $ allVarsF e1 ++ allVarsF e2 allVarsF (e1 :/\ e2) = nub $ allVarsF e1 ++ allVarsF e2 allVarsF (e1 :=> e2) = nub $ allVarsF e1 ++ allVarsF e2 allVarsF (Ex e1 e2) = nub $ e1 : allVarsF e2 allVarsF (Any e1 e2) = nub $ e1 : allVarsF e2 splitNth :: Integer -> Vector a -> ((Vector a, Vector a), a) splitNth n v = let (hd, tl) = V.splitAt (fromInteger n) v in ((hd, V.tail tl), V.head tl) type BuildingEnv = (Index, M.Map Ident Index) getIdx :: Ident -> State BuildingEnv Index getIdx ident = gets (M.lookup ident . snd) >>= \case Just i -> return i Nothing -> do (i, dic) <- get put (i+1, M.insert ident i dic) return i data Atomic = Atomic { coeffs :: Vector Integer , upperBound :: Integer } deriving (Read, Show, Eq, Ord) type MachineState = Integer eqToDFA :: Atomic -> DFA MachineState Bits eqToDFA a@Atomic{..} = atomicToDFA (== 0) (\k xi -> even (k - coeffs .*. xi)) a leqToDFA :: Atomic -> DFA MachineState Bits leqToDFA = atomicToDFA (>= 0) (const $ const True) atomicToDFA :: (Integer -> Bool) -- ^ Is final state? -> (Integer -> Vector Bit -> Bool) -- ^ Candidate reducer -> Atomic -> DFA Integer (Vector Bit) atomicToDFA chkFinal reduce Atomic{..} = let trans = loop (S.singleton upperBound) HS.empty M.empty dfa0 = DFA{ initial = upperBound , final = HS.empty , transition = trans } in renumberStates $ minimize $ expandLetters inputs $ dfa0 { final = HS.filter chkFinal (states dfa0) } where inputs = V.replicateM (V.length coeffs) [O, I] loop (S.viewl -> k S.:< ws) qs trans = let qs' = HS.insert k qs targs = map (\xi -> (xi, (k - (coeffs .*. xi)) `div` 2)) $ filter (reduce k) inputs trans' = M.fromList [ ((k, xi), j) | (xi, j) <- targs ] ws' = S.fromList $ filter (not . (`HS.member` qs')) (map snd targs) in loop (ws S.>< ws') qs' (trans `M.union` trans') loop _ _ tr = tr bitToInt :: Bit -> Integer bitToInt O = 0 bitToInt I = 1 {-# INLINE bitToInt #-} substitute :: Solution -> Expr a -> Integer substitute dic (Var e) = fromMaybe 0 $ M.lookup e dic substitute _ (Num e) = e substitute dic (e1 :+ e2) = substitute dic e1 + substitute dic e2 substitute dic (e1 :- e2) = substitute dic e1 - substitute dic e2 substitute dic (e1 :* e2) = e1 * substitute dic e2 decodeSolution :: VarDic -> [Vector Bit] -> Solution decodeSolution vdic vs | null vs = fmap (const 0) vdic | otherwise = let vvec = V.fromList $ map (foldr (\a b -> bitToInt a + 2*b) 0) $ transpose $ map V.toList vs in M.mapWithKey (const $ fromMaybe 0 . (vvec V.!?) . fromInteger) vdic getDFASolution :: (Ord a, Hashable a, Alternative f) => VarDic -> DFA a (Vector Bit) -> f Solution getDFASolution vdic dfa = let ss = walk dfa in asum $ map (pure . decodeSolution vdic . toList . snd) $ M.toList $ M.filterWithKey (\k _ -> isFinal dfa k) ss
konn/presburger-dfa
src/Arithmetic/Presburger/Solver/DFA.hs
bsd-3-clause
10,242
0
20
2,715
4,035
2,095
1,940
208
2
{-| Module : Data.Algorithm.PPattern.State.IncreasingFactorization Description : Jump to next increasing element facility Copyright : (c) Laurent Bulteau, Romeo Rizzi, Stéphane Vialette, 2016-2017 License : MIT Maintainer : vialette@gmaiList.com Stability : experimental Increasing factorization facility. -} module Data.Algorithm.PPattern.Search.State.IncreasingFactorization ( increasingFactorization ) where import qualified Data.List as List import qualified Data.IntMap.Strict as IntMap import qualified Data.Algorithm.PPattern.Geometry.Point as P import qualified Data.Algorithm.PPattern.Geometry.ColorPoint as ColorPoint import qualified Data.Algorithm.PPattern.Perm as Perm increasingFactorization :: Perm.Perm -> [ColorPoint.ColorPoint] increasingFactorization = increasingFactorization' [] IntMap.empty . Perm.points increasingFactorization' :: [ColorPoint.ColorPoint] -> IntMap.IntMap Int -> [P.Point] -> [ColorPoint.ColorPoint] increasingFactorization' acc _ [] = List.reverse acc increasingFactorization' acc m (p : ps) = increasingFactorization' (cp : acc) m' ps where y = P.yCoord p c = findSmallestColor y m m' = case IntMap.lookup c m of Nothing -> IntMap.insert c y m Just _ -> IntMap.update (\ _ -> Just y) c m cp = ColorPoint.mk' p c -- Auxialiary function for increasingFactorization'. -- Find the smallest color for a new y-coordinate findSmallestColor :: Int -> IntMap.IntMap Int -> Int findSmallestColor y m = aux 1 where aux c = case IntMap.lookup c m of Nothing -> c Just y' -> if y' < y then c else aux (c+1)
vialette/ppattern
src/Data/Algorithm/PPattern/Search/State/IncreasingFactorization.hs
mit
1,712
0
13
374
375
208
167
24
3
{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE PatternGuards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE UndecidableInstances #-} module Database.Persist.Sql.Class ( RawSql (..) , PersistFieldSql (..) , EntityWithPrefix(..) , unPrefix ) where import Data.Bits (bitSizeMaybe) import Data.ByteString (ByteString) import Data.Fixed import Data.Foldable (toList) import Data.Int import qualified Data.IntMap as IM import qualified Data.Map as M import Data.Maybe (fromMaybe) import Data.Proxy (Proxy(..)) import qualified Data.Set as S import Data.Text (Text, intercalate, pack) import qualified Data.Text as T import qualified Data.Text.Lazy as TL import Data.Time (Day, TimeOfDay, UTCTime) import qualified Data.Vector as V import Data.Word import GHC.TypeLits (KnownSymbol, Symbol, symbolVal) import Text.Blaze.Html (Html) import Database.Persist import Database.Persist.Sql.Types -- | Class for data types that may be retrived from a 'rawSql' -- query. class RawSql a where -- | Number of columns that this data type needs and the list -- of substitutions for @SELECT@ placeholders @??@. rawSqlCols :: (Text -> Text) -> a -> (Int, [Text]) -- | A string telling the user why the column count is what -- it is. rawSqlColCountReason :: a -> String -- | Transform a row of the result into the data type. rawSqlProcessRow :: [PersistValue] -> Either Text a instance PersistField a => RawSql (Single a) where rawSqlCols _ _ = (1, []) rawSqlColCountReason _ = "one column for a 'Single' data type" rawSqlProcessRow [pv] = Single <$> fromPersistValue pv rawSqlProcessRow _ = Left $ pack "RawSql (Single a): wrong number of columns." instance (PersistEntity a, PersistEntityBackend a ~ backend, IsPersistBackend backend) => RawSql (Key a) where rawSqlCols _ key = (length $ keyToValues key, []) rawSqlColCountReason key = "The primary key is composed of " ++ (show $ length $ keyToValues key) ++ " columns" rawSqlProcessRow = keyFromValues instance (PersistEntity record, PersistEntityBackend record ~ backend, IsPersistBackend backend) => RawSql (Entity record) where rawSqlCols escape _ent = (length sqlFields, [intercalate ", " $ toList sqlFields]) where sqlFields = fmap (((name <> ".") <>) . escapeWith escape) $ fmap fieldDB $ keyAndEntityFields entDef name = escapeWith escape (getEntityDBName entDef) entDef = entityDef (Nothing :: Maybe record) rawSqlColCountReason a = case fst (rawSqlCols (error "RawSql") a) of 1 -> "one column for an 'Entity' data type without fields" n -> show n <> " columns for an 'Entity' data type" rawSqlProcessRow row = case keyFromRecordM of Just mkKey -> do val <- fromPersistValues row pure Entity { entityKey = mkKey val , entityVal = val } Nothing -> case row of (k : rest) -> Entity <$> keyFromValues [k] <*> fromPersistValues rest [] -> Left "Row was empty" -- | This newtype wrapper is useful when selecting an entity out of the -- database and you want to provide a prefix to the table being selected. -- -- Consider this raw SQL query: -- -- > SELECT ?? -- > FROM my_long_table_name AS mltn -- > INNER JOIN other_table AS ot -- > ON mltn.some_col = ot.other_col -- > WHERE ... -- -- We don't want to refer to @my_long_table_name@ every time, so we create -- an alias. If we want to select it, we have to tell the raw SQL -- quasi-quoter that we expect the entity to be prefixed with some other -- name. -- -- We can give the above query a type with this, like: -- -- @ -- getStuff :: 'SqlPersistM' ['EntityWithPrefix' \"mltn\" MyLongTableName] -- getStuff = rawSql queryText [] -- @ -- -- The 'EntityWithPrefix' bit is a boilerplate newtype wrapper, so you can -- remove it with 'unPrefix', like this: -- -- @ -- getStuff :: 'SqlPersistM' ['Entity' MyLongTableName] -- getStuff = 'unPrefix' @\"mltn\" '<$>' 'rawSql' queryText [] -- @ -- -- The @ symbol is a "type application" and requires the @TypeApplications@ -- language extension. -- -- @since 2.10.5 newtype EntityWithPrefix (prefix :: Symbol) record = EntityWithPrefix { unEntityWithPrefix :: Entity record } -- | A helper function to tell GHC what the 'EntityWithPrefix' prefix -- should be. This allows you to use a type application to specify the -- prefix, instead of specifying the etype on the result. -- -- As an example, here's code that uses this: -- -- @ -- myQuery :: 'SqlPersistM' ['Entity' Person] -- myQuery = fmap (unPrefix @\"p\") <$> rawSql query [] -- where -- query = "SELECT ?? FROM person AS p" -- @ -- -- @since 2.10.5 unPrefix :: forall prefix record. EntityWithPrefix prefix record -> Entity record unPrefix = unEntityWithPrefix instance ( PersistEntity record , KnownSymbol prefix , PersistEntityBackend record ~ backend , IsPersistBackend backend ) => RawSql (EntityWithPrefix prefix record) where rawSqlCols escape _ent = (length sqlFields, [intercalate ", " $ toList sqlFields]) where sqlFields = fmap (((name <> ".") <>) . escapeWith escape) $ fmap fieldDB -- Hacky for a composite key because -- it selects the same field multiple times $ keyAndEntityFields entDef name = pack $ symbolVal (Proxy :: Proxy prefix) entDef = entityDef (Nothing :: Maybe record) rawSqlColCountReason a = case fst (rawSqlCols (error "RawSql") a) of 1 -> "one column for an 'Entity' data type without fields" n -> show n ++ " columns for an 'Entity' data type" rawSqlProcessRow row = case splitAt nKeyFields row of (rowKey, rowVal) -> fmap EntityWithPrefix $ Entity <$> keyFromValues rowKey <*> fromPersistValues rowVal where nKeyFields = length $ getEntityKeyFields entDef entDef = entityDef (Nothing :: Maybe record) -- | @since 1.0.1 instance RawSql a => RawSql (Maybe a) where rawSqlCols e = rawSqlCols e . extractMaybe rawSqlColCountReason = rawSqlColCountReason . extractMaybe rawSqlProcessRow cols | all isNull cols = return Nothing | otherwise = case rawSqlProcessRow cols of Right v -> Right (Just v) Left msg -> Left $ "RawSql (Maybe a): not all columns were Null " <> "but the inner parser has failed. Its message " <> "was \"" <> msg <> "\". Did you apply Maybe " <> "to a tuple, perhaps? The main use case for " <> "Maybe is to allow OUTER JOINs to be written, " <> "in which case 'Maybe (Entity v)' is used." where isNull PersistNull = True isNull _ = False instance (RawSql a, RawSql b) => RawSql (a, b) where rawSqlCols e x = rawSqlCols e (fst x) # rawSqlCols e (snd x) where (cnta, lsta) # (cntb, lstb) = (cnta + cntb, lsta ++ lstb) rawSqlColCountReason x = rawSqlColCountReason (fst x) ++ ", " ++ rawSqlColCountReason (snd x) rawSqlProcessRow = let x = getType processRow getType :: (z -> Either y x) -> x getType = error "RawSql.getType" colCountFst = fst $ rawSqlCols (error "RawSql.getType2") (fst x) processRow row = let (rowFst, rowSnd) = splitAt colCountFst row in (,) <$> rawSqlProcessRow rowFst <*> rawSqlProcessRow rowSnd in colCountFst `seq` processRow -- Avoids recalculating 'colCountFst'. instance (RawSql a, RawSql b, RawSql c) => RawSql (a, b, c) where rawSqlCols e = rawSqlCols e . from3 rawSqlColCountReason = rawSqlColCountReason . from3 rawSqlProcessRow = fmap to3 . rawSqlProcessRow 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 (RawSql a, RawSql b, RawSql c, RawSql d) => RawSql (a, b, c, d) where rawSqlCols e = rawSqlCols e . from4 rawSqlColCountReason = rawSqlColCountReason . from4 rawSqlProcessRow = fmap to4 . rawSqlProcessRow 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 (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e) => RawSql (a, b, c, d, e) where rawSqlCols e = rawSqlCols e . from5 rawSqlColCountReason = rawSqlColCountReason . from5 rawSqlProcessRow = fmap to5 . rawSqlProcessRow from5 :: (a,b,c,d,e) -> ((a,b),(c,d),e) from5 (a,b,c,d,e) = ((a,b),(c,d),e) to5 :: ((a,b),(c,d),e) -> (a,b,c,d,e) to5 ((a,b),(c,d),e) = (a,b,c,d,e) instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f) => RawSql (a, b, c, d, e, f) where rawSqlCols e = rawSqlCols e . from6 rawSqlColCountReason = rawSqlColCountReason . from6 rawSqlProcessRow = fmap to6 . rawSqlProcessRow from6 :: (a,b,c,d,e,f) -> ((a,b),(c,d),(e,f)) from6 (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) to6 ((a,b),(c,d),(e,f)) = (a,b,c,d,e,f) instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g) => RawSql (a, b, c, d, e, f, g) where rawSqlCols e = rawSqlCols e . from7 rawSqlColCountReason = rawSqlColCountReason . from7 rawSqlProcessRow = fmap to7 . rawSqlProcessRow from7 :: (a,b,c,d,e,f,g) -> ((a,b),(c,d),(e,f),g) from7 (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) to7 ((a,b),(c,d),(e,f),g) = (a,b,c,d,e,f,g) instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h) => RawSql (a, b, c, d, e, f, g, h) where rawSqlCols e = rawSqlCols e . from8 rawSqlColCountReason = rawSqlColCountReason . from8 rawSqlProcessRow = fmap to8 . rawSqlProcessRow from8 :: (a,b,c,d,e,f,g,h) -> ((a,b),(c,d),(e,f),(g,h)) from8 (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) to8 ((a,b),(c,d),(e,f),(g,h)) = (a,b,c,d,e,f,g,h) -- | @since 2.10.2 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i) => RawSql (a, b, c, d, e, f, g, h, i) where rawSqlCols e = rawSqlCols e . from9 rawSqlColCountReason = rawSqlColCountReason . from9 rawSqlProcessRow = fmap to9 . rawSqlProcessRow -- | @since 2.10.2 from9 :: (a,b,c,d,e,f,g,h,i) -> ((a,b),(c,d),(e,f),(g,h),i) from9 (a,b,c,d,e,f,g,h,i) = ((a,b),(c,d),(e,f),(g,h),i) -- | @since 2.10.2 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) -- | @since 2.10.2 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j) => RawSql (a, b, c, d, e, f, g, h, i, j) where rawSqlCols e = rawSqlCols e . from10 rawSqlColCountReason = rawSqlColCountReason . from10 rawSqlProcessRow = fmap to10 . rawSqlProcessRow -- | @since 2.10.2 from10 :: (a,b,c,d,e,f,g,h,i,j) -> ((a,b),(c,d),(e,f),(g,h),(i,j)) from10 (a,b,c,d,e,f,g,h,i,j) = ((a,b),(c,d),(e,f),(g,h),(i,j)) -- | @since 2.10.2 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) -- | @since 2.10.2 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k) => RawSql (a, b, c, d, e, f, g, h, i, j, k) where rawSqlCols e = rawSqlCols e . from11 rawSqlColCountReason = rawSqlColCountReason . from11 rawSqlProcessRow = fmap to11 . rawSqlProcessRow -- | @since 2.10.2 from11 :: (a,b,c,d,e,f,g,h,i,j,k) -> ((a,b),(c,d),(e,f),(g,h),(i,j),k) from11 (a,b,c,d,e,f,g,h,i,j,k) = ((a,b),(c,d),(e,f),(g,h),(i,j),k) -- | @since 2.10.2 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) -- | @since 2.10.2 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l) where rawSqlCols e = rawSqlCols e . from12 rawSqlColCountReason = rawSqlColCountReason . from12 rawSqlProcessRow = fmap to12 . rawSqlProcessRow -- | @since 2.10.2 from12 :: (a,b,c,d,e,f,g,h,i,j,k,l) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l)) from12 (a,b,c,d,e,f,g,h,i,j,k,l) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l)) -- | @since 2.10.2 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) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m) where rawSqlCols e = rawSqlCols e . from13 rawSqlColCountReason = rawSqlColCountReason . from13 rawSqlProcessRow = fmap to13 . rawSqlProcessRow -- | @since 2.11.0 from13 :: (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) from13 (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) -- | @since 2.11.0 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) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n) where rawSqlCols e = rawSqlCols e . from14 rawSqlColCountReason = rawSqlColCountReason . from14 rawSqlProcessRow = fmap to14 . rawSqlProcessRow -- | @since 2.11.0 from14 :: (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)) from14 (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)) -- | @since 2.11.0 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) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) where rawSqlCols e = rawSqlCols e . from15 rawSqlColCountReason = rawSqlColCountReason . from15 rawSqlProcessRow = fmap to15 . rawSqlProcessRow -- | @since 2.11.0 from15 :: (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) from15 (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) -- | @since 2.11.0 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) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) where rawSqlCols e = rawSqlCols e . from16 rawSqlColCountReason = rawSqlColCountReason . from16 rawSqlProcessRow = fmap to16 . rawSqlProcessRow -- | @since 2.11.0 from16 :: (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)) from16 (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)) -- | @since 2.11.0 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) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) where rawSqlCols e = rawSqlCols e . from17 rawSqlColCountReason = rawSqlColCountReason . from17 rawSqlProcessRow = fmap to17 . rawSqlProcessRow -- | @since 2.11.0 from17 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),q) from17 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),q) -- | @since 2.11.0 to17 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),q) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) to17 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),q) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r) where rawSqlCols e = rawSqlCols e . from18 rawSqlColCountReason = rawSqlColCountReason . from18 rawSqlProcessRow = fmap to18 . rawSqlProcessRow -- | @since 2.11.0 from18 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r)) from18 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r)) -- | @since 2.11.0 to18 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) to18 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s) where rawSqlCols e = rawSqlCols e . from19 rawSqlColCountReason = rawSqlColCountReason . from19 rawSqlProcessRow = fmap to19 . rawSqlProcessRow -- | @since 2.11.0 from19 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),s) from19 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),s) -- | @since 2.11.0 to19 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),s) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) to19 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),s) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) where rawSqlCols e = rawSqlCols e . from20 rawSqlColCountReason = rawSqlColCountReason . from20 rawSqlProcessRow = fmap to20 . rawSqlProcessRow -- | @since 2.11.0 from20 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t)) from20 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t)) -- | @since 2.11.0 to20 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) to20 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) where rawSqlCols e = rawSqlCols e . from21 rawSqlColCountReason = rawSqlColCountReason . from21 rawSqlProcessRow = fmap to21 . rawSqlProcessRow -- | @since 2.11.0 from21 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),u) from21 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),u) -- | @since 2.11.0 to21 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),u) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) to21 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),u) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) where rawSqlCols e = rawSqlCols e . from22 rawSqlColCountReason = rawSqlColCountReason . from22 rawSqlProcessRow = fmap to22 . rawSqlProcessRow -- | @since 2.11.0 from22 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v)) from22 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v)) -- | @since 2.11.0 to22 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) to22 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w) where rawSqlCols e = rawSqlCols e . from23 rawSqlColCountReason = rawSqlColCountReason . from23 rawSqlProcessRow = fmap to23 . rawSqlProcessRow -- | @since 2.11.0 from23 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),w) from23 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),w) -- | @since 2.11.0 to23 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),w) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) to23 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),w) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x) where rawSqlCols e = rawSqlCols e . from24 rawSqlColCountReason = rawSqlColCountReason . from24 rawSqlProcessRow = fmap to24 . rawSqlProcessRow -- | @since 2.11.0 from24 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x)) from24 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x)) -- | @since 2.11.0 to24 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) to24 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y) where rawSqlCols e = rawSqlCols e . from25 rawSqlColCountReason = rawSqlColCountReason . from25 rawSqlProcessRow = fmap to25 . rawSqlProcessRow -- | @since 2.11.0 from25 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),y) from25 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),y) -- | @since 2.11.0 to25 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),y) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) to25 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),y) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) where rawSqlCols e = rawSqlCols e . from26 rawSqlColCountReason = rawSqlColCountReason . from26 rawSqlProcessRow = fmap to26 . rawSqlProcessRow -- | @since 2.11.0 from26 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z)) from26 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z)) -- | @since 2.11.0 to26 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) to26 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2) where rawSqlCols e = rawSqlCols e . from27 rawSqlColCountReason = rawSqlColCountReason . from27 rawSqlProcessRow = fmap to27 . rawSqlProcessRow -- | @since 2.11.0 from27 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),a2) from27 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),a2) -- | @since 2.11.0 to27 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),a2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2) to27 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),a2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2) where rawSqlCols e = rawSqlCols e . from28 rawSqlColCountReason = rawSqlColCountReason . from28 rawSqlProcessRow = fmap to28 . rawSqlProcessRow -- | @since 2.11.0 from28 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2)) from28 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2)) -- | @since 2.11.0 to28 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2) to28 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2) where rawSqlCols e = rawSqlCols e . from29 rawSqlColCountReason = rawSqlColCountReason . from29 rawSqlProcessRow = fmap to29 . rawSqlProcessRow -- | @since 2.11.0 from29 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),c2) from29 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),c2) -- | @since 2.11.0 to29 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),c2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2) to29 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),c2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2) where rawSqlCols e = rawSqlCols e . from30 rawSqlColCountReason = rawSqlColCountReason . from30 rawSqlProcessRow = fmap to30 . rawSqlProcessRow -- | @since 2.11.0 from30 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2)) from30 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2)) -- | @since 2.11.0 to30 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2) to30 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2) where rawSqlCols e = rawSqlCols e . from31 rawSqlColCountReason = rawSqlColCountReason . from31 rawSqlProcessRow = fmap to31 . rawSqlProcessRow -- | @since 2.11.0 from31 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),e2) from31 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),e2) -- | @since 2.11.0 to31 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),e2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2) to31 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),e2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2) where rawSqlCols e = rawSqlCols e . from32 rawSqlColCountReason = rawSqlColCountReason . from32 rawSqlProcessRow = fmap to32 . rawSqlProcessRow -- | @since 2.11.0 from32 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2)) from32 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2)) -- | @since 2.11.0 to32 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2) to32 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2) where rawSqlCols e = rawSqlCols e . from33 rawSqlColCountReason = rawSqlColCountReason . from33 rawSqlProcessRow = fmap to33 . rawSqlProcessRow -- | @since 2.11.0 from33 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),g2) from33 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),g2) -- | @since 2.11.0 to33 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),g2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2) to33 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),g2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2) where rawSqlCols e = rawSqlCols e . from34 rawSqlColCountReason = rawSqlColCountReason . from34 rawSqlProcessRow = fmap to34 . rawSqlProcessRow -- | @since 2.11.0 from34 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2)) from34 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2)) -- | @since 2.11.0 to34 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2) to34 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2) where rawSqlCols e = rawSqlCols e . from35 rawSqlColCountReason = rawSqlColCountReason . from35 rawSqlProcessRow = fmap to35 . rawSqlProcessRow -- | @since 2.11.0 from35 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),i2) from35 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),i2) -- | @since 2.11.0 to35 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),i2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2) to35 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),i2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2) where rawSqlCols e = rawSqlCols e . from36 rawSqlColCountReason = rawSqlColCountReason . from36 rawSqlProcessRow = fmap to36 . rawSqlProcessRow -- | @since 2.11.0 from36 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2)) from36 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2)) -- | @since 2.11.0 to36 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2) to36 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2) where rawSqlCols e = rawSqlCols e . from37 rawSqlColCountReason = rawSqlColCountReason . from37 rawSqlProcessRow = fmap to37 . rawSqlProcessRow -- | @since 2.11.0 from37 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),k2) from37 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),k2) -- | @since 2.11.0 to37 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),k2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2) to37 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),k2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2) where rawSqlCols e = rawSqlCols e . from38 rawSqlColCountReason = rawSqlColCountReason . from38 rawSqlProcessRow = fmap to38 . rawSqlProcessRow -- | @since 2.11.0 from38 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2)) from38 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2)) -- | @since 2.11.0 to38 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2) to38 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2) where rawSqlCols e = rawSqlCols e . from39 rawSqlColCountReason = rawSqlColCountReason . from39 rawSqlProcessRow = fmap to39 . rawSqlProcessRow -- | @since 2.11.0 from39 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),m2) from39 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),m2) -- | @since 2.11.0 to39 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),m2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2) to39 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),m2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2) where rawSqlCols e = rawSqlCols e . from40 rawSqlColCountReason = rawSqlColCountReason . from40 rawSqlProcessRow = fmap to40 . rawSqlProcessRow -- | @since 2.11.0 from40 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2)) from40 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2)) -- | @since 2.11.0 to40 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2) to40 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2) where rawSqlCols e = rawSqlCols e . from41 rawSqlColCountReason = rawSqlColCountReason . from41 rawSqlProcessRow = fmap to41 . rawSqlProcessRow -- | @since 2.11.0 from41 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),o2) from41 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),o2) -- | @since 2.11.0 to41 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),o2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2) to41 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),o2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2) where rawSqlCols e = rawSqlCols e . from42 rawSqlColCountReason = rawSqlColCountReason . from42 rawSqlProcessRow = fmap to42 . rawSqlProcessRow -- | @since 2.11.0 from42 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2)) from42 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2)) -- | @since 2.11.0 to42 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2) to42 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2) where rawSqlCols e = rawSqlCols e . from43 rawSqlColCountReason = rawSqlColCountReason . from43 rawSqlProcessRow = fmap to43 . rawSqlProcessRow -- | @since 2.11.0 from43 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),q2) from43 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),q2) -- | @since 2.11.0 to43 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),q2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2) to43 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),q2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2) where rawSqlCols e = rawSqlCols e . from44 rawSqlColCountReason = rawSqlColCountReason . from44 rawSqlProcessRow = fmap to44 . rawSqlProcessRow -- | @since 2.11.0 from44 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2)) from44 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2)) -- | @since 2.11.0 to44 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2) to44 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2) where rawSqlCols e = rawSqlCols e . from45 rawSqlColCountReason = rawSqlColCountReason . from45 rawSqlProcessRow = fmap to45 . rawSqlProcessRow -- | @since 2.11.0 from45 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),s2) from45 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),s2) -- | @since 2.11.0 to45 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),s2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2) to45 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),s2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2) where rawSqlCols e = rawSqlCols e . from46 rawSqlColCountReason = rawSqlColCountReason . from46 rawSqlProcessRow = fmap to46 . rawSqlProcessRow -- | @since 2.11.0 from46 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2)) from46 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2)) -- | @since 2.11.0 to46 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2) to46 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2) where rawSqlCols e = rawSqlCols e . from47 rawSqlColCountReason = rawSqlColCountReason . from47 rawSqlProcessRow = fmap to47 . rawSqlProcessRow -- | @since 2.11.0 from47 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),u2) from47 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),u2) -- | @since 2.11.0 to47 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),u2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2) to47 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),u2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2) where rawSqlCols e = rawSqlCols e . from48 rawSqlColCountReason = rawSqlColCountReason . from48 rawSqlProcessRow = fmap to48 . rawSqlProcessRow -- | @since 2.11.0 from48 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2)) from48 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2)) -- | @since 2.11.0 to48 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2) to48 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2) where rawSqlCols e = rawSqlCols e . from49 rawSqlColCountReason = rawSqlColCountReason . from49 rawSqlProcessRow = fmap to49 . rawSqlProcessRow -- | @since 2.11.0 from49 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),w2) from49 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),w2) -- | @since 2.11.0 to49 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),w2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2) to49 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),w2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2) where rawSqlCols e = rawSqlCols e . from50 rawSqlColCountReason = rawSqlColCountReason . from50 rawSqlProcessRow = fmap to50 . rawSqlProcessRow -- | @since 2.11.0 from50 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2)) from50 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2)) -- | @since 2.11.0 to50 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2) to50 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2) where rawSqlCols e = rawSqlCols e . from51 rawSqlColCountReason = rawSqlColCountReason . from51 rawSqlProcessRow = fmap to51 . rawSqlProcessRow -- | @since 2.11.0 from51 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),y2) from51 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),y2) -- | @since 2.11.0 to51 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),y2) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2) to51 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),y2) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2) where rawSqlCols e = rawSqlCols e . from52 rawSqlColCountReason = rawSqlColCountReason . from52 rawSqlProcessRow = fmap to52 . rawSqlProcessRow -- | @since 2.11.0 from52 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2)) from52 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2)) -- | @since 2.11.0 to52 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2) to52 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3) where rawSqlCols e = rawSqlCols e . from53 rawSqlColCountReason = rawSqlColCountReason . from53 rawSqlProcessRow = fmap to53 . rawSqlProcessRow -- | @since 2.11.0 from53 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),a3) from53 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),a3) -- | @since 2.11.0 to53 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),a3) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3) to53 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),a3) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3) where rawSqlCols e = rawSqlCols e . from54 rawSqlColCountReason = rawSqlColCountReason . from54 rawSqlProcessRow = fmap to54 . rawSqlProcessRow -- | @since 2.11.0 from54 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3)) from54 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3)) -- | @since 2.11.0 to54 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3) to54 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3) where rawSqlCols e = rawSqlCols e . from55 rawSqlColCountReason = rawSqlColCountReason . from55 rawSqlProcessRow = fmap to55 . rawSqlProcessRow -- | @since 2.11.0 from55 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),c3) from55 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),c3) -- | @since 2.11.0 to55 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),c3) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3) to55 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),c3) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3) where rawSqlCols e = rawSqlCols e . from56 rawSqlColCountReason = rawSqlColCountReason . from56 rawSqlProcessRow = fmap to56 . rawSqlProcessRow -- | @since 2.11.0 from56 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3)) from56 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3)) -- | @since 2.11.0 to56 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3) to56 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3) where rawSqlCols e = rawSqlCols e . from57 rawSqlColCountReason = rawSqlColCountReason . from57 rawSqlProcessRow = fmap to57 . rawSqlProcessRow -- | @since 2.11.0 from57 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),e3) from57 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),e3) -- | @since 2.11.0 to57 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),e3) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3) to57 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),e3) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3) where rawSqlCols e = rawSqlCols e . from58 rawSqlColCountReason = rawSqlColCountReason . from58 rawSqlProcessRow = fmap to58 . rawSqlProcessRow -- | @since 2.11.0 from58 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3)) from58 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3)) -- | @since 2.11.0 to58 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3) to58 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3) where rawSqlCols e = rawSqlCols e . from59 rawSqlColCountReason = rawSqlColCountReason . from59 rawSqlProcessRow = fmap to59 . rawSqlProcessRow -- | @since 2.11.0 from59 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),g3) from59 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),g3) -- | @since 2.11.0 to59 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),g3) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3) to59 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),g3) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3, RawSql h3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3, h3) where rawSqlCols e = rawSqlCols e . from60 rawSqlColCountReason = rawSqlColCountReason . from60 rawSqlProcessRow = fmap to60 . rawSqlProcessRow -- | @since 2.11.0 from60 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3)) from60 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3)) -- | @since 2.11.0 to60 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3) to60 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3, RawSql h3, RawSql i3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3, h3, i3) where rawSqlCols e = rawSqlCols e . from61 rawSqlColCountReason = rawSqlColCountReason . from61 rawSqlProcessRow = fmap to61 . rawSqlProcessRow -- | @since 2.11.0 from61 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),i3) from61 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),i3) -- | @since 2.11.0 to61 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),i3) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3) to61 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),i3) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3) -- | @since 2.11.0 instance (RawSql a, RawSql b, RawSql c, RawSql d, RawSql e, RawSql f, RawSql g, RawSql h, RawSql i, RawSql j, RawSql k, RawSql l, RawSql m, RawSql n, RawSql o, RawSql p, RawSql q, RawSql r, RawSql s, RawSql t, RawSql u, RawSql v, RawSql w, RawSql x, RawSql y, RawSql z, RawSql a2, RawSql b2, RawSql c2, RawSql d2, RawSql e2, RawSql f2, RawSql g2, RawSql h2, RawSql i2, RawSql j2, RawSql k2, RawSql l2, RawSql m2, RawSql n2, RawSql o2, RawSql p2, RawSql q2, RawSql r2, RawSql s2, RawSql t2, RawSql u2, RawSql v2, RawSql w2, RawSql x2, RawSql y2, RawSql z2, RawSql a3, RawSql b3, RawSql c3, RawSql d3, RawSql e3, RawSql f3, RawSql g3, RawSql h3, RawSql i3, RawSql j3) => RawSql (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a2, b2, c2, d2, e2, f2, g2, h2, i2, j2, k2, l2, m2, n2, o2, p2, q2, r2, s2, t2, u2, v2, w2, x2, y2, z2, a3, b3, c3, d3, e3, f3, g3, h3, i3, j3) where rawSqlCols e = rawSqlCols e . from62 rawSqlColCountReason = rawSqlColCountReason . from62 rawSqlProcessRow = fmap to62 . rawSqlProcessRow -- | @since 2.11.0 from62 :: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3,j3) -> ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),(i3,j3)) from62 (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3,j3) = ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),(i3,j3)) -- | @since 2.11.0 to62 :: ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),(i3,j3)) -> (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3,j3) to62 ((a,b),(c,d),(e,f),(g,h),(i,j),(k,l),(m,n),(o,p),(q,r),(s,t),(u,v),(w,x),(y,z),(a2,b2),(c2,d2),(e2,f2),(g2,h2),(i2,j2),(k2,l2),(m2,n2),(o2,p2),(q2,r2),(s2,t2),(u2,v2),(w2,x2),(y2,z2),(a3,b3),(c3,d3),(e3,f3),(g3,h3),(i3,j3)) = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,a2,b2,c2,d2,e2,f2,g2,h2,i2,j2,k2,l2,m2,n2,o2,p2,q2,r2,s2,t2,u2,v2,w2,x2,y2,z2,a3,b3,c3,d3,e3,f3,g3,h3,i3,j3) extractMaybe :: Maybe a -> a extractMaybe = fromMaybe (error "Database.Persist.GenericSql.extractMaybe") -- | Tells Persistent what database column type should be used to store a Haskell type. -- -- ==== __Examples__ -- -- ===== Simple Boolean Alternative -- -- @ -- data Switch = On | Off -- deriving (Show, Eq) -- -- instance 'PersistField' Switch where -- 'toPersistValue' s = case s of -- On -> 'PersistBool' True -- Off -> 'PersistBool' False -- 'fromPersistValue' ('PersistBool' b) = if b then 'Right' On else 'Right' Off -- 'fromPersistValue' x = Left $ "File.hs: When trying to deserialize a Switch: expected PersistBool, received: " <> T.pack (show x) -- -- instance 'PersistFieldSql' Switch where -- 'sqlType' _ = 'SqlBool' -- @ -- -- ===== Non-Standard Database Types -- -- If your database supports non-standard types, such as Postgres' @uuid@, you can use 'SqlOther' to use them: -- -- @ -- import qualified Data.UUID as UUID -- instance 'PersistField' UUID where -- 'toPersistValue' = 'PersistLiteralEncoded' . toASCIIBytes -- 'fromPersistValue' ('PersistLiteralEncoded' uuid) = -- case fromASCIIBytes uuid of -- 'Nothing' -> 'Left' $ "Model/CustomTypes.hs: Failed to deserialize a UUID; received: " <> T.pack (show uuid) -- 'Just' uuid' -> 'Right' uuid' -- 'fromPersistValue' x = Left $ "File.hs: When trying to deserialize a UUID: expected PersistLiteralEncoded, received: "-- > <> T.pack (show x) -- -- instance 'PersistFieldSql' UUID where -- 'sqlType' _ = 'SqlOther' "uuid" -- @ -- -- ===== User Created Database Types -- -- Similarly, some databases support creating custom types, e.g. Postgres' <https://www.postgresql.org/docs/current/static/sql-createdomain.html DOMAIN> and <https://www.postgresql.org/docs/current/static/datatype-enum.html ENUM> features. You can use 'SqlOther' to specify a custom type: -- -- > CREATE DOMAIN ssn AS text -- > CHECK ( value ~ '^[0-9]{9}$'); -- -- @ -- instance 'PersistFieldSQL' SSN where -- 'sqlType' _ = 'SqlOther' "ssn" -- @ -- -- > CREATE TYPE rainbow_color AS ENUM ('red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'); -- -- @ -- instance 'PersistFieldSQL' RainbowColor where -- 'sqlType' _ = 'SqlOther' "rainbow_color" -- @ class PersistField a => PersistFieldSql a where sqlType :: Proxy a -> SqlType #ifndef NO_OVERLAP instance {-# OVERLAPPING #-} PersistFieldSql [Char] where sqlType _ = SqlString #endif instance PersistFieldSql ByteString where sqlType _ = SqlBlob instance PersistFieldSql T.Text where sqlType _ = SqlString instance PersistFieldSql TL.Text where sqlType _ = SqlString instance PersistFieldSql Html where sqlType _ = SqlString instance PersistFieldSql Int where sqlType _ | Just x <- bitSizeMaybe (0 :: Int), x <= 32 = SqlInt32 | otherwise = SqlInt64 instance PersistFieldSql Int8 where sqlType _ = SqlInt32 instance PersistFieldSql Int16 where sqlType _ = SqlInt32 instance PersistFieldSql Int32 where sqlType _ = SqlInt32 instance PersistFieldSql Int64 where sqlType _ = SqlInt64 instance PersistFieldSql Word where sqlType _ = SqlInt64 instance PersistFieldSql Word8 where sqlType _ = SqlInt32 instance PersistFieldSql Word16 where sqlType _ = SqlInt32 instance PersistFieldSql Word32 where sqlType _ = SqlInt64 instance PersistFieldSql Word64 where sqlType _ = SqlInt64 instance PersistFieldSql Double where sqlType _ = SqlReal instance PersistFieldSql Bool where sqlType _ = SqlBool instance PersistFieldSql Day where sqlType _ = SqlDay instance PersistFieldSql TimeOfDay where sqlType _ = SqlTime instance PersistFieldSql UTCTime where sqlType _ = SqlDayTime instance PersistFieldSql a => PersistFieldSql (Maybe a) where sqlType _ = sqlType (Proxy :: Proxy a) instance {-# OVERLAPPABLE #-} PersistFieldSql a => PersistFieldSql [a] where sqlType _ = SqlString instance PersistFieldSql a => PersistFieldSql (V.Vector a) where sqlType _ = SqlString instance (Ord a, PersistFieldSql a) => PersistFieldSql (S.Set a) where sqlType _ = SqlString instance (PersistFieldSql a, PersistFieldSql b) => PersistFieldSql (a,b) where sqlType _ = SqlString instance PersistFieldSql v => PersistFieldSql (IM.IntMap v) where sqlType _ = SqlString instance PersistFieldSql v => PersistFieldSql (M.Map T.Text v) where sqlType _ = SqlString instance PersistFieldSql PersistValue where sqlType _ = SqlInt64 -- since PersistValue should only be used like this for keys, which in SQL are Int64 instance PersistFieldSql Checkmark where sqlType _ = SqlBool instance (HasResolution a) => PersistFieldSql (Fixed a) where sqlType a = SqlNumeric long prec where prec = round $ (log $ fromIntegral $ resolution n) / (log 10 :: Double) -- FIXME: May lead to problems with big numbers long = prec + 10 -- FIXME: Is this enough ? n = 0 _mn = return n `asTypeOf` a instance PersistFieldSql Rational where sqlType _ = SqlNumeric 32 20 -- need to make this field big enough to handle Rational to Mumber string conversion for ODBC -- | This type uses the 'SqlInt64' version, which will exhibit overflow and -- underflow behavior. Additionally, it permits negative values in the -- database, which isn't ideal. -- -- @since 2.11.0 instance PersistFieldSql OverflowNatural where sqlType _ = SqlInt64 -- An embedded Entity instance (PersistField record, PersistEntity record) => PersistFieldSql (Entity record) where sqlType _ = SqlString
yesodweb/persistent
persistent/Database/Persist/Sql/Class.hs
mit
103,804
0
17
15,185
83,439
52,697
30,742
-1
-1