Sha256: 2b8446f43ed0697d8ebf6102baeb717c60d8a67d8f16a6accf345bd97d616a39

Contents?: true

Size: 516 Bytes

Versions: 396

Compression:

Stored size: 516 Bytes

Contents

module Allergies (Allergen(..), isAllergicTo, allergies) where
import Data.Bits (testBit)
data Allergen = Eggs
              | Peanuts
              | Shellfish
              | Strawberries
              | Tomatoes
              | Chocolate
              | Pollen
              | Cats
              deriving (Show, Eq, Enum)

isAllergicTo :: Allergen -> Int -> Bool
isAllergicTo allergen code = testBit code (fromEnum allergen)

allergies :: Int -> [Allergen]
allergies code = filter (`isAllergicTo` code) [Eggs ..]

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.179 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.178 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.177 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.176 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.175 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.174 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.173 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.172 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.171 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.170 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.169 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.167 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.166 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.165 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.164 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.163 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.162 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.161 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.160 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs