From ade13f767b0bf914a0bb8358b0bff6243d06f5f7 Mon Sep 17 00:00:00 2001 From: Abhinav Sarkar Date: Wed, 22 Jun 2016 16:52:04 +0530 Subject: [PATCH] Removes FactColumnType pattern synonyms to simplify the code. --- ringo/src/Ringo/Generator/Create.hs | 5 ++--- ringo/src/Ringo/Generator/Populate/Dimension.hs | 4 ++-- ringo/src/Ringo/Generator/Populate/Fact.hs | 3 +-- ringo/src/Ringo/Types.hs | 12 ------------ ringo/src/Ringo/Types/Internal.hs | 13 ------------- ringo/src/Ringo/Validator.hs | 14 +++++++------- stack.yaml | 2 +- 7 files changed, 13 insertions(+), 40 deletions(-) diff --git a/ringo/src/Ringo/Generator/Create.hs b/ringo/src/Ringo/Generator/Create.hs index 1342bcd..85d78f0 100644 --- a/ringo/src/Ringo/Generator/Create.hs +++ b/ringo/src/Ringo/Generator/Create.hs @@ -2,7 +2,6 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE PatternSynonyms #-} module Ringo.Generator.Create (dimensionTableDefnSQL, factTableDefnSQL) where @@ -78,8 +77,8 @@ factTableIndexStmts fact table = do Settings {..} <- asks envSettings tables <- asks envTables - let dimTimeCol = head [ cName | DimTimeV cName <- factColumns fact ] - tenantIdCol = listToMaybe [ cName | TenantIdV cName <- factColumns fact ] + let dimTimeCol = head [ cName | FactColumn cName DimTime <- factColumns fact ] + tenantIdCol = listToMaybe [ cName | FactColumn cName TenantId <- factColumns fact ] tabName = tableName table <> settingTableNameSuffixTemplate dimTimeColName cName = timeUnitColumnName settingDimTableIdColumnName cName settingTimeUnit diff --git a/ringo/src/Ringo/Generator/Populate/Dimension.hs b/ringo/src/Ringo/Generator/Populate/Dimension.hs index 372e026..a9f746b 100644 --- a/ringo/src/Ringo/Generator/Populate/Dimension.hs +++ b/ringo/src/Ringo/Generator/Populate/Dimension.hs @@ -1,7 +1,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE CPP #-} -{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE GADTs #-} module Ringo.Generator.Populate.Dimension (dimensionTablePopulateSQL) where @@ -34,7 +34,7 @@ dimensionTablePopulateStmt popMode fact dimTableName = withReader envView $ do selectCols = [ flip sia (nmc cName) $ coalesceColumn defaults (factTableName fact) col | (_, cName) <- colMapping , let col = fromJust . findColumn cName $ tableColumns factTable ] - timeCol = head ([ cName | DimTimeV cName <- factColumns fact ] :: [ColumnName]) + timeCol = head ([ cName | FactColumn cName DimTime <- factColumns fact ] :: [ColumnName]) isNotNullC = parens . foldBinop "or" . map (postop "isnotnull" . ei . snd) $ colMapping selectWhereC = Just . foldBinop "and" $ [ isNotNullC, binop "<" (ei timeCol) placeholder ] ++ diff --git a/ringo/src/Ringo/Generator/Populate/Fact.hs b/ringo/src/Ringo/Generator/Populate/Fact.hs index 1f5f1ae..ccc7425 100644 --- a/ringo/src/Ringo/Generator/Populate/Fact.hs +++ b/ringo/src/Ringo/Generator/Populate/Fact.hs @@ -5,7 +5,6 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE PatternSynonyms #-} module Ringo.Generator.Populate.Fact (factTablePopulateSQL) where @@ -201,7 +200,7 @@ factTablePopulateStmts popMode fact = do . map (factTableName . fst) $ allDims - timeCol = eqi fTableName $ head [ cName | DimTimeV cName <- factColumns fact ] + timeCol = eqi fTableName $ head [ cName | FactColumn cName DimTime <- factColumns fact ] extFactTableName = suffixTableName popMode settingTableNameSuffixTemplate $ extractedFactTableName settingFactPrefix settingFactInfix (factName fact) settingTimeUnit diff --git a/ringo/src/Ringo/Types.hs b/ringo/src/Ringo/Types.hs index 80bf6b3..610189d 100644 --- a/ringo/src/Ringo/Types.hs +++ b/ringo/src/Ringo/Types.hs @@ -3,24 +3,12 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE PatternSynonyms #-} module Ringo.Types ( ColumnName, ColumnType, TableName , Nullable(..), Column(..), TableConstraint(..), Table(..) , TimeUnit(..), timeUnitName, timeUnitToSeconds , Fact(..), FactColumnType(..), FactColumn(..), factSourceColumnName - , pattern DimTimeV - , pattern NoDimIdV - , pattern TenantIdV - , pattern DimIdV - , pattern DimValV - , pattern FactCountV - , pattern FactCountDistinctV - , pattern FactSumV - , pattern FactAverageV - , pattern FactMaxV - , pattern FactMinV , Settings(..), defSettings , ValidationError(..), TypeDefaults , Env, EnvV(..), envView diff --git a/ringo/src/Ringo/Types/Internal.hs b/ringo/src/Ringo/Types/Internal.hs index aee8390..ad6ef00 100644 --- a/ringo/src/Ringo/Types/Internal.hs +++ b/ringo/src/Ringo/Types/Internal.hs @@ -3,7 +3,6 @@ {-# LANGUAGE GADTs #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE PatternSynonyms #-} module Ringo.Types.Internal where @@ -99,18 +98,6 @@ data FactColumnType a where deriving instance Show (FactColumnType a) -pattern DimTimeV col <- FactColumn col DimTime -pattern NoDimIdV col <- FactColumn col NoDimId -pattern TenantIdV col <- FactColumn col TenantId -pattern DimIdV col <- FactColumn col DimId {..} -pattern DimValV col <- FactColumn col DimVal {..} -pattern FactCountV col <- FactColumn col FactCount {..} -pattern FactCountDistinctV col <- FactColumn col FactCountDistinct {..} -pattern FactSumV col <- FactColumn col FactSum {..} -pattern FactAverageV col <- FactColumn col FactAverage {..} -pattern FactMaxV col <- FactColumn col FactMax {..} -pattern FactMinV col <- FactColumn col FactMin {..} - data FactColumn = forall a. FactColumn { factColTargetColumn :: !ColumnName , factColType :: FactColumnType a } diff --git a/ringo/src/Ringo/Validator.hs b/ringo/src/Ringo/Validator.hs index fb49e48..547e98c 100644 --- a/ringo/src/Ringo/Validator.hs +++ b/ringo/src/Ringo/Validator.hs @@ -56,19 +56,19 @@ validateFact Fact {..} = do parentVs <- concat <$> mapM checkFactParents factParentNames let colVs = concatMap (checkColumn tables table) factColumns timeVs = [ MissingTimeColumn factTableName - | null ([ cName | DimTimeV cName <- factColumns ] :: [ColumnName]) ] + | null ([ cName | FactColumn cName DimTime <- factColumns ] :: [ColumnName]) ] notNullVs = [ MissingNotNullConstraint factTableName cName - | DimTimeV cName <- factColumns - , let col = findColumn cName (tableColumns table) + | FactColumn cName DimTime <- factColumns + , let col = findColumn cName (tableColumns table) , isJust col , columnNullable (fromJust col) == Null ] typeDefaultVs = [ MissingTypeDefault cType - | cName <- [ c | DimValV c <- factColumns ] - ++ [ c | NoDimIdV c <- factColumns ] - ++ [ c | TenantIdV c <- factColumns ] - ++ [ c | DimIdV c <- factColumns ] + | cName <- [ c | FactColumn c DimVal {..} <- factColumns ] + ++ [ c | FactColumn c NoDimId <- factColumns ] + ++ [ c | FactColumn c TenantId <- factColumns ] + ++ [ c | FactColumn c DimId {..} <- factColumns ] , let col = findColumn cName (tableColumns table) , isJust col , let cType = columnType $ fromJust col diff --git a/stack.yaml b/stack.yaml index e97787e..80a3e0b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,7 +1,7 @@ # For more information, see: https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) -resolver: lts-5.1 +resolver: lts-6.4 # Local packages, usually specified by relative directory name packages: