{-# LANGUAGE FunctionalDependencies, RoleAnnotations #-}
module Lorentz.Range
( RangeBoundaryInclusion(..)
, Range(..)
, RangeIE(..)
, RangeEI(..)
, RangeEE(..)
, OnRangeAssertFailure(..)
, RangeFailureInfo(..)
, RangeBoundary
, NiceRange
, CanCheckEmpty
, mkRange
, mkRange_
, mkRangeFor
, mkRangeFor_
, mkRangeForSafe_
, fromRange_
, toRange_
, rangeLower
, rangeUpper
, rangeLower_
, rangeUpper_
, inRange
, inRange_
, inRangeCmp
, inRangeCmp_
, assertInRange_
, assertInRangeSimple_
, isRangeEmpty
, isRangeEmpty_
, assertRangeNonEmpty_
, mkOnRangeAssertFailureSimple
, customErrorORAF
, customErrorORAFSimple
, isInclusive
) where
import Data.Coerce (coerce)
import Data.Constraint (Bottom(..))
import Data.Singletons (demote)
import Fmt (Buildable(..))
import GHC.TypeLits (ErrorMessage(..), TypeError)
import Lorentz.ADT as L
import Lorentz.Annotation as L
import Lorentz.Arith as L
import Lorentz.Base as L
import Lorentz.Coercions as L
import Lorentz.Constraints.Scopes as L
import Lorentz.Doc as L
import Lorentz.Errors as L
import Lorentz.Instr as L
import Lorentz.Macro as L
import Lorentz.Value
import Morley.Michelson.Typed qualified as T
import Morley.Michelson.Untyped (noAnn, pattern UnsafeAnnotation, typeAnnQ, unAnnotation)
import Morley.Util.Interpolate (i)
import Morley.Util.Named
data RangeBoundaryInclusion = IncludeBoundary | ExcludeBoundary
type RangeBoundary :: RangeBoundaryInclusion -> Constraint
class (DefaultToInclusive r, Typeable r) => RangeBoundary r where
rangeParens :: (Text, Text)
inRangeComp :: Ord a => a -> a -> Bool
inRangeComp_ :: NiceComparable a => a : a : s :-> Bool : s
rangeName :: Text
isInclusive :: Bool
instance RangeBoundary 'IncludeBoundary where
rangeParens :: (Text, Text)
rangeParens = (Text
"[", Text
"]")
inRangeComp :: forall a. Ord a => a -> a -> Bool
inRangeComp = a -> a -> Bool
forall a. Ord a => a -> a -> Bool
(<=)
inRangeComp_ :: forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
inRangeComp_ = (a : a : s) :-> (Bool : s)
forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
L.ge
rangeName :: Text
rangeName = Text
"Inclusive"
isInclusive :: Bool
isInclusive = Bool
True
instance RangeBoundary 'ExcludeBoundary where
rangeParens :: (Text, Text)
rangeParens = (Text
"(", Text
")")
inRangeComp :: forall a. Ord a => a -> a -> Bool
inRangeComp = a -> a -> Bool
forall a. Ord a => a -> a -> Bool
(<)
inRangeComp_ :: forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
inRangeComp_ = (a : a : s) :-> (Bool : s)
forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
L.gt
rangeName :: Text
rangeName = Text
"Exclusive"
isInclusive :: Bool
isInclusive = Bool
False
class DefaultToInclusive bound
instance DefaultToInclusive 'IncludeBoundary
instance DefaultToInclusive 'ExcludeBoundary
instance {-# incoherent #-} a ~ 'IncludeBoundary => DefaultToInclusive a
type Range' :: RangeBoundaryInclusion -> RangeBoundaryInclusion -> Type -> Type
data Range' lower upper a = Range' { forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Range' lower upper a -> a
rangeLower' :: a, forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Range' lower upper a -> a
rangeUpper' :: a }
deriving stock ((forall x. Range' lower upper a -> Rep (Range' lower upper a) x)
-> (forall x. Rep (Range' lower upper a) x -> Range' lower upper a)
-> Generic (Range' lower upper a)
forall x. Rep (Range' lower upper a) x -> Range' lower upper a
forall x. Range' lower upper a -> Rep (Range' lower upper a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a x.
Rep (Range' lower upper a) x -> Range' lower upper a
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a x.
Range' lower upper a -> Rep (Range' lower upper a) x
$cfrom :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a x.
Range' lower upper a -> Rep (Range' lower upper a) x
from :: forall x. Range' lower upper a -> Rep (Range' lower upper a) x
$cto :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a x.
Rep (Range' lower upper a) x -> Range' lower upper a
to :: forall x. Rep (Range' lower upper a) x -> Range' lower upper a
Generic, Int -> Range' lower upper a -> ShowS
[Range' lower upper a] -> ShowS
Range' lower upper a -> String
(Int -> Range' lower upper a -> ShowS)
-> (Range' lower upper a -> String)
-> ([Range' lower upper a] -> ShowS)
-> Show (Range' lower upper a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Show a =>
Int -> Range' lower upper a -> ShowS
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Show a =>
[Range' lower upper a] -> ShowS
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Show a =>
Range' lower upper a -> String
$cshowsPrec :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Show a =>
Int -> Range' lower upper a -> ShowS
showsPrec :: Int -> Range' lower upper a -> ShowS
$cshow :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Show a =>
Range' lower upper a -> String
show :: Range' lower upper a -> String
$cshowList :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Show a =>
[Range' lower upper a] -> ShowS
showList :: [Range' lower upper a] -> ShowS
Show, Range' lower upper a -> Range' lower upper a -> Bool
(Range' lower upper a -> Range' lower upper a -> Bool)
-> (Range' lower upper a -> Range' lower upper a -> Bool)
-> Eq (Range' lower upper a)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Eq a =>
Range' lower upper a -> Range' lower upper a -> Bool
$c== :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Eq a =>
Range' lower upper a -> Range' lower upper a -> Bool
== :: Range' lower upper a -> Range' lower upper a -> Bool
$c/= :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Eq a =>
Range' lower upper a -> Range' lower upper a -> Bool
/= :: Range' lower upper a -> Range' lower upper a -> Bool
Eq)
deriving anyclass WellTypedToT (Range' lower upper a)
WellTypedToT (Range' lower upper a)
-> (Range' lower upper a -> Value (ToT (Range' lower upper a)))
-> (Value (ToT (Range' lower upper a)) -> Range' lower upper a)
-> IsoValue (Range' lower upper a)
Value (ToT (Range' lower upper a)) -> Range' lower upper a
Range' lower upper a -> Value (ToT (Range' lower upper a))
forall a.
WellTypedToT a
-> (a -> Value (ToT a)) -> (Value (ToT a) -> a) -> IsoValue a
forall {lower :: RangeBoundaryInclusion}
{upper :: RangeBoundaryInclusion} {a}.
IsoValue a =>
WellTypedToT (Range' lower upper a)
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
IsoValue a =>
Value (ToT (Range' lower upper a)) -> Range' lower upper a
forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
IsoValue a =>
Range' lower upper a -> Value (ToT (Range' lower upper a))
$ctoVal :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
IsoValue a =>
Range' lower upper a -> Value (ToT (Range' lower upper a))
toVal :: Range' lower upper a -> Value (ToT (Range' lower upper a))
$cfromVal :: forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
IsoValue a =>
Value (ToT (Range' lower upper a)) -> Range' lower upper a
fromVal :: Value (ToT (Range' lower upper a)) -> Range' lower upper a
IsoValue
type role Range' nominal nominal _
instance (HasAnnotation a, RangeBoundary lower, RangeBoundary upper)
=> HasAnnotation (Range' lower upper a) where
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (Range' lower upper a))
getAnnotation FollowEntrypointFlag
f =
let aann :: Notes (ToT a)
aann = forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @a FollowEntrypointFlag
f
e :: forall x. RangeBoundary x => Text
e :: forall (x :: RangeBoundaryInclusion). RangeBoundary x => Text
e | forall (r :: RangeBoundaryInclusion). RangeBoundary r => Bool
isInclusive @x = Text
"i"
| Bool
otherwise = Text
"e"
lann :: Annotation FieldTag
lann = Text -> Annotation FieldTag
forall {k} (tag :: k). Text -> Annotation tag
UnsafeAnnotation (Text -> Annotation FieldTag) -> Text -> Annotation FieldTag
forall a b. (a -> b) -> a -> b
$ Text
"l_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> forall (x :: RangeBoundaryInclusion). RangeBoundary x => Text
e @lower
uann :: Annotation FieldTag
uann = Text -> Annotation FieldTag
forall {k} (tag :: k). Text -> Annotation tag
UnsafeAnnotation (Text -> Annotation FieldTag) -> Text -> Annotation FieldTag
forall a b. (a -> b) -> a -> b
$ Text
"u_" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> forall (x :: RangeBoundaryInclusion). RangeBoundary x => Text
e @upper
in TypeAnn
-> Annotation FieldTag
-> Annotation FieldTag
-> VarAnn
-> VarAnn
-> Notes (ToT a)
-> Notes (ToT a)
-> Notes ('TPair (ToT a) (ToT a))
forall (p :: T) (q :: T).
TypeAnn
-> Annotation FieldTag
-> Annotation FieldTag
-> VarAnn
-> VarAnn
-> Notes p
-> Notes q
-> Notes ('TPair p q)
T.NTPair [typeAnnQ|range|] Annotation FieldTag
lann Annotation FieldTag
uann VarAnn
forall {k} (a :: k). Annotation a
noAnn VarAnn
forall {k} (a :: k). Annotation a
noAnn Notes (ToT a)
aann Notes (ToT a)
aann
newtype Range a = MkRangeII (Range' 'IncludeBoundary 'IncludeBoundary a)
deriving newtype (Typeable (Range a)
Markdown
SingI (TypeDocFieldDescriptions (Range a))
FieldDescriptionsValid
(TypeDocFieldDescriptions (Range a)) (Range a)
Typeable (Range a)
-> SingI (TypeDocFieldDescriptions (Range a))
-> FieldDescriptionsValid
(TypeDocFieldDescriptions (Range a)) (Range a)
-> (Proxy (Range a) -> Text)
-> Markdown
-> (Proxy (Range a) -> WithinParens -> Markdown)
-> (Proxy (Range a) -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep (Range a)
-> TypeDocMichelsonRep (Range a)
-> TypeHasDoc (Range a)
Proxy (Range a) -> [SomeDocDefinitionItem]
TypeDocMichelsonRep (Range a)
Proxy (Range a) -> Text
TypeDocHaskellRep (Range a)
Proxy (Range a) -> WithinParens -> Markdown
forall a.
Typeable a
-> SingI (TypeDocFieldDescriptions a)
-> FieldDescriptionsValid (TypeDocFieldDescriptions a) a
-> (Proxy a -> Text)
-> Markdown
-> (Proxy a -> WithinParens -> Markdown)
-> (Proxy a -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep a
-> TypeDocMichelsonRep a
-> TypeHasDoc a
forall {a}. TypeHasDoc a => Typeable (Range a)
forall a. TypeHasDoc a => Markdown
forall {a}.
TypeHasDoc a =>
SingI (TypeDocFieldDescriptions (Range a))
forall {a}.
TypeHasDoc a =>
FieldDescriptionsValid
(TypeDocFieldDescriptions (Range a)) (Range a)
forall a.
TypeHasDoc a =>
Proxy (Range a) -> [SomeDocDefinitionItem]
forall a. TypeHasDoc a => TypeDocMichelsonRep (Range a)
forall a. TypeHasDoc a => Proxy (Range a) -> Text
forall a. TypeHasDoc a => TypeDocHaskellRep (Range a)
forall a.
TypeHasDoc a =>
Proxy (Range a) -> WithinParens -> Markdown
$ctypeDocName :: forall a. TypeHasDoc a => Proxy (Range a) -> Text
typeDocName :: Proxy (Range a) -> Text
$ctypeDocMdDescription :: forall a. TypeHasDoc a => Markdown
typeDocMdDescription :: Markdown
$ctypeDocMdReference :: forall a.
TypeHasDoc a =>
Proxy (Range a) -> WithinParens -> Markdown
typeDocMdReference :: Proxy (Range a) -> WithinParens -> Markdown
$ctypeDocDependencies :: forall a.
TypeHasDoc a =>
Proxy (Range a) -> [SomeDocDefinitionItem]
typeDocDependencies :: Proxy (Range a) -> [SomeDocDefinitionItem]
$ctypeDocHaskellRep :: forall a. TypeHasDoc a => TypeDocHaskellRep (Range a)
typeDocHaskellRep :: TypeDocHaskellRep (Range a)
$ctypeDocMichelsonRep :: forall a. TypeHasDoc a => TypeDocMichelsonRep (Range a)
typeDocMichelsonRep :: TypeDocMichelsonRep (Range a)
TypeHasDoc, (forall x. Range a -> Rep (Range a) x)
-> (forall x. Rep (Range a) x -> Range a) -> Generic (Range a)
forall x. Rep (Range a) x -> Range a
forall x. Range a -> Rep (Range a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Range a) x -> Range a
forall a x. Range a -> Rep (Range a) x
$cfrom :: forall a x. Range a -> Rep (Range a) x
from :: forall x. Range a -> Rep (Range a) x
$cto :: forall a x. Rep (Range a) x -> Range a
to :: forall x. Rep (Range a) x -> Range a
Generic, Int -> Range a -> ShowS
[Range a] -> ShowS
Range a -> String
(Int -> Range a -> ShowS)
-> (Range a -> String) -> ([Range a] -> ShowS) -> Show (Range a)
forall a. Show a => Int -> Range a -> ShowS
forall a. Show a => [Range a] -> ShowS
forall a. Show a => Range a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Range a -> ShowS
showsPrec :: Int -> Range a -> ShowS
$cshow :: forall a. Show a => Range a -> String
show :: Range a -> String
$cshowList :: forall a. Show a => [Range a] -> ShowS
showList :: [Range a] -> ShowS
Show, [Range a] -> Markdown
Range a -> Markdown
(Range a -> Markdown)
-> ([Range a] -> Markdown) -> Buildable (Range a)
forall a. Buildable a => [Range a] -> Markdown
forall a. Buildable a => Range a -> Markdown
forall a. (a -> Markdown) -> ([a] -> Markdown) -> Buildable a
$cbuild :: forall a. Buildable a => Range a -> Markdown
build :: Range a -> Markdown
$cbuildList :: forall a. Buildable a => [Range a] -> Markdown
buildList :: [Range a] -> Markdown
Buildable, Maybe AnnOptions
FollowEntrypointFlag -> Notes (ToT (Range a))
(FollowEntrypointFlag -> Notes (ToT (Range a)))
-> Maybe AnnOptions -> HasAnnotation (Range a)
forall a. HasAnnotation a => Maybe AnnOptions
forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (Range a))
forall a.
(FollowEntrypointFlag -> Notes (ToT a))
-> Maybe AnnOptions -> HasAnnotation a
$cgetAnnotation :: forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (Range a))
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (Range a))
$cannOptions :: forall a. HasAnnotation a => Maybe AnnOptions
annOptions :: Maybe AnnOptions
HasAnnotation, Range a -> Range a -> Bool
(Range a -> Range a -> Bool)
-> (Range a -> Range a -> Bool) -> Eq (Range a)
forall a. Eq a => Range a -> Range a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => Range a -> Range a -> Bool
== :: Range a -> Range a -> Bool
$c/= :: forall a. Eq a => Range a -> Range a -> Bool
/= :: Range a -> Range a -> Bool
Eq)
deriving anyclass WellTypedToT (Range a)
WellTypedToT (Range a)
-> (Range a -> Value (ToT (Range a)))
-> (Value (ToT (Range a)) -> Range a)
-> IsoValue (Range a)
Value (ToT (Range a)) -> Range a
Range a -> Value (ToT (Range a))
forall a.
WellTypedToT a
-> (a -> Value (ToT a)) -> (Value (ToT a) -> a) -> IsoValue a
forall {a}. IsoValue a => WellTypedToT (Range a)
forall a. IsoValue a => Value (ToT (Range a)) -> Range a
forall a. IsoValue a => Range a -> Value (ToT (Range a))
$ctoVal :: forall a. IsoValue a => Range a -> Value (ToT (Range a))
toVal :: Range a -> Value (ToT (Range a))
$cfromVal :: forall a. IsoValue a => Value (ToT (Range a)) -> Range a
fromVal :: Value (ToT (Range a)) -> Range a
IsoValue
newtype RangeEE a = MkRangeEE (Range' 'ExcludeBoundary 'ExcludeBoundary a)
deriving newtype (Typeable (RangeEE a)
Markdown
SingI (TypeDocFieldDescriptions (RangeEE a))
FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeEE a)) (RangeEE a)
Typeable (RangeEE a)
-> SingI (TypeDocFieldDescriptions (RangeEE a))
-> FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeEE a)) (RangeEE a)
-> (Proxy (RangeEE a) -> Text)
-> Markdown
-> (Proxy (RangeEE a) -> WithinParens -> Markdown)
-> (Proxy (RangeEE a) -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep (RangeEE a)
-> TypeDocMichelsonRep (RangeEE a)
-> TypeHasDoc (RangeEE a)
Proxy (RangeEE a) -> [SomeDocDefinitionItem]
TypeDocMichelsonRep (RangeEE a)
Proxy (RangeEE a) -> Text
TypeDocHaskellRep (RangeEE a)
Proxy (RangeEE a) -> WithinParens -> Markdown
forall a.
Typeable a
-> SingI (TypeDocFieldDescriptions a)
-> FieldDescriptionsValid (TypeDocFieldDescriptions a) a
-> (Proxy a -> Text)
-> Markdown
-> (Proxy a -> WithinParens -> Markdown)
-> (Proxy a -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep a
-> TypeDocMichelsonRep a
-> TypeHasDoc a
forall {a}. TypeHasDoc a => Typeable (RangeEE a)
forall a. TypeHasDoc a => Markdown
forall {a}.
TypeHasDoc a =>
SingI (TypeDocFieldDescriptions (RangeEE a))
forall {a}.
TypeHasDoc a =>
FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeEE a)) (RangeEE a)
forall a.
TypeHasDoc a =>
Proxy (RangeEE a) -> [SomeDocDefinitionItem]
forall a. TypeHasDoc a => TypeDocMichelsonRep (RangeEE a)
forall a. TypeHasDoc a => Proxy (RangeEE a) -> Text
forall a. TypeHasDoc a => TypeDocHaskellRep (RangeEE a)
forall a.
TypeHasDoc a =>
Proxy (RangeEE a) -> WithinParens -> Markdown
$ctypeDocName :: forall a. TypeHasDoc a => Proxy (RangeEE a) -> Text
typeDocName :: Proxy (RangeEE a) -> Text
$ctypeDocMdDescription :: forall a. TypeHasDoc a => Markdown
typeDocMdDescription :: Markdown
$ctypeDocMdReference :: forall a.
TypeHasDoc a =>
Proxy (RangeEE a) -> WithinParens -> Markdown
typeDocMdReference :: Proxy (RangeEE a) -> WithinParens -> Markdown
$ctypeDocDependencies :: forall a.
TypeHasDoc a =>
Proxy (RangeEE a) -> [SomeDocDefinitionItem]
typeDocDependencies :: Proxy (RangeEE a) -> [SomeDocDefinitionItem]
$ctypeDocHaskellRep :: forall a. TypeHasDoc a => TypeDocHaskellRep (RangeEE a)
typeDocHaskellRep :: TypeDocHaskellRep (RangeEE a)
$ctypeDocMichelsonRep :: forall a. TypeHasDoc a => TypeDocMichelsonRep (RangeEE a)
typeDocMichelsonRep :: TypeDocMichelsonRep (RangeEE a)
TypeHasDoc, (forall x. RangeEE a -> Rep (RangeEE a) x)
-> (forall x. Rep (RangeEE a) x -> RangeEE a)
-> Generic (RangeEE a)
forall x. Rep (RangeEE a) x -> RangeEE a
forall x. RangeEE a -> Rep (RangeEE a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (RangeEE a) x -> RangeEE a
forall a x. RangeEE a -> Rep (RangeEE a) x
$cfrom :: forall a x. RangeEE a -> Rep (RangeEE a) x
from :: forall x. RangeEE a -> Rep (RangeEE a) x
$cto :: forall a x. Rep (RangeEE a) x -> RangeEE a
to :: forall x. Rep (RangeEE a) x -> RangeEE a
Generic, Int -> RangeEE a -> ShowS
[RangeEE a] -> ShowS
RangeEE a -> String
(Int -> RangeEE a -> ShowS)
-> (RangeEE a -> String)
-> ([RangeEE a] -> ShowS)
-> Show (RangeEE a)
forall a. Show a => Int -> RangeEE a -> ShowS
forall a. Show a => [RangeEE a] -> ShowS
forall a. Show a => RangeEE a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> RangeEE a -> ShowS
showsPrec :: Int -> RangeEE a -> ShowS
$cshow :: forall a. Show a => RangeEE a -> String
show :: RangeEE a -> String
$cshowList :: forall a. Show a => [RangeEE a] -> ShowS
showList :: [RangeEE a] -> ShowS
Show, [RangeEE a] -> Markdown
RangeEE a -> Markdown
(RangeEE a -> Markdown)
-> ([RangeEE a] -> Markdown) -> Buildable (RangeEE a)
forall a. Buildable a => [RangeEE a] -> Markdown
forall a. Buildable a => RangeEE a -> Markdown
forall a. (a -> Markdown) -> ([a] -> Markdown) -> Buildable a
$cbuild :: forall a. Buildable a => RangeEE a -> Markdown
build :: RangeEE a -> Markdown
$cbuildList :: forall a. Buildable a => [RangeEE a] -> Markdown
buildList :: [RangeEE a] -> Markdown
Buildable, Maybe AnnOptions
FollowEntrypointFlag -> Notes (ToT (RangeEE a))
(FollowEntrypointFlag -> Notes (ToT (RangeEE a)))
-> Maybe AnnOptions -> HasAnnotation (RangeEE a)
forall a. HasAnnotation a => Maybe AnnOptions
forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (RangeEE a))
forall a.
(FollowEntrypointFlag -> Notes (ToT a))
-> Maybe AnnOptions -> HasAnnotation a
$cgetAnnotation :: forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (RangeEE a))
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (RangeEE a))
$cannOptions :: forall a. HasAnnotation a => Maybe AnnOptions
annOptions :: Maybe AnnOptions
HasAnnotation, RangeEE a -> RangeEE a -> Bool
(RangeEE a -> RangeEE a -> Bool)
-> (RangeEE a -> RangeEE a -> Bool) -> Eq (RangeEE a)
forall a. Eq a => RangeEE a -> RangeEE a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => RangeEE a -> RangeEE a -> Bool
== :: RangeEE a -> RangeEE a -> Bool
$c/= :: forall a. Eq a => RangeEE a -> RangeEE a -> Bool
/= :: RangeEE a -> RangeEE a -> Bool
Eq)
deriving anyclass WellTypedToT (RangeEE a)
WellTypedToT (RangeEE a)
-> (RangeEE a -> Value (ToT (RangeEE a)))
-> (Value (ToT (RangeEE a)) -> RangeEE a)
-> IsoValue (RangeEE a)
Value (ToT (RangeEE a)) -> RangeEE a
RangeEE a -> Value (ToT (RangeEE a))
forall a.
WellTypedToT a
-> (a -> Value (ToT a)) -> (Value (ToT a) -> a) -> IsoValue a
forall {a}. IsoValue a => WellTypedToT (RangeEE a)
forall a. IsoValue a => Value (ToT (RangeEE a)) -> RangeEE a
forall a. IsoValue a => RangeEE a -> Value (ToT (RangeEE a))
$ctoVal :: forall a. IsoValue a => RangeEE a -> Value (ToT (RangeEE a))
toVal :: RangeEE a -> Value (ToT (RangeEE a))
$cfromVal :: forall a. IsoValue a => Value (ToT (RangeEE a)) -> RangeEE a
fromVal :: Value (ToT (RangeEE a)) -> RangeEE a
IsoValue
newtype RangeIE a = MkRangeIE (Range' 'IncludeBoundary 'ExcludeBoundary a)
deriving newtype (Typeable (RangeIE a)
Markdown
SingI (TypeDocFieldDescriptions (RangeIE a))
FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeIE a)) (RangeIE a)
Typeable (RangeIE a)
-> SingI (TypeDocFieldDescriptions (RangeIE a))
-> FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeIE a)) (RangeIE a)
-> (Proxy (RangeIE a) -> Text)
-> Markdown
-> (Proxy (RangeIE a) -> WithinParens -> Markdown)
-> (Proxy (RangeIE a) -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep (RangeIE a)
-> TypeDocMichelsonRep (RangeIE a)
-> TypeHasDoc (RangeIE a)
Proxy (RangeIE a) -> [SomeDocDefinitionItem]
TypeDocMichelsonRep (RangeIE a)
Proxy (RangeIE a) -> Text
TypeDocHaskellRep (RangeIE a)
Proxy (RangeIE a) -> WithinParens -> Markdown
forall a.
Typeable a
-> SingI (TypeDocFieldDescriptions a)
-> FieldDescriptionsValid (TypeDocFieldDescriptions a) a
-> (Proxy a -> Text)
-> Markdown
-> (Proxy a -> WithinParens -> Markdown)
-> (Proxy a -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep a
-> TypeDocMichelsonRep a
-> TypeHasDoc a
forall {a}. TypeHasDoc a => Typeable (RangeIE a)
forall a. TypeHasDoc a => Markdown
forall {a}.
TypeHasDoc a =>
SingI (TypeDocFieldDescriptions (RangeIE a))
forall {a}.
TypeHasDoc a =>
FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeIE a)) (RangeIE a)
forall a.
TypeHasDoc a =>
Proxy (RangeIE a) -> [SomeDocDefinitionItem]
forall a. TypeHasDoc a => TypeDocMichelsonRep (RangeIE a)
forall a. TypeHasDoc a => Proxy (RangeIE a) -> Text
forall a. TypeHasDoc a => TypeDocHaskellRep (RangeIE a)
forall a.
TypeHasDoc a =>
Proxy (RangeIE a) -> WithinParens -> Markdown
$ctypeDocName :: forall a. TypeHasDoc a => Proxy (RangeIE a) -> Text
typeDocName :: Proxy (RangeIE a) -> Text
$ctypeDocMdDescription :: forall a. TypeHasDoc a => Markdown
typeDocMdDescription :: Markdown
$ctypeDocMdReference :: forall a.
TypeHasDoc a =>
Proxy (RangeIE a) -> WithinParens -> Markdown
typeDocMdReference :: Proxy (RangeIE a) -> WithinParens -> Markdown
$ctypeDocDependencies :: forall a.
TypeHasDoc a =>
Proxy (RangeIE a) -> [SomeDocDefinitionItem]
typeDocDependencies :: Proxy (RangeIE a) -> [SomeDocDefinitionItem]
$ctypeDocHaskellRep :: forall a. TypeHasDoc a => TypeDocHaskellRep (RangeIE a)
typeDocHaskellRep :: TypeDocHaskellRep (RangeIE a)
$ctypeDocMichelsonRep :: forall a. TypeHasDoc a => TypeDocMichelsonRep (RangeIE a)
typeDocMichelsonRep :: TypeDocMichelsonRep (RangeIE a)
TypeHasDoc, (forall x. RangeIE a -> Rep (RangeIE a) x)
-> (forall x. Rep (RangeIE a) x -> RangeIE a)
-> Generic (RangeIE a)
forall x. Rep (RangeIE a) x -> RangeIE a
forall x. RangeIE a -> Rep (RangeIE a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (RangeIE a) x -> RangeIE a
forall a x. RangeIE a -> Rep (RangeIE a) x
$cfrom :: forall a x. RangeIE a -> Rep (RangeIE a) x
from :: forall x. RangeIE a -> Rep (RangeIE a) x
$cto :: forall a x. Rep (RangeIE a) x -> RangeIE a
to :: forall x. Rep (RangeIE a) x -> RangeIE a
Generic, Int -> RangeIE a -> ShowS
[RangeIE a] -> ShowS
RangeIE a -> String
(Int -> RangeIE a -> ShowS)
-> (RangeIE a -> String)
-> ([RangeIE a] -> ShowS)
-> Show (RangeIE a)
forall a. Show a => Int -> RangeIE a -> ShowS
forall a. Show a => [RangeIE a] -> ShowS
forall a. Show a => RangeIE a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> RangeIE a -> ShowS
showsPrec :: Int -> RangeIE a -> ShowS
$cshow :: forall a. Show a => RangeIE a -> String
show :: RangeIE a -> String
$cshowList :: forall a. Show a => [RangeIE a] -> ShowS
showList :: [RangeIE a] -> ShowS
Show, [RangeIE a] -> Markdown
RangeIE a -> Markdown
(RangeIE a -> Markdown)
-> ([RangeIE a] -> Markdown) -> Buildable (RangeIE a)
forall a. Buildable a => [RangeIE a] -> Markdown
forall a. Buildable a => RangeIE a -> Markdown
forall a. (a -> Markdown) -> ([a] -> Markdown) -> Buildable a
$cbuild :: forall a. Buildable a => RangeIE a -> Markdown
build :: RangeIE a -> Markdown
$cbuildList :: forall a. Buildable a => [RangeIE a] -> Markdown
buildList :: [RangeIE a] -> Markdown
Buildable, Maybe AnnOptions
FollowEntrypointFlag -> Notes (ToT (RangeIE a))
(FollowEntrypointFlag -> Notes (ToT (RangeIE a)))
-> Maybe AnnOptions -> HasAnnotation (RangeIE a)
forall a. HasAnnotation a => Maybe AnnOptions
forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (RangeIE a))
forall a.
(FollowEntrypointFlag -> Notes (ToT a))
-> Maybe AnnOptions -> HasAnnotation a
$cgetAnnotation :: forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (RangeIE a))
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (RangeIE a))
$cannOptions :: forall a. HasAnnotation a => Maybe AnnOptions
annOptions :: Maybe AnnOptions
HasAnnotation, RangeIE a -> RangeIE a -> Bool
(RangeIE a -> RangeIE a -> Bool)
-> (RangeIE a -> RangeIE a -> Bool) -> Eq (RangeIE a)
forall a. Eq a => RangeIE a -> RangeIE a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => RangeIE a -> RangeIE a -> Bool
== :: RangeIE a -> RangeIE a -> Bool
$c/= :: forall a. Eq a => RangeIE a -> RangeIE a -> Bool
/= :: RangeIE a -> RangeIE a -> Bool
Eq)
deriving anyclass WellTypedToT (RangeIE a)
WellTypedToT (RangeIE a)
-> (RangeIE a -> Value (ToT (RangeIE a)))
-> (Value (ToT (RangeIE a)) -> RangeIE a)
-> IsoValue (RangeIE a)
Value (ToT (RangeIE a)) -> RangeIE a
RangeIE a -> Value (ToT (RangeIE a))
forall a.
WellTypedToT a
-> (a -> Value (ToT a)) -> (Value (ToT a) -> a) -> IsoValue a
forall {a}. IsoValue a => WellTypedToT (RangeIE a)
forall a. IsoValue a => Value (ToT (RangeIE a)) -> RangeIE a
forall a. IsoValue a => RangeIE a -> Value (ToT (RangeIE a))
$ctoVal :: forall a. IsoValue a => RangeIE a -> Value (ToT (RangeIE a))
toVal :: RangeIE a -> Value (ToT (RangeIE a))
$cfromVal :: forall a. IsoValue a => Value (ToT (RangeIE a)) -> RangeIE a
fromVal :: Value (ToT (RangeIE a)) -> RangeIE a
IsoValue
newtype RangeEI a = MkRangeEI (Range' 'ExcludeBoundary 'IncludeBoundary a)
deriving newtype (Typeable (RangeEI a)
Markdown
SingI (TypeDocFieldDescriptions (RangeEI a))
FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeEI a)) (RangeEI a)
Typeable (RangeEI a)
-> SingI (TypeDocFieldDescriptions (RangeEI a))
-> FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeEI a)) (RangeEI a)
-> (Proxy (RangeEI a) -> Text)
-> Markdown
-> (Proxy (RangeEI a) -> WithinParens -> Markdown)
-> (Proxy (RangeEI a) -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep (RangeEI a)
-> TypeDocMichelsonRep (RangeEI a)
-> TypeHasDoc (RangeEI a)
Proxy (RangeEI a) -> [SomeDocDefinitionItem]
TypeDocMichelsonRep (RangeEI a)
Proxy (RangeEI a) -> Text
TypeDocHaskellRep (RangeEI a)
Proxy (RangeEI a) -> WithinParens -> Markdown
forall a.
Typeable a
-> SingI (TypeDocFieldDescriptions a)
-> FieldDescriptionsValid (TypeDocFieldDescriptions a) a
-> (Proxy a -> Text)
-> Markdown
-> (Proxy a -> WithinParens -> Markdown)
-> (Proxy a -> [SomeDocDefinitionItem])
-> TypeDocHaskellRep a
-> TypeDocMichelsonRep a
-> TypeHasDoc a
forall {a}. TypeHasDoc a => Typeable (RangeEI a)
forall a. TypeHasDoc a => Markdown
forall {a}.
TypeHasDoc a =>
SingI (TypeDocFieldDescriptions (RangeEI a))
forall {a}.
TypeHasDoc a =>
FieldDescriptionsValid
(TypeDocFieldDescriptions (RangeEI a)) (RangeEI a)
forall a.
TypeHasDoc a =>
Proxy (RangeEI a) -> [SomeDocDefinitionItem]
forall a. TypeHasDoc a => TypeDocMichelsonRep (RangeEI a)
forall a. TypeHasDoc a => Proxy (RangeEI a) -> Text
forall a. TypeHasDoc a => TypeDocHaskellRep (RangeEI a)
forall a.
TypeHasDoc a =>
Proxy (RangeEI a) -> WithinParens -> Markdown
$ctypeDocName :: forall a. TypeHasDoc a => Proxy (RangeEI a) -> Text
typeDocName :: Proxy (RangeEI a) -> Text
$ctypeDocMdDescription :: forall a. TypeHasDoc a => Markdown
typeDocMdDescription :: Markdown
$ctypeDocMdReference :: forall a.
TypeHasDoc a =>
Proxy (RangeEI a) -> WithinParens -> Markdown
typeDocMdReference :: Proxy (RangeEI a) -> WithinParens -> Markdown
$ctypeDocDependencies :: forall a.
TypeHasDoc a =>
Proxy (RangeEI a) -> [SomeDocDefinitionItem]
typeDocDependencies :: Proxy (RangeEI a) -> [SomeDocDefinitionItem]
$ctypeDocHaskellRep :: forall a. TypeHasDoc a => TypeDocHaskellRep (RangeEI a)
typeDocHaskellRep :: TypeDocHaskellRep (RangeEI a)
$ctypeDocMichelsonRep :: forall a. TypeHasDoc a => TypeDocMichelsonRep (RangeEI a)
typeDocMichelsonRep :: TypeDocMichelsonRep (RangeEI a)
TypeHasDoc, (forall x. RangeEI a -> Rep (RangeEI a) x)
-> (forall x. Rep (RangeEI a) x -> RangeEI a)
-> Generic (RangeEI a)
forall x. Rep (RangeEI a) x -> RangeEI a
forall x. RangeEI a -> Rep (RangeEI a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (RangeEI a) x -> RangeEI a
forall a x. RangeEI a -> Rep (RangeEI a) x
$cfrom :: forall a x. RangeEI a -> Rep (RangeEI a) x
from :: forall x. RangeEI a -> Rep (RangeEI a) x
$cto :: forall a x. Rep (RangeEI a) x -> RangeEI a
to :: forall x. Rep (RangeEI a) x -> RangeEI a
Generic, Int -> RangeEI a -> ShowS
[RangeEI a] -> ShowS
RangeEI a -> String
(Int -> RangeEI a -> ShowS)
-> (RangeEI a -> String)
-> ([RangeEI a] -> ShowS)
-> Show (RangeEI a)
forall a. Show a => Int -> RangeEI a -> ShowS
forall a. Show a => [RangeEI a] -> ShowS
forall a. Show a => RangeEI a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> RangeEI a -> ShowS
showsPrec :: Int -> RangeEI a -> ShowS
$cshow :: forall a. Show a => RangeEI a -> String
show :: RangeEI a -> String
$cshowList :: forall a. Show a => [RangeEI a] -> ShowS
showList :: [RangeEI a] -> ShowS
Show, [RangeEI a] -> Markdown
RangeEI a -> Markdown
(RangeEI a -> Markdown)
-> ([RangeEI a] -> Markdown) -> Buildable (RangeEI a)
forall a. Buildable a => [RangeEI a] -> Markdown
forall a. Buildable a => RangeEI a -> Markdown
forall a. (a -> Markdown) -> ([a] -> Markdown) -> Buildable a
$cbuild :: forall a. Buildable a => RangeEI a -> Markdown
build :: RangeEI a -> Markdown
$cbuildList :: forall a. Buildable a => [RangeEI a] -> Markdown
buildList :: [RangeEI a] -> Markdown
Buildable, Maybe AnnOptions
FollowEntrypointFlag -> Notes (ToT (RangeEI a))
(FollowEntrypointFlag -> Notes (ToT (RangeEI a)))
-> Maybe AnnOptions -> HasAnnotation (RangeEI a)
forall a. HasAnnotation a => Maybe AnnOptions
forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (RangeEI a))
forall a.
(FollowEntrypointFlag -> Notes (ToT a))
-> Maybe AnnOptions -> HasAnnotation a
$cgetAnnotation :: forall a.
HasAnnotation a =>
FollowEntrypointFlag -> Notes (ToT (RangeEI a))
getAnnotation :: FollowEntrypointFlag -> Notes (ToT (RangeEI a))
$cannOptions :: forall a. HasAnnotation a => Maybe AnnOptions
annOptions :: Maybe AnnOptions
HasAnnotation, RangeEI a -> RangeEI a -> Bool
(RangeEI a -> RangeEI a -> Bool)
-> (RangeEI a -> RangeEI a -> Bool) -> Eq (RangeEI a)
forall a. Eq a => RangeEI a -> RangeEI a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => RangeEI a -> RangeEI a -> Bool
== :: RangeEI a -> RangeEI a -> Bool
$c/= :: forall a. Eq a => RangeEI a -> RangeEI a -> Bool
/= :: RangeEI a -> RangeEI a -> Bool
Eq)
deriving anyclass WellTypedToT (RangeEI a)
WellTypedToT (RangeEI a)
-> (RangeEI a -> Value (ToT (RangeEI a)))
-> (Value (ToT (RangeEI a)) -> RangeEI a)
-> IsoValue (RangeEI a)
Value (ToT (RangeEI a)) -> RangeEI a
RangeEI a -> Value (ToT (RangeEI a))
forall a.
WellTypedToT a
-> (a -> Value (ToT a)) -> (Value (ToT a) -> a) -> IsoValue a
forall {a}. IsoValue a => WellTypedToT (RangeEI a)
forall a. IsoValue a => Value (ToT (RangeEI a)) -> RangeEI a
forall a. IsoValue a => RangeEI a -> Value (ToT (RangeEI a))
$ctoVal :: forall a. IsoValue a => RangeEI a -> Value (ToT (RangeEI a))
toVal :: RangeEI a -> Value (ToT (RangeEI a))
$cfromVal :: forall a. IsoValue a => Value (ToT (RangeEI a)) -> RangeEI a
fromVal :: Value (ToT (RangeEI a)) -> RangeEI a
IsoValue
{-# WARNING MkRangeII, MkRangeEE, MkRangeEI, MkRangeIE
"Avoid using data constructors directly, use mkRange instead."
#-}
instance (TypeHasDoc a, RangeBoundary lower, RangeBoundary upper)
=> TypeHasDoc (Range' lower upper a) where
typeDocName :: Proxy (Range' lower upper a) -> Text
typeDocName Proxy (Range' lower upper a)
_ = case (forall (r :: RangeBoundaryInclusion). RangeBoundary r => Bool
isInclusive @lower, forall (r :: RangeBoundaryInclusion). RangeBoundary r => Bool
isInclusive @upper) of
(Bool
True, Bool
True) -> Text
"Range"
(Bool
True, Bool
False) -> Text
"RangeIE"
(Bool
False, Bool
True) -> Text
"RangeEI"
(Bool
False, Bool
False) -> Text
"RangeEE"
typeDocMdDescription :: Markdown
typeDocMdDescription =
Markdown
"Signifies a range, which is " Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Text -> Markdown
forall a. Buildable a => a -> Markdown
build (forall (x :: RangeBoundaryInclusion). RangeBoundary x => Text
rangeName @lower) Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Markdown
" wrt its lower boundary and "
Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Text -> Markdown
forall a. Buildable a => a -> Markdown
build (forall (x :: RangeBoundaryInclusion). RangeBoundary x => Text
rangeName @upper) Markdown -> Markdown -> Markdown
forall a. Semigroup a => a -> a -> a
<> Markdown
" wrt its upper boundary."
typeDocMdReference :: Proxy (Range' lower upper a) -> WithinParens -> Markdown
typeDocMdReference Proxy (Range' lower upper a)
pa =
(Text, DType) -> [DType] -> WithinParens -> Markdown
customTypeDocMdReference
(Proxy (Range' lower upper a) -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy (Range' lower upper a)
pa, Proxy (Range' lower upper a) -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType Proxy (Range' lower upper a)
pa) [Proxy a -> DType
forall a. TypeHasDoc a => Proxy a -> DType
DType (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a)]
typeDocHaskellRep :: TypeDocHaskellRep (Range' lower upper a)
typeDocHaskellRep Proxy (Range' lower upper a)
pa FieldDescriptionsV
_ = (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a. a -> Maybe a
Just ((Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc))
-> (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
-> Maybe (Maybe DocTypeRepLHS, ADTRep SomeTypeWithDoc)
forall a b. (a -> b) -> a -> b
$
( DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a. a -> Maybe a
Just (DocTypeRepLHS -> Maybe DocTypeRepLHS)
-> DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ String -> DocTypeRepLHS
forall a. IsString a => String -> a
fromString (String -> DocTypeRepLHS)
-> (Text -> String) -> Text -> DocTypeRepLHS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
forall a. ToString a => a -> String
toString (Text -> DocTypeRepLHS) -> Text -> DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ Proxy (Range' lower upper a) -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy (Range' lower upper a)
pa Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" Integer"
, [Text
-> Maybe Text
-> [FieldRep SomeTypeWithDoc]
-> ConstructorRep SomeTypeWithDoc
forall a. Text -> Maybe Text -> [FieldRep a] -> ConstructorRep a
T.ConstructorRep (Proxy (Range' lower upper a) -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy (Range' lower upper a)
pa) Maybe Text
forall a. Maybe a
Nothing [FieldRep SomeTypeWithDoc]
fields]
)
where
fields :: [FieldRep SomeTypeWithDoc]
fields = case forall a. HasAnnotation a => FollowEntrypointFlag -> Notes (ToT a)
getAnnotation @(Range' lower upper Integer) FollowEntrypointFlag
NotFollowEntrypoint of
T.NTPair TypeAnn
_ Annotation FieldTag
lower Annotation FieldTag
upper VarAnn
_ VarAnn
_ Notes p
_ Notes q
_ ->
[ Maybe Text
-> Maybe Text -> SomeTypeWithDoc -> FieldRep SomeTypeWithDoc
forall a. Maybe Text -> Maybe Text -> a -> FieldRep a
T.FieldRep (Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> Text -> Maybe Text
forall a b. (a -> b) -> a -> b
$ Annotation FieldTag -> Text
forall {k} (tag :: k). Annotation tag -> Text
unAnnotation Annotation FieldTag
lower) (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Lower boundary") SomeTypeWithDoc
intRef
, Maybe Text
-> Maybe Text -> SomeTypeWithDoc -> FieldRep SomeTypeWithDoc
forall a. Maybe Text -> Maybe Text -> a -> FieldRep a
T.FieldRep (Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> Text -> Maybe Text
forall a b. (a -> b) -> a -> b
$ Annotation FieldTag -> Text
forall {k} (tag :: k). Annotation tag -> Text
unAnnotation Annotation FieldTag
upper) (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Upper boundary") SomeTypeWithDoc
intRef
]
intRef :: SomeTypeWithDoc
intRef = Proxy Integer -> SomeTypeWithDoc
forall td. TypeHasDoc td => Proxy td -> SomeTypeWithDoc
SomeTypeWithDoc (Proxy Integer -> SomeTypeWithDoc)
-> Proxy Integer -> SomeTypeWithDoc
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @Integer
typeDocMichelsonRep :: TypeDocMichelsonRep (Range' lower upper a)
typeDocMichelsonRep Proxy (Range' lower upper a)
pa =
( DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a. a -> Maybe a
Just (DocTypeRepLHS -> Maybe DocTypeRepLHS)
-> DocTypeRepLHS -> Maybe DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ String -> DocTypeRepLHS
forall a. IsString a => String -> a
fromString (String -> DocTypeRepLHS)
-> (Text -> String) -> Text -> DocTypeRepLHS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
forall a. ToString a => a -> String
toString (Text -> DocTypeRepLHS) -> Text -> DocTypeRepLHS
forall a b. (a -> b) -> a -> b
$ Proxy (Range' lower upper a) -> Text
forall a. TypeHasDoc a => Proxy a -> Text
typeDocName Proxy (Range' lower upper a)
pa Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" Integer"
, forall {k} (a :: k). (SingKind k, SingI a) => Demote k
forall (a :: T). (SingKind T, SingI a) => Demote T
demote @(ToT (Range' lower upper Integer))
)
instance (RangeBoundary lower, RangeBoundary upper, Buildable a)
=> Buildable (Range' lower upper a) where
build :: Range' lower upper a -> Markdown
build (Range' a
l a
r) = [i|#{lpar}#{l}, #{r}#{rpar}|]
where lpar :: Text
lpar = (Text, Text) -> Text
forall a b. (a, b) -> a
fst ((Text, Text) -> Text) -> (Text, Text) -> Text
forall a b. (a -> b) -> a -> b
$ forall (r :: RangeBoundaryInclusion).
RangeBoundary r =>
(Text, Text)
rangeParens @lower
rpar :: Text
rpar = (Text, Text) -> Text
forall a b. (a, b) -> b
snd ((Text, Text) -> Text) -> (Text, Text) -> Text
forall a b. (a -> b) -> a -> b
$ forall (r :: RangeBoundaryInclusion).
RangeBoundary r =>
(Text, Text)
rangeParens @upper
class (RangeBoundary lower, RangeBoundary upper, ToT (range a) ~ ToT (a, a), KnownValue (range a)
, Coercible range (Range' lower upper))
=> NiceRange range lower upper a | range -> lower upper, lower upper -> range
instance KnownValue a => NiceRange Range 'IncludeBoundary 'IncludeBoundary a
instance KnownValue a => NiceRange RangeIE 'IncludeBoundary 'ExcludeBoundary a
instance KnownValue a => NiceRange RangeEI 'ExcludeBoundary 'IncludeBoundary a
instance KnownValue a => NiceRange RangeEE 'ExcludeBoundary 'ExcludeBoundary a
rangeLower :: forall range lower upper a. NiceRange range lower upper a => range a -> a
rangeLower :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
range a -> a
rangeLower = (Range' lower upper a -> a) -> range a -> a
forall a b. Coercible a b => a -> b
coerce ((Range' lower upper a -> a) -> range a -> a)
-> (Range' lower upper a -> a) -> range a -> a
forall a b. (a -> b) -> a -> b
$ forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Range' lower upper a -> a
rangeLower' @lower @upper @a
rangeUpper :: forall range lower upper a. NiceRange range lower upper a => range a -> a
rangeUpper :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
range a -> a
rangeUpper = (Range' lower upper a -> a) -> range a -> a
forall a b. Coercible a b => a -> b
coerce ((Range' lower upper a -> a) -> range a -> a)
-> (Range' lower upper a -> a) -> range a -> a
forall a b. (a -> b) -> a -> b
$ forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
Range' lower upper a -> a
rangeUpper' @lower @upper @a
mkRange :: forall range lower upper a. NiceRange range lower upper a => a -> a -> range a
mkRange :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
a -> a -> range a
mkRange = (a -> a -> Range' lower upper a) -> a -> a -> range a
forall a b. Coercible a b => a -> b
coerce ((a -> a -> Range' lower upper a) -> a -> a -> range a)
-> (a -> a -> Range' lower upper a) -> a -> a -> range a
forall a b. (a -> b) -> a -> b
$ forall (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
a -> a -> Range' lower upper a
Range' @lower @upper @a
fromRange_ :: NiceRange range lower upper a => range a : s :-> (a, a) : s
fromRange_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> ((a, a) : s)
fromRange_ = (range a : s) :-> ((a, a) : s)
forall a b (s :: [*]).
MichelsonCoercible a b =>
(a : s) :-> (b : s)
forcedCoerce_
toRange_ :: NiceRange range lower upper a => (a, a) : s :-> range a : s
toRange_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
((a, a) : s) :-> (range a : s)
toRange_ = ((a, a) : s) :-> (range a : s)
forall a b (s :: [*]).
MichelsonCoercible a b =>
(a : s) :-> (b : s)
forcedCoerce_
rangeLower_ :: NiceRange range lower upper a => range a : s :-> a : s
rangeLower_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> (a : s)
rangeLower_ = (range a : s) :-> ((a, a) : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> ((a, a) : s)
fromRange_ ((range a : s) :-> ((a, a) : s))
-> (((a, a) : s) :-> (a : s)) -> (range a : s) :-> (a : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# ((a, a) : s) :-> (a : s)
forall a b (s :: [*]). ((a, b) : s) :-> (a : s)
car
rangeUpper_ :: NiceRange range lower upper a => range a : s :-> a : s
rangeUpper_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> (a : s)
rangeUpper_ = (range a : s) :-> ((a, a) : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> ((a, a) : s)
fromRange_ ((range a : s) :-> ((a, a) : s))
-> (((a, a) : s) :-> (a : s)) -> (range a : s) :-> (a : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# ((a, a) : s) :-> (a : s)
forall a b (s :: [*]). ((a, b) : s) :-> (b : s)
cdr
mkRangeFor :: (NiceRange range lower upper a, Num a) => a -> a -> range a
mkRangeFor :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
(NiceRange range lower upper a, Num a) =>
a -> a -> range a
mkRangeFor a
start a
len = a -> a -> range a
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
a -> a -> range a
mkRange a
start (a
start a -> a -> a
forall a. Num a => a -> a -> a
+ a
len)
mkRange_
:: NiceRange range lower upper a
=> ("min" :! a) : ("max" :! a) : s :-> range a : s
mkRange_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(("min" :! a) : ("max" :! a) : s) :-> (range a : s)
mkRange_ = Label "min"
-> (("min" :! a) : ("max" :! a) : s) :-> (a : ("max" :! a) : s)
forall (name :: Symbol) a (s :: [*]).
Label name -> ((name :! a) : s) :-> (a : s)
fromNamed Label "min"
#min ((("min" :! a) : ("max" :! a) : s) :-> (a : ("max" :! a) : s))
-> ((a : ("max" :! a) : s) :-> (a : a : s))
-> (("min" :! a) : ("max" :! a) : s) :-> (a : a : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# ((("max" :! a) : s) :-> (a : s))
-> (a : ("max" :! a) : s) :-> (a : a : s)
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "max" -> (("max" :! a) : s) :-> (a : s)
forall (name :: Symbol) a (s :: [*]).
Label name -> ((name :! a) : s) :-> (a : s)
fromNamed Label "max"
#max) ((("min" :! a) : ("max" :! a) : s) :-> (a : a : s))
-> ((a : a : s) :-> ((a, a) : s))
-> (("min" :! a) : ("max" :! a) : s) :-> ((a, a) : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# (a : a : s) :-> ((a, a) : s)
forall a b (s :: [*]). (a : b : s) :-> ((a, b) : s)
L.pair ((("min" :! a) : ("max" :! a) : s) :-> ((a, a) : s))
-> (((a, a) : s) :-> (range a : s))
-> (("min" :! a) : ("max" :! a) : s) :-> (range a : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# ((a, a) : s) :-> (range a : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
((a, a) : s) :-> (range a : s)
toRange_
mkRangeFor_
:: ( NiceRange range lower upper a
, Dupable a
, ArithOpHs T.Add a b a
)
=> ("start" :! a) : ("length" :! b) : s :-> range a : s
mkRangeFor_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a b (s :: [*]).
(NiceRange range lower upper a, Dupable a, ArithOpHs Add a b a) =>
(("start" :! a) : ("length" :! b) : s) :-> (range a : s)
mkRangeFor_
= Label "start"
-> (("start" :! a) : ("length" :! b) : s)
:-> (a : ("length" :! b) : s)
forall (name :: Symbol) a (s :: [*]).
Label name -> ((name :! a) : s) :-> (a : s)
fromNamed Label "start"
#start
# L.dup
# L.dip
( L.dip (fromNamed #length)
# L.add
)
# L.pair
# toRange_
mkRangeForSafe_
:: forall a b s.
( Dupable a
, ArithOpHs T.Add a b a
, ToT b ~ 'T.TNat
)
=> ("start" :! a) : ("length" :! b) : s :-> Range a : s
mkRangeForSafe_ :: forall a b (s :: [*]).
(Dupable a, ArithOpHs Add a b a, ToT b ~ 'TNat) =>
(("start" :! a) : ("length" :! b) : s) :-> (Range a : s)
mkRangeForSafe_ = (("start" :! a) : ("length" :! b) : s) :-> (Range a : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a b (s :: [*]).
(NiceRange range lower upper a, Dupable a, ArithOpHs Add a b a) =>
(("start" :! a) : ("length" :! b) : s) :-> (range a : s)
mkRangeFor_
where
Dict (ToT b ~ 'TNat)
_ = forall (a :: Constraint). a => Dict a
T.Dict @(ToT b ~ 'T.TNat)
inRange :: (NiceRange range lower upper a, Ord a) => range a -> a -> Bool
inRange :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
(NiceRange range lower upper a, Ord a) =>
range a -> a -> Bool
inRange = (Ordering -> Ordering -> Bool
forall a. Eq a => a -> a -> Bool
== Ordering
EQ) (Ordering -> Bool)
-> (range a -> a -> Ordering) -> range a -> a -> Bool
forall a b c. SuperComposition a b c => a -> b -> c
... range a -> a -> Ordering
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
(NiceRange range lower upper a, Ord a) =>
range a -> a -> Ordering
inRangeCmp
inRangeCmp
:: forall range lower upper a. (NiceRange range lower upper a, Ord a)
=> range a -> a -> Ordering
inRangeCmp :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
(NiceRange range lower upper a, Ord a) =>
range a -> a -> Ordering
inRangeCmp range a
r a
x
| Bool -> Bool
forall a. Boolean a => a -> a
Prelude.not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ forall (r :: RangeBoundaryInclusion) a.
(RangeBoundary r, Ord a) =>
a -> a -> Bool
inRangeComp @lower (range a -> a
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
range a -> a
rangeLower range a
r) a
x = Ordering
LT
| Bool -> Bool
forall a. Boolean a => a -> a
Prelude.not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ forall (r :: RangeBoundaryInclusion) a.
(RangeBoundary r, Ord a) =>
a -> a -> Bool
inRangeComp @upper a
x (range a -> a
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
range a -> a
rangeUpper range a
r) = Ordering
GT
| Bool
otherwise = Ordering
EQ
inRange_
:: forall range lower upper a s. (NiceRange range lower upper a, NiceComparable a, Dupable a)
=> range a : a : s :-> Bool : s
inRange_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, NiceComparable a, Dupable a) =>
(range a : a : s) :-> (Bool : s)
inRange_
= (range a : a : s) :-> ((a, a) : a : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> ((a, a) : s)
fromRange_
# L.unpair
# L.dupN @3
# inRangeComp_ @lower
# L.dug @2
# inRangeComp_ @upper
# L.and
inRangeCmp_
:: forall range lower upper a s. (NiceRange range lower upper a, NiceComparable a, Dupable a)
=> range a : a : s :-> Integer : s
inRangeCmp_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, NiceComparable a, Dupable a) =>
(range a : a : s) :-> (Integer : s)
inRangeCmp_
= (range a : a : s) :-> ((a, a) : a : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> ((a, a) : s)
fromRange_
# L.unpair
# L.dupN @3
# inRangeComp_ @lower
# flip if_ (L.dropN @2 # push (-1))
(inRangeComp_ @upper
# if_ (push 0) (push 1)
)
assertInRange_
:: forall range lower upper a s. (NiceRange range lower upper a, NiceComparable a, Dupable a)
=> OnRangeAssertFailure a
-> range a : a : s :-> s
assertInRange_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, NiceComparable a, Dupable a) =>
OnRangeAssertFailure a -> (range a : a : s) :-> s
assertInRange_ OnRangeAssertFailure{forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafUnderflow :: forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafOverflow :: forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafUnderflow :: forall a.
OnRangeAssertFailure a
-> forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafOverflow :: forall a.
OnRangeAssertFailure a
-> forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
..}
= ((a : s) :-> (("value" :! a) : s))
-> (range a : a : s) :-> (range a : ("value" :! a) : s)
forall a (s :: [*]) (s' :: [*]).
HasCallStack =>
(s :-> s') -> (a : s) :-> (a : s')
dip (Label "value" -> (a : s) :-> (("value" :! a) : s)
forall (name :: Symbol) a (s :: [*]).
Label name -> (a : s) :-> ((name :! a) : s)
toNamed Label "value"
#value)
# L.dupN @2
# L.dupN @2
# fromRange_
# L.unpair
# L.dupN @3
# fromNamed #value
# inRangeComp_ @lower
# if_
( dip (fromNamed #value)
# inRangeComp_ @upper
# if_ (L.dropN @2)
( rangeUpper_ # toNamed #boundary
# push (isInclusive @upper)
# mkRangeFailureInfo
# orafOverflow
)
)
( L.dropN @2
# rangeLower_ # toNamed #boundary
# push (isInclusive @lower)
# mkRangeFailureInfo
# orafUnderflow
)
assertInRangeSimple_
:: forall range lower upper a s. (NiceRange range lower upper a, NiceComparable a, Dupable a)
=> (forall s' any. s' :-> any)
-> range a : a : s :-> s
assertInRangeSimple_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, NiceComparable a, Dupable a) =>
(forall (s' :: [*]) (any :: [*]). s' :-> any)
-> (range a : a : s) :-> s
assertInRangeSimple_ forall (s' :: [*]) (any :: [*]). s' :-> any
err
= (range a : a : s) :-> (Bool : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, NiceComparable a, Dupable a) =>
(range a : a : s) :-> (Bool : s)
inRange_ ((range a : a : s) :-> (Bool : s))
-> ((Bool : s) :-> s) -> (range a : a : s) :-> s
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# (s :-> s) -> (s :-> s) -> (Bool : s) :-> s
forall (s :: [*]) (s' :: [*]).
(s :-> s') -> (s :-> s') -> (Bool : s) :-> s'
if_ s :-> s
forall (s :: [*]). s :-> s
nop s :-> s
forall (s' :: [*]) (any :: [*]). s' :-> any
err
mkRangeFailureInfo
:: forall a s. IsoValue a
=> Bool : "boundary" :! a : "value" :! a : s :-> RangeFailureInfo a : s
mkRangeFailureInfo :: forall a (s :: [*]).
IsoValue a =>
(Bool : ("boundary" :! a) : ("value" :! a) : s)
:-> (RangeFailureInfo a : s)
mkRangeFailureInfo = (('[Bool, a, a] ++ s) :-> (RangeFailureInfo a : s))
-> (Bool : ("boundary" :! a) : ("value" :! a) : s)
:-> (RangeFailureInfo a : s)
forall a b. Coercible a b => a -> b
coerce ((('[Bool, a, a] ++ s) :-> (RangeFailureInfo a : s))
-> (Bool : ("boundary" :! a) : ("value" :! a) : s)
:-> (RangeFailureInfo a : s))
-> (('[Bool, a, a] ++ s) :-> (RangeFailureInfo a : s))
-> (Bool : ("boundary" :! a) : ("value" :! a) : s)
:-> (RangeFailureInfo a : s)
forall a b. (a -> b) -> a -> b
$ forall dt (fields :: [*]) (st :: [*]).
(InstrConstructC dt, fields ~ ConstructorFieldTypes dt,
(ToTs fields ++ ToTs st) ~ ToTs (fields ++ st)) =>
(fields ++ st) :-> (dt : st)
constructStack @(RangeFailureInfo a) @_ @s
data RangeFailureInfo a = RangeFailureInfo
{ forall a. RangeFailureInfo a -> Bool
rfiInclusive :: Bool
, forall a. RangeFailureInfo a -> a
rfiBoundary :: a
, forall a. RangeFailureInfo a -> a
rfiValue :: a
} deriving stock (forall x. RangeFailureInfo a -> Rep (RangeFailureInfo a) x)
-> (forall x. Rep (RangeFailureInfo a) x -> RangeFailureInfo a)
-> Generic (RangeFailureInfo a)
forall x. Rep (RangeFailureInfo a) x -> RangeFailureInfo a
forall x. RangeFailureInfo a -> Rep (RangeFailureInfo a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (RangeFailureInfo a) x -> RangeFailureInfo a
forall a x. RangeFailureInfo a -> Rep (RangeFailureInfo a) x
$cfrom :: forall a x. RangeFailureInfo a -> Rep (RangeFailureInfo a) x
from :: forall x. RangeFailureInfo a -> Rep (RangeFailureInfo a) x
$cto :: forall a x. Rep (RangeFailureInfo a) x -> RangeFailureInfo a
to :: forall x. Rep (RangeFailureInfo a) x -> RangeFailureInfo a
Generic
deriving anyclass WellTypedToT (RangeFailureInfo a)
WellTypedToT (RangeFailureInfo a)
-> (RangeFailureInfo a -> Value (ToT (RangeFailureInfo a)))
-> (Value (ToT (RangeFailureInfo a)) -> RangeFailureInfo a)
-> IsoValue (RangeFailureInfo a)
Value (ToT (RangeFailureInfo a)) -> RangeFailureInfo a
RangeFailureInfo a -> Value (ToT (RangeFailureInfo a))
forall a.
WellTypedToT a
-> (a -> Value (ToT a)) -> (Value (ToT a) -> a) -> IsoValue a
forall {a}. IsoValue a => WellTypedToT (RangeFailureInfo a)
forall a.
IsoValue a =>
Value (ToT (RangeFailureInfo a)) -> RangeFailureInfo a
forall a.
IsoValue a =>
RangeFailureInfo a -> Value (ToT (RangeFailureInfo a))
$ctoVal :: forall a.
IsoValue a =>
RangeFailureInfo a -> Value (ToT (RangeFailureInfo a))
toVal :: RangeFailureInfo a -> Value (ToT (RangeFailureInfo a))
$cfromVal :: forall a.
IsoValue a =>
Value (ToT (RangeFailureInfo a)) -> RangeFailureInfo a
fromVal :: Value (ToT (RangeFailureInfo a)) -> RangeFailureInfo a
IsoValue
deriving Text -> Text
(Text -> Text) -> TypeHasFieldNamingStrategy (RangeFailureInfo a)
forall a. Text -> Text
forall {k} (a :: k). (Text -> Text) -> TypeHasFieldNamingStrategy a
$ctypeFieldNamingStrategy :: forall a. Text -> Text
typeFieldNamingStrategy :: Text -> Text
TypeHasFieldNamingStrategy via T.FieldCamelCase
instance TypeHasDoc a => TypeHasDoc (RangeFailureInfo a) where
type TypeDocFieldDescriptions (RangeFailureInfo a) =
'[ '( "RangeFailureInfo", '( 'Nothing,
'[ '("rfiInclusive", "Whether the boundary is inclusive or not")
, '("rfiBoundary", "The boundary that failed to check")
, '("rfiValue", "The value that failed to check")
])
)
]
typeDocMdDescription :: Markdown
typeDocMdDescription = Markdown
"Information about the range check failure"
typeDocMdReference :: Proxy (RangeFailureInfo a) -> WithinParens -> Markdown
typeDocMdReference = Proxy (RangeFailureInfo a) -> WithinParens -> Markdown
forall (t :: * -> *) r a.
(r ~ t a, Typeable t, Each '[TypeHasDoc] '[r, a],
IsHomomorphic t) =>
Proxy r -> WithinParens -> Markdown
poly1TypeDocMdReference
typeDocHaskellRep :: TypeDocHaskellRep (RangeFailureInfo a)
typeDocHaskellRep
= (Text -> Text)
-> TypeDocHaskellRep (RangeFailureInfo a)
-> TypeDocHaskellRep (RangeFailureInfo a)
forall a.
(Text -> Text) -> TypeDocHaskellRep a -> TypeDocHaskellRep a
T.haskellRepMap (forall a. TypeHasFieldNamingStrategy a => Text -> Text
forall {k} (a :: k). TypeHasFieldNamingStrategy a => Text -> Text
typeFieldNamingStrategy @(RangeFailureInfo a))
(TypeDocHaskellRep (RangeFailureInfo a)
-> TypeDocHaskellRep (RangeFailureInfo a))
-> TypeDocHaskellRep (RangeFailureInfo a)
-> TypeDocHaskellRep (RangeFailureInfo a)
forall a b. (a -> b) -> a -> b
$ forall a b.
(Typeable a, GenericIsoValue a, GTypeHasDoc (GRep a),
HaveCommonTypeCtor b a) =>
TypeDocHaskellRep b
concreteTypeDocHaskellRep @(RangeFailureInfo Integer)
typeDocMichelsonRep :: TypeDocMichelsonRep (RangeFailureInfo a)
typeDocMichelsonRep = forall a b.
(Typeable a, KnownIsoT a, HaveCommonTypeCtor b a) =>
TypeDocMichelsonRep b
concreteTypeDocMichelsonRep @(RangeFailureInfo Integer)
data OnRangeAssertFailure a = OnRangeAssertFailure
{ forall a.
OnRangeAssertFailure a
-> forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafUnderflow :: forall s any. RangeFailureInfo a : s :-> any
, forall a.
OnRangeAssertFailure a
-> forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafOverflow :: forall s any. RangeFailureInfo a : s :-> any
}
mkOnRangeAssertFailureSimple
:: (forall s any. RangeFailureInfo a : s :-> any)
-> OnRangeAssertFailure a
mkOnRangeAssertFailureSimple :: forall a.
(forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a
mkOnRangeAssertFailureSimple forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
f = (forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any)
-> (forall (s :: [*]) (any :: [*]).
(RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a
forall a.
(forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any)
-> (forall (s :: [*]) (any :: [*]).
(RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a
OnRangeAssertFailure (RangeFailureInfo a : s) :-> any
forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
f (RangeFailureInfo a : s) :-> any
forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
f
customErrorORAF
:: (NiceConstant a
, ErrorArg underflow ~ RangeFailureInfo a
, ErrorArg overflow ~ RangeFailureInfo a
, CustomErrorHasDoc underflow
, CustomErrorHasDoc overflow
)
=> ("underflow" :! Label underflow)
-> ("overflow" :! Label overflow)
-> OnRangeAssertFailure a
customErrorORAF :: forall a (underflow :: Symbol) (overflow :: Symbol).
(NiceConstant a, ErrorArg underflow ~ RangeFailureInfo a,
ErrorArg overflow ~ RangeFailureInfo a,
CustomErrorHasDoc underflow, CustomErrorHasDoc overflow) =>
("underflow" :! Label underflow)
-> ("overflow" :! Label overflow) -> OnRangeAssertFailure a
customErrorORAF (Name "underflow"
-> ("underflow" :! Label underflow) -> Label underflow
forall (name :: Symbol) a. Name name -> (name :! a) -> a
arg Name "underflow"
#underflow -> Label underflow
ufl) (Name "overflow" -> ("overflow" :! Label overflow) -> Label overflow
forall (name :: Symbol) a. Name name -> (name :! a) -> a
arg Name "overflow"
#overflow -> Label overflow
ofl) = OnRangeAssertFailure
{ orafUnderflow :: forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafUnderflow = Label underflow -> (RangeFailureInfo a : s) :-> any
forall (tag :: Symbol) err (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, err), CustomErrorHasDoc tag,
KnownError err) =>
Label tag -> (err : s) :-> any
failCustom Label underflow
ufl
, orafOverflow :: forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any
orafOverflow = Label overflow -> (RangeFailureInfo a : s) :-> any
forall (tag :: Symbol) err (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, err), CustomErrorHasDoc tag,
KnownError err) =>
Label tag -> (err : s) :-> any
failCustom Label overflow
ofl
}
customErrorORAFSimple
:: (NiceConstant a
, ErrorArg err ~ RangeFailureInfo a
, CustomErrorHasDoc err
)
=> Label err
-> OnRangeAssertFailure a
customErrorORAFSimple :: forall a (err :: Symbol).
(NiceConstant a, ErrorArg err ~ RangeFailureInfo a,
CustomErrorHasDoc err) =>
Label err -> OnRangeAssertFailure a
customErrorORAFSimple Label err
err = (forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a
forall a.
(forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a
mkOnRangeAssertFailureSimple ((forall (s :: [*]) (any :: [*]). (RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a)
-> (forall (s :: [*]) (any :: [*]).
(RangeFailureInfo a : s) :-> any)
-> OnRangeAssertFailure a
forall a b. (a -> b) -> a -> b
$ Label err -> (RangeFailureInfo a : s) :-> any
forall (tag :: Symbol) err (s :: [*]) (any :: [*]).
(MustHaveErrorArg tag (MText, err), CustomErrorHasDoc tag,
KnownError err) =>
Label tag -> (err : s) :-> any
failCustom Label err
err
isRangeEmpty
:: forall range lower upper a.
(NiceRange range lower upper a, Ord a, CanCheckEmpty lower upper)
=> range a -> Bool
isRangeEmpty :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
(NiceRange range lower upper a, Ord a,
CanCheckEmpty lower upper) =>
range a -> Bool
isRangeEmpty range a
r = forall {k} {k} (l :: k) (u :: k) a.
(CanCheckEmpty l u, Ord a) =>
a -> a -> Bool
forall (l :: RangeBoundaryInclusion) (u :: RangeBoundaryInclusion)
a.
(CanCheckEmpty l u, Ord a) =>
a -> a -> Bool
checkEmpty @lower @upper (range a -> a
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
range a -> a
rangeLower range a
r) (range a -> a
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a.
NiceRange range lower upper a =>
range a -> a
rangeUpper range a
r)
isRangeEmpty_
:: forall range lower upper a s.
( NiceRange range lower upper a
, CanCheckEmpty lower upper
, NiceComparable a
)
=> range a : s :-> Bool : s
isRangeEmpty_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, CanCheckEmpty lower upper,
NiceComparable a) =>
(range a : s) :-> (Bool : s)
isRangeEmpty_
= (range a : s) :-> ((a, a) : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
NiceRange range lower upper a =>
(range a : s) :-> ((a, a) : s)
fromRange_
# L.unpair
# checkEmpty_ @lower @upper
class CanCheckEmpty l u where
checkEmpty :: Ord a => a -> a -> Bool
checkEmpty_ :: NiceComparable a => a : a : s :-> Bool : s
instance CanCheckEmpty 'IncludeBoundary 'IncludeBoundary where
checkEmpty :: forall a. Ord a => a -> a -> Bool
checkEmpty = a -> a -> Bool
forall a. Ord a => a -> a -> Bool
(>)
checkEmpty_ :: forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
checkEmpty_ = (a : a : s) :-> (Bool : s)
forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
L.gt
instance CanCheckEmpty 'IncludeBoundary 'ExcludeBoundary where
checkEmpty :: forall a. Ord a => a -> a -> Bool
checkEmpty = a -> a -> Bool
forall a. Ord a => a -> a -> Bool
(>=)
checkEmpty_ :: forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
checkEmpty_ = (a : a : s) :-> (Bool : s)
forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
L.ge
instance CanCheckEmpty 'ExcludeBoundary 'IncludeBoundary where
checkEmpty :: forall a. Ord a => a -> a -> Bool
checkEmpty = a -> a -> Bool
forall a. Ord a => a -> a -> Bool
(>=)
checkEmpty_ :: forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
checkEmpty_ = (a : a : s) :-> (Bool : s)
forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
L.ge
instance (Bottom, TypeError
('Text "This function can't be used to check whenter a \
\range with both boundaries excluded is empty")) =>
CanCheckEmpty 'ExcludeBoundary 'ExcludeBoundary where
checkEmpty :: forall a. Ord a => a -> a -> Bool
checkEmpty = a -> a -> Bool
forall a. Bottom => a
forall a. a
no
checkEmpty_ :: forall a (s :: [*]). NiceComparable a => (a : a : s) :-> (Bool : s)
checkEmpty_ = (a : a : s) :-> (Bool : s)
forall a. Bottom => a
forall a. a
no
assertRangeNonEmpty_
:: ( NiceRange range lower upper a
, CanCheckEmpty lower upper
, NiceComparable a
, Dupable (range a)
)
=> (forall s' any. range a : s' :-> any)
-> range a : s :-> range a : s
assertRangeNonEmpty_ :: forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, CanCheckEmpty lower upper,
NiceComparable a, Dupable (range a)) =>
(forall (s' :: [*]) (any :: [*]). (range a : s') :-> any)
-> (range a : s) :-> (range a : s)
assertRangeNonEmpty_ forall (s' :: [*]) (any :: [*]). (range a : s') :-> any
err = (range a : s) :-> (range a : range a : s)
forall a (s :: [*]). Dupable a => (a : s) :-> (a : a : s)
dup ((range a : s) :-> (range a : range a : s))
-> ((range a : range a : s) :-> (Bool : range a : s))
-> (range a : s) :-> (Bool : range a : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# (range a : range a : s) :-> (Bool : range a : s)
forall (range :: * -> *) (lower :: RangeBoundaryInclusion)
(upper :: RangeBoundaryInclusion) a (s :: [*]).
(NiceRange range lower upper a, CanCheckEmpty lower upper,
NiceComparable a) =>
(range a : s) :-> (Bool : s)
isRangeEmpty_ ((range a : s) :-> (Bool : range a : s))
-> ((Bool : range a : s) :-> (range a : s))
-> (range a : s) :-> (range a : s)
forall (a :: [*]) (b :: [*]) (c :: [*]).
(a :-> b) -> (b :-> c) -> a :-> c
# ((range a : s) :-> (range a : s))
-> ((range a : s) :-> (range a : s))
-> (Bool : range a : s) :-> (range a : s)
forall (s :: [*]) (s' :: [*]).
(s :-> s') -> (s :-> s') -> (Bool : s) :-> s'
if_ (range a : s) :-> (range a : s)
forall (s' :: [*]) (any :: [*]). (range a : s') :-> any
err (range a : s) :-> (range a : s)
forall (s :: [*]). s :-> s
nop