News aggregator

Read and sort text file?

Haskell on Reddit - Thu, 04/23/2015 - 4:09pm

Hi, I've recently decided to pursue Haskell as the language of choice for a school project and, being the beginner I am, have found myself hitting a wall.

The assignment is to take in a list of names, sort it, then print it out. Reading in the list of names was easy, as was printing it out. The wall I'm hitting is sorting it. From what I'm seeing, and correct me if I'm wrong, when it read in the file it just popped all the characters into a string. When I tried to use the sort function, it sorted each character, including the new line characters.

I've searched high and low and the solutions I found that most represent my problem involve integers instead of strings and don't fully explain what's happening.

Like I said before, I don't know a lot about Haskell and there isn't anyone I know that I can physically ask for help. From my understanding, one thing I could potentially do is group each line and then sort the list, which should actually sort the words rather than the characters, but I'm having a hard time figuring out the syntax for that. I'm going to continue to research this, but hopefully someone here can help and give me more specific advice.

Thanks.

submitted by pakispride
[link] [10 comments]
Categories: Incoming News

Why is vs `Data.Monoid.mappend` [v] better than vs ++ [v]

Haskell on Reddit - Thu, 04/23/2015 - 3:59pm

HLint recently made the following suggestion to me:

Use mappend Found: vs ++ [v] Why not: vs `Data.Monoid.mappend` [v]

I was trying to append a single element to an existing list. What are the benefits of using mappend instead of (++) ? Other than that you get the generality? Because it sure isn't more pleasing to the eye or easy on the fingers.

submitted by stasiana
[link] [21 comments]
Categories: Incoming News

CFP: FHPC 2015: Workshop on FunctionalHigh-Performance Computing [w/ICFP]

haskell-cafe - Thu, 04/23/2015 - 2:57pm
Apologies if you receive this message more than once. ====================================================================== CALL FOR PAPERS FHPC 2015 The 4th ACM SIGPLAN Workshop on Functional High-Performance Computing Vancouver, British Columbia, Canada, Canada September 3, 2015 https://sites.google.com/site/fhpcworkshops/ Co-located with the International Conference on Functional Programming (ICFP 2015) Submission Deadline: Friday, 15 May, 2015 (anywhere on earth) ====================================================================== The FHPC workshop aims at bringing together researchers exploring uses of functional (or more generally, declarative or high-level) programming technology in application domains where high performance is essential. The aim of the meeting is to enable sharing of results, experiences, and novel idea
Categories: Offsite Discussion

CFP: FHPC 2015: Workshop on Functional High-PerformanceComputing [w/ICFP]

General haskell list - Thu, 04/23/2015 - 2:56pm
Apologies if you receive this message more than once. ====================================================================== CALL FOR PAPERS FHPC 2015 The 4th ACM SIGPLAN Workshop on Functional High-Performance Computing Vancouver, British Columbia, Canada, Canada September 3, 2015 https://sites.google.com/site/fhpcworkshops/ Co-located with the International Conference on Functional Programming (ICFP 2015) Submission Deadline: Friday, 15 May, 2015 (anywhere on earth) ====================================================================== The FHPC workshop aims at bringing together researchers exploring uses of functional (or more generally, declarative or high-level) programming technology in application domains where high performance is essential. The aim of the meeting is to enable sharing of results, experiences, and novel idea
Categories: Incoming News

Definition of fix

Haskell on Reddit - Thu, 04/23/2015 - 1:14pm

fix is defined in Data.Function as

fix f = let x = f x in x

As far as I can tell, this is equivalent to

fix f = f (fix f)

which seems much clearer. Does anyone know why the first version was chosen?

submitted by anschelsc
[link] [15 comments]
Categories: Incoming News

Implementing zip for a dependently typed list using GHC.TypeLits?

Haskell on Reddit - Thu, 04/23/2015 - 12:20pm

The following implementation of a dependently typed list compiles without problems:

{-# LANGUAGE DataKinds, GADTs, KindSignatures #-} module DTListPeano where data Nat = Z | S Nat data DTList :: Nat -> * -> * where Nil :: DTList Z a Cons :: a -> DTList n a -> DTList (S n) a zip' :: DTList n a -> DTList n b -> DTList n (a,b) zip' Nil Nil = Nil zip' (Cons x xs) (Cons y ys) = Cons (x,y) $ zip' xs ys

However, I wanted to use GHC.TypeLits, so I tried the following, which won't compile though:

{-# LANGUAGE DataKinds, GADTs, KindSignatures, TypeOperators #-} module DTListTypeLits where import GHC.TypeLits data DTList :: Nat -> * -> * where Nil :: DTList 0 a Cons :: a -> DTList n a -> DTList (n+1) a zip' :: DTList n a -> DTList n b -> DTList n (a,b) zip' Nil Nil = Nil zip' (Cons x xs) (Cons y ys) = Cons (x,y) $ zip' xs ys

The error message I get is:

DTListTypeLits.hs:13:53: Could not deduce (n2 ~ n1) from the context (n ~ (n1 + 1)) bound by a pattern with constructor Cons :: forall a (n :: Nat). a -> DTList n a -> DTList (n + 1) a, in an equation for ‘zip'’ at DTListTypeLits.hs:13:7-15 or from (n ~ (n2 + 1)) bound by a pattern with constructor Cons :: forall a (n :: Nat). a -> DTList n a -> DTList (n + 1) a, in an equation for ‘zip'’ at DTListTypeLits.hs:13:19-27 ‘n2’ is a rigid type variable bound by a pattern with constructor Cons :: forall a (n :: Nat). a -> DTList n a -> DTList (n + 1) a, in an equation for ‘zip'’ at DTListTypeLits.hs:13:19 ‘n1’ is a rigid type variable bound by a pattern with constructor Cons :: forall a (n :: Nat). a -> DTList n a -> DTList (n + 1) a, in an equation for ‘zip'’ at DTListTypeLits.hs:13:7 Expected type: DTList n1 b Actual type: DTList n2 b Relevant bindings include ys :: DTList n2 b (bound at DTListTypeLits.hs:13:26) xs :: DTList n1 a (bound at DTListTypeLits.hs:13:14) In the second argument of ‘zip'’, namely ‘ys’ In the second argument of ‘($)’, namely ‘zip' xs ys’

Am I missing something obvious here?

submitted by Regimardyl
[link] [3 comments]
Categories: Incoming News

Practical equality constraint solver in the wild!

Haskell on Reddit - Thu, 04/23/2015 - 12:10pm

While trying to answer this SO question, I stumbled upon a Nat equality constraint solver plugin I had never seen before, made by Christiaan Baaij.

I haven't seen any announcements for it, so I thought the community might find it interesting.

It allows us to do exactly what the author of the SO question had in mind, namely solve the equality ((n1 + n2) - 1) ~ ((n1 - 1) + n2) which I find extremely powerful compared to what I've seen earlier.

With apologies to the author of the question, here is the working example:

{-# LANGUAGE RankNTypes #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise #-} import GHC.TypeLits data List (n :: Nat) a where Nil :: List 0 a (:>) :: a -> List n a -> List (n + 1) a infixr :> append :: forall n1 n2 a. ((n1 + n2) - 1) ~ ((n1 - 1) + n2) -- Explicit constraint unnecessary! => List n1 a -> List n2 a -> List (n1 + n2) a append Nil ys = ys append (x :> xs) ys = x :> append xs ys foo :: List 2 Integer foo = 1 :> 2 :> Nil

And according to the Haddocks, much more impressive things are possible and practical!

submitted by srhb
[link] [5 comments]
Categories: Incoming News

ANN: dns-server: forward DNS queries to StatDNS RESTAPI

haskell-cafe - Thu, 04/23/2015 - 11:41am
Bad news: ISP is intercepting packets to UDP port 53. Good news: There is DNS resolution over HTTP (http://www.statdns.com/api/). Bad news: The software bridging DNS clients and that HTTP service is missing. Good news: I made (a small but working part of) it. I've been using it on my computer. The code is here: https://github.com/edom/dns-server
Categories: Offsite Discussion

Providing a beginner platform to Haskell

Haskell on Reddit - Thu, 04/23/2015 - 10:35am

Hello fellow Haskellers,

I'm a CompSci student from Belgium and picked up Haskell about half a year ago in a course on declarative programming languages. Since then, I got really interested in the language and started attending the User Group meetings at my university. Struggling with the concepts there, I decided to restart my learning from zero.

I found the tutorial of bitemyapp on GitHub and I am working my way through it. I feel lucky I have read LYAH and had lectures of my own, but I feel that for someone without those extra's, picking up knowledge and experience from the reading material there can be quite a hard task.

Therefor I decided to put all my solutions to the homeworks online (on my GitHub) together with a ReadMe explaining the thought process behind the exercises.

My question now has 2 parts. First off, are there any legal problems with this? I'm re-using other people's material, although I credit them (for now it's just Brent Yorgey, but everything I learn, every exercise I make will be on there).
Secondly I'm open to criticism. What do you think of my coding and writing style? You can read a first mini-tutorial at CIS 194/Homework 1. (I have to finish that tutorial and rewrite a few parts of my code to match the tutorial. Also, should I document my code or would the ReadMe be enough?)

Thanks in advance

submitted by MusicalWatermelon
[link] [14 comments]
Categories: Incoming News

Extended Deadline (May 1), VSTTE'15

General haskell list - Thu, 04/23/2015 - 10:05am
********************************************************************** 7th Working Conference on Verified Software: Theories, Tools, and Experiments July 18 - 19, 2015 San Francisco, California, USA http://www.eecs.berkeley.edu/vstte15 Co-located with 25th Conference on Computer Aided Verification (http://i-cav.org/2015) ********************************************************************** Abstract submission: Extended to April 27, 2015 Full Paper Submission Deadline: Extended to May 1, 2015 SCOPE: The Seventh Working Conference on Verified Software: Theories, Tools, and Experiments follows a successful inaugural working conference at Zurich in 2005 followed by conferences in Toronto (2008), Edinburgh (2010), Philadelphia (2012), Atherton (2013), and Vienna (2014). The goal of this conference is to advance the state of the art in the science and technology of software verification, through the interaction of theory development, tool evolution, and experimental validation. We welcome submissions descri
Categories: Incoming News

New haddocks on Hackage now have links to instance sources!

Haskell on Reddit - Thu, 04/23/2015 - 9:01am

I noticed this while browsing the haddocks for Earley -- check out those lovely "Source" links next to "instance Functor (Prod r e t)"... it's beautiful!

submitted by dmwit
[link] [15 comments]
Categories: Incoming News

[FUN] Cheryl's birthday; solved using Haskell/SBV

haskell-cafe - Thu, 04/23/2015 - 3:20am
For those of us who'd rather have Haskell do the thinking for us: https://gist.github.com/LeventErkok/654a86a3ec7d3799b624 Honestly, this is more an exercise in how to formalize such puzzles as opposed to demonstrating the capabilities of SBV or SMT-solvers in general; but fun nonetheless. The backend SMT solver (I used Z3) solves the puzzle instantly. Enjoy.. -Levent. PS. Thanks to Amit Goel for suggesting the formalization strategy used in the encoding. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

"Cogito, ergo sum"

Haskell on Reddit - Thu, 04/23/2015 - 1:48am

I am not a number: I am a free variable. -- Conor McBride

I am not a free variable, I am a free monad! -- Edward Kmett

Wikipedia states:

Informally, a free object over a set A can be thought as being a "generic" algebraic structure over A: the only equations that hold between elements of the free object are those that follow from the defining axioms of the algebraic structure.

Let (C,F) be a concrete category (i.e. F: C → Set is a faithful functor), let X be a set (called basis), A ∈ C an object, and i: X → F(A) a map between sets (called canonical injection). We say that A is the free object on X (with respect to i) if and only if they satisfy this universal property:

for any object B and any map between sets f: X → F(B), there exists a unique morphism g: A → B such that f = F(g) o i.

In this way the free functor that builds the free object A from the set X becomes left adjoint to the forgetful functor.

There are several ideas running interleaved through my head at the moment (in no particular order):

  • Vectors, lists, trees, complex numbers, "7 trees in one"
  • Combinatorial species, calculi, "programming" languages
  • Conor's answer about cursors and comonads [1] (and his thesis...)
  • Monads joining, duplicating, returning, (aka "binding"), extracting (aka "cojoining"), Clowns and Jokers, Leibniz (and "Triples" :P)
  • Adjoints, adjucnctions, holes, continuations, representations, Yoneda, Kan extensions, machines, and homotopy
  • "All concepts are Kan extensions"
  • Points, lines, circles, Euclid and Cartesian-ness
  • Completeness, incompleteness, and causality
  • Logic, type theory, syntax, semantics, Truth, and communication
  • Peter Hancock's "AMEN" paper, logarithms, Church Numeral / Turing Machine duality, specifically "And so, lambda-calculus and Turing machine are duals: In a (universal) TM, an integer encodes an operation. In lambda-calculus, an operation encodes an integer." Numerals and lists in lambda-calculus: P-numerals
  • Church vs. Curry typing and other paradigmatic "dualities"
  • Lawvere's fixed point theorem, Yanofsky's exposition, and "heterological"
  • Lenses, prisms, isos, traversals, and telescopes.
  • What the Tortoise said to Achilles.
  • Terminology is a minefield
  • How, where, when, why, to what, to who any of these things matter (theoretically, pedagogically, and practically) and their "connections"?
  • Whether this is all just a bunch of abstract nonsense and should forget about it?
  • Much else
  • Last, but certainly not least, bad puns :)

Just thinking out loud... Other than that, just thought I would stop by and say hello. I'll be updating with other references if anyone else is interested. Anyhow, back to the trenches.

[1]: Writing cojoin or cobind for n-dimensional grid type "Jagger/Richards: you can't always get what you want, but if you try sometime you just might find that you get what you need."

submitted by ShadowyOrdeal
[link] [1 comment]
Categories: Incoming News

Python anti-patterns are mostly all solved by Haskell

Haskell on Reddit - Thu, 04/23/2015 - 12:27am

I ran across this in /r/python today:

http://www.reddit.com/r/Python/comments/33h964/the_little_book_of_python_antipatterns/

I thought it was a very good collection of anti-patterns. But I also realized that the vast majority of those anti-patterns, the bits of code you should not write, are impossible to write in Haskell, and this made me feel a bit smug.

This is not really news, because static typing solves so many problems that duck-typed languages create. But some of the items that stood out to me were:

You can educate your developers to avoid these anti-patterns, or you could use just use a statically typed language and have the type checker enforce these rules for you.

It blows my mind that anyone would even consider using Python for large software projects, or anything apart from simple ad-hoc scripting to automate simple day-to-day tasks.

submitted by Ramin_HAL9001
[link] [14 comments]
Categories: Incoming News