New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ignore Haskell char node function match #97
base: main
Are you sure you want to change the base?
fix: ignore Haskell char node function match #97
Conversation
This is obviously just a hack, but without it, the autocommand is going haywire when moving around in Haskell files, making it impossible to work.
Hey! What exactly is going on in Haskell files? I couldn't really reproduce any weird behaviour with this file: ExampleputTodo :: (Int, String) -> IO ()
putTodo (n, todo) = putStrLn (show n ++ ": " ++ todo)
prompt :: [String] -> IO ()
prompt todos = do
putStrLn ""
putStrLn "Current TODO list:"
mapM_ putTodo (zip [0..] todos)
command <- getLine
interpret command todos
interpret :: String -> [String] -> IO ()
interpret ('+':' ':todo) todos = prompt (todo:todos)
interpret ('-':' ':num ) todos =
case delete (read num) todos of
Nothing -> do
putStrLn "No TODO entry matches the given number\
\hello"
prompt todos
Just todos' -> prompt todos'
interpret "q" todos = return ()
interpret command todos = do
putStrLn ("Invalid command: `" ++ command ++ "`")
prompt todos
delete :: Int -> [a] -> Maybe [a]
delete 0 (_:as) = Just as
delete n (a:as) = do
as' <- delete (n - 1) as
return (a:as')
delete _ [] = Nothing
main = do
putStrLn "Commands:"
putStrLn "+ <String> - Add a TODO entry"
putStrLn "- <Int> - Delete the numbered entry"
putStrLn "q - Quit"
prompt [] I was moving the cursor around and didn't notice anything weird. Maybe it's an issue with your config? Could you try a minimal config to reproduce the issue? |
It does not seem to happen for all files, but I found one that cause me trouble: module DNA (nucleotideCounts, Nucleotide (..)) where
import Data.List (group, sort)
import Data.Map (Map)
import qualified Data.Map as Map
data Nucleotide = A | C | G | T deriving (Eq, Ord, Show)
nucleotideCounts :: String -> Either String (Map Nucleotide Int)
nucleotideCounts dna = case counts of
Just xs -> Right $ Map.fromList xs
Nothing -> Left $ "invalid DNA strand" ++ dna
where
counts = mapM count $ group $ sort dna
count :: String -> Maybe (Nucleotide, Int)
count xs = case xs of
[] -> Nothing
x : _ -> case x of
'A' -> Just (A, length xs)
'C' -> Just (C, length xs)
'G' -> Just (G, length xs)
'T' -> Just (T, length xs)
_ -> Nothing
I'll try to recreate with a minimal config… |
I tried to use the minimal config from here:
Indeed there are no issues with this minimal config, even with the problematic source file I posted in the comment above. |
This is obviously just a hack, but without it, the autocommand is going haywire when moving around in Haskell files, making it impossible to work.
I could not find out where the function is for char nodes is coming from. Any hints / help for a proper fix are welcome.