News aggregator

Were usage types ever in GHC

glasgow-user - Fri, 01/22/2016 - 1:14am
I've recently been digging around to see if there has ever been any attempt to perform any sort of data reuse optimization in functional languages. Along with many other papers, I've come across `Once upon a type' as well as `Once upon a polymorphic type'. They both mention a desire to include a similar system in GHC. Then in `Playing by the rules: rewriting as a practical optimization technique in GHC' I see usage types mentioned in section 5.3: """ To express this, GHC adds extra usage type arguments to map, both at its definition and at its call sites. Once this is done, a specialised version of map can be compiled for the case when the usage-type argument is “once”, and a rule generated to match such calls, in exactly the same way as for specialising overloading. """ I can't tell if this is simply a hypothetical optimization or if this really happened at one point in the history of GHC. I was hoping somebody could shed some light on this topic Was a usage type system or something simi
Categories: Offsite Discussion

How do you make a polyvardiac mconcat?

Haskell on Reddit - Thu, 01/21/2016 - 9:49pm
<!-- SC_OFF --><div class="md"><p>As you know, <a href="https://hackage.haskell.org/package/base-4.5.0.0/docs/Text-Printf.html#v:printf"><code>printf</code></a> is polyvardiac. It does this using type magic.</p> <p>I tried adapting this to make a <a href="http://stackoverflow.com/q/34938560/1172541">polyvardiac <code>mconcat</code></a>, but can't seem to get it to work (the polymorphic <code>m</code> is the problem).</p> <p>Any ideas on how to accomplish this?</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

Why no subtyping/subtype polymorphism?

Haskell on Reddit - Thu, 01/21/2016 - 9:20pm
<!-- SC_OFF --><div class="md"><p>Is there some reason these features conflict with Haskell philosophy?</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

Munich Haskell Meeting, 2016-01-25 < at > 19:30

haskell-cafe - Thu, 01/21/2016 - 3:15pm
Dear all, Next week, our monthly Munich Haskell Meeting will take place again on Monday, January 25 at Cafe Puck at 19h30. For details see here: http://chneukirchen.github.io/haskell-munich.de/dates If you plan to join, please add yourself to this dudle so we can reserve enough seats! It is OK to add yourself to the dudle anonymously or pseudonymously. https://dudle.inf.tu-dresden.de/haskell-munich-jan-2016/ Everybody is welcome! cu,
Categories: Offsite Discussion

How to make this tableHeaders work with the boxes library

Haskell on Reddit - Thu, 01/21/2016 - 3:13pm
<!-- SC_OFF --><div class="md"><p>Hello, </p> <p>I have now this : </p> <pre><code>module Lib where data Table = Table {tableHeaders :: [String], tableData :: [[String]]} exampleData :: Table exampleData = Table { tableHeaders = [&quot;Cat Name&quot;, &quot;Age&quot;], tableData = [[&quot;Mr Bigglesworth&quot;, &quot;205&quot;], [&quot;Crazy Cat&quot;, &quot;50&quot;]] } printTable :: String -&gt; Table -&gt; Box printTable title bank = let heading = alignHoriz center1 40 (text title) tablehead = leftright (tableHeaders bank) --contents = vcat left (map accountRow bank) in heading -- /+/ tablehead /+/ contents -- accountRow :: PrintItem -&gt; Box -- accountRow (name, amount) = -- leftright name (show amount) leftright lft rght = let leftBox = alignHoriz left 27 (text lft) rightBox = alignHoriz right 12 (text rght) in leftBox &lt;+&gt; rightBox </code></pre> <p>Now im wonder how I can take that the tableHeaders are being printed by the lefright function. Right now its a list with 2 items. But I can be more on other exampledata's .</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

Regex library for custom containers

Haskell on Reddit - Thu, 01/21/2016 - 1:10pm
<!-- SC_OFF --><div class="md"><p>Is there a haskell regex library that can operate on custom containers? (E.g. where I have to implement some typeclass)</p> <p>Thanks in advance!</p> <p>Btw, I tried to read the source code of the yi editor to find out how they do it but I couldn't figure it out.</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

an automatic refactoring idea

haskell-cafe - Thu, 01/21/2016 - 10:08am
I had a data structure with a redundant field [1]. I refactored to make that field go away. Here is the code [2]. The following is a simplification of it. I was using this type: data X = X1 | X2 Int To make the Int go away, I made a duplicate type: data X' = X1' | X2' Then, every function for which any argument was of type X, I similarly duplicated, replacing every X with X', X1 for X1', and X2 for X2'. Next I had to similarly duplicate every function that used one of those. And so on, and so on ... until eventually I was duplicating the tests. At that point I was able to determine from the duplicate tests that everything was working. There was a little more work involved than that, but the vast, vast majority of the edits that got me there were the simple duplication I just described. I looked once at automatic refactoring in Haskell and was either unimpressed or scared. I may not have understood what I was looking at enough to appreciate its power. Is there something that can do the refactoring
Categories: Offsite Discussion

First class commands and free monads

Haskell on Reddit - Thu, 01/21/2016 - 9:50am
<!-- SC_OFF --><div class="md"><p>I saw <a href="http://raganwald.com/2016/01/19/command-pattern.html">this article about first class commands</a> over <a href="https://www.reddit.com/r/programming/comments/41v00n/firstclass_commands_the_annotated_presentation/">on r/programming</a>, and the way the author discussed commands reminded me a lot of free monads.</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

2D List/Vector Performance?

Haskell on Reddit - Thu, 01/21/2016 - 6:38am
<!-- SC_OFF --><div class="md"><p>Hi everyone,</p> <p>I would love to know the performance of the following variable:</p> <pre><code> a = [1,2,3,4,5] b = [[11,12,13,14,15],[21,22,23,24,25],[31,32,33,34,35],[41,42,43,44,45],[51,52,53,54,55]] c = Data.Vector.fromList b </code></pre> <p>If it takes O(4) to access a!!4, how long does it takes to access b!!4, b!!4!!4, c!!4, c!!4!!4?</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

Streaming a Unix tool's output to Haskell?

Haskell on Reddit - Thu, 01/21/2016 - 3:56am
<!-- SC_OFF --><div class="md"><p>I'm looking into making a simple wget frontend with Haskell. The idea I had was to just have a Haskell server that can instantiate wget requests and report back on the progress. Concretely, that would require the following things:</p> <ul> <li>Execute a command via Haskell (shouldn't be too hard)</li> <li>Monitor the command's output (No idea how...)</li> <li>Interpret the output and send it to a web client (I'll work that out once I get there)</li> </ul> </div><!-- SC_ON --> submitted by
Categories: Incoming News

PostgreSQL Simple FromField help

Haskell on Reddit - Thu, 01/21/2016 - 2:55am
<!-- SC_OFF --><div class="md"><p>For the love of me I can't figure out how to use FromField in postgresql-simple package.</p> <p>I have a custom type in my code :</p> <pre><code>data Role = Staff | Student deriving (Eq, Ord, Show) </code></pre> <p>I intend to use integers 1 and 2 in postgres to represent these two values but I simply can't figure out how to convert integer in database to Role in Haskell using FromField.</p> <p>Example on hackage is not really helping me much here.</p> <p><a href="https://hackage.haskell.org/package/postgresql-simple-0.5.1.2/docs/Database-PostgreSQL-Simple-FromField.html">postgresql-simple on hackage</a></p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

&quot;Haskell Design Patterns&quot; any good?

Haskell on Reddit - Thu, 01/21/2016 - 2:22am
<!-- SC_OFF --><div class="md"><p>I saw this <a href="https://www.packtpub.com/application-development/haskell-design-patterns">Haskell Design Patterns / pact</a> on the <a href="https://wiki.haskell.org/Books">books HaskellWiki page</a></p> <p>Is this a good resource (well pact seems not to have the best reputation)?</p> <hr/> <p>Seems as this book is not really all that great - sad I fell like there is should be a good book bridging the gap between LYAH and most of the papers out there.</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

Can this be ported to Haskell

Haskell on Reddit - Thu, 01/21/2016 - 1:59am
<!-- SC_OFF --><div class="md"><p>Hello, </p> <p>I like the way this clojure plugin is working: <a href="https://github.com/joegallo/doric">https://github.com/joegallo/doric</a></p> <p>Can this also be done in Haskell and how. I tried it myself to do with the boxes library but no luck so far.</p> <p>Roelof</p> </div><!-- SC_ON --> submitted by
Categories: Incoming News

[Template Haskell Question] On defining recursivetemplates.

haskell-cafe - Wed, 01/20/2016 - 9:01pm
Hello Haskellers, I'm currently diving into Template Haskell and I just read the original TH paper [1]. There they give the following example of a generic zip function:
Categories: Offsite Discussion

Demo of IHaskell Notebook [video]

Haskell on Reddit - Wed, 01/20/2016 - 7:54pm
submitted by
Categories: Incoming News