News aggregator

deriving clauses' instance context algorithm?

Haskell on Reddit - Thu, 03/05/2015 - 3:20pm

Some background info: I'm currently developing text-show, which is intended to be a drop-in replacement for Show that uses Text instead of String. text-show can be used just about anywhere that regular Show can with one notable exception: deriving Show clauses.

Currently, I have a Template Haskell–based module in text-show that has a function (deriveShow) that can simulate a deriving Show clause. It turns out the hardest part (that I haven't fully figured out) is figuring out the instance context that would be generated.

For most ADTs, this is pretty simple to infer. For example, data ADT = ADT deriving Show would generate instance Show ADT where ..., and data ABC a b c = A a | B b | C c deriving Show would generate instance (Show a, Show b, Show c) => Show (ABC a b c) where .... However, there are a number of corner cases that make this analysis difficult:

  1. Phantom types. For example, data Phantom a b c = Phantom b deriving Show generates instance Show b => Show (Phantom a b c) where ....
  2. Higher-kinded type parameters. For example, data HK f a = HK (f a) deriving Show generates instance Show (f a) => Show (HK f a) where ...
  3. Restricted Show instances. For example, if you have data Restriction a = Restriction a with a Show instance like instance (Show a, Read a) => Show (Restriction a) where ..., then as a result, data Wrapper a = Wrapper (Restriction a) deriving Show generates instance (Show a, Read a) => Show (Wrapper a) where ...

Trying to come up with an algorithm to infer the instance context for all cases seems pretty daunting, and unfortunately, the Haskell 98 Report is pretty vague about the implementation of deriving clauses. Yet clearly it's been implemented before, as GHC is evidence of.

My question is: is there either a paper which describes how this aspect of deriving clauses are implemented, or an existing Haskell package that solves this problem with Template Haskell? Most of the packages I've looked at (derive, aeson, th-lift, etc.) all choke on at least one of the above corner cases.

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

{-# LANGUAGE DeriveApplicative #-} ?

Haskell on Reddit - Thu, 03/05/2015 - 2:26pm

So there I was, generalizing a record type full of Text fields so that it could hold Maybe Text fields, Just representing an update to that field, Nothing representing no change.

data Rec a = Rec { recField1 :: a, recField2 :: a, recField3 :: a } updateRec :: Rec Text -> Rec (Maybe Text) -> Rec Text updateRec old new = Rec { recField1 = fromMaybe (recField1 old) (recField1 new), recField2 = fromMaybe (recField2 old) (recField2 new), recField3 = fromMaybe (recField3 old) (recField3 new) }

Noticing a pattern, I realized this was just "zipWith" over my record type. I found myself wishing for a "Zippy" class.

-- Seems like there should be a class for this zipRecWith :: (a -> b -> c) -> Rec a -> Rec b -> Rec c zipRecWith f ra rb = Rec { recField1 = f (recField1 ra) (recField1 rb), recField2 = f (recField2 ra) (recField2 rb), recField3 = f (recField3 ra) (recField3 rb) } updateRec :: Rec a -> Rec (Maybe a) -> Rec a updateRec = zipRecWith fromMaybe

Then I realized that the class I was wishing for was Applicative, and I just had a zippy instance.

instance Applicative Rec where pure a = Rec { recField1 = a, recField2 = a, recField3 = a } rf <*> ra = Rec { recField1 = (recField1 rf) (recField1 ra), recField2 = (recField2 rf) (recField2 ra), recField3 = (recField3 rf) (recField3 ra) } zipRecWith :: (a -> b -> c) -> Rec a -> Rec b -> Rec c zipRecWith = liftA2 updateRec :: Rec a -> Rec (Maybe a) -> Rec a updateRec = liftA2 fromMaybe

That instance is really boilerplatey. Surely someone has written an automatic derivation for such instances? (I realize that not all data declarations lend themselves to an automatically-derived instance of Applicative.)

[edit] further thoughts as provoked by yitz

class Traversable t => Zippable t where zipWithA :: Applicative f => (a -> b -> f c) -> t a -> t b -> f (t c) zipWithA k fa fb = sequenceA (zipWith k fa fb) zipWith :: (a -> b -> c) -> t a -> t b -> t c -- default impl of zipWith using the Identity applicative and zipWithA -- left as exercise for reader

See also: https://mail.haskell.org/pipermail/haskell-cafe/2009-July/064403.html

submitted by drb226
[link] [43 comments]
Categories: Incoming News

bittorrent-based Tor pluggable transport in Haskell

Haskell on Reddit - Thu, 03/05/2015 - 1:48pm

Hey,

I've been working on a pluggable transport for Tor written in haskell. A pluggable transport is an obfuscation tunnel for network traffic meant to help a user avoid network censorship and surveillance.

https://github.com/danoctavian/bit-smuggler

BitSmuggler uses BitTorrent as cover traffic and uses real bittorrent clients to generate realistic traffic patterns. I'm currently debating with ppl on tor-dev about the security of the solution, so stopped developing for a while to get some feedback on the approach.

Although BitTorrent as cover has a few nice properties, it's quite troublesome to control well and, to get real-time tunneling, you need to break the integrity of the file being transferred over the network (break the checksums specified in the .torrent file) so there are questions about using it in situations where compromising its undetectability is a life threatening for the user.

I thought you might find it interesting. Any feedback on the code or the design of the project or suggestions on how it can be used are greatly appreciated.

Thanks! dandroid

submitted by dandroid3000
[link] [7 comments]
Categories: Incoming News

Design of protocol implementation?

haskell-cafe - Thu, 03/05/2015 - 12:42pm
By now I've written a couple of implementations of (reply / response) protocols in Haskell. They all basically follow the same pattern: 1. One message type with a constructor for each, e.g. data Message = PingMsg | ... 2. One reply type with a constructor for each, e.g. data Reply = PingReply | ... 3. Any message or reply containing data has a constructor taking an argument of a type for that data, e.g. data Message = ... | SendDataMsg SendDataD | ... data SendDataD = SendDataD ByteString 4. The raw data is received from somewhere and passed through a parser written using attoparsec. 5. The messages are rendered into ByteString using ByteString.Builder. So, in essence something like this: +------+ +----------+ +-------+ +------------+ +------+ | read | --> | parse | --> | stuff | --> | render | --> | send | | raw | | into | +-------+ | to | | raw | +------+ | Messages | | ByteString |
Categories: Offsite Discussion

CFP: Workshop on Generic Programming 2015 - Deadline May15

General haskell list - Thu, 03/05/2015 - 12:10pm
====================================================================== CALL FOR PAPERS WGP 2015 11th ACM SIGPLAN Workshop on Generic Programming Vancouver, Canada Sunday, August 30, 2015 http://www.wgp-sigplan.org/2015 Co-located with the International Conference on Functional Programming (ICFP 2015) ====================================================================== Goals of the workshop --------------------- Generic programming is about making programs more adaptable by making them more general. Generic programs often embody non-traditional kinds of polymorphism; ordinary programs are obtained from them by suitably instantiating their parameters. In contrast with normal programs, the parameters of a generic program are often quite rich in structure; for example they may be other programs, types or type constructors, class hierarchies, or
Categories: Incoming News

Haskell projects looking for contributors?

Haskell on Reddit - Thu, 03/05/2015 - 11:34am

Is there a place where project maintainers that would like to get more contributors to their projects can indicate so? Alternatively, can you post here about projects that could do with some love? People that would like to do some open source Haskell can of course search on Hackage and Github for projects that may interest them, but knowing that some of these projects actively want helpers may encourage some to participate. Thanks!

submitted by JPMoresmau
[link] [29 comments]
Categories: Incoming News

HaskVan/HaskellKoans · GitHub

del.icio.us/haskell - Thu, 03/05/2015 - 11:05am
Categories: Offsite Blogs

HaskVan/HaskellKoans · GitHub

del.icio.us/haskell - Thu, 03/05/2015 - 11:05am
Categories: Offsite Blogs

[TFPIE 2015] 2nd call for papers

haskell-cafe - Thu, 03/05/2015 - 10:09am
Trends in Functional Programming in Education (TFPIE 2015) 2nd Call for papers https://wiki.science.ru.nl/tfpie/TFPIE2015 The 4th International Workshop on Trends in Functional Programming in Education, TFPIE 2015, will be held on June 2, 2015 in Sophia-Antipolis in France. It is co-located with the Symposium on Trends in Functional Programming (TFP 2015) which takes place from June 3 - 5. *** Goal *** The goal of TFPIE is to gather researchers, teachers and professionals that use, or are interested in the use of, functional programming in education. TFPIE aims to be a venue where novel ideas, classroom-tested ideas and work-in-progress on the use of functional programming in education are discussed. The one-day workshop will foster a spirit of open discussion by having a review process for publication after the workshop. The program chair of TFPIE 2015 will screen submissions to ensure that all presentations are within scope and are of interest to particip
Categories: Offsite Discussion

[TFPIE 2015] 2nd call for papers

General haskell list - Thu, 03/05/2015 - 10:08am
Trends in Functional Programming in Education (TFPIE 2015) 2nd Call for papers https://wiki.science.ru.nl/tfpie/TFPIE2015 The 4th International Workshop on Trends in Functional Programming in Education, TFPIE 2015, will be held on June 2, 2015 in Sophia-Antipolis in France. It is co-located with the Symposium on Trends in Functional Programming (TFP 2015) which takes place from June 3 - 5. *** Goal *** The goal of TFPIE is to gather researchers, teachers and professionals that use, or are interested in the use of, functional programming in education. TFPIE aims to be a venue where novel ideas, classroom-tested ideas and work-in-progress on the use of functional programming in education are discussed. The one-day workshop will foster a spirit of open discussion by having a review process for publication after the workshop. The program chair of TFPIE 2015 will screen submissions to ensure that all presentations are within scope and are of interest to particip
Categories: Incoming News

Clay: Request for new maintainer

Haskell on Reddit - Thu, 03/05/2015 - 3:22am

Hello, I'm the author and current maintainer of Clay, your favorite Haskell EDSL for writing CSS stylesheets. The github project for Clay receives a moderate number of pull requests every now and then, which makes me believe people actually use the tool and some might even like it.

Luckily, merging pull requests and doing the occasional release for now hasn't been much work. But, I don't use the project myself at all, and therefor don't have a very strong opinion about its future direction. I don't want to just abandon the project, but I don't find myself in a position lately to spend much time on it either.

If there is anyone who enjoys working with Clay and wants to contribute to it, take over, or help with maintenance and releases, I'd love to hear it.

As a side note: anyone that uses Clay (or has used it in the past) who has feedback on the project, I'd love to hear that as well. As an author, it's very hard to put an open source project into context. I've no idea how many people use it and how it's received.

Thanks!

submitted by sfvisser
[link] [13 comments]
Categories: Incoming News

Haskell on RedHat?

haskell-cafe - Wed, 03/04/2015 - 11:01pm
What is the recommended route for installing a recent GHC on RedHat Enterprise Linux? All I could find on the official haskell.org Web pages is a GHC 7.8.4 repository for Fedora 21. Also, are there any potential difficulties with deploying a Haskell executable compiled on an Ubuntu system to RedHat EL, or vice versa? Thank you.
Categories: Offsite Discussion

Haskell Weekly News

haskell-cafe - Wed, 03/04/2015 - 9:44pm
*Top picks:* Jasper Van der Jeugt <http://jaspervdj.be/posts/2015-02-24-lru-cache.html> shows how you can write an intuitive, obviously correct LRU cache perfectly polymorphic in both the key and value types of the cache lookup function. (Reddit discussion.) <http://www.reddit.com/r/haskell/comments/2wz4tj/writing_an_lru_cache_in_haskell/> Core is broken! Well, no, ticket 9858 <https://ghc.haskell.org/trac/ghc/ticket/9858> reported previously is still open, and it's about translating an exotic species of Haskell into Core. But Javran Cheng <https://ghc.haskell.org/trac/ghc/ticket/10121> found out that the documented specification of Core's operational semantics is incomplete. Neil Mitchell <http://neilmitchell.blogspot.com/2015/02/making-withsocketsdo-unnecessary.html> removes the error-prone wart of withSocketsDo <http://hackage.haskell.org/package/network-2.6.0.2/docs/Network.html#v:withSocketsDo> in Windows network programming. Moving in for the kill is the triple combo of evaluate, NOINLINE, and unsafe
Categories: Offsite Discussion

Haskell 2015: 2nd Call for Papers

haskell-cafe - Wed, 03/04/2015 - 2:33pm
===================================================================== ACM SIGPLAN CALL FOR SUBMISSIONS Haskell Symposium 2015 Vancouver, Canada, 3-4 September 2015, directly after ICFP http://www.haskell.org/haskell-symposium/2015 ===================================================================== ** The Haskell Symposium has an early track this year ** ** See the Submission Timetable for details. ** The ACM SIGPLAN Haskell Symposium 2015 will be co-located with the International Conference on Functional Programming (ICFP 2015) in Vancouver, Canada. The Haskell Symposium aims to present original research on Haskell, discuss practical experience and future development of the language, and to promote other forms of denotative programming. Topics of interest include: * Language Design, with a focus on possible extensions and modifications of Haskell as well as critical discussions of the status quo; * Theory, such as f
Categories: Offsite Discussion

How do I upload documentation to Hackage

Haskell on Reddit - Wed, 03/04/2015 - 2:01pm

I'm the author of, amongst other things, the geodetics package on Hackage. It seems that Hackage has now stopped doing automatic builds, but on the upload page it says that "Documentation for library packages should be generated by a maintainer. The means of doing this is still up in the air."

So how do I get Haddock docs on to Hackage?

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

ANN: ZuriHac 2015: registration is open

haskell-cafe - Wed, 03/04/2015 - 12:35pm
Hi everybody, it is my pleasure to announce that the registration for ZuriHac 2015 <https://wiki.haskell.org/ZuriHac2015> is open now. If you want to participate in this year's Haskell Hackathon in Zurich, please fill out this form <http://goo.gl/forms/L24NgFRvCw>. Make sure to wait for a confirmation email afterwards before booking. The event can only host around 90 participants. We will confirm registrations at a first come first served basis. Please spread the word. Hope to see you soon! Alex _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

How do you learn a library that has no documentation or tutorials?

Haskell on Reddit - Wed, 03/04/2015 - 12:33pm

I'm a Haskell novice. I have learned a few small libraries, like gloss, and feel comfortable referencing their raw Hackage documentation. However, larger libraries like Parsec (which is actually relatively small, right?) are hard for me to gain an understanding of.

I'm working through "Write Yourself a Scheme" and I understand the Haskell concepts, but don't understand what all the Parsec functions, like many, many1, oneOf, etc. I looked up the Hackage documentation for Parsec, but it seems to be a random collection of functions and modules. It is larger and more complex than other libraries I have learned. I'm sure learning new libraries will become easier with experience.

That's a bit of background. I don't want to ask about Parsec specifically, so setting my situation aside:

Does anyone have suggestions on how to approach a Haskell library that has little or no documentation or tutorials? It seems most libraries have at least a sentence or two describing each function, but how should I approach what seems like a random list of functions?

submitted by Buttons840
[link] [35 comments]
Categories: Incoming News