Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. atIdx ::
  2. forall fname a arrlen. (
  3. HasField fname a,
  4. IsFieldArray fname a 'True,
  5. arrlen ~ FieldArrayLength fname a,
  6. KnownNat arrlen
  7. ) =>
  8. Integer ->
  9. (forall idx. CanReadFieldArray fname idx a => Proxy.Proxy idx -> FieldType fname a) ->
  10. Maybe (FieldType fname a)
  11. atIdx i f =
  12. case someNatVal i of
  13. Just (SomeNat iproxy) ->
  14. case cmpNat iproxy (Proxy.Proxy :: Proxy.Proxy arrlen) of
  15. CLT Refl -> Just (f iproxy)
  16. _ -> Nothing
  17. Nothing -> Nothing
  18.  
  19. {-
  20. src/Main.hs:685:27-34: error:
  21. • Overlapping instances for CanReadFieldArray fname n a
  22. arising from a use of ‘f’
  23. Matching instances:
  24. instance [overlappable] (HasField fname a,
  25. IsFieldArray fname a 'True, IndexInBounds fname idx a,
  26. (TypeError ...)) =>
  27. CanReadFieldArray fname idx a
  28. -- Defined in ‘Graphics.Vulkan.Marshal’
  29. instance [overlapping] (KnownNat idx,
  30. IndexInBounds "float32" idx VkClearColorValue) =>
  31. CanReadFieldArray "float32" idx VkClearColorValue
  32. -- Defined in ‘vulkan-api-1.1.3.0:Graphics.Vulkan.Types.Struct.Clear’
  33. instance [overlapping] (KnownNat idx,
  34. IndexInBounds "int32" idx VkClearColorValue) =>
  35. CanReadFieldArray "int32" idx VkClearColorValue
  36. -- Defined in ‘vulkan-api-1.1.3.0:Graphics.Vulkan.Types.Struct.Clear’
  37. ...plus 25 others
  38. ...plus one instance involving out-of-scope types
  39. (use -fprint-potential-instances to see them all)
  40. (The choice depends on the instantiation of ‘fname, n, a’
  41. To pick the first instance above, use IncoherentInstances
  42. when compiling the other instance declarations)
  43. • In the first argument of ‘Just’, namely ‘(f iproxy)’
  44. In the expression: Just (f iproxy)
  45. In a case alternative: CLT Refl -> Just (f iproxy)
  46. |
  47. 685 | CLT Refl -> Just (f iproxy)
  48. | ^^^^^^^^
  49. -}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement