Skocz do zawartości

Recommended Posts

Napisano

Mam mały problem z kompilacją kodu:

-- encrypted with https://www.stringencrypt.com (v1.0.0) [Haskell]
module Main where
 
import qualified Data.Char
import qualified Data.Bits
 
main = do
  putStrLn $ ffffff
 
-- ffffff = "abc!"
ffffff = zipWith f [0..] [ 0x41F6, 0x41F0, 0x41EE, 0x41AF ]
  where
    f wlyxp wflco = let rhsfn0 = wflco
                        rhsfn1 = rhsfn0 + wlyxp
                        rhsfn2 = rhsfn1 `Data.Bits.xor` 0x531D
                        rhsfn3 = rhsfn2 - 0xC028
                        rhsfn4 = rhsfn3 + wlyxp
                        rhsfn5 = rhsfn4 `Data.Bits.xor` 0x1851
                        rhsfn6 = rhsfn5 + wlyxp
                        rhsfn7 = rhsfn6 - wlyxp
                        rhsfn8 = rhsfn7 `Data.Bits.xor` wlyxp
                        rhsfn9 = Data.Bits.complement rhsfn8
                        rhsfn10 = rhsfn9 + 0x6B0A
                        rhsfn11 = rhsfn10 + wlyxp
                        rhsfn12 = rhsfn11 `Data.Bits.xor` 0x2016
                        rhsfn13 = rhsfn12 `Data.Bits.xor` wlyxp
                    in Data.Char.chr ( Data.Bits..&. 0xFFFF)

Ideone wypluwa mi taki błąd

[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:27:40:
    Couldn't match expected type `Int' with actual type `a0 -> a0'
    In the first argument of `Data.Char.chr', namely
      `(Data.Bits..&. 65535)'
    In the expression: Data.Char.chr (Data.Bits..&. 65535)
    In the expression:
      let
        rhsfn0 = wflco
        rhsfn1 = rhsfn0 + wlyxp
        rhsfn2 = rhsfn1 `Data.Bits.xor` 21277
        ....
      in Data.Char.chr (Data.Bits..&. 65535)

Jako, że moja znajomość Haskella jest znikoma może ktoś wie jak to poprawić?

Napisano

Sorry, dopiero teraz zauważyłem post.

Ostatnia linijka, chyba wypadła Ci nazwa zmiennej z lewej strony operatora ".&.", tzn.:

in Data.Char.chr ( rhsfn13 Data.Bits..&. 0xFFFF )

U mnie działa :P

$ ghc prog2.hs
[1 of 1] Compiling Main             ( prog2.hs, prog2.o )
Linking prog2 ...

$ ./prog2 
abc!
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gość
Odpowiedz...

×   Wkleiłeś zawartość bez formatowania.   Usuń formatowanie

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Utwórz nowe...