我想在Haskell中依次组合两个monad动作,丢弃第二个动作产生的任何值,并将参数传递给两个动作.目前我正在使用这样的do-block:
ask = do
result <- getLine
putStrLn result
return result
Run Code Online (Sandbox Code Playgroud)
我本来希望写一点免费和整洁,所以我尝试了这个:
ask' = getLine <* putStrLn
Run Code Online (Sandbox Code Playgroud)
但是,这甚至不进行类型检查,问题是<*不会将第一个动作的结果传递给第二个动作.我希望将操作链接起来>>=,但不会更改结果.类型应该是(a -> m b) -> (a -> m c) -> (a -> m b),但Hoogle没有产生合适的结果.实现此功能组合的操作员是什么?
我正在开发一个应用程序,我已经做了以下显示的布局:
有一个CircleImageView和一个CardView.
这是XML代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.playrapp.playr.Profile"
tools:showIn="@layout/activity_profile">
<android.support.v7.widget.CardView
android:id="@+id/profileCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:contentPadding="10dp">
</android.support.v7.widget.CardView>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/userImageProfile"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginTop="50dp"
android:src="@mipmap/ic_launcher"
android:layout_centerHorizontal="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在这里,cardview在imageview上.我希望imageview能够超越cardview.我怎样才能做到这一点?
请告诉我.
android android-layout android-xml android-imageview android-cardview
更新到React 16.9.0之后,我得到了这样的警告:
警告:作为安全预防措施,未来版本的React将阻止javascript:URL。如果可以,请改用事件处理程序。如果您需要生成不安全的HTML,请尝试使用dragonallySetInnerHTML。React已传递“ javascript :;”。
它来自如下代码:
const Component = ({someAction}) => (
<a href="javascript:void(0)" onClick={someAction}>click me</a>
);
Run Code Online (Sandbox Code Playgroud)
查看关于我应该为 HTML中的JavaScript链接使用哪个“ href”值的StackOverflow问题,似乎你们中的大多数人都同意这javascript:void(0)是最好的选择,在React 16.9.0中将不再可能。
仅替换为href="#"是有问题的,因为浏览器将滚动到页面顶部并更改显示的URL。尤其是如果您使用哈希链接进行路由,这将是一个很大的问题。
我可以更新整个代码库,使其包含e.preventDefault();在每个事件处理程序中,但这似乎很难做到,尤其是当事件处理程序是由Redux动作创建者或挂钩自动创建时。我不会在任何地方寻找答案“仅包括e.preventDefault();”!
另外,<button>我还必须使用一种方法来处理许多不必要的样式。
所以我想知道:是否有特定于React库的解决方案才能获得<a>可以触发动作而没有副作用的有效链接?我想尽可能少地更改代码,并摆脱弃用警告。
algorithm ×1
android ×1
android-xml ×1
boost ×1
do-notation ×1
graph ×1
graph-theory ×1
haskell ×1
javascript ×1
planar-graph ×1
pointfree ×1
reactjs ×1
refactoring ×1