Cook cayenne, cumin, and turmeric, stirring, until fragrant, about 1 minute.
Add onion, garlic, and ginger and cook, stirring, until softened, about 3 minutes.
Add apple and lentils and stir to coat.
Stir in coconut milk and water and bring to a boil. Reduce heat and simmer, stirring occasionally, until lentils are completely soft and dal is thick, 20–25 minutes. Add lime juice and season with salt and pepper.
To serve, top with yogurt, cilantro, and coconut flakes; season with more pepper.
Notes:
Serve with warm naan bread or over rice for a heartier meal.