Test post with new blog

by sandersn 2. April 2011 17:24

I'm testing a new blog engine, blogengine.net. I plan to migrate my old posts on b2evo to this database at some point, and at that point I'll figure out how this blog will be shared between sandersn.com and cackhanded.com. Since cackhanded will probably stay as projects-only, I think I'll point both sandersn.com and cackhanded.com/blog to this blog eventually.

Supposedly this blog has code highlighting:

foreach(var language in languagesThatStartWithP)
  it(has, highlighting);
else
  noHighlighting(); // wait, are comments even coloured?

But so far Python didn't work, whereas C# did.

Tags:

General

Thanksgiving east of the Mississippi

by sandersn 5. December 2010 02:34

It's been over a year since my last travelogue. This one is likely to be less interesting because it's all places I've been before. I'm flying, not driving, too, so the only down time I have is when I'm waiting for a flight.

Day 1: Seattle

And actually, the only observation I can make so far is that I am really tired of airport security. It's a reminder; not that things are necessarily worse in the US now, but the meaning of 'American' is changing.

Anyway, they have the new scanners installed in Seattle but they aren't using them over the holiday. There were signs up that showed what the scanners can see, but not mentioning their potential health risk. Bah humbug.

What does feel American is that terminal D is a terminal with TVs. They even have the sound on! I moved to the San Diego gate because the volume is lower here. The channel is some airport-branded amalgamation of CNN and TCM (Turner Classic Movies). CNN just put up a commercial claiming to be the impartial news channel, opposing MSNBC on the left and FOX on the right. That is pretty hilarious because all the American news channels are classic yellow journalism, competing to come up with the craziest headlines.

9 FOOT BOA YANKED OUT OF CAR ENGINE!

Now that it's TCM's turn, I see that they favour the "your TV is failing" filter for their commercials. Darkened at the edges, and a little grainy. It reminds me of the filter in the particularly bright levels of Mario Galaxy, the "Champs magnetiques" filter, also known as the "your CRT is sitting next to your refrigerator" filter: everything is a little too saturated, trending to purple around the edges. Why do they do this? If I wanted an old failing screen, I'd use one.

Anyway, I figured out how to avoid blue-screening Scrupilo when switching to battery power (and thereby switching off its discrete Nvidia card). I habitually run devenv as the admin user, a habit picked up at Microsoft. But the driver can't switch sudoed processes. It asks you to close them, but if you really insist it will go ahead and try, and then blue-screen. (Later:This only works when turning the card off. I haven't figured out how to avoid the blue screen when turning it back on.)

DRY STATES DRYING OUT? MORE STATES ALLOWING SUNDAY LIQUOR SALES.

If I were shopping now, rather than 6 months ago, I might consider one of the Macbook Airs, but so far I've really liked the Vaio Z. When it plays games (Fallout and Starcraft so far), they look about as good as a 360, which is good enough for me. I'm not sure if the Air could handle even that. Plus the VAIO has a million times more ports the Air--even a DVD drive, which I leave disabled most of the time to save power (probably? maybe it doesn't).

The worst part is using gmail. I'm really crippled without the emacs keyset. I suppose I should download Safari and see whether its supported there, but I've heard Safari is a hog on Windows.

SO I CAN JUST TYPE WHATEVER HERE?

Day 2 : St Louis

I am in Missouri now. Specifically, St Louis. And if St Louis means anything, it's funny place names. This time is better than ever because I drove down from the airport and saw a lot of hilarious names: Wentzville and of course the old standbys Festus, Herculaneum and Crystal City. But the best new one is Town & Country. Seriously! There is a town named Town & Country. I asked about it and my native friends claim that it's a really ritzy suburb.

Also, we are seriously getting old, going to bed so early at a LAN party. In previous years, I was always at a disadvaage because of coming from the Eastern time zone. But all these guys are going to bed at like midnight because they have to drive in the morning.

Oh Wait. It's midnight Pacific--that's 2 AM Central. OK, I have a little more sympathy now. I guess I should get to sleep soon because the sun comes up super early here (2+ hours compared to the west coast).

Anyway, this is turning into a pretty dismal travelogue. I haven't talked about the people I've visited, the places I've travelled through, or the junk on the roadway and deteriorating roads of the midwest.

Day 3 : Indiana

It turns out I am missing freak snow in Seattle while I'm in Indiana. Here, it's as warm as Seattle was in the middle of September. BUT snow is expected by Thursday. On the whole, I don't miss the midwest weather.

So far the only people I've seen have been the Wamplers and Chris Reese. Chris is graciously putting me up on the couch in the study. He definitely keeps the Wamplers' upstairs apartment neater than I used to. Unlike me, he's actually using the furnished bed instead of obstinately sleeping on the floor and using the bed as a place to keep clean clothes.

Also, I discovered this morning that I totally broke Fing somehow. It just ignores input and barfs singleton lists of Typar to stdout.

Day 4 : Indiana

The paper copy of my dissertation is finally in the hands of the linguistics department [secretary]. That means the only loose end is to mail the Graduate Recorder and tell her than I want to attend May commencement and not December.

Of the friends I've met so far, the overwhelming theme is that it's been a slow six months in Bloomington where not much has changed.* For me this has been a fast six months where everything has changed. So I do most of the tallking. Well, that hasn't changed at least.

At some point I'll have a reliably understandable account of my job, but right now I am still working on an explanation that's suitably impressive without being confusing. I start from the top down, saying "I work on the back end of the back end of Bing, where we compare and match ads to every page on the Internet." That's not actually what I do, so then I say "This is a huge job, so our system splits the billions and billions of pages into smaller bits of work to send to thousands of computers in a cluster." But I don't work on the splitting part. I work on the part that does actual does the little bits, the part that lives on thousands of computers.

Hmm. That's simple, but the clarity breaks down toward the end.

Also, Fing isn't broken. It just has a runaway debug print somewhere during startup. After those thousands of lines are dumped to the terminal, it runs just fine.

*Note: Actually five months.

Day 9 : Tennessee

Thanksgiving has come and gone and with it Black Friday. In fact, I got to Tennessee on Wednesday, but I am just now getting over sleep deprivation from the LAN which exacerbated what would otherwise be fairly tame jet lag. On Wednesday and Thursday I mostly felt like grumping around playing Dragon Quest. And Dragon Quest is not a complex game.

Of course, now that my break is nearly over, I actually feel like working on Fing. I'll see what I can do--I'm still stuck trial-and-erroring my way through the basic primitives of map/fold/etc.

Day 10 : Chicago

Well, I'm in the Chicago airport. Two surprising things: (1) there don't seem to be massive delays and (2) there is no free wifi. (Note: I've added wifi to my vocabulary solely under the condition that it's pronounced either [wifi] or [vifi] ("weefy" for non-IPA-readers).) But whatever. I don't need the Internet. I've got plenty of bits in my personal battery-powered possession. I played as much The World Ends With You as I could take back in the Chattanooga airport, so I'm back to working on Fing. I found a problem with my Type.fold: terminals are treated differently than non-terminals, meaning that an attempted to write `Type.const` fails (and `Type.id` requires a call to `List.head`, which is a bad sign too). I think having a `concat`-esque function used for compound types is wrong.

First impressions of The World Ends With You: it's almost a cross between a visual novel and a JRPG. The battle system is a lot less frenetic than it appears. The story is an, um, look into the youth culture of Japan? I don't know. The soundtrack could be a LOT bigger than it is, and repeats too much, unless you really like J-Pop (I don't). They still haven't cracked the battle/story mismatch, but the battles are fun so it's not much of a problem.

I bought the game because reviewers said it was a fresh take on the JRPG. That's sort of true, but really they're getting more mileage out of the influence from visual novels. The battle system is kind of cool, but not a *huge* innovation from the typical action-RPG. You alternate DS-style slashes and old-style button mashing, that's all. However, being able to swap attacks at least makes it more interesting than something like Kingdom Hearts (NOTE: Maybe it's because Kingdom Hearts is TOO LONG and I never got to the interesting part. Not likely.) Overall, the theme seems to carry the weight of the perception of novelty. It *is* cool that it's not Yet Another Fantasy Story, but to be honest the story doesn't seem that different from what I've heard of Persona so maybe it's not all that it's cracked up to be. It could be just that not enough people have played Persona--I, for example, have not.

Wait, I forgot about Fashion. Accessories do more and less damage based on what's in fashion in the district you're in. So that's cool--the closest thing I can think of is the camo in Snake Eater. I thought that was really cool, although the interface was clunky. Same here--switching isn't so much a pain as shopping is, because you can't jump back and forth between "information on what you need" and "information on what's for sale".

Anyway, I know I'm at the right gate, because there's a guy wearing a Halo Reach t-shirt in the chair across the way. I myself am wearing the O'Reilly Linux pony shirt, which has much the same function for Microsofties in the geek world as a Canadian backpack does for Americans. (I harbour the same goodwill towards my kooky Linux brethren as I do my kooky Canadian brethren.)

Tags: , , , , , ,

General

Still Alive 2010 b/w Blue Monday 88

by sandersn 17. November 2010 01:24

I am still alive--I promised a revival of the Fing series, but the post on the module structure and primitive operations on the type expressions is held up because I have no clue what the right primitives are. Well, fold looks right, but I haven't figured out map yet. Somebody smarter than me would already know but I am still messing around trying to find the answer by trial and error. Maybe during my vacation I'll have time to figure things out.

Also, I put my dissertation online after finally getting a paper copy made for the IU linguistics department. It's pretty boring. But it's free, like information was meant to be.

I was also poking around my site, wondering if I'm over my space limit now, and I noticed that I never linked to my posts before the 2007 switch to b2evo (click 'View All' to get one giant page that includes 2004-2006). In case you've forgotten: blue-on-blue. Plus even more rambling about programming languages. I'm still writing about functional programming, but I think my English writing has (1) aged better than the code and (2) improved more than the code. (Secretly, I enjoy reading my own writing way too much.)

I also also have a new GUI editor with this new version of b2evo. It's Not That Great but I am giving it a try. Is this Times New Roman? I'm hoping the editor is less WYSIWYG than it appears, because I'd prefer to keep my old font.

Alsø alsø alsø, a moose ønce bit min syster.

Tags:

General

Impressions of Zune.net two week trial

by sandersn 7. August 2010 13:50
Since I'm working on a Windows computer all day now, and in a crowded workplace (Bing is hiring, by the way), I decided to try the Zune subscription. The bottom line is: good, but it can't compete with music I already own plus Pandora plus Youtube. At least, for me that's true—it may not be for you, depending on your taste. The Zune subscription bills itself as a way to explore new music, plus buy 10 songs per month. The means it's mostly competing with Pandora, except that you can listen to a complete album, or perhaps the greatest hits of a single artist. Pandora is randomised in order to comply with the FTC's ridiculous definition of a radio station, which puts them in a different tax bracket or something. But I don't have a burning desire to discover new music. Desire, yes, but not burning desire. So part of the draw for me is instead to have access to a huge library of music stored in the cloud instead of my various and sundry disk/flash drives. The problem is that I enjoy the obscure genre of video game music. It doesn't exist on Zune.net, at least the ones I looked for. So that's a large chunk of music that I can't get to. The other problem is that super famous artists often don't make their work available to subscriptions. Here are some artists I couldn't listen to on Zune.net:
  1. Nobuo Uematsu (Final Fantasies 1-12, many other JRPGs)
  2. Jeremy Soule (Monkey Island, Secret of Evermore, Elder Scrolls, some Harry Potter, many others)
  3. Hitoshi Sakimoto (Final Fantasy Tactics, FF12, many many others)
  4. Yoko Shimomura (Parasite Eve, Kingdom Hearts, Front Mission, Dark Cloud, many others)
  5. Martin Galway (Ocean Loader, many other C64 games)
  6. The Musicians at Valve (to wit, the Orange Box soundtrack)
  7. Jack Wall/Sam Hulick (to wit, the Mass Effect soundtrack)
  1. The Beatles
  2. Led Zeppelin
For the famous holdouts, you can put together a playlist of "artists like this", which is cool, but not any better than Pandora. For the obscure game composers, search turns up songs, but either they aren't for sale or aren't available for subscribers. I think the 'social' part of Zune means that people can index their existing music libraries, which then contribute to searches. This is vaguely cool, but contradicts the heading "marketplace", since the songs aren't for sale. Other bad things I noticed: The client-side DRM is pretty buggy and hard to set up to boot. I guess all that protection is hard to co-ordinate, because about 1 of 10 songs fails to authenticate. If you try again after 30 seconds, it usually works. I didn't have any trouble with the web client. The Zune client is super confusing—maybe after six months of using it, I would think it's better, but really I think the best way to use Zune is either by downloading tracks and listening via Winamp or just using the web interface. As for the 10 songs per month, Zune still has the iTunes-style Album Only restrictions on some. I guess you probably have to pay real money for those. Right now I'm going to skip subscribing and see if I miss it after two weeks of the trial. I should probably start transferring my music from my computer to my phone to my work computer etc etc ...

Tags: ,

General

First impressions of the Kinect

by sandersn 31. July 2010 10:17
So I got a chance to see a Kinect in action today, although I didn't play myself. Here are some impressions.
  1. The whole thing was technically more impressive than I had thought it would be. No finger tracking, but [once it decided which person to track,] it looked smooth and pretty accurate. A lot smoother than the demo I saw last year.
  2. One cool touch is that the Kinect swivels upward when booting. It was unaccountably impressive, although I don't know if it's technically necessary. It somehow makes the thing look intelligent.
  3. Safety warnings? Three of them? (Maybe it was only two, but it reminds me precisely of the Wii)
  4. Except for graphics and input system, the included games are early 80's arcade designs, just like all those Wii games. Good party games, not much else.
  5. Well, let me amend that statement. There are genius games in the simple early 80's arcade style. But not many. You can count the games that outlived that era on one hand.
  6. And there are innovative ways to incorporate Kinect technology into a primarily gamepad-based game. For example, Johnny Lee's head-tracking technology is possible for single player Kinect games. But coming up with new ideas is hard, and it's not something that happens in the game industry much. I think Johnny Lee works for XBox now, so there's some hope. But only a little, because I think the bottom line is that new gameplay doesn't sell as well as copies of existing gameplay.
  7. All in all, I don't have much hope that the cool tech in the Kinect will be used to create much more than copies of Wii games. I hope I'm wrong.

Tags: ,

General

Probable hiatus this summer

by sandersn 9. July 2010 21:54
I just started work at Bing, so don't expect many (any) blog posts for the next month or two. Actually, the real reason is that I have stopped working on Fing until I can finish my dissertation revisions. There aren't many—I estimate about a month's worth—but who knows how much furniture/clothes/computer/phone shopping will interfere on the weekends. If there's one thing I've learned during the move, it's that serious shopping takes FOREVER. Also that it's really tiring. But that means that I won't have anything super interesting to write about in the form of Fing code analysis. Or even anything at all, since I guess "super interesting" is about three notches about the normal fare for this blog. Oh, and I just went through the Mandatory Online Legal Training today. So let me remind you: I do not speak for Bing or Microsoft on this blog. Even if I do discuss Bing, I do not do it in an official capacity, and my statements should not be taken to be indicative of any Bing policies or future directions. I'm not even going to tell you my microsoft e-mail address, except to say that it's like 10 times better than the alphabet soup I got from Indiana University. I must have been at least the 23rd Nathan Sanders to go to IU. And now that I know all about trademark law, who knows whether Fing will continue to be called Fing. I may have to change the name to F#$`ing after all.

Tags:

General

The Future of Spam

by sandersn 2. July 2010 22:50
In Paul Graham's essay "A Plan for Spam", he laid out a way to use Bayesian classification to detect spam. In passing, he pointed out that the spam of the future. Well, here we are in the future. The spam I get on my blog isn't trying to get *me* to buy something. All it's trying to do is to boost its products in search engine rankings. That way, the odd people *searching* for spammy products. (Well, actually, spam like this is now used by more respectable products, although the companies themselves are still dishonest.) The funny part is how spam has evolved. In order to retain their payload, spammers try to contribute to the blog so that their message isn't deleted. A normal contribution is "you go buddy" There are more advanced versions of this: I've got "bing rocks, this is the third link; google doesn't have it anywhere." Except that BOTH engines have that page as the third link for "python type checking". ( More insidious are technical things like "this page looks funny in FF3.5/Ubuntu." That one got me worried because I don't HAVE an Ubuntu machine. There is a site to check these things out, though, and it showed nothing. But there are also on-topic, or nearly on-topic contributions: on the F# data structure creed, somebody said "". Actually, I'm not even sure that this is spam. Maybe Rob at Website Design Brisbane feels strongly that F# can be summarised in four words and that a complex data structure cheat sheet is not needed. On the Prejudice and the Dark Elves of Morrowind, a spammer for dog supplies said "it just shows that every living thing specifically animals has also rights". Almost on-topic, pretty close in fact. Maybe they just felt (somehow) that rights and prejudice are linked and that. I deleted that one but not the Brisbane one.

Tags: ,

General

Announcements June 2010

by sandersn 15. June 2010 10:51

It's about time some changes were made around here.

The first you'll notice is that the title of this site is no longer Journal, but Blogg. I didn't like the word 'blog'  when it was new, but I eventually got used to it. If I'm going to use it, though, it's going to be the Scandinavian version.

Why Scandinavian? I just finished my doctorate with a dissertation on Swedish dialects. I don't actually <i>speak</i> Swedish*, but I've picked up a little while getting my code to process it. So the change commemorates the fact that I am now (almost) officially Dr Sanders. Or Herr Doktor Sanders, a title bestowed upon students whose advisors are German.

The reason it's (almost) official is that I have a few revisions to make on the dissertation. When those are done, I'll upload the final version here. If you really want to see it before then, contact me.

Second, Fing 0.1 is out at github. There's a binary in case you don't want to download the source. There's also a script to load Fing into fsi for interactive use. 0.1 can find functions even if you get the order of arguments wrong. You can also have it search your own assemblies, not just FSharp.Core. But type aliasing doesn't work right yet, so if you rely on aliases with type variable arguments, you are out of luck until the next version.

The last announcement is that (if you didn't already know), I'm starting a job at Bing at the beginning of July. Now is a good time to remind everyone that I don't represent any of my employers, past, present or future, and that this blog is not connected officially or unofficially to Microsoft.

*Jag talar inte Svenska, med jag talar Swedish Chef, darfor vi har de har valdigt har bork bork bork!

Tags:

General

Uncharted : Drake's Fortune

by sandersn 19. May 2010 09:30

I liked Uncharted in spite of myself. Maybe it's that the main character is named Nathan. Maybe it's just a good adventure story. Maybe it's because Naughty Dog codes with a REPL. Maybe it's that they're just one of those groups that makes everybody else look like amateurs. (Hideo Kojima is another, though I think Kojima's secret is a combination of mad genius and huge budgets, not a REPL.)

Like Kojima's work, even though I enjoy Uncharted, I have reservations about the total move-likeness of the whole thing. Naughty Dog basically filmed a movie, papered over everything with digital meshes, and then put a game in with it. Isn't that a waste of a game? On the other hand, Hitchcock was a genius, and his movies (the ones I've seen anyway) are basically stage plays. So maybe there's a place for imitating other media. (Usual disclaimer: I know nothing about movies, but Hitchcock's are among the best I've seen.)

Maybe the reason I feel uncomfortable about Uncharted's movie nature is that it rips off the "brainless adventure" movie genre, eg Indiana Jones. These kinds of movies are fun to watch but not particularly intelligent. Here's the problem: in comparison to other video games, Uncharted's writing and acting is nuanced and intelligent. But it's a nuanced and intelligent copy of an adventure movie. Unlike, say, Mass Effect, whose story is just 5 concatenated episodes of Star Trek, it doesn't copy a B-movie from an 'intelligent' genre. But it does copy an A-movie from a 'dumb' genre. If games are serious about being narrative and not just procedural, then Uncharted is a sign that they have a long way to go: the best story tellers in the industry have just moved up from copying B-movies to A-movies**.

Besides Indiana Jones, It reminded me of Monkey Island. Was it the questionable historical accuracy*? A female lead named Elaine/Elena? The last boss is a QTE? The parallels are striking. Erm, well, the last bit of Monkey Island wasn't a QTE, but it was so fiddly as to be the moral equivalent.

My main complaint is that there is too much shooting. I decided this about a third of the way through and suffered until about half-way through. Then I remembered that the switch labelled "easy" should fix that. I tried it, but it didn't. It didn't even make much of a difference. Maybe I had to fire fewer shots per guy, but there were still like a hundred guys in every screen. After a while my ears get tired of gunfire and I definitely switched weapons a few times based solely on volume.

So basically yeah. Uncharted reminds me of a cross between Monkey Island and Indiana Jones, plus there is a fun game in there. I liked it, and that's a testament to Naughty Dog's level of craftmanship, because it's not normally the kind of thing I like. They did this with Jak on the PS2 as well. Jak is BASICALLY a cross between GTA and Mario, but it's actually super fun. Why? I can't tell. They're basically just really good at what they do.

*There are no elaborate Spanish forts on obscure Pacific islands off the coast of Chile. My dad's been to most of those islands and I asked him.

**I don't want to leave Kojima out. He moved up from B-movies (Metal Gear Solid, arguably) to making absurdist Metal Gear games about how Konami won't let him stop making Metal Gear games. I don't even know what the movie equivalent of THAT is.

Tags:

General

Developing Fing, part 1: Parsec tokeniser

by sandersn 2. April 2010 09:39

Neil Mitchell wrote* a tool for Haskell called Hoogle that lets you search for code by type:

Monad m => [m a] -> m [a]

gives you sequence, but also variations like Data.Traversable.sequence, which is

(Monad m, Traversable t) => t (m a) -> m (t a)

As well as a bunch of similar types, like

replicateM :: Monad m => Int -> m a -> m [a]
concat :: [[a]] -> [a]
*At least, Neil Mitchell is the most recent maintainer. I don't know who started it. I still haven't read the Hoogle source.

F# has no tool like this, as far as I know. F#'s type system is a lot more complicated than Haskell's, so it would be really hard to provide an equally complete matcher. But a stricter search could still be useful, in fact probably more useful because of the larger .NET standard library, and because MSDN doesn't offer anything comparably dense to Hackage for type documentation. The object browser in Visual Studio has better presentation than MSDN, but doesn't support type search (or any search, really, except exact-match-method-name).

The reason I qualify "no tool" with "as far as I know", is that I asked the question on Stack Overflow and nobody also knew either. kvb did write up a toy version which returns answers some of the time, which are right some of the time. But it ignores the complicated bits of the F# language spec.

So I'm starting to develop an F# equivalent to Hoogle, using kvb's code as a starting point. The tentative name is Fing, or perhaps F---ing or maybe F#`.ing. Pronunciation is up to the user, following in the tradition of offensive acronyms, like de Vrije Universiteit Compiler Kit.

However, I'm not going to show you Fing, because it doesn't exist yet. First I'm going to show you a Parsec parser for F# types. That's about all that's done so far. I used Haskell because Parsec is better documented (though still not very well) and because I don't have F# hooked into Emacs. Also, Haskell development is easier right now because Hoogle already exists. Also also, FParsec is less mature and lower-level than Parsec, so it requires more mucking about in its internals. (Though it's promised that this means very efficient parsers.)

The first step is a low-level token parser which ignores spaces and so on. Without this, it's difficult to get the lookahead right because you end up scattering individual char parsers throughout the parser with unreliable lookaheads all over the place. With the token parser doing the lexical analysis, the high-level parsers only need lookahead in a few places.

Writing a grammar, as always, is a trial and a tribulation and harder than it sounds. At first I chafed at Parsec's constraints, surprised that it really isn't any more powerful than the toy parser combinators you can whip up yourself for fun. Parsec prefers to make LL(1) grammars by default, which are terribly limited compared to the crazy natural language grammars you get in computational linguistics. (And which requires parsers that only process about 10 sentences per second...) You have to explicitly ask for backtracking by wrapping the backtracking parts with try.

But as I wrangled and struggled with Parsec, I decided that it's the right approach. Otherwise, writing a grammar for an efficient parser begins to feel like a variant of Prolog. One of the hallmarks of a backtracking-search language is that functions compose very badly. If you call two functions, which each call two functions, you have to know what a failure in one leaf function will do to your execution in the other leaf functions. So it's probably better to make you explicitly insert backtracking points instead of explicitly inserting cut points. Your code will fail more often, but it will rarely succeed in the wrong way.

OK, so here's the tokeniser.
import Text.ParserCombinators.Parsec
tokeniser = choice [try (many1 (digit <|> letter <|> oneOf ".`_"))
                   , string "->"
                   , try (string ":>")
                   , (return . list =<< oneOf "*<>()[],'^#:?")
                   ]
tok t = try $ do
  spaces
  x <- tokeniser
  if x==t then return x else fail "Token not recognised"
toks = mapM tok
notTok ts = try $ do
  spaces
  x <- tokeniser
  if x `elem` ts then fail "Incorrect token" else return x

The reason it's so simple is that lexically, F# types are simple. There are only two digraphs, and only one of those is ambiguous with the reserved punctuation. Additionally, there's no overlap between the reserved characters and the identifier characters.

Oops, actually if you check the spec, this does not match it. Identifiers are more complicated. Specifically, identifiers must start with a letter or underscore, and you can turn anything into an identifier by double-backquoting it. Oh well, I'll add those later. Shouldn't be too hard.

Then you can write things like tok, toks, notTok on top of tokeniser and away you go. I'll save the majority of the parser for part 2, but here's a preview:

typevarP = choice [anon, normal, structural]
  where anon = tok "_" >> return (Var Anonymous) -- 4 TEH LULZ
        normal = tok "'" >> liftM (Var . Normal) identP
        structural = tok "^" >> liftM (Var . Structural) identP
That parses type variables like _, 'a and the obscure ^b.

At the moment I am struggling with FParsec. Even after getting over the learning curve of writing Parsec-style parsers, I'm having to learn FParsec's innards because it is somewhat lower-level. So I'm basically copying FParsec's built-in parsers and modifying them in an extended session of trial and error. At this rate, you'll be lucky to see parts 2 and 3 before I finish my dissertation, because I shouldn't spend much more time hacking on it until then.

Tags: , , , ,

General