diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-04-25 10:51:21 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-04-25 15:22:59 +0200 |
| commit | 81d6d9f99ce8ea56df2c926156a3e3600a1a4117 (patch) | |
| tree | 4c61b3d51d7a7aa2da786053d10b74ca642467d6 /src/Parser.hs | |
| parent | d361b5cb163316d4e0c56cab30301e18b548afff (diff) | |
Polymorphic types in function arguments
Diffstat (limited to 'src/Parser.hs')
| -rw-r--r-- | src/Parser.hs | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index 191d40d..e3d174e 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,19 +101,9 @@ parseDefinition href = label "symbol definition" $ do getInferredTypes atypes = forM atypes $ \( off, vname, tvar@(TypeVar tvarname) ) -> do let err msg = do registerParseError . FancyError off . S.singleton . ErrorFail $ T.unpack msg - return ( vname, SomeArgumentType (OptionalArgument @DynamicType) ) - let getConcreteType = \case - (ExprTypeApp (ExprTypeConstr1 (Proxy :: Proxy a)) [ pb ]) - | ExprTypePrim (_ :: Proxy b) <- getConcreteType pb - -> ExprTypePrim (Proxy :: Proxy (a b)) - t -> t + return ( vname, SomeArgumentType OptionalArgument (ExprTypeForall (TypeVar "a") (ExprTypeVar (TypeVar "a"))) ) gets (M.lookup tvar . testTypeUnif) >>= \case - Just t - | ExprTypePrim (_ :: Proxy a) <- getConcreteType t - -> return ( vname, SomeArgumentType (RequiredArgument @a) ) - - | otherwise - -> err $ "expected concrete type for ‘" <> textVarName vname <> " : " <> textSomeExprType t <> "’" + Just t -> return ( vname, SomeArgumentType RequiredArgument t ) Nothing -> err $ "ambiguous type for ‘" <> textVarName vname <> " : " <> tvarname <> "’" replaceDynArgs :: forall a. Expr a -> TestParser (Expr a) |