doc[core/expression]: constructor fields
This commit is contained in:
parent
fa8d508e84
commit
a38a20a546
1 changed files with 7 additions and 6 deletions
|
@ -29,17 +29,18 @@ import Test.QuickCheck qualified as Gen
|
|||
type Expression :: (Type -> Type) -> Type
|
||||
type role Expression nominal
|
||||
data Expression f
|
||||
= RawInt (f Integer)
|
||||
| RawRational (f Rational)
|
||||
| RawString (f Text)
|
||||
| PatternMatch (f (NonEmpty (PatternMatchCase f)))
|
||||
| Lambda (f VariableIdentifier) (f (Expression f))
|
||||
= RawInt (f Integer) -- ^ e.g.: 42
|
||||
| RawRational (f Rational) -- ^ e.g.: 0.3000000000002
|
||||
| RawString (f Text) -- ^ raw text
|
||||
| PatternMatch (f (NonEmpty (PatternMatchCase f))) -- ^ cases
|
||||
| Lambda (f VariableIdentifier) (f (Expression f)) -- ^ argument name, calculation
|
||||
| Apply (f (Expression f)) (f (Expression f)) -- ^ function, argument
|
||||
|
||||
-- to me, this looks incredibly dangerous, because of Show (f (Expression f)) => Show (Expression f)
|
||||
-- let's hope UndecidableInstances won't have the compiler diverge
|
||||
deriving stock instance (Show (f Integer), Show (f Rational), Show (f Text), Show (f (NonEmpty (PatternMatchCase f))), Show (f VariableIdentifier), Show (f (Expression f))) => Show (Expression f)
|
||||
deriving stock instance (Read (f Integer), Read (f Rational), Read (f Text), Read (f (NonEmpty (PatternMatchCase f))), Read (f VariableIdentifier), Read (f (Expression f))) => Read (Expression f)
|
||||
deriving stock instance (Eq (f Integer), Eq (f Rational), Eq (f Text), Eq (f (NonEmpty (PatternMatchCase f))), Eq (f VariableIdentifier), Eq (f (Expression f))) => Eq (Expression f)
|
||||
deriving stock instance (Eq (f Integer), Eq (f Rational), Eq (f Text), Eq (f (NonEmpty (PatternMatchCase f))), Eq (f VariableIdentifier), Eq (f (Expression f))) => Eq (Expression f)
|
||||
|
||||
instance (Arbitrary (f Integer), Arbitrary (f Rational), Arbitrary (f UnicodeString), Functor f, Arbitrary (f (Expression f)), Arbitrary (f VariableIdentifier), Arbitrary (f (NonEmptyList (PatternMatchCase f))) ) => Arbitrary (Expression f) where
|
||||
arbitrary :: Gen (Expression f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue