当前在线人数7398
首页 - 分类讨论区 - 电脑网络 - 葵花宝典版 - 同主题阅读文章

此篇文章共收到打赏
0

  • 10
  • 20
  • 50
  • 100
您目前伪币余额:0
未名交友
[更多]
[更多]
Re: FP in C# or F#
[版面:葵花宝典][首篇作者:tan00001] , 2014年11月30日00:05:31 ,869次阅读,12次回复
来APP回复,赚取更多伪币 关注本站公众号:
[首页][上页] [下页] [末页][分页:1 2 ]
nkw
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 7 ]

发信人: nkw (非死非活), 信区: Programming
标  题: Re: FP in C# or F#
发信站: BBS 未名空间站 (Tue Dec  2 13:57:04 2014, 美东)

c# ADT support is weak. f# is also better at monad


【 在 tan00001 (声明) 的大作中提到: 】
: F#是为FP量身订做的,但讨论FP时却无人提及:
:     http://www.tryfsharp.org/Learn
: F#在企业中并不受欢迎,因为维护成本太高:大部分码工对FP不熟悉。
: 实际上在真正需要FP时,许多FP的元素已经渗入C#.例如:我们可以用IQueryable来
: 建立一个SQL Query:
: IQueryable query1 = dataContext.Ts;
: query1 = query1.Where(t => t.TimeStamp >= DateTime.UTCNow.AddDays(-7));
: IQueryable query2 = dataContext.Ss;
: query2 = query2.Where(s => s.Minimum >= 0);
: query1 = query1.Join(query2, t => t.SID, s => s.ID,(t, s)=> new { s.ID,
t
: ...................

--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 66.]

 
tan00001
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 8 ]

发信人: tan00001 (声明), 信区: Programming
标  题: Re: FP in C# or F#
发信站: BBS 未名空间站 (Wed Dec  3 03:01:59 2014, 美东)

"c# ADT support is weak" in what way? Can you give any examples?


【 在 nkw (非死非活) 的大作中提到: 】
: c# ADT support is weak. f# is also better at monad
:  t



--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 68.]

 
nkw
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 9 ]

发信人: nkw (非死非活), 信区: Programming
标  题: Re: FP in C# or F#
发信站: BBS 未名空间站 (Fri Dec  5 01:14:55 2014, 美东)

for example, c# doesn't have sum type like discriminated union. 硬要用class+
lambda也可以实现类似功能,当表达力差很多,类似于java里用匿名类pass function。

【 在 tan00001 (声明) 的大作中提到: 】
: "c# ADT support is weak" in what way? Can you give any examples?



--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 72.]

 
tan00001
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 10 ]

发信人: tan00001 (声明), 信区: Programming
标  题: Re: FP in C# or F#
发信站: BBS 未名空间站 (Fri Dec  5 01:45:28 2014, 美东)

这其实看你的个人喜好了。Types like "discriminated union" can easily be
replaced by other things. For example, although not an ADT, "discriminated
union" can easily be replaced by a polymorphic object hierarchy. Personally
I like the latter much more.

【 在 nkw (非死非活) 的大作中提到: 】
: for example, c# doesn't have sum type like discriminated union. 硬要用
class+
: lambda也可以实现类似功能,当表达力差很多,类似于java里用匿名类pass
function。



--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 68.]

 
nkw
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 11 ]

发信人: nkw (非死非活), 信区: Programming
标  题: Re: FP in C# or F#
发信站: BBS 未名空间站 (Fri Dec  5 02:12:37 2014, 美东)

discriminated union is light weight and it's used everywhere. think about
define 10 different class hierarchies for a page of code.

even though they may be used to solve some similar problems, i'm wondering
if they are semantically the same.

【 在 tan00001 (声明) 的大作中提到: 】
: 这其实看你的个人喜好了。Types like "discriminated union" can easily be
: replaced by other things. For example, although not an ADT, "discriminated
: union" can easily be replaced by a polymorphic object hierarchy.
Personally
: I like the latter much more.
: class+
: function。



--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 72.]

 
tan00001
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 12 ]

发信人: tan00001 (声明), 信区: Programming
标  题: Re: FP in C# or F#
发信站: BBS 未名空间站 (Fri Dec  5 02:39:32 2014, 美东)

Light-weight is the key. If you grow your objects with more complexity,say
with more overloaded methods with different implementation for different
types, you would probably have to ditch discriminated union anyway.

【 在 nkw (非死非活) 的大作中提到: 】
: discriminated union is light weight and it's used everywhere. think about
: define 10 different class hierarchies for a page of code.
: even though they may be used to solve some similar problems, i'm wondering
: if they are semantically the same.

: Personally



--
※ 来源:·WWW 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 68.]

 
guvest
进入未名形象秀
我的博客
[回复] [回信给作者] [本篇全文] [本讨论区] [修改] [删除] [转寄] [转贴] [收藏] [举报] [ 13 ]

发信人: guvest (我爱你老婆Anna), 信区: Programming
标  题: FP in C# or F#
发信站: BBS 未名空间站 (Tue Sep 17 01:20:47 2019, 美东)

楼主已经不来了吧?偶然看到楼主一首诗。非常厉害。10年以上的水平。

--
※ 来源:· 未名空间站 网址:mitbbs.com 移动:在应用商店搜索未名空间·[FROM: 47.]

[首页][上页] [下页] [末页][分页:1 2 ]
[快速返回] [ 进入葵花宝典讨论区] [返回顶部]
回复文章
标题:
内 容:

未名交友
将您的链接放在这儿

友情链接


 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996