x::Integer), ...">

Haskell: Show all items that are "indicative" in the Hlist

I tried

map show . mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()]

but he returned

["()"]
+5
source share
2 answers

Your code does not do what you expect from it. Long before dynamic behavior Data.Dynamicfires, the Haskell type validator resolves types. Type of the right part of the expression

mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()] :: Typeable b => [b]

and the type of the left side is

map show :: Show a => [a] -> [String]

to combine them, a type variable brespectively. aunites. If you are going to compile this from a regular Haskell file, the compiler will give you a warning ( The type variable `a' is ambigous). But in GHCi, the interpreter simply matters by default ().

fromDynamic Dynamic -> Maybe (), ().

, , , , fromDynamic :

Prelude Data.Dynamic Data.Maybe> map (show :: Integer -> String) . mapMaybe fromDynamic $ [toDyn "one", toDyn (\x -> x::Integer), toDyn 3, toDyn ()]
["3"]

, , : , show, fromDynamic.

+5

, fromDynamic . (), .

, , . , , , ( show).

. , ( String).

Dynamic (, !), dynApply.

+7

All Articles