Hello, I've been recently interested in programs that can program programs for you. That is, you give it a map of input/output pairs and it gives you the source code of a program that is valid for that map. If we had something like that that worked for arbitrary programs, programming would become so much ridiculously easier that the whole field would change. In order to investigate, I made a small program that finds the definition of the (λx -> x+tan(x*x)) function from 20 input/output pairs. I was actually surprised by how fast it could find the result, but, obviously, anything much more complex than that results in a combinatory explosion.
But thinking about it, most of the functions we write in Haskell are really small. Even complex stuff that take hours to get right, such as an interpreter for the lambda calculus, could be written in as few as 3 lines. So this makes me suspect that kind of thing, with some added heuristics (genetic programming?) could actually be useful to practical jobs. So this makes me wonder, why I never heard of it? Has anyone ever tried to use and incorporate this kind of thing in their daily Haskell work? How successful (or not) was it?submitted by SrPeixinho
[link] [8 comments]
Elimination rules play an important role in computations over datatypes in proof assistants like Coq. In his paper "Elimination with a Motive", Conor McBride argued that "we should exploit a hypothesis not in terms of its immediate consequences, but in terms of the leverage it exerts on an arbitrary goal: we should give elimination a motive." In other words, proofs in a refinement setting (backwards reasoning) should use their goals to guide elimination.
I recently had the opportunity to reread this historical paper, and in the process, I thought it would be nice to port the examples to Coq. Here is the result:
It's basically a short tutorial motivating John Major equality (also known as heterogenous equality.) The linked text is essentially an annotated version of the first part of the paper—I reused most of the text, adding comments here and there as necessary. The source is also available at:
Please, don't take it as an offence, but Cabal is terrible as a package manager, it is a serious problem about Haskell and it is about time the community does something to solve this.
I've been trying for months to install GHCJS to no success. Haste, Fay, many other things I try to install end up in a plain failure with terrible error messages that give you no hope to get it right. Getting anything to work with Haskell is a pain and I spent much more time installing and cleaning installs than ever coding on the language. This is completely unacceptable. Coming from Node.js, where npm install lib actually works makes me feel like I'm back to the 90's. You keep asking what is stopping Haskell from getting main adoption, and there it is. This. This is what is stopping it.
I think it is about time we unite ourselves as a community and try to solve the problem by creating an actual package manager for Haskell. And humbling ourselves to learn a lot from Node.js.submitted by SrPeixinho
[link] [27 comments]
Could someone provide a shell script that will clean any existing Haskell installation and install GHC 7.8 and GHCJS in OSX Mavericks?
As some might even know, I've tried installing GHCJS 7.8 on OSX several times already. I've even asked this a few times here to no luck. So now what I am asking is, could someone write a sh script that will do all I need - cleaning any existing Haskell and setting GHC 7.8 with working GHCJS up on OSX? That would be really great. :(submitted by SrPeixinho
[link] [5 comments]
I was experimenting with a "sort of" generalization of optional like the followingclass Constructable t where construct :: Alternative f => f a -> f (t a) instance Constructable Maybe where construct f = Just <$> f <|> pure Nothing -- with caveats below
Has anyone used this before? Does it exist elsewhere in Hackage? Hoogle didn't turn anything up.
It feels a lot like some kind of dualization of Traversable. I originally used it for generically enumerating data types:import Data.Traversable (Traversable, sequenceA) import Data.Functor.Foldable import Data.Function (fix) import Control.Monad.Omega (runOmega) every :: (Monad f, Alternative f , Traversable (Base t) , Constructable (Base t) , Fold t ) => f t every = fix (construct . pure >=> fmap embed . sequenceA) everyInterleaved :: (Traversable (Base t), Constructable (Base t), Fold t) => [t] everyInterleaved = runOmega every
Although, if this is the way Constructable is to be used then the construct instance for Maybe does not align with what it would need to be as the base functor for Nat: using it this way produces nats too strictlytype instance Base Int = Maybe instance Unfoldable Int where embed Nothing = 0 embed (Just x) = succ x > runOmega every :: [Int] *** Exception: <<loop>>
To fix this we just have to reverse the ordering of the cases in constructinstance Constructablr Maybe where construct f = pure Nothing <|> Just <$> f
indicating that Constructable is a bit like Series in that it needs to enumerate the cases smallest first.submitted by tel
[link] [8 comments]
As there were some questions recently about how to architect a real world Haskell application, here is an example of one: Architecture of a Real World Haskell Application. Questions and Feedback welcome.submitted by empowerg
[link] [36 comments]
Is there an existing library for an SMTP mail server? I would create an SMTP server using the library to process mail messages in a custom format. But I can't use an existing mail server program like postfix because every incoming mail needs to be processed by a seperate thread and based on the format of the received mail I need to do certain things. I searched all over but couldn't find a lightweight SMTP server library although I found a few SMTP server programs similar to postfix which is not what I need.submitted by desijays
[link] [9 comments]
Suppose that you were given a list of input/ouput pairs:f 0 = 0 f 1 = 2 f 2 = 1 f 3 = -1 f 4 = 0 f 5 = 0 f 6 = -76 f 7 = -3 f 8 = 3 f 9 = -1 f 10 = -1 f 11 = -6 f 12 = -1 f 13 = -1 f 14 = 4 f 15 = -2 f 16 = -10 f 17 = 0 f 18 = 0 f 19 = -1 f 20 = 2 f 21 = 3 f 22 = 0 f 23 = 4 f 24 = 2 f 25 = -1 f 26 = 0 f 27 = 0 f 28 = -4 f 29 = -2 f 30 = -14
Now suppose you were asked to find the definition of f. How would you do it? Spoil.submitted by SrPeixinho
[link] [18 comments]