Created
May 5, 2020 12:07
-
-
Save tim2CF/4eea37546f94189de0167a928813ff97 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 MultiParamTypeClasses #-} | |
module Injective | |
( Injective (..), | |
Foo (..), | |
) | |
where | |
class Injective a b where | |
to :: a -> b | |
from :: b -> Maybe a | |
data Foo = Foo | Bar | Buz | |
instance Injective Bool Foo where | |
to True = Foo | |
to False = Bar | |
from Foo = Just True | |
from Bar = Just False | |
from Buz = Nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment