Skip to content

Instantly share code, notes, and snippets.

@ExternalReality
Last active January 10, 2016 21:12
Show Gist options
  • Save ExternalReality/2961d4fc99210b897293 to your computer and use it in GitHub Desktop.
Save ExternalReality/2961d4fc99210b897293 to your computer and use it in GitHub Desktop.
sortdef quality = int
sortdef sell_in = int
sortdef age = int
datasort gilded_rose_item =
| aged_bree
| sulfuras
| backstage_passes
| conjured
| standard
typedef item(sell_in, quality) = @{sell_in= int(sell_in), quality= int(quality)}
datatype gilded_rose_item(gilded_rose_item, s:sell_in, q:quality) =
| { 0 <= q && q <= 50 } aged_bree (aged_bree, s, q) of item(s,q)
| { q == 80 } sulfuras (sulfuras, s, q) of item(s,q)
| { 0 >= q && q <= 50 } backstage_passes (backstage_passes, s, q) of item(s,q)
| { 0 >= q && q <= 50 } conjured (conjured, s, q) of item(s,q)
| { 0 >= q && q <= 50 } standard (standard, s, q) of item(s,q)
fn age_aged_bree: {b:int; c:int} gilded_rose_item(aged_bree, b, c) ->
[rb:int; rc:int | rb == b - 1; (c < 50 && rc == c + 1) || (c == 50 && rc == c)]
gilded_rose_item(aged_bree, rb, rc)
#include "share/atspre_staload.hats"
#include "share/atspre_define.hats"
staload "GildedRose.sats"
implement age_aged_bree (aged_bree m) = let
val quality = m.quality
in
if (quality < 50)
then aged_bree @{sell_in= m.sell_in -1, quality= m.quality + 1}
else aged_bree @{sell_in= m.sell_in -1, quality= quality}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment