Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Created September 28, 2017 10:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Icelandjack/1a57ae22fe221ef9a67c96dc24b4751f to your computer and use it in GitHub Desktop.
Save Icelandjack/1a57ae22fe221ef9a67c96dc24b4751f to your computer and use it in GitHub Desktop.
TODO Divisible implement later

http://www.michaelburge.us/2017/09/27/delta-debugging-in-haskell.html

data HList f xs where
  HNil  :: HList f '[]
  HCons :: f a -> HList f as -> HList f (a ': as)

divideGeneral :: forall f a bs. Divisible f => (a -> HList Identity bs) -> (HList f bs -> f a)
divideGeneral f = \case
  HNil ->
    conquer

  HCons (fb' :: f b') HNil ->
    contramap
      (\(f -> Identity b' `HCons` HNil) -> b')
      fb'

  HCons (fa' :: f a') (fbs :: HList f bs') -> let

    f' :: (x -> (y, z)) -> f y -> f z -> f x
    f' = divide @f

    -- new_f :: a -> HList Identity bs'
    new_f a =
      case f a of
        HCons x xs -> HCons undefined undefined

    x = divideGeneral @f new_f fbs

    in undefined

divide4 :: Divisible f => ( a -> ( b , c , d , e )) -> f b -> f c -> f d -> f e -> f a
divide3 :: Divisible f => ( a -> ( b , c , d )) -> f b -> f c -> f d -> f a
divide2 :: Divisible f => ( a -> ( b , c )) -> f b -> f c -> f a
divide1 :: Contravariant f => ( a -> ( b )) -> f b -> f a
divide0 :: Divisible f => ( a -> () ) -> f a

divide0 _ = conquer
divide1 = contramap
divide2 = divide
divide3 split3 pb pc pd = divide ( reassociate . split3 ) pb $ divide id pc pd where reassociate ( x , y , z ) = ( x ,( y , z ))
divide4 split4 pb pc pd pe = divide ( reassociate4 . split4 ) pb $ divide3 id pc pd pe where reassociate4 ( x , y , z , w ) = ( x ,( y , z , w ))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment