My Programming Escapades
Andraz Bajt
Chaining implicit conversion in scala
Today I was hanging in the #scala IRC channel and somebody came along(forgot the nick, sorry) and asked about some compilation error. I deduced he was trying to chain implicit conversions. And this doesn't work. Else compilation would take forever and would also compile some wrong code by inserting long strings of implicits. But then somebody else responded(I think nick started with d) and gave a solution to implicit chaining. But I'm not giving it away yet, you'll have to read a bit more.
2013-01-27
Generic singletons through dependent method types
Ever tried to write a generic singleton? It's an oxymoron of a sort. But sometimes my brain dreams up funny concepts to solve the problem at hand. Sadly I cannot remember what I wanted to use them for. Anyway I think I just made all the methods generic and solved it this way. But this doesn't really express the notion of one entity that's agnostic to type of the parameters. With generic methods you get a bunch of disconnected units - at least that's the picture in my head.
2013-01-27
Monadic IO with ScalaZ
I just recently scratched the surface with scalaz. Think of it as an additional standard library for scala that's FP oriented. It provides a bunch of type classes, instances for pretty much everything, some fancy data types, pimps(Pimp My Library) for standard library collections, actor implementation and probably some stuff I'm not aware of. I could really use a “map of scalaz” - but I'll probably dive into source and scaladoc anyway.
2013-01-27
Null-coalescing(??) in scala
I was doing my homework today(yes I am aware I should be enjoying myself on 30th December) and had some problems with concatenating possibly null strings in LINQ. Quick trip to StackOverflow and I find out C# has some funky operators that solve this in a (sort-of) clean way. var outputString = input1 ?? "" + input2 ?? ""; I like type inference so I use var's extensively - please don't judge me.
2013-01-27
Union types in scala
I've done some research a while ago on union types and found a nice implementation by Miles Sabin but it only works for declaring types of function parameters. And you can also do this with with type classes. What do I mean with “only function parameters”? In “everything is a function” kind of view there are three places to put types function parameters value(val or let binding in haskell and the like) function return type Even though Miles’ encoding with Curry-Howard isomorphism is ingenious it only applies to point 1.
2013-01-27
Cool Monday - Exploration of dynamic db acces from scala
I use scala on Android and I don't like the integrated database API. It's very verbose and very stateful. I had written my own ORM(DAO would be a more appropriate tag) a while back, before I used scala but it's not enough anymore. So now I'm on a quest for a better database API. My dream is something small that handles schema for me and is type-safe. A nice DSL that is converted to SQL at compile time and does code generation.
2012-12-10
Homework - functional style (outer sorting)
I'm attending Algorithms and data structures class this semester. Material it self is quite interesting and one TA is pretty cool too. But I don't like professor(makes whole experience very much worse) and I believe homeworks could be much better. Oh, and we didn't even mention functional approach…you know Haskell, Scala and the like. All we do is imperative, C-style code in Java. Enough ranting. This is how it saw the bright side.
2012-12-04
Cool Monday - Functional compilers and atoms
I've seen this great talk by Daniel Spiewak on Functional Compilers. He talks about lexical and semantic analysis in particular. First, problems with traditional lexing with scanner. You can only have regular tokens or you have do do some dirty hacking and backtrace the scanner therefore losing linearity. And you can solve this with scannerless parsing putting regular expressions into your grammar. In fact this approach seems simpler to me, as the only proper parser I've done works this way.
2012-11-26
Nomadic programming
DISCLAIMER: This is about my opinion. And may or may not contain some boasting. And is also a bit of a brain dump. Yep, this is not a typo. Not monadic but nomadic. Although monads are cool too. A few days ago the CTO of a company I work for said it's time to specialize. He was talking about my career. Offering me a few things to try and then pick one.
2012-11-23
Cool Monday - CERC and my trip to Krakow
This week's post is a bit different. Well very different. My team qualified for CERC ICPC(european programming contest) and that means a trip to Krakow, Poland. I plan on writing this in a journal style. A bit every day. Friday, 11. am I got up at 6. to check news and read a bit before departing. And of course to charge my laptop and phone to 100% batter for the long trip.
2012-11-19