diff options
-rw-r--r-- | lib/Numeric/ContainerBoot.hs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/Numeric/ContainerBoot.hs b/lib/Numeric/ContainerBoot.hs index d50dd36..dcb326c 100644 --- a/lib/Numeric/ContainerBoot.hs +++ b/lib/Numeric/ContainerBoot.hs | |||
@@ -510,20 +510,40 @@ type instance ElementOf (Matrix a) = a | |||
510 | class Build f where | 510 | class Build f where |
511 | build' :: BoundsOf f -> f -> ContainerOf f | 511 | build' :: BoundsOf f -> f -> ContainerOf f |
512 | 512 | ||
513 | type family BoundsOf x | ||
514 | 513 | ||
514 | #if MIN_VERSION_base(4,7,0) | ||
515 | -- ghc >= 7.7 considers: | ||
516 | -- | ||
517 | -- > a -> a | ||
518 | -- > b -> b -> b | ||
519 | -- | ||
520 | -- to overlap | ||
521 | type family BoundsOf x where | ||
522 | BoundsOf (a -> a) = Int | ||
523 | BoundsOf (a->a->a) = (Int,Int) | ||
524 | type family ContainerOf x where | ||
525 | ContainerOf (a->a) = Vector a | ||
526 | ContainerOf (a->a->a) = Matrix a | ||
527 | #else | ||
528 | type family BoundsOf x | ||
529 | type family ContainerOf x | ||
515 | type instance BoundsOf (a->a) = Int | 530 | type instance BoundsOf (a->a) = Int |
516 | type instance BoundsOf (a->a->a) = (Int,Int) | 531 | type instance BoundsOf (a->a->a) = (Int,Int) |
517 | |||
518 | type family ContainerOf x | ||
519 | |||
520 | type instance ContainerOf (a->a) = Vector a | 532 | type instance ContainerOf (a->a) = Vector a |
521 | type instance ContainerOf (a->a->a) = Matrix a | 533 | type instance ContainerOf (a->a->a) = Matrix a |
534 | #endif | ||
535 | |||
522 | 536 | ||
523 | instance (Element a, Num a) => Build (a->a) where | 537 | instance (Element a, Num a) => Build (a->a) where |
524 | build' = buildV | 538 | build' = buildV |
525 | 539 | ||
526 | instance (Element a, Num a) => Build (a->a->a) where | 540 | instance (Element a, |
541 | #if MIN_VERSION_base(4,7,0) | ||
542 | BoundsOf (a -> a -> a) ~ (Int,Int), | ||
543 | ContainerOf (a -> a -> a) ~ Matrix a, | ||
544 | #endif | ||
545 | Num a) | ||
546 | => Build (a->a->a) where | ||
527 | build' = buildM | 547 | build' = buildM |
528 | 548 | ||
529 | buildM (rc,cc) f = fromLists [ [f r c | c <- cs] | r <- rs ] | 549 | buildM (rc,cc) f = fromLists [ [f r c | c <- cs] | r <- rs ] |