Skip to content

Instantly share code, notes, and snippets.

@berberman
Created July 9, 2021 11:20
Show Gist options
  • Select an option

  • Save berberman/afbc5ed5315fac737b506aa4d8d2d319 to your computer and use it in GitHub Desktop.

Select an option

Save berberman/afbc5ed5315fac737b506aa4d8d2d319 to your computer and use it in GitHub Desktop.
SYB Test
{-# LANGUAGE RankNTypes #-}
module Test where
import Data.Generics
import Data.Void (Void)
myGeq :: forall a. Data a => a -> a -> Bool
myGeq a b = myGeq' a b
where
myGeq' :: GenericQ (GenericQ Bool)
myGeq' x y
| typeOf x == typeOf y,
toConstr x == toConstr y
= and $ gzipWithQ (
myGeq'
`extQ` impossible
) x y
| otherwise = False
impossible :: Void -> GenericQ Bool
impossible _ _ = undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment