Skip to content

Commit

Permalink
Fix all warnings (#156)
Browse files Browse the repository at this point in the history
Co-authored-by: Ollie Charles <oliver.charles@circuithub.com>
  • Loading branch information
shane-circuithub and ocharles committed Jan 25, 2022
1 parent d7b4286 commit 2a25126
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 11 deletions.
1 change: 1 addition & 0 deletions rel8.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ library
-Wno-missing-import-lists -Wno-prepositive-qualified-module
-Wno-monomorphism-restriction
-Wno-missing-local-signatures
-Wno-missing-kind-signatures
hs-source-dirs:
src
exposed-modules:
Expand Down
1 change: 1 addition & 0 deletions src/Rel8/Generic/Record.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ instance {-# OVERLAPPABLE #-} Snd (Count n rep) ~ rep => Countable n rep where
uncount = id


type Record :: Type -> Type
newtype Record a = Record
{ unrecord :: a
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rel8/Query/Exists.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Prelude hiding ( filter )

-- opaleye
import qualified Opaleye.Exists as Opaleye
import qualified Opaleye.Operators as Opaleye hiding ( exists )
import qualified Opaleye.Operators as Opaleye

-- rel8
import Rel8.Expr ( Expr )
Expand Down
3 changes: 2 additions & 1 deletion src/Rel8/Schema/HTable/Vectorize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Rel8.Schema.HTable.Vectorize
where

-- base
import Data.Kind ( Type )
import Data.Kind ( Constraint, Type )
import Data.List.NonEmpty ( NonEmpty )
import GHC.Generics (Generic)
import Prelude
Expand All @@ -53,6 +53,7 @@ import Rel8.Type.Information ( TypeInformation )
import Data.Zip ( Unzip, Zip, Zippy(..) )


type Vector :: (Type -> Type) -> Constraint
class Vector list where
listNotNull :: proxy a -> Dict NotNull (list a)
vectorTypeInformation :: ()
Expand Down
3 changes: 3 additions & 0 deletions src/Rel8/Schema/Table.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# language DerivingStrategies #-}
{-# language DisambiguateRecordFields #-}
{-# language NamedFieldPuns #-}
{-# language StandaloneKindSignatures #-}

module Rel8.Schema.Table
( TableSchema(..)
Expand All @@ -10,6 +11,7 @@ module Rel8.Schema.Table
where

-- base
import Data.Kind ( Type )
import Prelude

-- opaleye
Expand All @@ -26,6 +28,7 @@ import Text.PrettyPrint ( Doc )
--
-- For each selectable table in your database, you should provide a
-- @TableSchema@ in order to interact with the table via Rel8.
type TableSchema :: Type -> Type
data TableSchema names = TableSchema
{ name :: String
-- ^ The name of the table.
Expand Down
3 changes: 3 additions & 0 deletions src/Rel8/Statement/Select.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# language FlexibleContexts #-}
{-# language MonoLocalBinds #-}
{-# language ScopedTypeVariables #-}
{-# language StandaloneKindSignatures #-}
{-# language TypeApplications #-}

module Rel8.Statement.Select
Expand All @@ -17,6 +18,7 @@ where

-- base
import Data.Foldable ( toList )
import Data.Kind ( Type )
import Data.List.NonEmpty ( NonEmpty( (:|) ) )
import Data.Void ( Void )
import Prelude hiding ( undefined )
Expand Down Expand Up @@ -116,6 +118,7 @@ ppPrimSelect query =
(a, primQuery, _) = Opaleye.runSimpleQueryArrStart (toOpaleye query) ()


type Optimized :: Type -> Type
data Optimized a = Empty | Unit | Optimized a
deriving stock (Functor, Foldable, Traversable)

Expand Down
1 change: 1 addition & 0 deletions src/Rel8/Table/HKD.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ instance
=> HKDable a


type Top_ :: Constraint
class Top_
instance Top_

Expand Down
4 changes: 3 additions & 1 deletion src/Rel8/Table/Opaleye.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
{-# language TypeFamilies #-}
{-# language ViewPatterns #-}

{-# options_ghc -Wno-deprecations #-}

module Rel8.Table.Opaleye
( aggregator
, attributes
Expand Down Expand Up @@ -137,7 +139,7 @@ unpackspec = Opaleye.Unpackspec $ Opaleye.PackMap $ \f ->
{-# INLINABLE unpackspec #-}


valuesspec :: Table Expr a => Opaleye.ValuesspecSafe a a
valuesspec :: Table Expr a => Opaleye.Valuesspec a a
valuesspec = Opaleye.ValuesspecSafe (toPackMap undefined) unpackspec


Expand Down
16 changes: 8 additions & 8 deletions src/Rel8/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ instance DBType Int64 where
instance DBType Float where
typeInformation = TypeInformation
{ encode = \x -> Opaleye.ConstExpr
if | x == (1 /0) -> Opaleye.OtherLit "'Infinity'"
| isNaN x -> Opaleye.OtherLit "'NaN'"
| x == (-1/0) -> Opaleye.OtherLit "'-Infinity'"
| otherwise -> Opaleye.NumericLit $ realToFrac x
if | x == (1 / 0) -> Opaleye.OtherLit "'Infinity'"
| isNaN x -> Opaleye.OtherLit "'NaN'"
| x == (-1 / 0) -> Opaleye.OtherLit "'-Infinity'"
| otherwise -> Opaleye.NumericLit $ realToFrac x
, decode = Hasql.float4
, typeName = "float4"
}
Expand All @@ -141,10 +141,10 @@ instance DBType Float where
instance DBType Double where
typeInformation = TypeInformation
{ encode = \x -> Opaleye.ConstExpr
if | x == (1 /0) -> Opaleye.OtherLit "'Infinity'"
| isNaN x -> Opaleye.OtherLit "'NaN'"
| x == (-1/0) -> Opaleye.OtherLit "'-Infinity'"
| otherwise -> Opaleye.NumericLit $ realToFrac x
if | x == (1 / 0) -> Opaleye.OtherLit "'Infinity'"
| isNaN x -> Opaleye.OtherLit "'NaN'"
| x == (-1 / 0) -> Opaleye.OtherLit "'-Infinity'"
| otherwise -> Opaleye.NumericLit $ realToFrac x
, decode = Hasql.float8
, typeName = "float8"
}
Expand Down
1 change: 1 addition & 0 deletions src/Rel8/Type/Enum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class (DBType a, Enumable a) => DBEnum a where

-- | Types that are sum types, where each constructor is unary (that is, has no
-- fields).
type Enumable :: Type -> Constraint
class (Generic a, GEnumable (Rep a)) => Enumable a
instance (Generic a, GEnumable (Rep a)) => Enumable a

Expand Down
4 changes: 4 additions & 0 deletions src/Rel8/Type/JSONBEncoded.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# language StandaloneKindSignatures #-}

module Rel8.Type.JSONBEncoded ( JSONBEncoded(..) ) where

-- aeson
Expand All @@ -6,6 +8,7 @@ import Data.Aeson.Types ( parseEither )

-- base
import Data.Bifunctor ( first )
import Data.Kind ( Type )
import Prelude

-- hasql
Expand All @@ -20,6 +23,7 @@ import Data.Text ( pack )


-- | Like 'Rel8.JSONEncoded', but works for @jsonb@ columns.
type JSONBEncoded :: Type -> Type
newtype JSONBEncoded a = JSONBEncoded { fromJSONBEncoded :: a }


Expand Down
4 changes: 4 additions & 0 deletions src/Rel8/Type/JSONEncoded.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{-# language StandaloneKindSignatures #-}

module Rel8.Type.JSONEncoded ( JSONEncoded(..) ) where

-- aeson
import Data.Aeson ( FromJSON, ToJSON, parseJSON, toJSON )
import Data.Aeson.Types ( parseEither )

-- base
import Data.Kind ( Type )
import Prelude

-- rel8
Expand All @@ -15,6 +18,7 @@ import Rel8.Type.Information ( parseTypeInformation )
-- | A deriving-via helper type for column types that store a Haskell value
-- using a JSON encoding described by @aeson@'s 'ToJSON' and 'FromJSON' type
-- classes.
type JSONEncoded :: Type -> Type
newtype JSONEncoded a = JSONEncoded { fromJSONEncoded :: a }


Expand Down
2 changes: 2 additions & 0 deletions src/Rel8/Type/Num.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ instance DBIntegral Int64


-- | The class of database types that support the @/@ operator.
type DBFractional :: Type -> Constraint
class DBNum a => DBFractional a
instance DBFractional Float
instance DBFractional Double
instance DBFractional Scientific


-- | The class of database types that support the @/@ operator.
type DBFloating :: Type -> Constraint
class DBFractional a => DBFloating a
instance DBFloating Float
instance DBFloating Double
3 changes: 3 additions & 0 deletions src/Rel8/Type/ReadShow.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{-# language ScopedTypeVariables #-}
{-# language StandaloneKindSignatures #-}
{-# language TypeApplications #-}
{-# language ViewPatterns #-}

module Rel8.Type.ReadShow ( ReadShow(..) ) where

-- base
import Data.Kind ( Type )
import Data.Proxy ( Proxy( Proxy ) )
import Data.Typeable ( Typeable, typeRep )
import Prelude
Expand All @@ -20,6 +22,7 @@ import qualified Data.Text as Text

-- | A deriving-via helper type for column types that store a Haskell value
-- using a Haskell's 'Read' and 'Show' type classes.
type ReadShow :: Type -> Type
newtype ReadShow a = ReadShow { fromReadShow :: a }


Expand Down
1 change: 1 addition & 0 deletions src/Rel8/Type/Tag.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ instance DBMonoid MaybeTag where
memptyExpr = litExpr mempty


type Tag :: Type
newtype Tag = Tag Text
deriving newtype
( Eq, Ord, Read, Show
Expand Down

0 comments on commit 2a25126

Please sign in to comment.