Commits

Anonymous committed 72fefcb

Using right build targets in statefulie.fsproj

Comments (0)

Files changed (5)

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/statefulie.fsproj

     <AssemblyName>statefulie</AssemblyName>
     <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
     <Name>statefulie</Name>
+    <FscToolPath>..\..\..\lib\FSharp\</FscToolPath>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
   <ItemGroup>
     <Reference Include="mscorlib" />
     <Reference Include="FSharp.Core">
-      <Private>True</Private>
+      <HintPath>..\..\..\lib\FSharp\FSharp.Core.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core">
       <Private>True</Private>
     </ProjectReference>
   </ItemGroup>
-  <Import Project="$(MSBuildExtensionsPath32)\FSharp\1.0\Microsoft.FSharp.Targets" />
+  <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">