Commit f4e6d69b authored by John van Groningen's avatar John van Groningen Committed by Camil Staps

fix getConsPath for newtypes (patch from Mart Lubbers) (modified),

use n>>1 instead of n/2
parent fc8f7ed3
...@@ -46,19 +46,19 @@ where ...@@ -46,19 +46,19 @@ where
getConsPath :: !GenericConsDescriptor -> [ConsPos] getConsPath :: !GenericConsDescriptor -> [ConsPos]
getConsPath {gcd_index, gcd_type_def={gtd_num_conses}} getConsPath {gcd_index, gcd_type_def={gtd_num_conses}}
= doit gcd_index gtd_num_conses | gtd_num_conses==0
= [] // for newtype
= doit gcd_index gtd_num_conses
where where
doit i n doit i n
| n == 0
= abort "getConsPath: zero conses\n"
| i >= n | i >= n
= abort "getConsPath: cons index >= number of conses" = abort "getConsPath: cons index >= number of conses"
| n == 1 | n == 1
= [] = []
| i < (n/2) | i < (n>>1)
= [ ConsLeft : doit i (n/2) ] = [ ConsLeft : doit i (n>>1) ]
| otherwise | otherwise
= [ ConsRight : doit (i - (n/2)) (n - (n/2)) ] = [ ConsRight : doit (i - (n>>1)) (n - (n>>1)) ]
bimapId :: Bimap .a .a // deprecated, no longer used bimapId :: Bimap .a .a // deprecated, no longer used
bimapId = { map_to = id, map_from = id } bimapId = { map_to = id, map_from = id }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment