ghc

What cases do the GHC occurs check identify?

ⅰ亾dé卋堺 提交于 2021-01-02 07:09:21
问题 The GHC occurs check prevents you from constructing infinite types. Is its purpose to prevent common errors in code or to prevent the typechecker from looping indefinitely, or both? What cases does it identify and is it possible for a malicious user to trick it (as in a Safe Haskell context) into looping? If the type system is Turing-complete (is it?) I don't understand how GHC can guarantee that the computation will halt. 回答1: Think of type inference as solving a system of equations. Let's

What cases do the GHC occurs check identify?

时光总嘲笑我的痴心妄想 提交于 2021-01-02 07:08:16
问题 The GHC occurs check prevents you from constructing infinite types. Is its purpose to prevent common errors in code or to prevent the typechecker from looping indefinitely, or both? What cases does it identify and is it possible for a malicious user to trick it (as in a Safe Haskell context) into looping? If the type system is Turing-complete (is it?) I don't understand how GHC can guarantee that the computation will halt. 回答1: Think of type inference as solving a system of equations. Let's

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)

Hiding versions of random from GHCi

人盡茶涼 提交于 2020-12-10 06:24:55
问题 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)

Hiding versions of random from GHCi

我是研究僧i 提交于 2020-12-10 06:24:52
问题 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)

Hiding versions of random from GHCi

我与影子孤独终老i 提交于 2020-12-10 06:24:24
问题 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)

Can anybody explain GHC's definition of IO?

情到浓时终转凉″ 提交于 2020-11-28 07:58:33
问题 The title is pretty self-descriptive, but there's one part that caught my attention: newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #)) Stripping the newtype , we get: State# RealWorld -> (# State# RealWorld, a #) I don't know what State# stands for. Can we replace it with State like this: State RealWorld -> (State RealWorld, a) And can that be expressed as this, then? State (State RealWorld) a This particular construct caught my attention. I know that conceptually, type IO a =

Can anybody explain GHC's definition of IO?

∥☆過路亽.° 提交于 2020-11-28 07:56:59
问题 The title is pretty self-descriptive, but there's one part that caught my attention: newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #)) Stripping the newtype , we get: State# RealWorld -> (# State# RealWorld, a #) I don't know what State# stands for. Can we replace it with State like this: State RealWorld -> (State RealWorld, a) And can that be expressed as this, then? State (State RealWorld) a This particular construct caught my attention. I know that conceptually, type IO a =

What does left arrow <- mean outside a do block?

*爱你&永不变心* 提交于 2020-11-27 05:02:34
问题 I came across with the following code recently and it bothers me a lot lowerSafeForeignCall dflags block | (entry, middle, CmmForeignCall { .. }) <- blockSplit block = do -- do block stuffs -- Block doesn't end in a safe foreign call: | otherwise = return block This piece of code is from https://phabricator.haskell.org/rGHCb0534f78a73f972e279eed4447a5687bd6a8308e in file compiler/cmm/CmmLayoutStack.hs line 983 I really would like to konw what is this <- in the second line. I believe

What does left arrow <- mean outside a do block?

被刻印的时光 ゝ 提交于 2020-11-27 05:01:45
问题 I came across with the following code recently and it bothers me a lot lowerSafeForeignCall dflags block | (entry, middle, CmmForeignCall { .. }) <- blockSplit block = do -- do block stuffs -- Block doesn't end in a safe foreign call: | otherwise = return block This piece of code is from https://phabricator.haskell.org/rGHCb0534f78a73f972e279eed4447a5687bd6a8308e in file compiler/cmm/CmmLayoutStack.hs line 983 I really would like to konw what is this <- in the second line. I believe