Skip to content

Instantly share code, notes, and snippets.

@ChrisPenner
Created September 18, 2019 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisPenner/47412d118beacdcea3366195e1f001cf to your computer and use it in GitHub Desktop.
Save ChrisPenner/47412d118beacdcea3366195e1f001cf to your computer and use it in GitHub Desktop.
Infix Typed Holes
*Infix* typed holes!
>>> "suggest" `_` "concat" :: String
<interactive>:1:11: error:
• Found hole: _ :: [Char] -> [Char] -> String
Valid hole fits include
showString :: String -> ShowS
(++) :: forall a. [a] -> [a] -> [a]
showList :: forall a. Show a => [a] -> ShowS
seq :: forall a b. a -> b -> b
(>>) :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
(<>) :: forall a. Semigroup a => a -> a -> a
Even *kinda* works with lenses if you add enough type annotations!
>>> let x = ("abc", 1) :: (String, Int)
>>> x & (_1 `_` "thing") :: (String, Int)
• Found hole:
_ :: ((a0 -> f0 b0) -> s0 -> f0 t0)
-> [Char] -> (String, Int) -> (String, Int)
Valid hole fits include
(#~) :: forall s t a b. ALens s t a b -> b -> s -> t
storing :: forall s t a b. ALens s t a b -> b -> s -> t
(.~) :: forall s t a b. ASetter s t a b -> b -> s -> t
(<>~) :: forall a s t. Monoid a => ASetter s t a a -> a -> s -> t
set :: forall s t a b. ASetter s t a b -> b -> s -> t
set' :: forall s a. ASetter' s a -> a -> s -> s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment