File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -65,28 +65,19 @@ type NewRatTags lhs rhs =
65
65
RatTags lhs
66
66
)
67
67
68
- type family MoneyTagsFamily tags mtag where
69
- MoneyTagsFamily tags ('Just _ ) = tags
70
- MoneyTagsFamily tags ('Nothing :: Maybe k ) =
71
- TypeError
72
- ( 'ShowType k
73
- ':<>: 'Text " key is missing in "
74
- ':<>: 'ShowType tags
75
- )
76
-
77
68
type Money tags =
78
69
Tagged
79
70
tags
80
71
( Ratio
81
72
( IntRep
82
- ( MoneyTagsFamily tags ( MaybeGetTag MoneyKind tags )
73
+ ( RefineTags tags '[ SignedOrUnsigned , MoneyKind ]
83
74
)
84
75
)
85
76
)
86
77
87
78
type MoneyTags tags =
88
79
( RatTags tags ,
89
- tags ~ MoneyTagsFamily tags ( MaybeGetTag MoneyKind tags )
80
+ tags ~ RefineTags tags '[ SignedOrUnsigned , MoneyKind ]
90
81
)
91
82
92
83
type NewMoneyTags lhs rhs =
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ module Functora.TagsFamily
15
15
MaybeGetTag ,
16
16
GetTag ,
17
17
HasTag ,
18
+ RefineTags ,
18
19
19
20
-- * Fingerprints
20
21
-- $fingerprints
@@ -82,6 +83,8 @@ type HasTag (v :: k) tags =
82
83
v ~ GetTag k tags
83
84
)
84
85
86
+ type RefineTags tags keys = RefineTagsFamily tags keys
87
+
85
88
-- $fingerprints
86
89
-- Fingerprints
87
90
@@ -188,6 +191,22 @@ type family GetTagFamily k tags mv where
188
191
':<>: 'ShowType tags
189
192
)
190
193
194
+ type family RefineTagsFamily tags keys where
195
+ RefineTagsFamily tags '[] = tags
196
+ RefineTagsFamily tags (k ': keys ) =
197
+ RefineTagsFamilyRec tags k keys (MaybeGetTag k tags )
198
+
199
+ type family RefineTagsFamilyRec tags k keys mv where
200
+ RefineTagsFamilyRec tags _ '[] ('Just _ ) = tags
201
+ RefineTagsFamilyRec tags _ (k ': keys ) ('Just _ ) =
202
+ RefineTagsFamilyRec tags k keys (MaybeGetTag k tags )
203
+ RefineTagsFamilyRec tags k _ 'Nothing =
204
+ TypeError
205
+ ( 'ShowType k
206
+ ':<>: 'Text " key is missing in "
207
+ ':<>: 'ShowType tags
208
+ )
209
+
191
210
--
192
211
-- TODO : NEED A PROPER INSTANCE!
193
212
-- At the moment I don't know how to get
You can’t perform that action at this time.
0 commit comments