Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Last active September 20, 2022 23:40
Show Gist options
  • Save Lysxia/a83b16c992d9945576fbff3611ab8f3a to your computer and use it in GitHub Desktop.
Save Lysxia/a83b16c992d9945576fbff3611ab8f3a to your computer and use it in GitHub Desktop.
Incoherence in gsolomap
{-# LANGUAGE DeriveGeneric #-}
module Main where
import Generic.Functor
import GHC.Generics (Generic)
data T a b = C Int a b
deriving (Show, Generic)
fmapT :: (b -> b') -> T a b -> T a b'
fmapT = gsolomap
firstT :: (a -> a') -> T a b -> T a' b
firstT = gsolomap
bothT :: (a -> a') -> T a a -> T a' a'
bothT = gsolomap
watT ::
(a -> a') ->
T (a , a ) ((a -> a') -> Maybe a ) ->
T (a', a') ((a' -> a ) -> Maybe a')
watT = gsolomap
main :: IO ()
main = do
print (fmapT ((+1) :: Int -> Int) (C 0 0 0 :: T Int Int))
print (gsolomap ((+1) :: Int -> Int) (C 0 0 0 :: T Int Int) :: T Int Int)
-- NB: Type annotations are needed on both the input and output T Int Int.
putStrLn "We are not the same."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment