Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created September 14, 2013 08:38
Show Gist options
  • Save qoelet/6560034 to your computer and use it in GitHub Desktop.
Save qoelet/6560034 to your computer and use it in GitHub Desktop.
-- Another day in #haskell
-- (fix $ \goto x -> case x of Nothing -> "hello"; Just _ -> goto Nothing) (Just ())
-- lambdabot: "hello"
import Data.Function (fix)
goto :: Maybe t -> [Char]
goto t = (fix (\goto x -> case x of Nothing -> "hello"; Just _ -> goto Nothing)) t
-- ghci> goto (Just 5)
-- "hello"
-- fix: what does it do?
-- ghci> :type fix
-- fix :: (a -> a) -> a
-- (def?)
-- fix f = let x = f x in x
-- see: http://stackoverflow.com/questions/4787421/how-do-i-use-fix-and-how-does-it-work
-- what is domain theory?
-- ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment