Quantcast
Channel: Examples – Whiley
Browsing latest articles
Browse All 24 View Live

Example: Sum Over a Positive List

So, here’s the first Whiley programming example.  Obviously, it’s pretty simple as Whiley is not quite ready for big code just yet.  The idea is to compute the sum of a positive list which, of course,...

View Article



Whiley gets a While Loop!

Finally, in the upcoming release of Whiley, I have added support for both while and for loops — which is about time.  Here’s an example: define nat as int where $ >= 0 nat sum([nat] list): r=0 i=0...

View Article

Thoughts on Loop Invariants

With the recent addition of for and while loops to Whiley, I’ve been able to fiddle around with [[loop invariants]] and already I noticed a few things.  Consider this little program: // The current...

View Article

Actor Syntax in Whiley

Recently, I’ve been doing some work on the syntax for [[Actor model|Actors]] in Whiley. After some deliberation, I’ve decided to go with explicit syntax for both synchronous and asynchronous message...

View Article

Parallel Sum in Whiley

Recently, I’ve been working on a variety of sequential and concurrent micro benchmarks for testing Whiley’s performance.  An interesting and relatively simple example, is the parallel sum.  The idea is...

View Article


Whiley Talk at Wellington JUG (VIDEO)

Last month, the Wellington Java User Group was kind enough to invite me to give a talk on Whiley.  The talk is a general introduction to Whiley, including the syntax, some issues related to...

View Article

Image may be NSFW.
Clik here to view.

Writing a PNG Decoder in Whiley!

Over the last few days, I have been writing GIF and PNG decoders in Whiley.  These form part of an image manipulation benchmark which I’m planning to use for experimenting with the compiler.  The PNG...

View Article

Termination of Flow Typing in Whiley

Whiley uses flow typing to give it the look-and-feel of a dynamically typed language (see this page for more on flow typing).  In short, flow typing means that variables can have different types at...

View Article


Variable Scoping for Try-Catch Blocks in Whiley

A friend of mine was talking about how variable scoping for try-catch blocks in Java really frustrated him sometimes.  Specifically, the problem was related to variables declared inside try blocks not...

View Article


Illustrating Compile-Time Verification in Whiley

With the latest release of Whiley, compile-time checking of constraints can be enabled with a command-line switch.  So, I thought a few examples of this were in order. Example: Absolute of an Integer...

View Article

Flow Typing for References in Whiley

The Whiley language splits into a fully functional “core” and an imperative “outer layer”.  References and objects do not exist within the functional core.  However, they can exist within the...

View Article

Image may be NSFW.
Clik here to view.

Generating Verification Conditions for Whiley

Probably the most interesting aspect of the Whiley language is that it supports compile-time verification of preconditions, postconditions and other invariants.  There are two main aspects of how this...

View Article

Image may be NSFW.
Clik here to view.

Whiley Puzzler #1

I was having an interesting discussion with a colleague today about various aspects of Whiley, and we came up with an interesting bit of example code which is something of a puzzler. Consider these two...

View Article


Compile-Time Verification and I/O

A surprisingly common question people ask me when I talk about compile-time checking of pre-/post-conditions and invariants is: how do you deal with I/O? To understand what the difficulty is, let’s...

View Article

Iso-Recursive versus Equi-Recursive Types

An important component of the Whiley language is the use of recursive data types.  Whilst these are similar to the algebraic data types found in languages like Haskell, they are also more powerful...

View Article


Image may be NSFW.
Clik here to view.

Thoughts on Writing Loop Invariants

As the Whiley system is taking better shape every day, I’m starting to play around more and discover things.  In particular, there are some surprising issues surrounding while loops and their loop...

View Article

Loop invariants and Break Statements

In this article, I’ll look at some interesting issues relating to the use of break statements within loops, and how this affects the idea of a loop invariant. For some general background on writing...

View Article


Image may be NSFW.
Clik here to view.

Introducing the Whiley Cheat Sheet!

Recently, I created a Whiley Cheat Sheet for use in our SWEN224 course and I thought it was useful enough to share! The goal of the cheat sheet is to provide some simple examples to help you get going,...

View Article

Verification with Data from Untrusted Sources

Recently, I was listening to the latest edition of the Illegal Argument podcast, and it turns out they were discussing Whiley! (about 103:16 minutes in). The discussion was about how verification...

View Article

Verifying Software with Whiley

A couple of weeks back, I gave a presentation to the Wellington Java User Group. The talk provides a useful introduction to verifying software in Whiley, and shows a bunch of interesting examples....

View Article

Encoding C Strings in Whiley

In this post, we’re going to consider representing the classic C string in Whiley. This turns out to be useful as we can then try to verify properties about functions which operate on C strings (e.g....

View Article


Program Specification in Practice?

Recently, as part of our Programming Languages Reading group, we looked at the paper “Contracts in Practice” by Estler et al., (see here for a copy).  This is quite an interesting paper and the authors...

View Article


Understanding Effective Unions in Whiley

The concept of effective union types in Whiley exposes some interesting features worth considering.  In particular, they result in a separation between the readable and writeable view of a type.  But,...

View Article

Image may be NSFW.
Clik here to view.

Verifying leftPad() in Whiley

The leftPad(string,int) function simply pads a string up to a given size by inserted spaces at the beginning. For example, leftPad("hello",8) produces " hello". This little function shot to fame in...

View Article
Browsing latest articles
Browse All 24 View Live




Latest Images