diff --git a/code/FsComposite/.vs/FsComposite/v15/.suo b/code/FsComposite/.vs/FsComposite/v15/.suo deleted file mode 100644 index 28cc6e9..0000000 Binary files a/code/FsComposite/.vs/FsComposite/v15/.suo and /dev/null differ diff --git a/code/FsComposite/Composite.Core/AssemblyInfo.fs b/code/FsComposite/Composite.Core/AssemblyInfo.fs new file mode 100644 index 0000000..d2c61e0 --- /dev/null +++ b/code/FsComposite/Composite.Core/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Composite.Core.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/code/FsComposite/Composite.Core/Composite.Core.fsproj b/code/FsComposite/Composite.Core/Composite.Core.fsproj new file mode 100644 index 0000000..e6b268f --- /dev/null +++ b/code/FsComposite/Composite.Core/Composite.Core.fsproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + 2.0 + 8163fd00-6eaa-48b8-93a5-ce10f35da2db + Library + Composite.Core + Composite.Core + v4.7 + 4.4.1.0 + true + Composite.Core + + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + ..\packages\ExtCore.0.8.46\lib\net45\ExtCore.dll + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + + + \ No newline at end of file diff --git a/code/FsComposite/FsComposite/CompositeToolset.fs b/code/FsComposite/Composite.Core/Composite.fs similarity index 72% rename from code/FsComposite/FsComposite/CompositeToolset.fs rename to code/FsComposite/Composite.Core/Composite.fs index c047926..c9178d6 100644 --- a/code/FsComposite/FsComposite/CompositeToolset.fs +++ b/code/FsComposite/Composite.Core/Composite.fs @@ -1,16 +1,15 @@ -namespace FsComposite +namespace Composite.Core -module CompositeToolset = - - exception FatalError of string +module Composite = type 'a Composite = | Value of 'a | Composite of LazyList> - + exception FatalError of string + let l obj = - [obj] |> LazyList.ofList + [obj] |> LazyList.ofList let toComposite obj = match obj with @@ -22,6 +21,11 @@ module CompositeToolset = match obj with | Composite x -> x | x -> l x + + let rec flat o = + match o with + | Composite x -> LazyList.collect flat x + | Value x -> l x let rec ana scn obj = match scn with @@ -29,12 +33,6 @@ module CompositeToolset = | f :: scn_tail -> match obj with | Value x -> ana scn_tail (toComposite(f x)) | Composite x -> Composite(LazyList.map (ana scn) x) - - let rec flat o = - match o with - | Composite x -> LazyList.collect flat x - | Value x -> l x - let cata scn obj = match scn with | [] -> LazyList.empty @@ -46,13 +44,3 @@ module CompositeToolset = | Nil -> raise(FatalError "Empty data sequence is an invalid binding result.") | Cons(x, Nil) -> if x = obj then l x else [obj; x] |> LazyList.ofList | x -> LazyList.cons obj x - -// let flat obj = -// let rec flatInner o = -// match o with -// | Composite x -> LazyList.collect flatInner x -// | Value x -> l x -// -// match obj with -// | Value x -> obj -// | Composite x -> Composite (LazyList.map (fun y -> Composite(LazyList.map Value (flatInner y)) ) x) \ No newline at end of file diff --git a/code/FsComposite/Composite.Core/Processing.fs b/code/FsComposite/Composite.Core/Processing.fs new file mode 100644 index 0000000..9c6acea --- /dev/null +++ b/code/FsComposite/Composite.Core/Processing.fs @@ -0,0 +1,25 @@ +namespace Composite.Core + +open Composite.Core.Composite + +module Processing = + + let rec fold_2 acc f_update_acc lst = + match acc with + |(None, _) | (_, None) -> match lst with + | Nil -> acc + | Cons(h, tail) -> fold_2 (f_update_acc h acc) f_update_acc tail + | _ -> acc + + let find_2_and_transform f_is_1 f_is_2 f_transform lst = + let f h t = + match f_is_1 h, f_is_2 h, t with + | _, true, (a, None) -> (a, Some h) + | true, _, (None, b) -> (Some h, b) + | _ -> t + match fold_2 (None, None) f lst with + | x -> f_transform x + + let find_2_and_transform_strict f_is_1 f_is_2 f_transform lst = + let f_transform_strict = function | (Some x1, Some x2) -> l(f_transform (x1, x2)) | _ -> LazyList.empty + find_2_and_transform f_is_1 f_is_2 f_transform_strict lst diff --git a/code/FsComposite/Composite.Core/packages.config b/code/FsComposite/Composite.Core/packages.config new file mode 100644 index 0000000..e420a1c --- /dev/null +++ b/code/FsComposite/Composite.Core/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/code/FsComposite/Composite.Simple/AssemblyInfo.fs b/code/FsComposite/Composite.Simple/AssemblyInfo.fs new file mode 100644 index 0000000..beaf958 --- /dev/null +++ b/code/FsComposite/Composite.Simple/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace FsComposite.Simple.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/code/FsComposite/Composite.Simple/Composite.Simple.fsproj b/code/FsComposite/Composite.Simple/Composite.Simple.fsproj new file mode 100644 index 0000000..079f3e0 --- /dev/null +++ b/code/FsComposite/Composite.Simple/Composite.Simple.fsproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + 2.0 + d8aad155-ff6f-4957-82f7-dad5db8a606a + Library + FsComposite.Simple + Composite.Simple + v4.7 + 4.4.0.0 + true + Composite.Simple + + + + true + full + false + false + bin\Debug\ + DEBUG;TRACE + 3 + bin\Debug\FsComposite.Simple.XML + + + pdbonly + true + true + bin\Release\ + TRACE + 3 + bin\Release\FsComposite.Simple.XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + ..\packages\ExtCore.0.8.46\lib\net45\ExtCore.dll + + + + True + + + + + + + + Composite.Core + {8163fd00-6eaa-48b8-93a5-ce10f35da2db} + True + + + + \ No newline at end of file diff --git a/code/FsComposite/Composite.Simple/Data.fs b/code/FsComposite/Composite.Simple/Data.fs new file mode 100644 index 0000000..1cf695b --- /dev/null +++ b/code/FsComposite/Composite.Simple/Data.fs @@ -0,0 +1,32 @@ +namespace Composite.Simple + +open Composite.Core.Composite +open Composite.Core.Processing + +module Data = + + type Simple = + | A + | B + | C + + //how to expand + + let expand obj = + match obj with + | A -> l B + | x -> l x + + //how to fold + + let transformAB obj = + let f1 = function | A -> true | _ -> false + let f2 = function | B -> true | _ -> false + let f = function | (Some a, Some b) -> l C | (None, Some b) -> l C | _ -> LazyList.empty + find_2_and_transform f1 f2 f obj + + let transformABStrict obj = + let f1 = function | A -> true | _ -> false + let f2 = function | B -> true | _ -> false + let f = fun (a, b) -> C + find_2_and_transform_strict f1 f2 f obj diff --git a/code/FsComposite/Composite.Simple/packages.config b/code/FsComposite/Composite.Simple/packages.config new file mode 100644 index 0000000..c0490ce --- /dev/null +++ b/code/FsComposite/Composite.Simple/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/code/FsComposite/FsComposite/App.config b/code/FsComposite/Composite.Test/App.config similarity index 100% rename from code/FsComposite/FsComposite/App.config rename to code/FsComposite/Composite.Test/App.config diff --git a/code/FsComposite/FsComposite/AssemblyInfo.fs b/code/FsComposite/Composite.Test/AssemblyInfo.fs similarity index 100% rename from code/FsComposite/FsComposite/AssemblyInfo.fs rename to code/FsComposite/Composite.Test/AssemblyInfo.fs diff --git a/code/FsComposite/FsComposite/FsComposite.fsproj b/code/FsComposite/Composite.Test/Composite.Test.fsproj similarity index 86% rename from code/FsComposite/FsComposite/FsComposite.fsproj rename to code/FsComposite/Composite.Test/Composite.Test.fsproj index 58b82c7..b3912bb 100644 --- a/code/FsComposite/FsComposite/FsComposite.fsproj +++ b/code/FsComposite/Composite.Test/Composite.Test.fsproj @@ -8,11 +8,11 @@ e45a5ab4-3f37-4456-8ba4-4d3d886bc6f8 Exe FsComposite - FsComposite + Composite.Test v4.7 true 4.4.1.0 - FsComposite + Composite.Test true @@ -55,8 +55,6 @@ - - @@ -79,6 +77,18 @@ ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + + Composite.Core + {8163fd00-6eaa-48b8-93a5-ce10f35da2db} + True + + + Composite.Simple + {d8aad155-ff6f-4957-82f7-dad5db8a606a} + True + +