haskell

How to plot graph labels with Haskell's graphviz package

瘦欲@ 提交于 2021-02-08 06:24:15
问题 This question does not solve the problem that I'm facing, but my question is based on it. What I'm trying to achieve is to plot a directed graph with labelled nodes and unlabelled edges using graphviz package. In my case nodes have labels of type String (the type definition of the graph is Gr String () ). Here's the code (where used graph is a minified version of clr486 - a perfect example of my use case): module Main where import Data.Graph.Inductive.Graph (mkGraph) import Data.Graph

How to plot graph labels with Haskell's graphviz package

折月煮酒 提交于 2021-02-08 06:24:15
问题 This question does not solve the problem that I'm facing, but my question is based on it. What I'm trying to achieve is to plot a directed graph with labelled nodes and unlabelled edges using graphviz package. In my case nodes have labels of type String (the type definition of the graph is Gr String () ). Here's the code (where used graph is a minified version of clr486 - a perfect example of my use case): module Main where import Data.Graph.Inductive.Graph (mkGraph) import Data.Graph

On Windows, packages installed with cabal seem to be unavailable in ghc/ghci

妖精的绣舞 提交于 2021-02-08 04:49:34
问题 I'm running the latest version of Haskell Platform 8.6.3 on a fairly standard Windows 10 x64 system. Now I am at my wits end getting packages installed from Hackage to work reliably. Attributing my issues to local configuration problems, I've taken all steps short of nuking my Windows installation. I have uninstalled and reinstalled Hackage, rebooted, scoured every last configuration file I could in any hidden directory or otherwise, deleted every registry key apparently related to Haskell,

On Windows, packages installed with cabal seem to be unavailable in ghc/ghci

我与影子孤独终老i 提交于 2021-02-08 04:49:13
问题 I'm running the latest version of Haskell Platform 8.6.3 on a fairly standard Windows 10 x64 system. Now I am at my wits end getting packages installed from Hackage to work reliably. Attributing my issues to local configuration problems, I've taken all steps short of nuking my Windows installation. I have uninstalled and reinstalled Hackage, rebooted, scoured every last configuration file I could in any hidden directory or otherwise, deleted every registry key apparently related to Haskell,

Convert Text to Unicode Escape Sequence

余生颓废 提交于 2021-02-08 04:37:25
问题 I have a Text object that contains some number of Latin characters that needs to be converted to a unicode escape sequence of the format \u#### with # being hex digits As described here, haskell easily converts strings to escape sequences and vice versa. However, it will only go to the decimal representation. For example, > let s = "Ñ" > s "\209" Is there a way to specify the escape sequence encoding to force it to spit out in the correct format? i.e > let s = encodeUnicode16 "Ñ" > s "\u00d1"

Simple regular expression substitution crashes on Windows using regex-compat

匆匆过客 提交于 2021-02-08 03:44:26
问题 The following code crashes when using GHC on Windows. It works perfectly on Linux. Does this make any sense or is there a bug? module Main where import qualified Text.Regex as Re -- from regex-compat import Debug.Trace main :: IO () main = do putStr $ cleanWord "jan" putStr $ cleanWord "dec" putStr $ cleanWord "jun" -- crashes here cleanWord :: String -> String cleanWord word_ = let word = trace (show word_) word_ in let re = Re.mkRegexWithOpts "(jun|jul|aug|sep|oct|nov|dec)" True False in Re

Parsing non binary operators with Parsec

﹥>﹥吖頭↗ 提交于 2021-02-08 03:28:07
问题 Traditionally, arithmetic operators are considered to be binary (left or right associative), thus most tools are dealing only with binary operators. Is there an easy way to parse arithmetic operators with Parsec, which can have an arbitrary number of arguments? For example, the following expression should be parsed into the tree (a + b) + c + d * e + f 回答1: Yes! The key is to first solve a simpler problem, which is to model + and * as tree nodes with only two children. To add four things, we

Parsing non binary operators with Parsec

半城伤御伤魂 提交于 2021-02-08 03:28:01
问题 Traditionally, arithmetic operators are considered to be binary (left or right associative), thus most tools are dealing only with binary operators. Is there an easy way to parse arithmetic operators with Parsec, which can have an arbitrary number of arguments? For example, the following expression should be parsed into the tree (a + b) + c + d * e + f 回答1: Yes! The key is to first solve a simpler problem, which is to model + and * as tree nodes with only two children. To add four things, we

Why Parsec's sepBy stops and does not parse all elements?

爷,独闯天下 提交于 2021-02-08 02:10:21
问题 I am trying to parse some comma separated string which may or may not contain a string with image dimensions. For example "hello world, 300x300, good bye world" . I've written the following little program: import Text.Parsec import qualified Text.Parsec.Text as PS parseTestString :: Text -> [Maybe (Int, Int)] parseTestString s = case parse dimensStringParser "" s of Left _ -> [Nothing] Right dimens -> dimens dimensStringParser :: PS.Parser [Maybe (Int, Int)] dimensStringParser = (optionMaybe

Why Parsec's sepBy stops and does not parse all elements?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-08 02:05:47
问题 I am trying to parse some comma separated string which may or may not contain a string with image dimensions. For example "hello world, 300x300, good bye world" . I've written the following little program: import Text.Parsec import qualified Text.Parsec.Text as PS parseTestString :: Text -> [Maybe (Int, Int)] parseTestString s = case parse dimensStringParser "" s of Left _ -> [Nothing] Right dimens -> dimens dimensStringParser :: PS.Parser [Maybe (Int, Int)] dimensStringParser = (optionMaybe