uniplate

Simplifying a GADT with Uniplate

╄→гoц情女王★ 提交于 2020-01-09 09:49:45
问题 I'm trying to answer this stackoverflow question, using uniplate as I suggested, but the only solution I've come up with so far is pretty ugly. This seems like a fairly common issue, so I wanted to know if there was a more elegant solution. Basically, we've got a GADT which resolves to either Expression Int or Expression Bool (ignoring codataIf = If (B True) codataIf codataIf ): data Expression a where I :: Int -> Expression Int B :: Bool -> Expression Bool Add :: Expression Int -> Expression

How can holes and contexts be implemented for higher-kinded types in a lens style uniplate library?

末鹿安然 提交于 2019-12-01 04:33:40
András Kovács proposed this question in response to an answer to a previous question. In a lens-style uniplate library for types of kind * -> * based on the class class Uniplate1 f where uniplate1 :: Applicative m => f a -> (forall b. f b -> m (f b)) -> m (f a) analogous to the class for types of kind * class Uniplate on where uniplate :: Applicative m => on -> (on -> m on) -> m on is it possible to implement analogs to contexts and holes , which both have the type Uniplate on => on -> [(on, on -> on)] without requiring Typeable1 ? It's clear that this could be implemented in the old-style of

How can holes and contexts be implemented for higher-kinded types in a lens style uniplate library?

坚强是说给别人听的谎言 提交于 2019-12-01 02:25:16
问题 András Kovács proposed this question in response to an answer to a previous question. In a lens-style uniplate library for types of kind * -> * based on the class class Uniplate1 f where uniplate1 :: Applicative m => f a -> (forall b. f b -> m (f b)) -> m (f a) analogous to the class for types of kind * class Uniplate on where uniplate :: Applicative m => on -> (on -> m on) -> m on is it possible to implement analogs to contexts and holes , which both have the type Uniplate on => on -> [(on,

Simplifying a GADT with Uniplate

冷暖自知 提交于 2019-11-28 08:27:36
I'm trying to answer this stackoverflow question, using uniplate as I suggested , but the only solution I've come up with so far is pretty ugly. This seems like a fairly common issue, so I wanted to know if there was a more elegant solution. Basically, we've got a GADT which resolves to either Expression Int or Expression Bool (ignoring codataIf = If (B True) codataIf codataIf ): data Expression a where I :: Int -> Expression Int B :: Bool -> Expression Bool Add :: Expression Int -> Expression Int -> Expression Int Mul :: Expression Int -> Expression Int -> Expression Int Eq :: Expression Int