val ( When adding x to x then result is double x ) : x:int -> bool

Full name: Document.( When adding x to x then result is double x )
val x : int
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
val preconditionMaxHealth : maxHealth:int -> bool

Full name: Document.preconditionMaxHealth
val maxHealth : int
val healthComponent : 'a

F# in Onikira

Andrea Magnorsky

Digital Furnace Games ▀ BatCat Games ▀ GameCraft Foundation

Working on OniKira: Demon Killer

Release on 27th August 2015 on Steam

Working on OniKira: Demon Killer

Release on 27th August 2015 on Steam

Ecosystem: What we use now

  • FsCheck
  • Fake
  • Compiler Services

Property Testing with FsCheck

Why write tests, when you can generate them

What is a property?

x + x = 2 * x

or

List.rev(List.rev list) = list

FsCheck

  • Can be used from C#
  • Small library
  • Can run stand alone or integrates with NUnit and xUnit
  • QuickCheck paper by Koen Claessen and John Hughes
  • Superb article by Scott Wlaschin on Property based testing .
1: 
2: 
3: 
[<Property>]
let ``When adding x to x then result is double x``(x:int)=
    x + x = 2*x
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
let preconditionMaxHealth maxHealth = maxHealth > 0

[<Property(Verbose = true)>]    
let ``Health should never be higher than max`` (x:int)(maxHealth:int)=        
    let healthComponent = initedHealth
    healthComponent.MaxHealth <- maxHealth
    healthComponent.IncreaseHealth x
    preconditionMaxHealth maxHealth ==>  (healthComponent.MaxHealth >= healthComponent.Health)
fs

Fake

  • Use from any .net language
  • It's mature.
  • Builds for .net and mono, it's cross platform.
  • Integrates with CI Server.

Hello F# make world!

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
// include Fake lib
#r @"tools\FAKE\tools\FakeLib.dll"
open Fake 
Target "Foo" (fun _ ->
    trace "Hello World from Foo"
)

Target "Bar" (fun _ -> 
    trace "Hello World from Bar"
)
"Bar"
  ==> "Foo"

RunTargetOrDefault "Foo"

Scripting games with F#

Compiler.Services

Duality.Scripting

  • File watcher
  • Code in any editor :)
  • Compiler Services call to fsc
  • Runs on Android (probably iOS too with the correct Xamarin license)
  • Future -> live coding

repo

fs

Resources

Books Expert F# Real World Functional programming * More Books

Events

  • Kats Conf - Dublin - 12th September FK
  • Progressive F#
  • CodeMesh - 3rd 4th November ( London)

Thanks :D

onikira

Links