IK
fmap f (StrId a) = if matchesLast (polyTypeOf f) then StrId (f a) else StrId (f $! a)
matchesLast :: PolyType -> Bool
matchesLast (Forall _ nst) = last ft == head ft
where
ft = flattenArrows nst
flattenArrows ((Arrow :$ x) :$ xs) = x : flattenArrows xs
flattenArrows last = [last]
matchesLast _ = False
но при вызове
polyTypeOf f
Couldn't match type ‘b’ with ‘Polies.Var 1’arising from a use of ‘polyTypeOf’
‘b’ is a rigid type variable bound by
the type signature for:
fmap :: forall a b. (a -> b) -> StrId a -> StrId b
впрочем я уже понял, что так врядли получится сделать. во всяком случае с моими неглубокими познаниями в хаскеле