Commits

Anonymous committed 92e5705 Merge

Merge

Comments (0)

Files changed (34)

 *.resharper.user
 *.*proj.user
 desktop.ini
-
+glob:build/*.*
+glob:deploy/*.*
+relre:^test/.*
+glob:Doc/*.*
+glob:Doc/**/*.*
+glob:src/*.ReSharper.user
File contents unchanged.

lib/FAKE/FAKE.exe

Binary file modified.

lib/FAKE/FAKE.exe.config

File contents unchanged.

lib/FAKE/FSharp.Core.dll

Binary file modified.

lib/FAKE/FakeLib.XML

File contents unchanged.

lib/FAKE/FakeLib.dll

Binary file modified.

lib/FAKE/docu.exe

Binary file modified.

lib/FAKE/readme.txt

+What is "FAKE - F# Make"?
+
+The Google group can be found at http://groups.google.com/group/fsharpMake.
+More information on http://bitbucket.org/forki/fake/wiki/Home.
+
+Modern build automation systems are not limited to simply recompile programs
+if source code has changed. They are supposed to get the latest sources from 
+a source code management system, build test databases, run automatic tests, 
+check guidelines, create documentation 
+and much more. Some companies are even deploying virtual machines, 
+which are created during a nightly build process. In order to simplify the 
+writing of such build scripts and to provide reusability of common tasks most 
+build automation systems are using a domain-speci
+These tools can be divided into tools using external DSLs with a custom syntax
+like make, tools using external DSLs with an XML based syntax like MSBuild
+or Apache Ant and tools using internal DSLs which are integrated in a host
+language like Rake, which uses Ruby.
+
+"FAKE - F# Make" is a build automation system, which is intended to combine the
+advantages of the above mentioned tools but to provide a better tooling support.
+Due to its integration in F#, all bene
+functional programming can be used, including the extensive class library, 
+powerful debuggers and integrated development environments like 
+Visual Studio 2008 or SharpDevelop, which provide syntax highlighting 
+and code completion.
+
+The new language was designed to be succinct, typed, declarative, 
+extensible and easy to use. For instance custom build tasks can be added
+simply by referencing .NET assemblies and using the corresponding classes.
+
+Main Features
+
+    * Simple build infrastructure
+    * Easy systax
+    * Full power of .NET Framework
+    * Predefined tasks:
+    * Clean task
+    * NUnit support
+    * xUnit.net support
+    * NCover support
+    * FxCop support
+    * ExecProcess task (To run tools via the command line)
+    * MSBuild task (to compile *.csproj, *.fsproj projects or MSBuild scripts)
+    * XMLRead task
+    * VSS task (Get sources from Visual Source Safe)
+    * XCopy task
+    * Zip task
+    * AssemblyInfo task
+    * Simple TeamCity integration
+    * FinalTarget feature (to release resources even if build fails)
+    * Extensible platform (Write your own tasks)
+    * Easy debugging
+    * Intellisense support (when using Visual Studio)

lib/FSharp/FSharp.Build.dll

Binary file modified.

lib/FSharp/FSharp.Compiler.Interactive.Settings.dll

Binary file modified.

lib/FSharp/FSharp.Compiler.Server.Shared.dll

Binary file modified.

lib/FSharp/FSharp.Compiler.dll

Binary file modified.

lib/FSharp/FSharp.Core.dll

Binary file modified.

lib/FSharp/FSharp.Core.optdata

Binary file modified.

lib/FSharp/FSharp.Core.pdb

Binary file modified.

lib/FSharp/FSharp.Core.sigdata

Binary file modified.

lib/FSharp/FSharp.LanguageService.Base.dll

Binary file modified.

lib/FSharp/FSharp.LanguageService.dll

Binary file modified.

lib/FSharp/FSharp.ProjectSystem.Base.dll

Binary file modified.

lib/FSharp/FSharp.ProjectSystem.FSharp.dll

Binary file modified.

lib/FSharp/FSharp.ProjectSystem.PropertyPages.dll

Binary file modified.

lib/FSharp/FSharp.VS.FSI.dll

Binary file modified.

lib/FSharp/Fsc.exe

Binary file modified.

lib/FSharp/Fsi.exe

Binary file modified.

lib/naturalspec/NaturalSpec.dll

Binary file modified.

lib/naturalspec/NaturalSpec.pdb

Binary file removed.

src/app/statefulie/AssemblyInfo.fs

+module statefulie.AssemblyInfo
+#nowarn "49" // uppercase argument names
+#nowarn "67" // this type test or downcast will always hold
+#nowarn "66" // tis upast is unnecessary - the types are identical
+#nowarn "58" // possible incorrect indentation..
+#nowarn "57" // do not use create_DelegateEvent
+#nowarn "51" // address-of operator can occur in the code
+open System
+open System.Reflection
+open System.Runtime.CompilerServices
+open System.Runtime.InteropServices
+exception ReturnException183c26a427ae489c8fd92ec21a0c9a59 of obj
+exception ReturnNoneException183c26a427ae489c8fd92ec21a0c9a59
+
+[<assembly: ComVisible (false)>]
+
+[<assembly: CLSCompliant (false)>]
+
+[<assembly: Guid ("5017411A-CF26-4E1A-85D6-1C49470C5996")>]
+
+[<assembly: AssemblyTitle ("statefulie")>]
+
+[<assembly: AssemblyDescription ("A state machine implementation written in F#.")>]
+
+[<assembly: AssemblyProduct ("statefulie")>]
+
+[<assembly: AssemblyVersion ("LocalBuild")>]
+
+[<assembly: AssemblyFileVersion ("LocalBuild")>]
+
+[<assembly: AssemblyDelaySign (false)>]
+
+()

src/app/statefulie/StateMonad.fs

+module Statefulie.StateMonad
+  /// <summary>Defines a state computation.</summary>
+  type State<'a, 's> = State of ('s -> 'a * 's)
+
+  /// <summary>Runs the monad.</summary>
+  /// <returns>A tuple of the current and next states.</returns>
+  let runState (State s) initialState = s initialState
+
+  /// <summary>Gets the current state from the monad.</summary>
+  let getState = State (fun s -> (s, s))
+  
+  /// <summary>Updates the state in the monad.</summary>
+  let putState s = State (fun _ -> ((), s))
+
+  /// <summary>Returns the current state.</summary>
+  let eval m s = runState m s |> fst
+
+  /// <summary>Returns the next state.</summary>
+  let exec m s = runState m s |> snd
+
+  /// <summary>Defines a computation workflow for the state monad.</summary>
+  type StateBuilder() =
+    member this.Delay f = State (fun s -> runState (f()) s)
+    member this.Return a = State (fun s -> (a, s))
+    member this.Bind(m, k) =
+      State (fun s -> let (a, s') = runState m s in runState (k a) s')
+
+  /// <summary>The workflow name for the State Monad.</summary>
+  let state = StateBuilder()

src/app/statefulie/Statefulie.fs

+namespace Statefulie
+  open System
+
+  /// <summary>A type that maintains an internal state.</summary>
+  /// <typeparam name="'a">The type of the state.</typeparam>
+  /// <remarks>I really want to replace this with a state monad or agent (MailboxProcessor)</remarks>
+  type IStateful<'a> =
+    abstract member Status : 'a with get, set
+
+  /// <summary>An option type for state.</summary>
+  /// <typeparam name="'a">The type of the state.</typeparam>
+  /// <remarks>This is necessary to allow matching to any from or to state on an event.</remarks>
+  type State<'a> =
+    | One of 'a
+    | Any
+  
+  /// <summary>A state transition record.</summary>
+  /// <typeparam name="'a">The type of the state.</typeparam>
+  type Transition<'a> = {
+    Target : 'a IStateful
+    Event  : 'a IObservable   // IEvent implements IObservable
+    From   : 'a State
+    To     : 'a State }
+    with
+      /// <summary>Subscribes observers to the transition's event.</summary>
+      /// <param name="obs">The observer</param>
+      /// <remarks>
+      ///   I don't think I want to just add additional subscribers to the event.
+      ///   What I will probably do is change this to use Observable.Create,
+      ///   and allow for call/cc style actions.
+      /// </remarks>
+      member this.Subscribe(obs) = this.Event.Subscribe(obs)
+
+      /// <summary>Subscribes observers to the transition's event.</summary>
+      /// <param name="obs">The observer</param>
+      /// <remarks>
+      ///   I don't think I want to just add additional subscribers to the event.
+      ///   What I will probably do is change this to use Observable.Create,
+      ///   and allow for call/cc style actions.
+      /// </remarks>
+      interface IObservable<'a>
+          with member this.Subscribe(obs) = this.Subscribe(obs)
+
+  /// <summary>A state machine record.</summary>
+  /// <typeparam name="'a">The type of the state.</typeparam>
+  type StateMachine<'a> = {
+    Target      : 'a IStateful
+    Transitions : 'a Transition list }
+//  type StateMachine<'a>(target: 'a IStateful, transitions: (StateMachine<'a> -> 'a Transition) list) =
+//    member this.Target = target
+//    member this.Transitions = transitions
+
+  module StateMachine =
+    /// <summary>Creates a state machine target from a state.</summary>
+    /// <typeparam name="'a">The type of the state.</typeparam>
+    /// <returns>An anonymous 'a IStateful.</returns>
+    /// <remarks>
+    ///   This function reminds me an awful lot of the monadic Return...
+    ///   I would like to remove this and use a state monad in its place. (see above)
+    /// </remarks>
+    let createTarget state =
+      let status = ref state
+      { new IStateful<'a> with
+          member this.Status with get() = !status
+                             and  set s = status := s
+      }
+
+    let exiting<'a> = new Event<'a>()
+    
+    [<CLIEvent>]
+    let onExit<'a> = exiting<'a>.Publish
+    let entering<'a> = new Event<'a>()
+    
+    [<CLIEvent>]
+    let onEntry<'a> = entering<'a>.Publish
+
+    /// <summary>Creates a transition from the specified event and state machine.</summary>
+    /// <param name="event">The event on which to transition.</param>
+    /// <param name="m">The state machine.</param>
+    /// <returns>The transition for the event with the state machine target set.</returns>
+    /// <remarks>
+    ///   As of now, this is the only way to define a transition. I'm trying to decide why I want any other entry points.
+    ///   Well, aside from on state entry/exit events, defined above.
+    /// </remarks>
+    let on event m =
+      { Target = m.Target; Event = event; From = Any; To = Any }
+
+    /// <summary>Sets the state from which to transition.</summary>
+    /// <param name="oldState">The old, or current, state</param>
+    /// <param name="t">The transition</param>
+    /// <returns>A copy of the transition with the "from" state and filtered event.</returns>
+    /// <remarks>
+    ///   Use the from function to filter down your event to only those events fired from a specific state.
+    /// </remarks>
+    let from oldState t =
+      let fromEvent = t.Event |> Observable.filter (fun s -> s = oldState)
+      { t with Event = fromEvent; From = One(oldState) }
+
+    /// <summary>Sets the state to which to transition.</summary>
+    /// <param name="newState">The new state</param>
+    /// <param name="t">The transition</param>
+    /// <returns>A copy of the transition with the "to" state.</returns>
+    /// <remarks>
+    ///   The into function adds a subscriber to the transition event that performs the following actions:
+    ///   1) It fires an exiting event with the old state.
+    ///   2) It fires an entering event with the new state.
+    ///   3) It sets the machine's target's status to the new state.
+    /// </remarks>
+    let moveTo newState t =
+      let cancel = t.Event.Subscribe (fun oldState -> exiting.Trigger(oldState)
+                                                      entering.Trigger(newState)
+                                                      t.Target.Status <- newState)
+      { t with To = One(newState) }
+
+    /// <summary>Adds a transition to the machine's allowed transitions.</summary>
+    /// <param name="f">The function to create a transition from a state machine</param>
+    /// <param name="m">The state machine</param>
+    /// <returns>A new copy of the state machine with the new transition added to its list of transitions.</returns>
+    let allow f m = { m with Transitions = f m :: m.Transitions }

src/app/statefulie/statefulie.fsproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{d9df5ba7-4b1f-4137-82be-48bb3d7a818c}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>statefulie</RootNamespace>
+    <AssemblyName>statefulie</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <Name>statefulie</Name>
+    <TargetFrameworkProfile />
+    <FscToolPath>..\..\..\lib\FSharp\</FscToolPath>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <Tailcalls>false</Tailcalls>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <WarningLevel>3</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <Tailcalls>true</Tailcalls>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <WarningLevel>3</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
+    <DocumentationFile>bin\Release\statefulie.XML</DocumentationFile>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <DocumentationFile>bin\Debug\statefulie.xml</DocumentationFile>
+    <OtherFlags>
+    </OtherFlags>
+    <DefineConstants>TRACE;DEBUG</DefineConstants>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="AssemblyInfo.fs" />
+    <Compile Include="StateMonad.fs" />
+    <Compile Include="Statefulie.fs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="FSharp.Core">
+      <HintPath>..\..\..\lib\FSharp\FSharp.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="mscorlib" />
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+  </ItemGroup>
+  <Import Project="..\..\..\lib\FSharp\Microsoft.FSharp.Targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+	     Other similar extension points exist, see Microsoft.Common.targets.
+	<Target Name="BeforeBuild">
+	</Target>
+	<Target Name="AfterBuild">
+	</Target>
+	-->
+</Project>

src/statefulie.sln

File contents unchanged.

src/test/statefulie.specs/Statefulie.Specs.fs

+module Statefulie.Specs
+// This file is a script that can be executed with the F# Interactive.  
+// It can be used to explore and test the library project.
+// Note that script files will not be part of the project build.
+
+#if INTERACTIVE
+#r @"..\..\..\lib\naturalspec\nunit.framework.dll"
+#r @"..\..\..\lib\naturalspec\Rhino.Mocks.dll"
+#r @"..\..\..\lib\naturalspec\NaturalSpec.dll"
+#load @"..\..\app\statefulie\Statefulie.fs"
+#endif
+
+open NaturalSpec
+open Statefulie
+open Statefulie.StateMachine
+
+type SwitchState =
+  | Off   = 0
+  | On    = 1
+  | Broke = 2
+
+let flip = new Event<SwitchState>()
+let flipped = flip.Publish
+
+let shortOut = new Event<SwitchState>()
+let shortedOut = shortOut.Publish
+
+let createMachine initState =
+  { Target = createTarget initState; Transitions = [] }
+    |> allow ((on flipped) >> (from SwitchState.Off) >> (moveTo SwitchState.On))
+    |> allow (moveTo SwitchState.Off << from SwitchState.On << on flipped)
+    |> allow (moveTo SwitchState.Broke << on shortedOut)
+
+let status state (machine: StateMachine<'a>) =
+  printMethod state
+  NUnit.Framework.Assert.AreEqual(state, machine.Target.Status)
+  true
+
+// Flipping a switch tests.
+let the_switch_is_flipped machine =
+  printMethod machine
+  flip.Trigger(machine.Target.Status)
+  machine
+  
+[<Scenario>]
+let Turning_a_switch_from_off_to_on_should_set_the_switch_status_to_on() =
+  Given createMachine SwitchState.Off
+    |> When the_switch_is_flipped
+    |> It should have (status SwitchState.On)
+    |> Verify
+
+[<Scenario>]
+let Turning_a_switch_from_on_to_off_should_set_the_switch_status_to_off() =
+  Given createMachine SwitchState.On
+    |> When the_switch_is_flipped
+    |> It should have (status SwitchState.Off)
+    |> Verify
+
+// Shorting out a switch tests.
+let the_switch_is_shorted_out machine =
+  printMethod machine
+  shortOut.Trigger(machine.Target.Status)
+  machine
+
+[<Scenario>]
+let Shorting_out_a_switch_that_is_off_should_set_the_switch_status_to_broke() =
+  Given createMachine SwitchState.Off
+    |> When the_switch_is_shorted_out
+    |> It should have (status SwitchState.Broke)
+    |> Verify
+
+[<Scenario>]
+let Shorting_out_a_switch_that_is_on_should_set_the_switch_status_to_broke() =
+  Given createMachine SwitchState.On
+    |> When the_switch_is_shorted_out
+    |> It should have (status SwitchState.Broke)
+    |> Verify

src/test/statefulie.specs/statefulie.specs.fsproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{81d3da14-ad0f-4ef3-9e3b-024e9dbf2e2c}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>statefulie.specs</RootNamespace>
+    <AssemblyName>statefulie.specs</AssemblyName>
+    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+    <Name>statefulie.specs</Name>
+    <FscToolPath>..\..\..\lib\FSharp\</FscToolPath>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <Tailcalls>false</Tailcalls>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <WarningLevel>3</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <Tailcalls>true</Tailcalls>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <WarningLevel>3</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="FSharp.Core">
+      <HintPath>..\..\..\lib\FSharp\FSharp.Core.dll</HintPath>
+      <Private>True</Private>
+    </Reference>
+    <Reference Include="mscorlib" />
+    <Reference Include="NaturalSpec">
+      <HintPath>..\..\..\lib\naturalspec\NaturalSpec.dll</HintPath>
+    </Reference>
+    <Reference Include="nunit.framework">
+      <HintPath>..\..\..\lib\naturalspec\nunit.framework.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core">
+      <RequiredTargetFramework>3.5</RequiredTargetFramework>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Statefulie.Specs.fs" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\app\statefulie\statefulie.fsproj">
+      <Name>statefulie</Name>
+      <Project>{d9df5ba7-4b1f-4137-82be-48bb3d7a818c}</Project>
+      <Private>True</Private>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="..\..\..\lib\FSharp\Microsoft.FSharp.Targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+	     Other similar extension points exist, see Microsoft.Common.targets.
+	<Target Name="BeforeBuild">
+	</Target>
+	<Target Name="AfterBuild">
+	</Target>
+	-->
+</Project>