Skip to content

Instantly share code, notes, and snippets.

@melrief
Last active June 23, 2016 08:44
Show Gist options
  • Save melrief/c195eac6faf9ca7388563b3670531d2d to your computer and use it in GitHub Desktop.
Save melrief/c195eac6faf9ca7388563b3670531d2d to your computer and use it in GitHub Desktop.
class HasN a where
n :: a -> Int
data JobOne = JobOne Int
data JobTwo = JobTwo
data JobThree = JobThree Int
data JobDescriptionWithN = JobDescriptionWithNOne JobOne | JobDescriptionWithNThree JobThree
data JobDescription = JobDescriptionTwo JobTwo | JobWithN JobDescriptionWithN
instance HasN JobOne where
n (JobOne x) = x
instance HasN JobThree where
n (JobThree x) = x
instance HasN JobDescriptionWithN where
n (JobDescriptionWithNOne j) = n j
n (JobDescriptionWithNThree j) = n j
main = print . n $ JobOne 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment