Skip to content

Instantly share code, notes, and snippets.

@supki
Created September 28, 2013 08:49
Show Gist options
  • Save supki/6740038 to your computer and use it in GitHub Desktop.
Save supki/6740038 to your computer and use it in GitHub Desktop.
M
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverlappingInstances #-}
module Just where
class Just a b where
collapse :: Maybe a -> Maybe b
instance Just a a where
collapse = id
instance Just a b => Just (Maybe a) b where
collapse Nothing = Nothing
collapse (Just a) = collapse a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment