Skip to content

Commit 3887227

Browse files
committed
Fix bug where ADTs would generate incorrect number of arguments
Turns out I already had an implementation of the function I wanted, and that it had already correctly identified that (<>) has *slightly* different semantics for List and Either
1 parent b4f355d commit 3887227

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

src/TypeChecker.hs

+1-16
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ checkDataType state adt@(ADT name generics constructors) =
204204
argList =
205205
maybe
206206
(Right [])
207-
(constructorTypesToArgList (types state) errorMessage)
207+
constructorTypes
208208
types'
209209
arguments = zip (charToArgument <$> ['a' ..]) <$> argList
210210
declarationFromType x args =
@@ -244,21 +244,6 @@ checkTopLevel state topLevel =
244244
Right t -> addDeclarations state [t]
245245
Left e -> addError state e
246246

247-
constructorTypesToArgList ::
248-
Map Ident Type
249-
-> (Text -> CompileError)
250-
-> ConstructorType
251-
-> Either CompileError [Type]
252-
constructorTypesToArgList types compileError ct =
253-
case ct of
254-
CTConcrete i -> (\x -> [x]) <$> findTypeFromIdent types compileError i
255-
CTApplied a (CTConcrete i)
256-
| s i == T.toLower (s i) -> constructorTypesToArgList types compileError a
257-
CTApplied a b ->
258-
constructorTypesToArgList types compileError a <>
259-
constructorTypesToArgList types compileError b
260-
CTParenthesized ct -> constructorTypesToArgList types compileError ct
261-
262247
newtype Constraints =
263248
Constraints (Map Ident Type)
264249
deriving (Eq, Show)

0 commit comments

Comments
 (0)