News aggregator

Are there any tutorials (preferably in Haskell) about implementing a simple statically typed language?

Haskell on Reddit - Sun, 12/28/2014 - 3:39am

We all know about "Write your own Scheme in 48 hours", but what about a similar tutorial for implementing a simple typechecker? I think it would be interesting to see what it's like actually implementing a real type system.

submitted by SkoomaMudcrab
[link] [17 comments]
Categories: Incoming News

How to do exploratory programming?

Haskell on Reddit - Sun, 12/28/2014 - 12:11am

When I'm writing Python, I often ask the interpreter "what can I do with x" by typing x.<tab> in IPython. Then, if something looks useful, I'll verify that it does what I want by typing x.example_fn? and reading the documentation that comes up. If the function does what I need, I'll type y = x.example_fn(...) and repeat the process with y.

This works great for the following use cases:

  1. Learning to use a library
  2. Quickly hacking together automation scripts

Is there a way to mimic this workflow in Haskell? The closest I've found is checking the type of a variable, then querying Hoogle for functions involving that type.

Edit: A partial solution is to view the type (with :t), then see what type classes are implemented for the type (with :i). However, that doesn't help with discovering functions not defined in a type class.

submitted by sharewa
[link] [18 comments]
Categories: Incoming News

Beginner question: Sequentially and conditionally updating bits of state

Haskell on Reddit - Sat, 12/27/2014 - 6:27pm

Hey guys, after reading LYAH and some more tutorials I've decided to write my first program in Haskell. It's a very simple Uno game and buggy, but it works and coding it was fun, although there's a function which I'm very discontent with: gameRound which handles a single round (i.e. ask player which card to play, play this card, update the Game accordingly).

Coming from an imperative language (Python, C++), I would do something like

while not game.over(): player = if game.skip: game.skip = False continue move = player.getMove() if move == DRAW: move = player.getMove() elif ...: ... card = move.card player.removeCard(card) game.topCard = card

here, the game state is updated in little pieces, e.g. by, player.removeCard(...) and later settings may override previous variables (like move). The same function in Haskell took me about 80 lines, looks bad and has quite some repetition in it (e.g. topCard = card in every case). Additionally, to update a player's hand I have to construct a whole new Game. I know that some of that burden is because my data representation is bad, but generally, what's the best way to express a pattern like this in Haskell?

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

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