Skip to content

Comments

feat(Tuples): add tuple elements of unlimited length#50

Merged
emqplus merged 2 commits intohamler-lang:hamlerfrom
sdzx-1:test2
Jun 23, 2020
Merged

feat(Tuples): add tuple elements of unlimited length#50
emqplus merged 2 commits intohamler-lang:hamlerfrom
sdzx-1:test2

Conversation

@sdzx-1
Copy link
Collaborator

@sdzx-1 sdzx-1 commented Jun 23, 2020

No description provided.

@sdzx-1 sdzx-1 requested a review from emqplus June 23, 2020 10:13
@emqplus
Copy link

emqplus commented Jun 23, 2020

  1. Rename TuplesLiteral to TupleLiteral

lit ns (TupleLiteral6 a b c d e f) = foldl go ns [a,b,c,d,e,f]
lit ns (TupleLiteral7 a b c d e f g) = foldl go ns [a,b,c,d,e,f,g]

lit ns (TuplesLiteral xs) = foldl go ns xs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TuplesLiteral -> TupleLiteral

| CannotDefinePrimModules ModuleName
| MixedAssociativityError (NEL.NonEmpty (Qualified (OpName 'AnyOpName), Associativity))
| NonAssociativeError (NEL.NonEmpty (Qualified (OpName 'AnyOpName)))
| TuplesLengthDifferent Int Int
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TuplesLengthDifferent -> TupleLengthDifferent

| TupleLiteral6 a a a a a a
| TupleLiteral7 a a a a a a a

| TuplesLiteral [a]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TupleLiteral

show (TupleLiteral6 a b c d e f) = "(" <> show a <> "," <> show b <> "," <> show c <> "," <> show d <> "," <> show e <> "," <> show f <> ")"
show (TupleLiteral7 a b c d e f g) = "(" <> show a <> "," <> show b <> "," <> show c <> "," <> show d <> "," <> show e <> "," <> show f <> "," <> show g <> ")"

show (TuplesLiteral xs) = "(" <> show xs <> ")"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TupleLiteral

f' <- go f
g' <- go g
return $ TupleLiteral7 a' b' c' d' e' f' g'
litM go (TuplesLiteral xs) = TuplesLiteral <$> traverse go xs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TupleLiteral

go bound (ForAll _ v _ t _) = go (v : bound) t
go bound (ConstrainedType _ c t) = concatMap (go bound) (constraintArgs c) ++ go bound t
go bound (RCons _ _ t r) = go bound t ++ go bound r
go bound (Tuples _ t r) = go bound t ++ go bound r
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuples -> Tuple

go (ForAll ann arg mbK ty sco) = f (ForAll ann arg mbK (go ty) sco)
go (ConstrainedType ann c ty) = f (ConstrainedType ann (mapConstraintArgs (map go) c) (go ty))
go (RCons ann name ty rest) = f (RCons ann name (go ty) (go rest))
go (Tuples ann ty rest) = f (Tuples ann (go ty) (go rest))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuples -> Tuple

go (ForAll ann arg mbK ty sco) = ForAll ann arg mbK (go (f ty)) sco
go (ConstrainedType ann c ty) = ConstrainedType ann (mapConstraintArgs (map (go . f)) c) (go (f ty))
go (RCons ann name ty rest) = RCons ann name (go (f ty)) (go (f rest))
go (Tuples ann ty rest) = Tuples ann (go (f ty)) (go (f rest))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuples -> Tuple

go (ForAll ann arg mbK ty sco) = (ForAll ann arg mbK <$> go ty <*> pure sco) >>= f
go (ConstrainedType ann c ty) = (ConstrainedType ann <$> overConstraintArgs (mapM go) c <*> go ty) >>= f
go (RCons ann name ty rest) = (RCons ann name <$> go ty <*> go rest) >>= f
go (Tuples ann ty rest) = (Tuples ann <$> go ty <*> go rest) >>= f
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tuples -> Tuple


compareType (Tuples _ b c) (Tuples _ b' c') = compareType b b' <> compareType c c'
compareType (Tuples {}) _ = LT
compareType _ (Tuples {}) = GT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename all the Tuples to Tuple

@emqplus emqplus merged commit 07633b6 into hamler-lang:hamler Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants