Created
November 23, 2020 08:27
-
-
Save googleson78/df9f4a92df974d17c0ff8c91f2b8dcc9 to your computer and use it in GitHub Desktop.
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
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE InstanceSigs #-} | |
class ApplyCompose b c x res | b c x -> res where | |
(<|) :: (b -> c) -> x -> res | |
instance ApplyCompose b c (a -> b) (a -> c) where | |
(<|) :: (b -> c) -> (a -> b) -> a -> c | |
(<|) = (.) | |
instance ApplyCompose b c b c where | |
(<|) :: (b -> c) -> b -> c | |
(<|) = ($) | |
infixr 1 <| | |
-- > isSpace <| 'a' | |
-- False | |
-- > isSpace <| toEnum @Char <| (97 :: Int) | |
-- False | |
-- > (isSpace <| toEnum <| (97 :: Int)) :: Bool | |
-- ambiguity error | |
-- > f = map <| map id | |
-- ambiguity error | |
-- > f = (map <| map id) :: [[Int]] -> [[Int]] | |
-- ambiguity error | |
-- > f = map @[Int] @[Int] <| map @Int id | |
-- > :t f | |
-- f :: [[Int]] -> [[Int]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment