News aggregator

Detecting type errors with GHCi commands?

Haskell on Reddit - Sat, 01/09/2016 - 5:36am

I do a lot of exploratory coding in GHCi, and as such, I'm tinkering with a script to persist definitions across GHCi sessions and reloads like so:

*> :sr narp = putStrLn "Narp!" *> :do m <- return "Ok" *> narp Narp! *> m "Ok" *> :q ...>ghci *> :ls *> narp Narp! *> m "Ok"

... and I've run into a snag. If I use :sr to define a function which does not type check, I still persist it. Now, I do have a :dl command to delete the last definition persisted with :sr, but that is subject to human error. Is there any fairly simple trick I'm overlooking that would let me catch this automatically?

Alternatively, is there something that already does this so I don't have to?

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

Is there any tutorial about the reducers package ?

Haskell on Reddit - Sat, 01/09/2016 - 3:32am

The question is in the title. I know that with the reducers, I can transform

getSum $ mconcat (map Sum xs)

to something like getSum $ reduce?? xs


??? getSum xs

But it always take me half an hour to figure out which import to do and which function to call. This package seems great though.

In the example I gave, it doesn't look really usefull, but it is when you reducing tuples and could do thing like

(getSum a, getSum b, getMax c) = reduce??? [(1,2,3), (4,5,6)] submitted by maxigit
[link] [2 comments]
Categories: Incoming News

Why is Apply defined as `forall a b. f (a -> b) -> f a -> f b`?

Haskell on Reddit - Fri, 01/08/2016 - 9:42pm

Even after years of programming in Haskell, I always get hung up on this when implementing Applicative or Apply for some type.

I get that <*> has this signature to allow the SomeConstructor <$> foo <*> bar pattern which is definitely useful. But why are applicative functor instances defined in this specific pattern, when, for example, forall a b. f a -> f b -> f (a, b) is isomorphic and may be easier to grok (given that there are similar patterns in other languages, for example Promise.all in JavaScript)?

Is it this way because of historic reason, is there a benefit to the former representation (performance?), or is it purely arbitrary?

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

What do you call this kind of type inference

Haskell on Reddit - Fri, 01/08/2016 - 8:38pm

(Spinning off from this post on g+)

So given

data Proxy (t :: k) = Proxy proxify :: forall c. (forall a. c a => a -> String) -> Proxy c proxify _ = Proxy

GHC-7.8.2 can confirm my type inferences for applications of proxify:

λ :t proxify show :: Proxy Show proxify show :: Proxy Show :: Proxy Show λ :t proxify id :: Proxy ((~) String) proxify id :: Proxy ((~) String) :: Proxy ((~) String)

But can't make those predictions itself:

λ :t proxify show <interactive>:1:9: Could not deduce (Show a) arising from a use of ‘show’ from the context (c a) ... λ :t proxify id <interactive>:1:9: Could not deduce (a ~ String) from the context (c a) ...

My problem isn't that GHC can't do it (maybe GHC-7.10 can), so much as I don't even know how to describe this kind of type inference.

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

What is the current state of ghci or any editor documentation tools?

Haskell on Reddit - Fri, 01/08/2016 - 7:17pm

Problem: I think everyone guessed from the title, but maybe my language is bad and ambiguous. Well, for example you use :browse Data.List and found dropWhile which sounds like what you need, but there is also dropWhileEnd with same type. To see difference you open hoogle, search by name, search in list, read the docs. There should be something faster, like command line tool and something smart enough to get documentation for current entity. Example: python's "help" function. My search of solution was difficult, because there is a lot of noise: people recommend to use type information and hoogle instead of documentation, but it is addition to documentation - not replacement.

Possible solutions:

  • As far as I discovered - there is the ticket for haddock documentation in ghci - it is sounds nice but it is 8 years old. 10 month ago was posted two nice comments and priority changed to normal, but it means nothing. Is there any published plans about .hi metadata?
  • hoogle. Well, it is nice cli search tool, can I somehow specify package, open item in browser?
  • dash, zeal. I am found two tools ( and ) for generating docsets from cabal (second tool using stack) packages. Zeal have command line util, so may be used from ghci. Also zeal may specify package. I'm not tried yet, but it is very close to that I want and still can't be used with loaded entities - only manual typing.
  • Haddock have api!. Which used in two tools above. And also in leksah (someone using lesah? any documentation support for entity under cursor?).

What I want to know:

  • anyone has a better solution? (any solution)
  • anyone want a better solution?
  • is it possible to solve the problem? I am planning to spend some time for it. But as far as I can see there is no any interest or it is very hard (more then 8 years) task.

Probably developer of solution need to get current modules loaded in ghci and pass to haddock api and get entity by name.

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

Haskell Weekly News

General haskell list - Fri, 01/08/2016 - 1:34pm
Folks: Recall the quote from the May Day 2015 issue: <> The MLs and Haskell remind me of Brian Eno's line about how the first Velvet Underground album only sold 30,000 copies, but "everyone who bought one of those 30,000 copies started a band". This issue spotlights Elm and Idris, two languages implemented in Haskell. Enjoy! *Top Picks:* - Evan Czaplicki of the Elm web-front-end language leaves Prezi for NoRedInk <>. A startup dedicated to improving high-school English grammar, NoRedInk already employs 5 engineers writing Elm full-time. A HN comment hyperbolizes that Elm <> "is Clojure without parens, it's Haskell without academy, it's Redux without facebook, it's duck-typing without quacks, it's MVC without objects, and last but not least Evan Czaplicki (the creator) is the new Aaron Patterson (bright a
Categories: Incoming News

Data declaration vs type classes

haskell-cafe - Fri, 01/08/2016 - 11:55am
Dear haskellers, What is the difference between writing data Task = GroceryTask String | LaundryTask Int doTask :: Task -> IO () doTask (GroceryTask s) = print "Going to " ++ s doTask (LaundryTask n) = print (show n ++ " pieces washed" and class Task a where work :: a -> IO () data GroceryTask = GroceryTask String data LaundryTask = LaundryTask Int instance Task GroceryTask where .. instance Task LaundryTask where .. doTask :: Task a => a -> IO () doTask = work They seem to be similar functionality wise, except that one is on the data level and another is on the class level. How should one go about deciding to use data or class? Is there a semantic difference? Which is more appropriate here? Happy new year, Hon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >
Categories: Offsite Discussion

New gtk2hs 0.12.4 release

gtk2hs - Wed, 11/21/2012 - 12:56pm

Thanks to John Lato and Duncan Coutts for the latest bugfix release! The latest packages should be buildable on GHC 7.6, and the cairo package should behave a bit nicer in ghci on Windows. Thanks to all!


Categories: Incoming News