|* and |** are defined here, and they look almost identical in definition:
The error it throws:
Warning: GHCi | <interactive>:1126:6: error:
Warning: GHCi | * No instance for (Floating ValueMap) arising from a use of |**'
Warning: GHCi | * In the second argument of `($)', namely
Warning: GHCi | s "superfork" |+| note "7 2" |** note 2'
I'm also asking for
d1 $ s "super" |++| s "fork"
Warning: GHCi | <interactive>:1132:21: error:
Warning: GHCi | * Couldn't match type Data.Map.Internal.Map String Value'
Warning: GHCi | with [a0]'
Warning: GHCi | Expected type: Pattern [a0]
Warning: GHCi | Actual type: ControlPattern
Warning: GHCi | * In the second argument of (|++|)', namely s "fork"'
like, why does |+| work anywhere on a pattern but |++| and |**| don't seem to work
The reason that |*| and * works is because patterns are defined to be numbers with this kind of thing:
instance Num a => Num (Pattern a) where
negate = fmap negate
(+) = liftA2 (+)
(*) = liftA2 (*)
fromInteger = pure . fromInteger
abs = fmap abs
signum = fmap signum
instance Num ValueMap where
negate = (applyFIS negate negate id <$>)
(+) = Map.unionWith (fNum2 (+) (+))
(*) = Map.unionWith (fNum2 (*) (*))
fromInteger i = Map.singleton "n" $ VI (fromInteger i)
signum = (applyFIS signum signum id <$>)
abs = (applyFIS abs abs id <$>)
However ** only works on things of class Floating. You can hack it to work with an instance definition:
None of the functions required by the Floating instance are useful to define for ValueMap, the noOv function just fails with an error message.. But by defining it at least |**| et al start working as expected.