haskell

How to install Haskell Platform on Linux Debian Wheezy?

半世苍凉 提交于 2019-12-30 08:16:19
问题 Initially I thought I would get install Haskell with couple of commands using apt-get but its seems somehow complex. As I look at the haskell org download page, I downloaded haskell-platform-2013.2.0.0.tar.gz . Then next step is somehow confusing. It ask to install GHC before installing platform but at the same time if one opens GHC download page , it shows some warning e.g Stop ! ..... we recommend installing the Haskell Platform instead of GHC . Please guide me how to install Haskell on

Where is it specified whether Unicode identifiers should be allowed in a Haskell implementation?

♀尐吖头ヾ 提交于 2019-12-30 08:14:39
问题 I wanted to write some educational code in Haskell with Unicode characters (non-Latin) in the identifiers. (So that the identifiers look nice and natural for speakers of a natural language other than English which is not using the Latin characters in its writing.) So, I set out for finding an appropriate Haskell implementation that would allow this. But where is this feature specified in the language specification? How would I refer to this feature when looking for a conforming implementation

Why is there not 'Alternative' instance for 'Control.Applicative.Const'

醉酒当歌 提交于 2019-12-30 08:06:27
问题 There is an instance Monoid a => Monoid (Const a b) for the Const functor from Control.Applicative . There is also an instance Monoid m => Applicative (Const m) . I would therefore expect that there is also an instance Monoid m => Alternative (Const m) that coincides with the one for Monoid . Is this just an omission that should be fixed, or is there a deeper reason? 回答1: I believe there is a deeper reason. While it seems there is no canonical set of rules for Alternative , in order for

Why is there not 'Alternative' instance for 'Control.Applicative.Const'

风流意气都作罢 提交于 2019-12-30 08:06:07
问题 There is an instance Monoid a => Monoid (Const a b) for the Const functor from Control.Applicative . There is also an instance Monoid m => Applicative (Const m) . I would therefore expect that there is also an instance Monoid m => Alternative (Const m) that coincides with the one for Monoid . Is this just an omission that should be fixed, or is there a deeper reason? 回答1: I believe there is a deeper reason. While it seems there is no canonical set of rules for Alternative , in order for

Why is there no `-XDeriveApplicative` extension?

扶醉桌前 提交于 2019-12-30 08:05:13
问题 GHC has several useful language extensions for mechanically deriving various common Haskell typeclasses ( -XDeriveFunctor , -XDeriveFoldable , -XDeriveTraversable ). It seems that Applicative is another class which is often needed and frequently easily derived. For a simple record containing slots of type a , e.g., data SimpleRecord a = Simple a a a the Applicative instance is trivially derived, instance Applicative SimpleRecord where pure x = Simple x x x Simple a1 b1 c1 <*> Simple a2 b2 c2

Why is there no `-XDeriveApplicative` extension?

家住魔仙堡 提交于 2019-12-30 08:04:08
问题 GHC has several useful language extensions for mechanically deriving various common Haskell typeclasses ( -XDeriveFunctor , -XDeriveFoldable , -XDeriveTraversable ). It seems that Applicative is another class which is often needed and frequently easily derived. For a simple record containing slots of type a , e.g., data SimpleRecord a = Simple a a a the Applicative instance is trivially derived, instance Applicative SimpleRecord where pure x = Simple x x x Simple a1 b1 c1 <*> Simple a2 b2 c2

Haskell Pattern Matching on the Empty Set

╄→尐↘猪︶ㄣ 提交于 2019-12-30 07:54:15
问题 I'm changing some Haskell code from using lists to sets. I understand everything required, I think, but I'm not sure how to pattern match on sets. Lists have this nice literal syntax that seems hard to emulate with the Set constructor. For example, I might have some code like this: foo [] = [] foo x = other_thing How can I write this code so it uses Sets instead of lists? 回答1: Well, you can't. Set is an abstract data type [0] that deliberately hides its internal representation, primarily to

Haskell (n+1) in pattern matching

若如初见. 提交于 2019-12-30 07:53:10
问题 I was doing the 99 Problems in Haskell when I encountered a solution to Problem 19 that I did not fully understand. The task is to write a rotate function that works like this *Main> rotate ['a','b','c','d','e','f','g','h'] 3 "defghabc" *Main> rotate ['a','b','c','d','e','f','g','h'] (-2) "ghabcdef" One provided solution is rotate [] _ = [] rotate l 0 = l rotate (x:xs) (n+1) = rotate (xs ++ [x]) n rotate l n = rotate l (length l + n) I don't understand how the pattern matching can ever reach

Haskell: Splitting pipes (broadcast) without using spawn

橙三吉。 提交于 2019-12-30 07:02:39
问题 This question is a bit codegolf and a lot newb. I'm using the awesome pipes library in Haskell, and I'd like to split a pipe to send the same data along multiple channels (do a broadcast). The Pipes.Concurrent tutorial suggests using spawn to create mailboxes, taking advantage of Output 's monoid status. For example, we might do something like this: main = do (output1, input1) <- spawn Unbounded (output2, input2) <- spawn Unbounded let effect1 = fromInput input1 >-> pipe1 let effect2 =

How to model hierarchical data types in Haskell?

独自空忆成欢 提交于 2019-12-30 07:01:11
问题 I have a bunch of types where their hierarchy stores some useful information. I'm trying to avoid having to bake in knowledge of the hierarchy of the types into the functions that operate on them. The following is a little excerpt of Stanford's Typed Dependencies for natural language processing: root - root dep - dependent aux - auxiliary auxpass - passive auxiliary cop - copula arg - argument agent - agent I would like to create some data types that mirror this structure so that I can define