haskell

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

泪湿孤枕 提交于 2021-02-07 19:13:55
问题 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

Can't install and use Cabal (Haskell) on CentOS Server - zlib-0.5.4.1 failed during the building phase

我的未来我决定 提交于 2021-02-07 18:38:18
问题 I'm trying to install a Haskell server which runs in Cabal on my server. When I configure a server normally to run this, I follow these instructions which we've refined - they work 100% every time on a blank rackspace cloud server. yum update yum install git yum install vim yum install ghc-zlib-devel.x86_64 wget http://www.haskell.org/ghc/dist/7.8.2/ghc-7.8.2-x86_64-unknown-linux-centos65.tar.xz wget http://www.haskell.org/cabal/release/cabal-install-1.20.0.1/cabal-x86_64-unknown-linux.tar.gz

fmap putStrLn getLine does not perform IO

不问归期 提交于 2021-02-07 18:28:17
问题 The title said it all, actually. I can't understand why this following code does not actually print "Hello World" as opposed of what >>= does. main = fmap putStrLn getLine Currently, here is my line of reasoning, please check if it has any fallacy. If we compare fmap with >>= (>>=) :: Monad m => m a -> (a -> m b) -> m b fmap :: Functor f => (a -> b) -> f a -> f b In bind, the context, or in IO terms "World" the first m and the second m is entirely different aside of the types. (a -> m b)

Haskell - Illegal Polymorphic type?

限于喜欢 提交于 2021-02-07 16:31:52
问题 Why does the single usage of this type compile, but putting it into a list fails? ft1 :: (Foldable t, Num a) => t a -> a ft1 = (F.foldl (+) 0) fTest :: [(Foldable t, Num a) => t a -> a ] fTest = [ F.foldl (+) 0 ] The latter gives the error: folding.hs:80:10: Illegal polymorphic or qualified type: (Foldable t, Num a) => t a -> a Perhaps you intended to use ImpredicativeTypes In the type signature for `fTest': fTest :: [(Foldable t, Num a) => t a -> a] Simliarly, trying to name it fails

Haskell - Illegal Polymorphic type?

寵の児 提交于 2021-02-07 16:26:59
问题 Why does the single usage of this type compile, but putting it into a list fails? ft1 :: (Foldable t, Num a) => t a -> a ft1 = (F.foldl (+) 0) fTest :: [(Foldable t, Num a) => t a -> a ] fTest = [ F.foldl (+) 0 ] The latter gives the error: folding.hs:80:10: Illegal polymorphic or qualified type: (Foldable t, Num a) => t a -> a Perhaps you intended to use ImpredicativeTypes In the type signature for `fTest': fTest :: [(Foldable t, Num a) => t a -> a] Simliarly, trying to name it fails

What is the equivalent statement of a while loop in Haskell?

本秂侑毒 提交于 2021-02-07 14:43:51
问题 Being very new to Haskell, I'm wondering how to 1) compute something until a certain criterion is satisfied, and then 2) return the computed value. In the languages I know, you would use a while loop for that. How do you do it in Haskell? 回答1: You should use recursion : func :: <function type> func <arguments> = if condition then <recursive call> else computedValue There are also other utilities you'll discover in the future, such as until, that will help you with this. In the end it really

What is the equivalent statement of a while loop in Haskell?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 14:43:02
问题 Being very new to Haskell, I'm wondering how to 1) compute something until a certain criterion is satisfied, and then 2) return the computed value. In the languages I know, you would use a while loop for that. How do you do it in Haskell? 回答1: You should use recursion : func :: <function type> func <arguments> = if condition then <recursive call> else computedValue There are also other utilities you'll discover in the future, such as until, that will help you with this. In the end it really

What is the equivalent statement of a while loop in Haskell?

Deadly 提交于 2021-02-07 14:38:46
问题 Being very new to Haskell, I'm wondering how to 1) compute something until a certain criterion is satisfied, and then 2) return the computed value. In the languages I know, you would use a while loop for that. How do you do it in Haskell? 回答1: You should use recursion : func :: <function type> func <arguments> = if condition then <recursive call> else computedValue There are also other utilities you'll discover in the future, such as until, that will help you with this. In the end it really

Cases in which we shall not use monadic bind to write mfix down using loop

有些话、适合烂在心里 提交于 2021-02-07 13:22:53
问题 I have been trying to write mfix down using Control.Arrow.loop. I came up with different definitions and would like to see which one is mfix 's actual workalike. So, the solution I reckon to be the right one is the following: mfix' :: MonadFix m => (a -> m a) -> m a mfix' k = let f ~(_, d) = sequenceA (d, k d) in (flip runKleisli () . loop . Kleisli) f As one can see, the loop . Kleisli 's argument works for Applicative instances. I find it to be a good sign as we mostly have our knot-tying

Cases in which we shall not use monadic bind to write mfix down using loop

佐手、 提交于 2021-02-07 13:21:11
问题 I have been trying to write mfix down using Control.Arrow.loop. I came up with different definitions and would like to see which one is mfix 's actual workalike. So, the solution I reckon to be the right one is the following: mfix' :: MonadFix m => (a -> m a) -> m a mfix' k = let f ~(_, d) = sequenceA (d, k d) in (flip runKleisli () . loop . Kleisli) f As one can see, the loop . Kleisli 's argument works for Applicative instances. I find it to be a good sign as we mostly have our knot-tying