git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Parse argument into a Type, :k works but only for fully qualified names
44607c4Benjamin Kovach]
psci/Commands.hs+2−2
@@ -56,7 +56,7 @@ data Command
56 -- |
56 -- |
57 -- Find the kind of an expression
57 -- Find the kind of an expression
58 --
58 --
59− | KindOf Value
59+ | KindOf Type
60
60
61-- |
61-- |
62-- The help menu.
62-- The help menu.
@@ -69,5 +69,5 @@ help =
69 , [":q ", "Quit PSCi"]
69 , [":q ", "Quit PSCi"]
70 , [":r ", "Reset"]
70 , [":r ", "Reset"]
71 , [":t <expr> ", "Show the type of <expr>"]
71 , [":t <expr> ", "Show the type of <expr>"]
72− , [":k <expr> ", "Show the kind of <expr>"]
72+ , [":k <type> ", "Show the kind of <type>"]
73 ]
73 ]
psci/Main.hs+10−13
@@ -300,23 +300,20 @@ handleTypeOf value = do
300-- |
300-- |
301-- Takes a value and prints its kind
301-- Takes a value and prints its kind
302--
302--
303−handleKindOf :: P.Value -> PSCI ()
303+handleKindOf :: P.Type -> PSCI ()
304−handleKindOf value = do
304+handleKindOf typ = do
305 st <- PSCI $ lift get
305 st <- PSCI $ lift get
306− let m = createTemporaryModule False st value
306+ let m = createTemporaryModule False st (P.BooleanLiteral True) -- dummy value
307 mName = P.ModuleName [P.ProperName "Main"]
307 mName = P.ModuleName [P.ProperName "Main"]
308 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("Main.purs", m)])
308 e <- psciIO . runMake $ P.make modulesDir options (psciLoadedModules st ++ [("Main.purs", m)])
309 case e of
309 case e of
310 Left err -> PSCI $ outputStrLn err
310 Left err -> PSCI $ outputStrLn err
311− Right env' ->
311+ Right env' -> do
312− case M.lookup (mName, P.Ident "it") (P.names env') of
313− Just (ty, _, _) -> do
314− let st = P.CheckState env' 0 0 (Just mName)
312+ let st = P.CheckState env' 0 0 (Just mName)
315− k = L.runStateT (P.unCheck (P.kindOf mName ty)) st
313+ k = L.runStateT (P.unCheck (P.kindOf mName typ)) st
316− case k of
314+ case k of
317− Left errStack -> PSCI . outputStrLn . P.prettyPrintErrorStack False $ errStack
315+ Left errStack -> PSCI . outputStrLn . P.prettyPrintErrorStack False $ errStack
318− Right (kind, _) -> PSCI . outputStrLn . P.prettyPrintKind $ kind
316+ Right (kind, _) -> PSCI . outputStrLn . P.prettyPrintKind $ kind
319− Nothing -> PSCI $ outputStrLn "Could not find kind"
320
317
321-- Commands
318-- Commands
322
319
@@ -361,7 +358,7 @@ handleCommand Reset = do
361 Left err -> psciIO $ putStrLn err >> exitFailure
358 Left err -> psciIO $ putStrLn err >> exitFailure
362 Right modules -> PSCI . lift $ put (PSCiState files defaultImports modules [])
359 Right modules -> PSCI . lift $ put (PSCiState files defaultImports modules [])
363handleCommand (TypeOf val) = handleTypeOf val
360handleCommand (TypeOf val) = handleTypeOf val
364−handleCommand (KindOf val) = handleKindOf val
361+handleCommand (KindOf typ) = handleKindOf typ
365handleCommand _ = PSCI $ outputStrLn "Unknown command"
362handleCommand _ = PSCI $ outputStrLn "Unknown command"
366
363
367inputFiles :: Cmd.Term [FilePath]
364inputFiles :: Cmd.Term [FilePath]
psci/Parser.hs+1−1
@@ -96,4 +96,4 @@ psciTypeOf = TypeOf <$> (char 't' *> P.whiteSpace *> P.parseValue)
96-- Parses 'Commands.KindOf' command.
96-- Parses 'Commands.KindOf' command.
97--
97--
98psciKindOf :: Parsec String P.ParseState Command
98psciKindOf :: Parsec String P.ParseState Command
99−psciKindOf = KindOf <$> (char 'k' *> P.whiteSpace *> P.parseValue)
99+psciKindOf = KindOf <$> (char 'k' *> P.whiteSpace *> P.parseType)