Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/20260921_122034_teofilcamarasu_expr_role.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Make `Expr` have a representational role, which disallows freely coercing the type within `Expr`. Users can still use `unsafeCastExpr` if they want this behaviour.
2 changes: 2 additions & 0 deletions rel8-internal/src/Rel8/Internal/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{-# language TypeApplications #-}
{-# language TypeFamilies #-}
{-# language UndecidableInstances #-}
{-# language RoleAnnotations #-}

module Rel8.Internal.Expr
( Expr(..)
Expand Down Expand Up @@ -53,6 +54,7 @@ import Data.Scientific (fromRationalRepetendLimited)

-- | Typed SQL expressions.
type Expr :: K.Context
type role Expr nominal
newtype Expr a = Expr Opaleye.PrimExpr
deriving stock Show

Expand Down
2 changes: 2 additions & 0 deletions rel8-internal/src/Rel8/Internal/Expr.hs-boot
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# language DataKinds #-}
{-# language StandaloneKindSignatures #-}
{-# language RoleAnnotations #-}

module Rel8.Internal.Expr
( Expr(..)
Expand All @@ -17,4 +18,5 @@ import Rel8.Internal.Schema.Kind ( Context )


type Expr :: Context
type role Expr nominal
newtype Expr a = Expr Opaleye.PrimExpr
Loading