haskell

Stop command prompt from opening when running exe file built from haskell project

社会主义新天地 提交于 2020-12-12 09:39:30
问题 I have created a small application that uses the gloss library for a GUI. When typing "cabal run [cabal file]" the project is built and run, and only prompts the GUI. When I instead go and click on the .exe file that was generated from the build, the GUI opens but so does the command prompt. I want to stop the command prompt from opening and only have the window from gloss open. 回答1: By default on Windows GHC builds console programs, which open a Command Prompt terminal if one isn’t open

Stop command prompt from opening when running exe file built from haskell project

浪子不回头ぞ 提交于 2020-12-12 09:39:10
问题 I have created a small application that uses the gloss library for a GUI. When typing "cabal run [cabal file]" the project is built and run, and only prompts the GUI. When I instead go and click on the .exe file that was generated from the build, the GUI opens but so does the command prompt. I want to stop the command prompt from opening and only have the window from gloss open. 回答1: By default on Windows GHC builds console programs, which open a Command Prompt terminal if one isn’t open

Stop command prompt from opening when running exe file built from haskell project

旧街凉风 提交于 2020-12-12 09:38:05
问题 I have created a small application that uses the gloss library for a GUI. When typing "cabal run [cabal file]" the project is built and run, and only prompts the GUI. When I instead go and click on the .exe file that was generated from the build, the GUI opens but so does the command prompt. I want to stop the command prompt from opening and only have the window from gloss open. 回答1: By default on Windows GHC builds console programs, which open a Command Prompt terminal if one isn’t open

Can I print in Haskell the type of a polymorphic function as it would become if I passed to it an entity of a concrete type? [duplicate]

喜欢而已 提交于 2020-12-12 05:39:42
问题 This question already has answers here : Unifying c -> a -> b and (a -> b) -> c (3 answers) Closed 35 mins ago . Here's a function polymorphic in 3 types: :t (.) (.) :: (b -> c) -> (a -> b) -> a -> c and here a non polymorphic function: :t Data.Char.digitToInt Data.Char.digitToInt :: Char -> Int If we apply the former to the latter, we get a function polymorphic in 1 type: :t (.) Data.Char.digitToInt (.) Data.Char.digitToInt :: (a -> Char) -> a -> Int which means that (.) was "instantiated"

Haskell from integer into a string (own function)

爷,独闯天下 提交于 2020-12-12 04:49:07
问题 I need help with my function to convert an integer into a string: for example: fromInteger 19 == "91" My auxiliary-function to convert an integer into a character: fromDigit :: Integer -> Char fromDigit 0 = '0' fromDigit 1 = '1' fromDigit 2 = '2' fromDigit 3 = '3' fromDigit 4 = '4' fromDigit 5 = '5' fromDigit 6 = '6' fromDigit 7 = '7' fromDigit 8 = '8' fromDigit 9 = '9' This is my main function: fromInteger :: Integer -> String fromInteger n = if n == 0 then "" else fromInteger(tail n) ++

Haskell from integer into a string (own function)

守給你的承諾、 提交于 2020-12-12 04:47:09
问题 I need help with my function to convert an integer into a string: for example: fromInteger 19 == "91" My auxiliary-function to convert an integer into a character: fromDigit :: Integer -> Char fromDigit 0 = '0' fromDigit 1 = '1' fromDigit 2 = '2' fromDigit 3 = '3' fromDigit 4 = '4' fromDigit 5 = '5' fromDigit 6 = '6' fromDigit 7 = '7' fromDigit 8 = '8' fromDigit 9 = '9' This is my main function: fromInteger :: Integer -> String fromInteger n = if n == 0 then "" else fromInteger(tail n) ++

How to convert arbitrary type to string, without adding extra quotes to strings?

拟墨画扇 提交于 2020-12-12 02:05:11
问题 I want to define a function which converts to strings, like the following 'toString': toString 1 = "1" toString True = "True" toString "1" = "1" Note that 'show' does not do this. By contrast it does the following: show 1 = "1" show True = "True" show "1" = "\"1\"" That is, it adds extra quotes around strings. In this case I don't want to add extra quotes if I already have a string. I'm considering using something like: import Data.Typeable toString a :: (Show a) => a -> String toString a |

How to convert arbitrary type to string, without adding extra quotes to strings?

只愿长相守 提交于 2020-12-12 02:03:25
问题 I want to define a function which converts to strings, like the following 'toString': toString 1 = "1" toString True = "True" toString "1" = "1" Note that 'show' does not do this. By contrast it does the following: show 1 = "1" show True = "True" show "1" = "\"1\"" That is, it adds extra quotes around strings. In this case I don't want to add extra quotes if I already have a string. I'm considering using something like: import Data.Typeable toString a :: (Show a) => a -> String toString a |

How to build a project with an icon by `cabal build` or `stack build`

半城伤御伤魂 提交于 2020-12-10 13:05:12
问题 I want to build an executable with an icon. By googling it, I find the instruction here, but it only works by compiling a source file with ghc . If I want to build a project with an executable by cabal build or stack build , how should I configure the .cabal or .yaml files such that cabal build or stack build can directly create an executable with an icon? I've googled it for a while, but nothing useful. I appreciate it if any tips are given. 回答1: According to @Willem Van Onsem's suggestion,

Hiding versions of random from GHCi

感情迁移 提交于 2020-12-10 06:25:04
问题 I am working with the newsynth package and am running into a bug that I am starting to suspect has to do with the update random-1.2.0 over the summer ( newsynth was last updated in late 2019, and random-1.2.0 came out in June. I have run cabal update since then, which is why both seem to be installed.) Here is the code that I ran in GHCi: λ> import System.Random λ> import Quantum.Synthesis.Ring λ> import Quantum.Synthesis.Diophantine λ> g <- getStdGen λ> diophantine g (RootTwo 5 0)