Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern synonyms for different encodings of Day convolution #36

Open
Icelandjack opened this issue Apr 2, 2017 · 0 comments
Open

Pattern synonyms for different encodings of Day convolution #36

Icelandjack opened this issue Apr 2, 2017 · 0 comments

Comments

@Icelandjack
Copy link
Contributor

It's possible to encode Day differently:

data Day2__ :: (Type -> Type) -> (Type -> Type) -> (Type -> Type) where
  Day2__ :: f xx -> g (xx -> a) -> (Day2__ f g) a

data Day3__ :: (Type -> Type) -> (Type -> Type) -> (Type -> Type) where
  Day3__ :: f (xx -> a) -> g xx -> (Day3__ f g) a

Users might want access to them for some reason, we can expose pattern synonyms to access them

day2 :: forall f g a. Functor g => Day f g a -> Day2__ f g a
day2 (Day fa gb f) = Day2__ fa (flip f gb)

day3 :: Functor f => Day f g a -> Day3__ f g a
day3 (Day fa gb f) = Day3__ (fmap f fa) gb 

pattern Day2 :: forall f g a. Functor g => forall xx. f xx -> g (xx -> a) -> Day f g a
pattern Day2 fa gb <- (day2 -> Day2__ fa gb)
  where Day2 fa gb = Day fa gb (&)

pattern Day3 :: forall f g a. Functor f => forall xx. f (xx -> a) -> g xx -> Day f g a
pattern Day3 fa gb <- (day3 -> Day3__ fa gb)
  where Day3 fa gb = Day fa gb id

Useful or not? I didn't put thought into choosing encodings or names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant