Skip to content

Commit 0757ab1

Browse files
committed
refactor tags
1 parent 67ca083 commit 0757ab1

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

pub/functora/src/money/Functora/Money.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import Functora.Prelude
4747
import Functora.Tags as X
4848
import qualified Language.Haskell.TH.Syntax as TH
4949

50-
type IntRep tags = NewIntRep (GetKey SignedOrUnsigned tags)
50+
type IntRep tags = NewIntRep (GetTag SignedOrUnsigned tags)
5151

5252
type family NewIntRep sig where
5353
NewIntRep 'Signed = Integer
@@ -297,7 +297,7 @@ unJsonRational = toRational <$> A.scientific
297297
unJsonMoney ::
298298
forall tags (sig :: SignedOrUnsigned).
299299
( MoneyTags tags,
300-
GetTag sig tags
300+
HasTag sig tags
301301
) =>
302302
A.Decoder (Money tags)
303303
unJsonMoney = do

pub/functora/src/sql/Functora/SqlOrphan.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ deriving via
7676
Rational
7777
instance
7878
( MoneyTags tags,
79-
GetTag (sig :: SignedOrUnsigned) tags
79+
HasTag (sig :: SignedOrUnsigned) tags
8080
) =>
8181
PersistFieldSql (Money tags)
8282

8383
instance
8484
( MoneyTags tags,
85-
GetTag (sig :: SignedOrUnsigned) tags
85+
HasTag (sig :: SignedOrUnsigned) tags
8686
) =>
8787
PersistField (Money tags)
8888
where

pub/functora/src/tags/Functora/TagsFamily.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Functora.TagsFamily
1313
-- * Accessors
1414
-- $accessors
1515
GetTag,
16-
GetKey,
16+
HasTag,
1717

1818
-- * Fingerprints
1919
-- $fingerprints
@@ -69,12 +69,15 @@ type family lhs |&| rhs where
6969
-- $accessors
7070
-- Accessors
7171

72-
type GetTag (v :: k) tags =
73-
( v ~ GetTagFamily ('Nothing :: Maybe k) k tags tags,
74-
SingI v
75-
)
72+
type GetTag k tags = GetTagFamily ('Nothing :: Maybe k) k tags tags
7673

77-
type GetKey k tags = GetTagFamily ('Nothing :: Maybe k) k tags tags
74+
type HasTag (v :: k) tags =
75+
( SingI v,
76+
Typeable v,
77+
Typeable k,
78+
Typeable tags,
79+
v ~ GetTag k tags
80+
)
7881

7982
-- $fingerprints
8083
-- Fingerprints

pub/functora/test/Functora/TagsSpec.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ newMoney = Tagged $ 4 % 5
1414

1515
getSymbolTag ::
1616
forall (tag :: Symbol) tags rep.
17-
( GetTag tag tags
17+
( HasTag tag tags
1818
) =>
1919
Tagged tags rep ->
2020
Demote Symbol
@@ -23,7 +23,7 @@ getSymbolTag _ =
2323

2424
getGainOrLoseTag ::
2525
forall (tag :: GainOrLose) tags rep.
26-
( GetTag tag tags
26+
( HasTag tag tags
2727
) =>
2828
Tagged tags rep ->
2929
GainOrLose

0 commit comments

Comments
 (0)