haskell

Mutable, random-access array/vector with high performance in haskell

 ̄綄美尐妖づ 提交于 2021-02-08 02:00:40
问题 This a topic on Haskell discussed a lot (e.g. mutable-array-implementation), but I am still not sure what is the best practice for the case requiring frequent modification and random-access of an array/vector. Say a vector of length 1,000,000. Operation on it involves accessing a (small, e.g 1000) subset of it based on input, and modifying the values based on the input. Furthermore, such operation are repeated 2,000,000 times. The task itself can be implemented in pure data structure such as

My installed transformers version is not considered by cabal-install

寵の児 提交于 2021-02-07 22:38:50
问题 I am totally new to Haskell an cabal and I'm trying to make yesod work. My cabal version is cabal-install version 1.20.0.3 using version 1.20.0.2 of the Cabal library This is what happends when I tru to install alex: $ cabal install alex Resolving dependencies... cabal: Could not resolve dependencies: trying: alex-3.1.4 (user goal) next goal: QuickCheck (dependency of alex-3.1.4) rejecting: QuickCheck-2.8.1, 2.8 (global constraint requires ==2.7.6) trying: QuickCheck-2.7.6 next goal:

My installed transformers version is not considered by cabal-install

Deadly 提交于 2021-02-07 22:38:11
问题 I am totally new to Haskell an cabal and I'm trying to make yesod work. My cabal version is cabal-install version 1.20.0.3 using version 1.20.0.2 of the Cabal library This is what happends when I tru to install alex: $ cabal install alex Resolving dependencies... cabal: Could not resolve dependencies: trying: alex-3.1.4 (user goal) next goal: QuickCheck (dependency of alex-3.1.4) rejecting: QuickCheck-2.8.1, 2.8 (global constraint requires ==2.7.6) trying: QuickCheck-2.7.6 next goal:

Haskero fails with “Not a valid Unicode code point!”

浪子不回头ぞ 提交于 2021-02-07 21:29:09
问题 I'm trying to run Haskero to do Haskell editing with VSCode. However, it's failing on initialization, with the following error: Initializing Haskero... Spawning process 'stack' with command 'stack ghci --with-ghc intero "--ghci-options=-ignore-dot-ghci -Wall" --no-build --no-load' (node:3726) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: reason.indexOf is not a function (node:3726) DeprecationWarning: Unhandled promise rejections are deprecated.

ReaderT Design Pattern: Parametrize the Environment

只谈情不闲聊 提交于 2021-02-07 20:32:58
问题 I build a project based on the ReaderT design pattern. Instead of using a typeclass approach for dependency injection, I choose to use simple injection of handlers as function arguments. This part works fine as one is able to construct a dependency tree statically and define an environment dynamically. The environment may contain configuration as well as a logging effect :: String -> IO () , an effect of time :: IO UTCDate etc. Consider the following minified example import Control.Monad

ReaderT Design Pattern: Parametrize the Environment

纵饮孤独 提交于 2021-02-07 20:30:17
问题 I build a project based on the ReaderT design pattern. Instead of using a typeclass approach for dependency injection, I choose to use simple injection of handlers as function arguments. This part works fine as one is able to construct a dependency tree statically and define an environment dynamically. The environment may contain configuration as well as a logging effect :: String -> IO () , an effect of time :: IO UTCDate etc. Consider the following minified example import Control.Monad

How can QuickCheck test all properties for each sample

天大地大妈咪最大 提交于 2021-02-07 19:22:15
问题 ...instead of generating 100 new random samples for each property? My testsuite contains the TemplateHaskell hack explained here [1] to test all functions named prop_*. Running the test program prints === prop_foo from tests/lala.lhs:20 === +++ OK, passed 100 tests. === prop_bar from tests/lala.lhs:28 === +++ OK, passed 100 tests. and it looks like going through 100 random samples for each of the properties. Problemis: Generating the samples is quite expensive, checking the properties is not.

What are the prerequisites for a point-free function in Haskell

跟風遠走 提交于 2021-02-07 19:20:56
问题 I always thought that the prerequisites for a pointfree function were to get the function arguments to the end of the definition. E.g. -- This can be made pointfree quite easily: let lengths x = map length x let lengths' = map length -- However this cannot: let lengthz x = length `map` x -- let lengthz' = length `map` (parse error) I originally came across this reading this question. There we have this example: agreeLen :: (Eq a) => [a] -> [a] -> Int agreeLen x y = length $ takeWhile id $

How can QuickCheck test all properties for each sample

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 19:20:04
问题 ...instead of generating 100 new random samples for each property? My testsuite contains the TemplateHaskell hack explained here [1] to test all functions named prop_*. Running the test program prints === prop_foo from tests/lala.lhs:20 === +++ OK, passed 100 tests. === prop_bar from tests/lala.lhs:28 === +++ OK, passed 100 tests. and it looks like going through 100 random samples for each of the properties. Problemis: Generating the samples is quite expensive, checking the properties is not.

Why is it fair to think of just locally small cartesian closed categories in Haskell for the Curry class?

元气小坏坏 提交于 2021-02-07 19:14:41
问题 Control.Category.Constrained is a very interesting project that presents the class for cartesian closed categories - Curry. Yet, I do not see why we think of all cartesian closed categories which allow curry and uncurry ( Hom(X * Y, Z) ≅ Hom(X, Z^Y) in terms of category theory). Wikipedia says that such property holds only for locally small cartesian closed categories. Under this post many people suggest that Hask itself is not locally small (on the other hand, everyone says that Hask is not