update
This commit is contained in:
parent
ac0bedb90b
commit
27d00296ec
|
@ -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)
|
||||
|
||||
ensureProperty :: Property NoInfo -> Propellor Result
|
||||
ensureProperty (SimpleProperty d r) = r
|
||||
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.
|
||||
|
||||
(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.)
|
||||
|
|
Loading…
Reference in New Issue