Created
November 23, 2014 07:35
-
-
Save josiah14/e4f2c6f5a2657a557b49 to your computer and use it in GitHub Desktop.
Hmm. Haskell wont treat a (Functor f) => f String as a single value, so I can't make ((->) SomeType) into a Functor if the value returned by the Arrow is a Functor...
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
-- apply a style function to a shell prompt functor | |
-- e.g. | |
-- bold & fgColor red `style` gitCurrentBranch | |
style :: (String -> ShellPromptType -> String) -> ShellPromptSegment String | |
-> ShellPromptType -> ShellPromptSegment String | |
style f segment = \shType -> (flip f) shType <$> segment | |
-- this is fine | |
style' :: (String -> ShellPromptType -> String) | |
-> (ShellPromptType -> ShellPromptSegment String) | |
-> ShellPromptType -> ShellPromptSegment String | |
style' f makeSegment = flip f >>= \g shellType -> fmap g $ makeSegment shellType | |
-- this apparently is not. Compiler complains that it wants the type (String -> String) -> ShellPromptType -> b | |
-- for my lambda function there, but it gets (String -> String) -> ShellPromptType -> ShellPromptSegment String | |
-- instead. I guess 'b' is not allowed to be a functor? | |
instance Functor ((->) ShellPromptType) where | |
fmap f makeSegment = ((flip f) :: ShellPromptType -> String -> String) | |
>>= ((\g shellType -> fmap g $ makeSegment shellType) | |
:: (String -> String) -> ShellPromptType -> (ShellPromptSegment String)) |
Author
josiah14
commented
Nov 23, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment