-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out Data.ZipMatchK, remove ZipMatch
- Loading branch information
Showing
12 changed files
with
150 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
haskell/free-foil/src/Control/Monad/Free/Foil/TH/ZipMatch.hs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Data.ZipMatchK ( | ||
module Data.ZipMatchK.Mappings, | ||
ZipMatchK(..), | ||
zipMatchK, | ||
zipMatch2, | ||
zipMatchViaEq, | ||
zipMatchViaChooseLeft, | ||
) where | ||
|
||
import Generics.Kind | ||
|
||
import Data.ZipMatchK.Generic | ||
import Data.ZipMatchK.Mappings | ||
|
||
zipMatchK :: forall f as bs. (ZipMatchK f, PairMappings as bs) => f :@@: as -> f :@@: bs -> Maybe (f :@@: ZipLoT as bs) | ||
zipMatchK = zipMatchWithK @_ @f @as @bs pairMappings | ||
|
||
zipMatch2 :: forall f a b a' b'. (ZipMatchK f) => f a b -> f a' b' -> Maybe (f (a, a') (b, b')) | ||
zipMatch2 = zipMatchK @f @(a :&&: b :&&: LoT0) @(a' :&&: b' :&&: LoT0) | ||
|
||
zipMatchViaEq :: Eq a => Mappings as bs cs -> a -> a -> Maybe a | ||
zipMatchViaEq _ x y | ||
| x == y = Just x | ||
| otherwise = Nothing | ||
|
||
zipMatchViaChooseLeft :: Mappings as bs cs -> a -> a -> Maybe a | ||
zipMatchViaChooseLeft _ x _ = Just x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{-# OPTIONS_GHC -Wno-orphans #-} | ||
{-# LANGUAGE AllowAmbiguousTypes #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
module Data.ZipMatchK.Bifunctor where | ||
|
||
import Data.Kind (Type) | ||
import Generics.Kind | ||
import Data.Bifunctor.Sum | ||
import Data.Bifunctor.Product | ||
|
||
import Data.ZipMatchK | ||
|
||
instance GenericK (Sum f g) where | ||
type RepK (Sum f g) = | ||
Field ((Kon f :@: Var0) :@: Var1) | ||
:+: Field ((Kon g :@: Var0) :@: Var1) | ||
instance GenericK (Product f g) where | ||
type RepK (Product f g) = | ||
Field ((Kon f :@: Var0) :@: Var1) | ||
:*: Field ((Kon g :@: Var0) :@: Var1) | ||
|
||
instance (ZipMatchK f, ZipMatchK g) => ZipMatchK (Sum (f :: Type -> Type -> Type) g) | ||
instance (ZipMatchK f, ZipMatchK g) => ZipMatchK (Product (f :: Type -> Type -> Type) g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.