有沒有更好的方式來保存一些字符串作爲附件通過Paperlip作爲一個tmp文件,將字符串放入它,再次打開並保存爲附件? 像這樣: def save_string data
tmp_file = "/some/path"
File.open(tmp_file,'w') do |f|
f.write(data)
end
File.open(tmp_
我無法獲得此方法。一直都在犯錯誤。我在哪裏犯錯誤?它應該接受字符串數組,取頭,創建一個點。不過,我認爲問題出在遞歸調用中。 data Point = Point(Int, Int) -- y, x
instance Show Point where
show (Point(y, x)) = "(" ++ show x ++ "," ++ show y ++ ")"
gimmePoi
The following code一類產生「預期的約束」錯誤: {-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExistentialQuantification #-}
type family Note a
type instance Note String = String
data SomeNote = forall a. Note a =
我做了一個函數,它讀取文件並在每行中刪除在同一行中遇到的所有單詞。 {-# OPTIONS_GHC -Wall #-}
module Main where
import System.Environment
import System.IO()
main :: IO()
main = do args <- getArgs
if (length args > 0) then
我想爲我的Hakyll站點的上下文添加一個字段。如果某個關鍵字存在於元數據中,那麼我想轉換相應的值並將其包含在上下文中。如果密鑰不存在於元數據中,則不應將任何內容添加到上下文中。 我寫了這個功能應該做什麼,我描述: -- | Creates a new field based on the item's metadata. If the metadata field is
-- not pres
我已經找到一種方法來一個Nat轉換成Integer使用Proxy和natVal,你可以在下面的代碼中看到: {-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Proxy (Proxy)
import Data.Monoid ((<>))
impor