News aggregator

The "What Are Monads?" Fallacy

Haskell on Reddit - Thu, 01/01/2015 - 9:19pm
Categories: Incoming News

Continuing the "monad definition quest" ...

Haskell on Reddit - Thu, 01/01/2015 - 8:02pm

Continuing this discussion, I came across this definition in Wikipedia:

In functional programming, a monad is a structure that represents computations defined as sequences of steps: a type with a monad structure defines what it means to chain operations, or nest functions of that type together. This allows the programmer to build pipelines that process data in steps, in which each action is decorated with additional processing rules provided by the monad.

While obvious not an ELI5 version, is this a correct definition for when Haskell uses the term?

submitted by AlexKingstonsGigolo
[link] [23 comments]
Categories: Incoming News

Ken T Takusagawa: [okucbyxc] Happy 2015!

Planet Haskell - Thu, 01/01/2015 - 7:09pm

The factorial of 2015 expressed in base 147 gives a nice random-looking blob of symbols. (Ironically, it ends in even more exclamation points.) We use the wbr HTML tag to break lines to the width of your browser window. See source code in Haskell. Naive radix conversion is an unfold, though divide and conquer would be more efficient.

radix_convert :: Integer -> Integer -> [Integer];
radix_convert base = unfoldr $ \n -> if n==0 then Nothing else Just $ swap $ divMod n base;

The 147 digits are a subset of Latin-1: !<wbr>#<wbr>$<wbr>%<wbr>&<wbr>(<wbr>)<wbr>*<wbr>+<wbr>-<wbr>/<wbr>0<wbr>1<wbr>2<wbr>3<wbr>4<wbr>5<wbr>6<wbr>7<wbr>8<wbr>9<wbr>:<wbr>;<wbr><<wbr>=<wbr>><wbr>?<wbr>@<wbr>A<wbr>B<wbr>C<wbr>D<wbr>E<wbr>F<wbr>G<wbr>H<wbr>I<wbr>J<wbr>K<wbr>L<wbr>M<wbr>N<wbr>O<wbr>P<wbr>Q<wbr>R<wbr>S<wbr>T<wbr>U<wbr>V<wbr>W<wbr>X<wbr>Y<wbr>Z<wbr>[<wbr>\<wbr>]<wbr>^<wbr>a<wbr>b<wbr>c<wbr>d<wbr>e<wbr>f<wbr>g<wbr>h<wbr>i<wbr>j<wbr>k<wbr>l<wbr>m<wbr>n<wbr>o<wbr>p<wbr>q<wbr>r<wbr>s<wbr>t<wbr>u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!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!<wbr>!

Categories: Offsite Blogs

Haskell REST Library/Server Breakdown

Haskell on Reddit - Thu, 01/01/2015 - 4:46pm

Recently, a lot of REST libraries and servers have been popping up. They don't all do the same exact thing but they're in the same family of utilities (listed roughly in reverse chronological order):

Has anyone had experience with more than just one of these? I'd love a breakdown of how they compare and contrast as well as the nutshell value proposition of each. Where does each library or server shine? Comments from what motivated the authors to not simply use what was already out there would be great. Thanks guys!

submitted by LukeHoersten
[link] [8 comments]
Categories: Incoming News

Roman Cheplyaka: Lexical analysis with parser combinators

Planet Haskell - Thu, 01/01/2015 - 4:00pm

When writing a programming language parser in Haskell, the usual dilemma is whether to use lexer/parser generators (Alex+Happy), or make a single parser (using a parser combinator library like Parsec) without an explicit tokenizer.

In this article, I’ll explain why you may want to use a separate lexer built with applicative parser combinators, and how you might go about writing one.

Alex

Alex, the Haskell lexer generator, is a nice tool, but it has a weakness. With Alex, you cannot observe the internal structure of a token.

The most common instance of this problem is parsing string interpolation, think "Hello, ${name}!". Such a string is a single token, yet it has some internal structure to it. To analyze this with Alex, you’ll probably need to have two different lexers, and run one inside the other.

Another instance is date literals (useful for many DSLs), such as 2015-01-02 (or d"2015-01-02" to avoid confusion with infix subtraction.) You can recognize such a literal with an Alex regular expression $d+\-$d+\-$d+. However, you won’t be able to get hold of the individual $d+ pieces — Alex regexps lack capture groups. So you’ll need to use a separate date parsing function to parse the same string second time.

Parsec

On the other hand, we have parser combinators that solve this problem nicely. You define parsers for numbers; then you glue them with dashes, and you get a parser for dates.

However, using Parsec (or similar) without a separate lexer is not the best choice:

  1. Dealing with whitespace and comments is awkward in the parser; you need to wrap everything in a token combinator. (If you decide to do that, at least use a free applicative functor to ensure that you don’t forget to consume that whitespace).

  2. Separating parsing into lexical and syntax analysis is just a good engineering practice. It reduces the overall complexity through «divide and conquer». The two phases usually have well-defined responsibilities and a simple interface — why not take advantage of that?

  3. If a language needs the maximal munch rule, it’s hard to impossible to encode that with Parsec or similar libraries.

  4. Tokens enable the syntax analyzer to report better errors. This is because you can tell which token you didn’t expect. In a Char-based Parsec parser, you can only tell which character (or an arbitrary number of characters) you didn’t expect, because you don’t know what constitutes a token.

  5. Potential performance considerations. If a parser has to try several syntax tree alternatives, it reparses low-level lexical tokens anew every time. From this perspective, the lexical analyzer provides a natural «caching layer».

regex-applicative

My regex-applicative library provides applicative parser combinators with regexp semantics. We can write a simple lexer on top of it that would give us the benefits of both Alex and Parsec.

{-# LANGUAGE OverloadedStrings, OverloadedLists #-} import qualified Data.Text as T import qualified Data.HashSet as HS import Text.Regex.Applicative import Text.Regex.Applicative.Common (decimal) import Data.Char import Data.Time

For example, here’s a parser for dates. (For simplicity, this one doesn’t check dates for validity.)

pDate :: RE Char Day pDate = fromGregorian <$> decimal <* "-" <*> decimal <* "-" <*> decimal

And here’s a parser for templates — strings that may include interpolated variables and escaping.

pTemplate :: RE Char [Either T.Text T.Text] -- Left = text, Right = variable pTemplate = "\"" *> some piece <* "\"" where -- piece of text or interpolated variable piece = (Left . T.pack <$> some ch) <|> (Right <$> var) -- interpolated variable var = "${" *> pVar <* "}" -- normal character, plain or escaped ch = psym (\c -> not $ c `HS.member` escapable) <|> ("\\" *> psym (\c -> c `HS.member` escapable)) -- set of escapable characters escapable = ['"', '\\', '$'] pVar = T.pack <$> some (psym isAlpha)

Individual parsers are merged into a single pToken parser:

data Token = Template [Either T.Text T.Text] | Date Day -- | ... pToken :: RE Char Token pToken = (Template <$> pTemplate) <|> (Date <$> pDate) -- <|> ...

Finally, a simple tokenizing function might look something like this:

tokens :: String -> [Token] tokens "" = [] tokens s = let re = (Just <$> pToken) <|> (Nothing <$ some (psym isSpace)) in case findLongestPrefix re s of Just (Just tok, rest) -> tok : tokens rest Just (Nothing, rest) -> tokens rest -- whitespace Nothing -> error "lexical error"

The resulting token list can be further parsed with Parsec or Happy.

This simple function can be extended to do a lot more:

  1. Track position in the input string, use it for error reporting, include it into tokens
  2. Consume input incrementally
  3. Get feedback from the syntax analyzer, and, depending on the syntactic context, perform different lexical analyses. This is useful for more complex features of programming languages, such as the off-side rule in Haskell or arbitrarily-nested command substitution and «here documents» in POSIX Shell. (This is another thing Alex cannot do, by the way.)
Categories: Offsite Blogs

Call Me ..

Haskell on Reddit - Thu, 01/01/2015 - 3:21pm
Categories: Incoming News

What would be the effects of something like "The Machine" for Haskell and for the market?

Haskell on Reddit - Thu, 01/01/2015 - 3:09pm

AFAIK, The Machine is a (very suspect) endeavor from HP to bring a 1 PB memory with ~100ns delay random access. If I am not mistaken, one of the reasons purely functional programming is slower than imperative programming in many cases is the old lists vs array debate, and the whole "bad cache use" issue. Such a machine would make this argument moot, sequential arrays pointless and tree-based structures fast enough. How would that affect Haskell?

submitted by SrPeixinho
[link] [4 comments]
Categories: Incoming News

What is a monad?

Haskell on Reddit - Thu, 01/01/2015 - 1:00pm

Does anyone have an ELI5 explanation of what monads are?

submitted by AlexKingstonsGigolo
[link] [53 comments]
Categories: Incoming News

Functional Education

Haskell on Reddit - Thu, 01/01/2015 - 11:49am
Categories: Incoming News

Is literate Haskell a "dead" concept?

Haskell on Reddit - Thu, 01/01/2015 - 11:44am

After doing some poking around, I get the impression support for literate Haskell is kind of an abandoned idea; one which might have been popular ages ago but is now no longer used except by the most die-hard fans. Is this an accurate assessment? Should someone new to Haskell not expect support for literate Haskell now or in the future?

submitted by AlexKingstonsGigolo
[link] [23 comments]
Categories: Incoming News

How to use free theorems?

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

I am somewhat confused about how to apply the "free theorems" that arise from relational parametricity. For example, the free theorem for i :: a -> a is (I believe)

f . i_A == i_B . f

where i_A is i specialised to a = A and f :: A -> B.

It seems that for x :: A I can choose f = const x to deduce that x == i_A x and that i must be \a -> a. Is this a correct deduction?

I believe the free theorem for b :: a -> a -> a is

f (b_A a a') == b_B (f a) (f a')

How can I deduce that b is either const or flip const?

[EDIT: I really want results for System F rather than Haskell, so I don't care about _|_.]

submitted by tomejaguar
[link] [8 comments]
Categories: Incoming News

Is Haskell floating point potentially non-deterministic?

Haskell on Reddit - Thu, 01/01/2015 - 5:30am

Until recently, I believed floating point arithmetic was deterministic. At the hardware level, at least AFAIK, it is deterministic. However, using C or C++, floating point arithmetic really can be non-deterministic.

Part of the issue is "extra precision" - while values are kept in FPU registers they typically have more precision than the types indicate. This precision isn't deliberately discarded with each operation because (1) that's costs performance, and (2) the extra precision in intermediate results is considered beneficial for many purposes. However, when values are moved to main memory, the extra precision is discarded.

That in itself doesn't make calculations non-deterministic, but function calls can be inlined. Two separate calls to the same apparently referentially transparent function with the same arguments supplied can give two different results because different inline decisions resulted in the same function having two different target-code implementations, and because different register allocation and other optimisation decisions were made for those target-code implementations, so extra precision is retained/discarded differently - intermediate results may have different precisions for different calls of the same code.

So not only might you get different results on a different hardware platform, or on the same platform but with a different compiler, but you can get different results from during the same run of the program from different calls of the same source code with the exact same arguments.

So I was wondering if a principled decision on this issue had been made by Haskell. GHC certainly takes efficiency seriously, and certain Haskell extensions are specifically aimed at handling numeric code well - if competing with C for numeric efficiency is a goal, using all the same optimization tricks that C does must be tempting. At the same time, non-determinism seems an obvious breach of referential transparency - the same function given the same parameters can yield different results. Or maybe this is "morally pure" given that the value being approximated is still referentially transparent, and it's only the precision of the approximation that varies in a referentially opaque way?

submitted by ninereeds314
[link] [32 comments]
Categories: Incoming News

A common recommendation which has me worried

Haskell on Reddit - Wed, 12/31/2014 - 8:20pm

In a large number of posts/pages/discussions/etc., I keep seeing something along the lines of "When learning Haskell, if you don't understand something, ask on IRC." Something about this recommendation, which I see very often, feels irksome to me. To illustrate, when I wanted to learn how to program in Python, I picked up a Python book, read it and practiced the exercises until I felt comfortable with it, wrote increasing complex programs, and so on and so on. However, with Haskell, it feels as if the expected approach is "pick up a Haskell book, learn something, ask a question on IRC, hope someone is available to answer the question, hope that person knows the answer to answer the question, hope that person has the patience to answer that question, hope that person is not having a bad day, hope that person is not sick of you asking questions which should otherwise be pretty obvious, hope you don't become addicted to that person's kindness, hope others don't start seeing you as some sort of 'psychic leech', hope you recognize when you should stop asking questions and go back to the original text, and continue from there, repeating along the way". Now, maybe it's just me and maybe I am misinterpreting expectations but something about this perceived process strikes me as flawed. I am not familiar with any other arena where such an approach has ever worked in any sustainable fashion. Maybe I'm too attached to the idea of individual initiative but it just feels as if, if I were to take this (perceived) approach, I'm not going to feel/be any more than infantile with respect to Haskell programming and, having said it out loud, that really feels more discouraging than I expected it too. Am I the only one finding this approach troubling? Is there some aspect of this method I have somehow missed? I hope I don't seem appreciative of the willingness of others to help; I just know ... well ... I know me and how I get, so to speak. I know it is very very easy for me to become a "psychic leech" and I trying very hard to keep myself from doing so. It just feels as if the "ask on IRC" recommendation is just inviting "psychic leeches".

submitted by AlexKingstonsGigolo
[link] [25 comments]
Categories: Incoming News