从Haskell中的列表更改变量值

时间:2019-01-17 09:12:44

标签: haskell

我必须制作一个待办事项应用程序。创建和删除功能已经完成,但是我需要创建一个编辑功能,与删除功能相同,按数字获取变量并进行编辑。我是这个领域的新手。谢谢。

    static IntPtr SetHook(LowLevelMouseProc proc)
    {
        ....
        var setHookResult = UnsafeNativeMethods.SetWindowsHookEx(WH_MOUSE_LL, proc, moduleHandle, 0);
        ....
    }

    delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);

    static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
    {
        if (nCode >= 0)
        {
            var info = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            var extraInfo = (uint)info.dwExtraInfo.ToInt32();
            if ((extraInfo & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH)
            {
                ...
                I need identify touch device.
                ....
            }
        }
    }

1 个答案:

答案 0 :(得分:1)

您的edit函数所需要做的就是接受另一个参数,该参数将更改已编辑的项目:

edit :: Int -> (a -> a) -> [a] -> Maybe [a]
edit 0 f (a:as) = Just (f a : as)
edit n (a:as) = do
    let x = n - 1
    y <- x `seq` edit x f as
    return (a:y)
edit _ [] = Nothing