From 27d00296ec549e17ec94125dc82fb9f2fb0fb34f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 7 Dec 2014 20:31:22 -0400 Subject: update --- .../info_propigation_out_of_nested_properties.mdwn | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'doc/todo/info_propigation_out_of_nested_properties.mdwn') diff --git a/doc/todo/info_propigation_out_of_nested_properties.mdwn b/doc/todo/info_propigation_out_of_nested_properties.mdwn index bc7deb36..e4bb443a 100644 --- a/doc/todo/info_propigation_out_of_nested_properties.mdwn +++ b/doc/todo/info_propigation_out_of_nested_properties.mdwn @@ -12,6 +12,7 @@ This works, but it's error-prone. Consider this example: Here, the Info of `foo` is not propigated out. Nor is `bar`'s Info. Of course, only one of them will be run, and only its info should be propigated out.. + ---- Currently, ensureProperty detects if it's called on a property with a @@ -73,8 +74,7 @@ that has no Info. Only allow calling ensureProperty on this new type. (Or, remove propertyInfo from Property, and add a new InfoProperty that has the info.) -This would surely work, but it adds a lot of complexity to property -combiators. Also, propertyList could only contain one type at a time, +But, propertyList can only contain one type at a time, not a mixed list of Property and SimpleProperty. Could a GADT be used instead? @@ -85,9 +85,21 @@ Could a GADT be used instead? data HasInfo data NoInfo - data Property i where - InfoProperty :: Desc -> Propellor Result -> Info -> Property HasInfo - SimpleProperty :: Desc -> Propellor Result -> Property NoInfo + data Property = IProperty (GProperty HasInfo) | SProperty (GProperty NoInfo) + + data GProperty i where + GIProperty :: Desc -> Propellor Result -> Info -> GProperty HasInfo + GSProperty :: Desc -> Propellor Result -> GProperty NoInfo + + ensureProperty :: GProperty NoInfo -> Propellor Result + ensureProperty (GSProperty d r) = r + +That works. I made a `gadtwip` git branch that elaborated on that, +to the point that Property.File compiles, but is otherwise +unfinished. Most definitions of `Property` need to be changed to +`GProperty NoInfo`, so that ensureProperty can call them. It's a big, +intrusive change, and it may complicate propellor too much. - ensureProperty :: Property NoInfo -> Propellor Result - ensureProperty (SimpleProperty d r) = r +(I may need to make instances of Prop for `GProperty NoInfo` and `GProperty +HasInfo`, if that's possible, and make more Property combinators work on +Prop.) -- cgit v1.2.3