@@ -486,9 +486,9 @@ class IsCborable a
486486
487487instance IsCborable ByteString
488488
489- instance IsCborable CRef
489+ instance IsCborable CRefType
490490
491- instance IsCborable CGRef
491+ instance IsCborable CGRefType
492492
493493cbor :: (IsCborable b , IsConstrainable c b ) => c -> Rule -> Constrained
494494cbor v r@ (Named n _ _) =
@@ -507,9 +507,9 @@ class IsComparable a
507507
508508instance IsComparable Int
509509
510- instance IsComparable CRef
510+ instance IsComparable CRefType
511511
512- instance IsComparable CGRef
512+ instance IsComparable CGRefType
513513
514514le :: (IsComparable a , IsConstrainable c a ) => c -> Word64 -> Constrained
515515le v bound =
@@ -633,10 +633,14 @@ instance IsType0 HuddleItem where
633633 toType0 (HIGroup g) = toType0 g
634634 toType0 (HIGRule g) =
635635 error $
636- " Attempt to reference generic rule from HuddleItem not supported: " <> show g
636+ " Attempt to reference a raw generic rule: "
637+ <> show g
638+ <> " . Most likely this indicates you haven't provided generic parameters."
637639 toType0 (HIGRule' g) =
638640 error $
639- " Attempt to reference generic rule from HuddleItem not supported: " <> show g
641+ " Attempt to reference a raw generic rule: "
642+ <> show g
643+ <> " . Most likely this indicates you haven't provided generic parameters."
640644
641645class CanQuantify a where
642646 -- | Apply a lower bound
@@ -960,12 +964,13 @@ binding2 fRule t0 t1 =
960964type GRuleDef' = Named (FnWithArg GRef Type0 )
961965
962966data GRuleCallAux = GRuleCallAux
963- { defFn :: FnWithArg GRef Type0 ,
964- callArg :: Type2
967+ { defFn :: FnWithArg GRef Type0
968+ , callArg :: Type2
965969 }
966970
967971type GRuleCall' = Named GRuleCallAux
968972
973+ -- | Create a generic rule definition binding a single generic parameter.
969974binding' :: (GRef -> Rule ) -> GRuleDef'
970975binding' fRule =
971976 Named
@@ -983,15 +988,18 @@ instance IsGRuleDef GRuleDef' where
983988
984989instance IsGRuleDef HuddleItem where
985990 toGRuleDef (HIGRule' gd) = gd
986- toGRuleDef _ = error " Attempt to use a non-generic rule as a GRuleDef"
991+ toGRuleDef hi =
992+ error $
993+ " Attempt to apply generic parameters to a non-generic rule: " <> show hi
987994
995+ -- | Call a generic definition, applying the given type parameter.
988996(<--) :: (IsType0 t0 , IsGRuleDef gd ) => gd -> t0 -> GRuleCall'
989997(toGRuleDef -> f) <-- t0 = fmap toCall f
990998 where
991999 toCall rd =
9921000 GRuleCallAux
993- { defFn = rd,
994- callArg = t2
1001+ { defFn = rd
1002+ , callArg = t2
9951003 }
9961004 t2 = case toType0 t0 of
9971005 NoChoice x -> x
@@ -1228,7 +1236,7 @@ toCDDL' mkPseudoRoot hdl =
12281236 toGenericCall' (Named n gr _) =
12291237 C. T2Name
12301238 (C. Name n)
1231- (Just . C. GenericArg $ ( toCDDLType1 (callArg gr) ) NE. :| [] )
1239+ (Just . C. GenericArg $ toCDDLType1 (callArg gr) NE. :| [] )
12321240
12331241 toGenRuleDef :: GRuleDef -> C. WithComments C. Rule
12341242 toGenRuleDef (Named n gr c) =
0 commit comments