我试图定义一个代数类型:
data MyType t = MyType t
Run Code Online (Sandbox Code Playgroud)
并使它成为Show的一个实例:
instance Show (MyType t) where
show (MyType x) = "MyType: " ++ (show x)
Run Code Online (Sandbox Code Playgroud)
GHC抱怨因为它不能推断'Show(MyType t)'中的类型't'实际上是Show的实例,这是(show x)所需要的.
我不知道在哪里以及如何声明't'是Show的一个实例?
这是我尝试过的第一个powershell脚本.当我运行它时,第一部分运行良好并创建log.txt,但在再次运行后它仍然运行第1部分.如何检查日志文件是否存在?
编辑:我忘了提到我从PowerShell ISE运行脚本,如果这有所作为.
#Variables.
#Set working directory to scripts location.
$scriptpath = $MyInvocation.MyCommand.Path
$dir = Split-Path $scriptpath
#Check if log file exists.
$ChkFile = "%userprofile%\Desktop\log.txt"
$FileExists = (Test-Path $ChkFile -PathType Leaf)
#Set dir to script location.
Set-Location $dir
#Part 1.
If (!($FileExists))
{
Write-Host "Part 1"
echo 0 >>log.txt
}
#Part 2.
ElseIf ($FileExists)
{
Write-Host "Part 2"
}
Run Code Online (Sandbox Code Playgroud) Rebol中的IN函数查明字段是否在对象中:
USAGE:
IN object word
DESCRIPTION:
Returns the word or block in the object's context.
IN is a native value.
ARGUMENTS:
object (any-object! block!)
word -- (modified if series) (any-word! block! paren!)
Run Code Online (Sandbox Code Playgroud)
声称它适用于对象或块.如果我用一个对象尝试它可以正常工作:
>> in object [foo: 10 bar: 20] 'foo
== foo
Run Code Online (Sandbox Code Playgroud)
但是,如果我只是尝试使用原始块,它会返回NONE:
>> in [foo: 10 bar: 20] 'foo
== none
Run Code Online (Sandbox Code Playgroud)
猜猜我明白它是否不支持块(Rebol2没有).但在什么情况下它不会返回NONE允许的块?
并且有可能将这两个问题合二为一,接受BLOCK的协议是什么!对于word参数?如果你有一组你想要的单词,我认为它会占用一块,但它似乎只是返回块:
>> in object [foo: 10 bar: 20] [mumble frotz bar]
== [mumble frotz bar]
>> in object [foo: 10 bar: 20] …Run Code Online (Sandbox Code Playgroud) 似乎REBOL/View 2.7.8.3.1有一个出现在Windows 8中的错误(或者可能是Windows 8有一个错误).
在磁盘C的根分区中创建文件时:它在Windows资源管理器,Windows命令行以及访问C:\文件夹的任何Windows程序中都不可见,该文件位于Windows的另一个Universe中.
>> save %/c/a.txt "hello universe!"
C:\> dir
(no clue about a.txt)
Run Code Online (Sandbox Code Playgroud)
但是如果你在Rebol/View控制台中进行目录列表,它就在那里!你可以读它,加载它甚至删除它
>> ls %/c/
$Recycle.Bin/ a.txt Users/ Windows/
Run Code Online (Sandbox Code Playgroud)
这个奇怪的错误的结果是你无法打开任何使用任何Windows程序从Rebol/View 2.7创建的文件,在Rebol中创建的文件只对Rebol可见.但这只发生在根文件夹中创建的文件,如果你在任何其他文件夹中创建文件似乎都没问题.
>> save %/c/aeat/b.txt "hello universe"
>> ls %/c/aeat
b.txt
Run Code Online (Sandbox Code Playgroud)
并且
c:\aeat> dir
13/04/2015 00:24 <DIR> .
13/04/2015 00:24 <DIR> ..
13/04/2015 00:24 16 b.txt
Run Code Online (Sandbox Code Playgroud) 有可能我可以为多个域配置RewriteRule.
就像我的要求是我当前的域名www.maindomain.com并且假设我有三个domian和子域名子域名url是example1.maindomain.com example2.maindomain.com example3.maindomain.com
现在我希望当用户尝试访问www.example1.com时,它应该获得example1.maindomain.com的内容,并且对于example2,example3也是如此
我正在使用apache + passenger.
感谢帮助.
帮助,我需要更改此代码以支持远程域访问:
document.write(url);
var http = getHTTPObject();
http.open("GET", url, true);
http.onreadystatechange = function() {
if (http.readyState == 4) {
parseData(http.responseText);
}
}
http.send(null);
Run Code Online (Sandbox Code Playgroud) 我在Go程序中执行shell命令时遇到了一些麻烦:
var command = pwd + "/build " + file_name
dateCmd := exec.Command(string(command))
dateOut, err := dateCmd.Output()
check(err)
Run Code Online (Sandbox Code Playgroud)
如果command变量等于单个单词/home/slavik/project/build(构建是shell脚本),它可以工作,但是如果我尝试传递一些arg ie /home/slavik/project/build xxx或者/home/slavik/project/build -v=1Go程序引发异常,就像file /home/slavik/project/build not found
我的代码出了什么问题?
rebol ×2
.htaccess ×1
ajax ×1
apache ×1
bash ×1
exec ×1
file ×1
go ×1
haskell ×1
javascript ×1
mod-rewrite ×1
object ×1
polymorphism ×1
powershell ×1
rebol3 ×1
typeclass ×1
types ×1
windows-8 ×1