Skip to content

Instantly share code, notes, and snippets.

@joneshf
Created September 1, 2017 15:19
Show Gist options
  • Save joneshf/c5b7798ac4d50108478eead4f2e83771 to your computer and use it in GitHub Desktop.
Save joneshf/c5b7798ac4d50108478eead4f2e83771 to your computer and use it in GitHub Desktop.
module Main where
times :: forall a f. Semigroup f a (Int -> a -> a)
times n x = times n x
-- Adding explicit types doesn't work either
-- times' :: forall a f. Semigroup f a (Int -> a -> a)
-- times' n x = (times' :: Semigroup f a (Int -> a -> a)) n x
-- This doesn't work either
-- times'' :: forall a f. Associate f a => Op f a => Int -> a -> a
-- times'' n x = times'' n x
class Op f a where
op :: f a -> f a -> f a
class Op f a <= Associate f a
type Magma f a b = Op f a => b
type Semigroup f a b = Associate f a => Magma f a b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment