From c1f2a5dfd7def108180111153c9bfa34e5430124 Mon Sep 17 00:00:00 2001 From: bruderj15 Date: Thu, 28 Nov 2024 14:07:52 +0100 Subject: [PATCH 1/3] main: fix arg names --- src/Data/Some/Constraint.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Some/Constraint.hs b/src/Data/Some/Constraint.hs index 284ecd7..6e0b700 100644 --- a/src/Data/Some/Constraint.hs +++ b/src/Data/Some/Constraint.hs @@ -51,4 +51,4 @@ data Somes1 csf csa where (AllC csf f, AllC csa a) => f a -> Somes1 csf csa -- | Alias for 'Somes1' with just one 'Constraint'. -type Some1 ca cf = Somes1 '[ca] '[cf] +type Some1 cf ca = Somes1 '[cf] '[ca] From 82c1e40b527468e48c47d834e8c4777dba207f0b Mon Sep 17 00:00:00 2001 From: bruderj15 Date: Thu, 28 Nov 2024 16:59:06 +0100 Subject: [PATCH 2/3] instances: Show --- src/Data/Some/Constraint.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Data/Some/Constraint.hs b/src/Data/Some/Constraint.hs index 6e0b700..c709e58 100644 --- a/src/Data/Some/Constraint.hs +++ b/src/Data/Some/Constraint.hs @@ -1,10 +1,14 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE QuantifiedConstraints #-} {-# LANGUAGE StandaloneKindSignatures #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE GADTs #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE ScopedTypeVariables #-} module Data.Some.Constraint where @@ -52,3 +56,9 @@ data Somes1 csf csa where -- | Alias for 'Somes1' with just one 'Constraint'. type Some1 cf ca = Somes1 '[cf] '[ca] + +instance {-# OVERLAPPING #-} Show (Somes (Show ': cs)) where + showsPrec d (Some x) = showParen (d > 10) $ showString "Some " . showsPrec 11 x + +instance {-# OVERLAPPABLE #-} Show (Somes cs) => Show (Somes (c ': cs)) where + showsPrec d (Some x) = showsPrec d (Some @cs x) From 2c932faf36d462ff4fa4e3b6c707de3f77e9beb7 Mon Sep 17 00:00:00 2001 From: bruderj15 Date: Fri, 29 Nov 2024 14:29:24 +0100 Subject: [PATCH 3/3] instances: bump version --- CHANGELOG.md | 7 ++++++- constrained-some.cabal | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e35e306..cb49b2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,12 @@ file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PVP versioning](https://pvp.haskell.org/). -## Initial release: v0.0.1 _(2024-11-27)_ +## v0.1.1 _(2024-11-29)_ + +### Added +- Added instance `Show (Somes cs)` if `cs` contains `Show` + +## Initial release: v0.1.0 _(2024-11-27)_ ### Added - Existentials `Somes` and `Somes1` diff --git a/constrained-some.cabal b/constrained-some.cabal index 08698ec..7b5e938 100644 --- a/constrained-some.cabal +++ b/constrained-some.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: constrained-some -version: 0.1.0.0 +version: 0.1.1 synopsis: Existential type that can be constrained description: This library provides utilities for working with existential types and type-level constraints. It allows you to enforce multiple constraints on polymorphic types and containers complementing the package some.