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.159 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.158 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.157 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.156 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.155 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.154 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.153 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.152 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.151 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.150 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.149 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.148 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.147 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.146 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.145 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.144 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.143 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.142 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.141 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs
trackler-2.2.1.140 tracks/haskell/exercises/allergies/examples/success-standard/src/Allergies.hs