haskell

Generics and Constrained Polymorphism versus Subtyping

别等时光非礼了梦想. 提交于 2019-12-31 10:35:43
问题 In this PDF presentation on Haskell Type Classes, slide #54 has this question: Open Question : In a language with generics and constrained polymorphism, do you need subtyping too? My questions are: How do generics and constrained polymorphism make subtyping unnecessary? If generics and constrained polymorphism make subtyping unnecessary, why does Scala have subtyping? 回答1: How do generics and constrained polymorphism make subtyping unnecessary? It is not known that they do. If you put the

Minimal Warp webserver example

醉酒当歌 提交于 2019-12-31 09:11:28
问题 I want to create a website using the Warp webserver in Haskell. As I'm a Haskell beginner, examples like this one are too complex for me. Can anyone show me a simple, minimal example of how to use Warp ? Note: This question intentionally shows no research effort as it was answered Q&A-style. 回答1: Here's a minimal Hello World application using Warp 3.0+. Run it, then navigate to http://localhost:3000 . This example will show Hello world . In order to keep this example minimal, URL paths are

Singleton types in Haskell

删除回忆录丶 提交于 2019-12-31 09:11:22
问题 As part of doing a survey on various dependently typed formalization techniques, I have ran across a paper advocating the use of singleton types (types with one inhabitant) as a way of supporting dependently typed programming. Acording to this source, in Haskell, there is a separation betwen runtime values and compile-time types that can be blurred when using singleton types, due to the induced type/value isomorphism. My question is: How do singleton types differ from type-classes or from

What do “reify” and “reification” mean in the context of (functional?) programming?

这一生的挚爱 提交于 2019-12-31 08:33:27
问题 I read this term a lot in blogs about haskell and functional programming (specially in sigfpe's blog) but I don't have a clue about what it means. I get away with not knowing it most of the times, but I probably would have understood the texts a lot better if I knew. Google didn't help me. I get lost in the technical stuff. Also the non-technical meaning of the world ("turning the abstract concrete") doesn't help me understand what it practically means to reify something in code. I'm kinda

What do “reify” and “reification” mean in the context of (functional?) programming?

a 夏天 提交于 2019-12-31 08:32:50
问题 I read this term a lot in blogs about haskell and functional programming (specially in sigfpe's blog) but I don't have a clue about what it means. I get away with not knowing it most of the times, but I probably would have understood the texts a lot better if I knew. Google didn't help me. I get lost in the technical stuff. Also the non-technical meaning of the world ("turning the abstract concrete") doesn't help me understand what it practically means to reify something in code. I'm kinda

Representing continuous probability distributions

☆樱花仙子☆ 提交于 2019-12-31 08:12:23
问题 I have a problem involving a collection of continuous probability distribution functions, most of which are determined empirically (e.g. departure times, transit times). What I need is some way of taking two of these PDFs and doing arithmetic on them. E.g. if I have two values x taken from PDF X, and y taken from PDF Y, I need to get the PDF for (x+y), or any other operation f(x,y). An analytical solution is not possible, so what I'm looking for is some representation of PDFs that allows such

Has anyone ever encountered a Monad Transformer in the wild?

北城余情 提交于 2019-12-31 08:07:31
问题 In my area of business - back office IT for a financial institution - it is very common for a software component to carry a global configuration around, to log its progress, to have some kind of error handling / computation short circuit... Things that can be modelled nicely by Reader-, Writer-, Maybe-monads and the like in Haskell and composed together with monad transformers. But there seem to some drawbacks: The concept behind monad transformers is quite tricky and hard to understand,

Explanation of Monad laws

非 Y 不嫁゛ 提交于 2019-12-31 08:05:20
问题 From a gentle introduction to Haskell, there are the following monad laws. Can anyone intuitively explain what they mean? return a >>= k = k a m >>= return = m xs >>= return . f = fmap f xs m >>= (\x -> k x >>= h) = (m >>= k) >>= h Here is my attempted explanation: We expect the return function to wrap a so that its monadic nature is trivial. When we bind it to a function, there are no monadic effects, it should just pass a to the function. The unwrapped output of m is passed to return that

Techniques for Tracing Constraints

独自空忆成欢 提交于 2019-12-31 07:54:29
问题 Here's the scenario: I've written some code with a type signature and GHC complains could not deduce x ~ y for some x and y . You can usually throw GHC a bone and simply add the isomorphism to the function constraints, but this is a bad idea for several reasons: It does not emphasize understanding the code. You can end up with 5 constraints where one would have sufficed (for example, if the 5 are implied by one more specific constraint) You can end up with bogus constraints if you've done

Haskell, Lisp, and verbosity [closed]

。_饼干妹妹 提交于 2019-12-31 07:53:05
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . For those of you experienced in both Haskell and some flavor of Lisp, I'm curious how "pleasant" (to use a horrid term) it is to write