Last active
September 5, 2018 13:50
-
-
Save nkpart/8922083d3c18a8f777b8 to your computer and use it in GitHub Desktop.
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
{-# LANGUAGE GADTs #-} | |
module Yolo where | |
import System.IO.Unsafe | |
class Yolo f where | |
yolo :: f a -> a | |
instance Yolo Maybe where | |
yolo (Just x) = x | |
instance Yolo (Either a) where | |
yolo (Right x) = x | |
instance Yolo ([]) where yolo = head | |
data ReadMe a = Read a => ReadMe String | |
instance Yolo ReadMe where | |
yolo (ReadMe s) = read s | |
instance Yolo IO where | |
yolo = unsafePerformIO | |
-- > yolo (Just 3) | |
-- 3 | |
-- > yolo (Right 3) | |
-- 3 | |
-- > take 5 $ yolo (readFile "Yolo.hs") | |
-- "{-# L"}" | |
-- > yolo (ReadMe "5" :: ReadMe Int) | |
-- 5 |
HuwCampbell
commented
Jan 25, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment